%% temppaw32.m is the second part of the temppaw3#.m series. It 
%% determines the seasonal and daily F10.7 solar correction. Use the
%% UT=0 F107 flux for the given day, since on a daily basis it does
%% not change rapidly. Note that for each input there is also
%% a conjugate output, since seasonal effects different.
%% See temppaw31.m for more details.
%% It is designed to be called by plasimod.m and should probably not
%% be called otherwise as it requires a specific input format.
%% 

function [t0d,t0dc,t0n,t0nc,g0d,g0dc,g0n,g0nc]=temppaw32(t0d,t0n,g0d,g0n,dno,sl,f107)

% t0d = day base temperature (K)
% t0dc = conjugate day base temperature (K)
% t0n = night base temperature (K)
% t0nc = conjugate night base temperature (K)
% g0d = day gradient temperature (K/km)
% g0dc = conjugate day gradient temperature (K/km)
% g0n = night gradient temperature (K/km)
% g0nc = conjuagte night gradient temperature (K/km)
% dno = day number (scalar)
% sl = sl parameter
% f107 = 0 UT F10.7 solar flux 
   
%% Modify the values of G0 and T0 to reflect changes in solar activity.
%% Modify the values of G0 and T0 to reflect changes in solar activity.
[fct0d,fct0n,fcg0d,fcg0n]=temppawf107(sl,f107);        %calculate fractional change due to F10.7
t0d=t0d.*fct0d;                                        %corrected day T0 
t0n=t0n.*fct0n;                                        %corrected night T0 
g0d=g0d.*fcg0d;                                        %corrected day G0 
g0n=g0n.*fcg0n;                                        %corrected night G0 

% Modify the values of G0 and T0 to reflect changes due to season. Because
% the seasonal change is different in each hemisphere, need to separate the
% day and night into northern and southern hemisphere values.
t0dc=t0d;                          %conjugate copy of t0d
t0nc=t0n;                          %conjugate copy of t0n
g0dc=g0d;                          %conjugate copy of g0d
g0nc=g0n;                          %conjugate copy of g0n

%Calculate seasonal variation from mean.
[dt0d,dt0n,dg0d,dg0n,dt0dc,dt0nc,dg0dc,dg0nc]=temppawsea(sl,dno);

%Modify the values of T0 and G0 due to the season
t0d=t0d+dt0d;
t0dc=t0dc+dt0dc;
t0n=t0n+dt0n;
t0nc=t0nc+dt0nc;
g0d=g0d.*dg0d;
g0dc=g0dc.*dg0dc;
g0n=g0n.*dg0n;
g0nc=g0nc.*dg0nc;



