close all
clear 


Year  = 2002;   %    Year:  Year
DoY   = 80;    %    DoY:  Date number of year
UTsec = 12*3600;    %    UTsec:    seconds in day in universal time (UT)
Alt=   400;    %    Alt:     altitude in km
Lon = 60;   %    Lon:   geodetic longitude in degrees.
Lat  = 30;   %    Lat:    geodetic latitude in degrees.
f107    = 200;     %    F107:      daily F10.7 flux for previous day
f107A = 200;     %    F107A:   81 day average of F10.7 flux (centered on doy).
Aplist  = [0,0,0,0];
%    Aplsit:    magnetic index information
%                Aplist = [Ap1,Ap2,Ap3,Ap4]   
%                                  Ap1:       daily averaged Ap
%                                  Ap2:       3 hour AP for current time
%                                  Ap3:       3 hour AP for 3 hours before current time 
%                                  Ap4:       3 hour AP for 6 hours before current time

tic
[T,den] =  ETM_model(Year,DoY,UTsec,Alt,Lon,Lat,f107,f107A,Aplist);
toc
%    T:            exopsheric temperature in K
%    den:       mass density in kg/m3


% Calculate for a global map
lon      = (-180 :5:180 )';
lat      = (-87.5:5:87.5)';

[LON,LAT]=meshgrid(lon,lat);

% Make the parameters same size
YEAR     = Year*ones(size(LON));
DOY      = DoY*ones(size(LON));
UTSEC   = UTsec*ones(size(LON));
F107      = f107*ones(size(LON));
F107A   = f107A*ones(size(LON));
ALT        = Alt*ones(size(LON));

Ap1        = 0*ones(size(LON(:)));
Ap2        = 0*ones(size(LON(:)));
Ap3        = 0*ones(size(LON(:)));
Ap4        = 0*ones(size(LON(:)));

APLIST = cat(2,Ap1,Ap2,Ap3,Ap4);
tic
[Tem_Map,Den_Map]  = ETM_model(YEAR,DOY,UTSEC,ALT,LON,LAT,F107,F107A,APLIST);
toc


% plot the exospheric temperature 
figure('position',[680   166   560   812])

subplot(2,1,1)
contourf(lon,lat,Tem_Map)
colormap jet

hp=colorbar;
post = get(hp,'position');
post(1)=post(1)+0.11;
post(3)=post(3)*0.3;
set(hp,'position',post)
set(gca,'xlim',[-180,180],'xtick',[-180:30:180])
ylabel('Latitude (deg)','fontsize',10,'color','k','FontWeight','Bold')
xlabel('Longitude (deg)','fontsize',10,'color','k','FontWeight','Bold')
title('Exospheric Temperature','fontsize',12,'color','b','FontWeight','Bold')
 
% plot the thermospheric density
subplot(2,1,2)
contourf(lon,lat,Den_Map)
colormap jet

hp=colorbar;
post = get(hp,'position');
post(1)=post(1)+0.11;
post(3)=post(3)*0.3;
set(hp,'position',post)

set(gca,'xlim',[-180,180],'xtick',[-180:30:180])
ylabel('Latitude (deg)','fontsize',10,'color','k','FontWeight','Bold')
xlabel('Longitude (deg)','fontsize',10,'color','k','FontWeight','Bold')
title('Thermospheric Density @ Height = 400','fontsize',12,'color','b','FontWeight','Bold')










































