%% modgall2.m is the empirical equatorial electron density component
%% of the model by Gallagher et al to be published in late 1999 or
%% early 2000 in JGR. 

function eden=modgall2(lsh,year,month,day,timmat)

% lsh = L-shell of point of interest
% timmat = UT time
% day = day matrix
% month = month matrix
% year = year matrix
% eden = electron density (cm^-3)

dno=daynum(day,month,year);                            %day number
ssno=sunspn(timmat,dno,year);                          %sunspot number  
x1=-0.6061*lsh+4.8596;                                 %base component
x2=0.15*cos(2*pi*(dno+9)/365).*exp(-(lsh-2)/1.5);      %annual term
x3=-0.075*cos(4*pi*(dno+9)/365).*exp(-(lsh-2)/1.5);    %semi-annual term
x4=(0.00127*ssno-0.0635).*exp(-(lsh-2)/1.5);           %solar term
eden=10.^(x1+x2+x3+x4);                                %electron density
 
 
