%%
%% This program is written for plotting the TIEGCM dres TEC data at 8 lonsra
%% BA Emery, October 2011 from /aim3/emery/tiegcm_dres/plots/tec8lon.m 
%% Revised for climatology output November 2011
clear all; close all

loncutsE=[25,90,140,175,200,250,285,345]; % specify climatology longitudes to plot
 nday1 = 325;
 nday2 = 366+20;

xt24 = [0,24];
wx = 35;
wn = -45.;
ytot = [wn,wx];
zero = [0.,0.];
fsize = 12;
figure
% position [left bottom width height]
% Set size to be 8.5x11 inches
set(gcf,'position',[142    99   647   822])
H = gcf;
clf

for j=1:8

% Open file with Scherliess quiet-time drift model for 285 glon 70 f10.7 flux
%   run from vdrift-model_jgr0499.f and located in file wijro_07355_70fx_drift
filwiq = sprintf('/home/emery/cetic/vdrift_07355_70fx_%3.3d',loncutsE(j))
datwiq = dlmread(filwiq,'',1,0);

% Assign ii of geomagnetic equator (+10,+10,+7.5,+0,+0,-5,-12.5,+10) of 36 5deg bins
if j<3 | j==8
imag = 21;
end
if j==3
imag = 20;
end
if j==5 | j==5
imag = 19;
end
if j==6
imag = 17;
end
if j==7;
imag = 16;
end
ut0 = (360.-loncutsE(j))/15. + 0.49;
n0 = fix(ut0);
utnoon = 24.-loncutsE(j)/15.+12.;
if utnoon>23.9
 utnoon = utnoon - 24.;
end
xnoon = [utnoon,utnoon];

Dnam = sprintf('/hao/aim3/emery/cetic_climatology/long_%3.3d_07325_08020_2_TIE-GCM.dat',loncutsE(j))
% ut_beg glat glon1 glon2 tecmed tecmean tecstd nmf2med,mean,std hmf2med,mean,std numdaystec,hmf2 (max 61) wimed wimean wistd
Din = fopen(Dnam,'r');

for n=1:24
 nlt = n-n0;
 if nlt<1
   nlt = nlt + 24;
 end
 ut24(n) = n-0.5;
 quietmod(n) = 0.5*(datwiq(nlt,2)+datwiq(nlt+1,2));
for ii=1:36
 linemod = fgetl(Din);
 inmod = sscanf(linemod,'%f');
 if ii==imag
  wimed(n) = inmod(16);
 end
end	% ii=1:36
end	% n=1:24

%% Make plots
            subplot(4,2,j)
hold on;
title(['TIEGCM-WT Magnetic Equator Viz (m/s) LON=',num2str(loncutsE(j))]);
plot (ut24,wimed,'k');
plot (ut24,quietmod,'--r');
plot(xt24,zero,'--k');
plot(xnoon,ytot,':k');
text(utnoon-0.5,wx-4.,'noon','Color','k','FontSize',fsize,'FontWeight','bold');
text(16.,wn+4.,'Q model','Color','r','FontSize',fsize,'FontWeight','bold');
if (j==7)
 text (0.5,wx-5.,'Jicamarca','Color','k','FontSize',fsize,'FontWeight','bold');
end
ylabel('Wi (m/s)','FontSize',fsize);
xlabel('UT(h)','FontSize',fsize);
set (gca,'xlim',[0,24],'ylim',[wn,wx],'xtick',([0:2:24]),'FontSize',fsize,'box','on');


end	% for j=1:8

hold off;


