%%
%% This program is written for plotting the CMIT-TIEGCM WI_ExB data at the equator
clear all; close all

ht1 = 250.e+5;
ht2 = 325.e+5;
% May 2012 wi_schmitt_dec06.nc from 329-348 every 0 UT, then every 30 min to 350 0 UT
 [nt2d,dayfrac2d,ut2d,wiav2d] = get_wi_nc('wi_schmitt_dec06.nc',ht1,ht2,18);
% wi_22_24ut.nc on 06348 every 5 min from 22-24 UT
 [nt2h,dayfrac2h,ut2h,wiav2h] = get_wi_nc('wi_22_24ut.nc',ht1,ht2,18);
% 25 Sep 2012 wi_schmitt_dec06.nc from 329-348 every 0 UT, then every 30 min to 350 0 UT
 [nt3d,dayfrac3d,ut3d,wiav3d] = get_wi_nc('wi_calccloc_dec06.nc',ht1,ht2,18);

 ut1 = 0;
 ut2 = 48;

% i=72 from -180 to +180; Jicamarca = -76 or i=22
i1=22;
noon76w = 12.+5.;
% 180 deg apart (105E)
i2=22+36;
noon105e = 12.-7.;
% 90 deg before 165W
noon165w = 12.+11.;
i3=22-18;
% 90 deg after 15E
noon15e=12.-1.;
i4=22+18;
for it=20:nt2d
 ut30m(it-19)=0+(it-20)*0.5;
 wi76w(it-19)=wiav2d(i1,it);
 wi105e(it-19)=wiav2d(i2,it);
 wi165w(it-19)=wiav2d(i3,it);
 wi15e(it-19)=wiav2d(i4,it);
 wi76w3(it-19)=wiav3d(i1,it);
 wi105e3(it-19)=wiav3d(i2,it);
 wi165w3(it-19)=wiav3d(i3,it);
 wi15e3(it-19)=wiav3d(i4,it);
end
for it=1:nt2h
 ut05m(it) = 22+it*5./60.;
 wi76w2(it) = wiav2h(i1,it);
 wi105e2(it) = wiav2h(i2,it);
 wi165w2(it) = wiav2h(i3,it);
 wi15e2(it) = wiav2h(i4,it);
end
% Save only every 30 min
 ut30m2(1) = 22.5;
 ut30m2(2) = 23.0;
 ut30m2(3) = 23.5;
 ut30m2(4) = 24.0;
 wi76w30m(1) = wi76w2(6);
 wi76w30m(2) = wi76w2(12);
 wi76w30m(3) = wi76w2(18);
 wi76w30m(4) = wi76w2(24);
 wi105e30m(1) = wi105e2(6);
 wi105e30m(2) = wi105e2(12);
 wi105e30m(3) = wi105e2(18);
 wi105e30m(4) = wi105e2(24);
 wi165w30m(1) = wi165w2(6);
 wi165w30m(2) = wi165w2(12);
 wi165w30m(3) = wi165w2(18);
 wi165w30m(4) = wi165w2(24);
 wi15e30m(1) = wi15e2(6);
 wi15e30m(2) = wi15e2(12);
 wi15e30m(3) = wi15e2(18);
 wi15e30m(4) = wi15e2(24);


xt24 = [ut1,ut2];
wx = 170.;
wn = -170.;
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

%% Make plots
subplot('Position',[0.10,0.72,0.85,0.22])
hold on;
title('TIEGCM-CMIT at 2.5S (... at noon)','FontSize',15,'FontWeight','bold');
xnoon = [noon165w,noon165w];
xnoon2 = [noon165w+24,noon165w+24];
plot (ut05m,wi165w2,'c');
plot (ut30m,wi165w,'k');
plot (ut30m,wi165w3,'r');
%plot (ut30m2,wi165w30m,'y');
text (1.0,0.8*wx,'165W','Color','k','FontSize',fsize,'FontWeight','bold');
text (8.,0.8*wx,'crit(1)=15','Color','k','FontSize',fsize,'FontWeight','bold');
text (26.,0.8*wx,'calccloc crit(1)=Rc+5','Color','r','FontSize',fsize,'FontWeight','bold');
text (43.,0.8*wx,'5 min','Color','c','FontSize',fsize,'FontWeight','bold');
plot(xt24,zero,'--k');
plot(xnoon,ytot,':k');
plot(xnoon2,ytot,':k');
ylabel('Wi (m/s)','FontSize',fsize);
xlabel('UT(h)','FontSize',fsize);
set (gca,'xlim',[0,48],'ylim',[wn,wx],'xtick',([0:2:48]),'XTickLabel',{' ';},'FontSize',fsize,'box','on');

subplot('Position',[0.10,0.50,0.85,0.22])
hold on;
xnoon = [noon76w,noon76w];
xnoon2 = [noon76w+24,noon76w+24];
plot (ut05m,wi76w2,'c');
plot (ut30m,wi76w,'k');
plot (ut30m,wi76w3,'r');
%plot (ut30m2,wi76w30m,'y');
text (1.0,0.8*wx,'75W','Color','k','FontSize',fsize,'FontWeight','bold');
plot(xt24,zero,'--k');
plot(xnoon,ytot,':k');
plot(xnoon2,ytot,':k');
ylabel('Wi (m/s)','FontSize',fsize);
xlabel('UT(h)','FontSize',fsize);
set (gca,'xlim',[0,48],'ylim',[wn,wx],'xtick',([0:2:48]),'XTickLabel',{' ';},'FontSize',fsize,'box','on');

subplot('Position',[0.10,0.28,0.85,0.22])
hold on;
xnoon = [noon15e,noon15e];
xnoon2 = [noon15e+24,noon15e+24];
plot (ut05m,wi15e2,'c');
plot (ut30m,wi15e,'k');
plot (ut30m,wi15e3,'r');
%plot (ut30m2,wi15e30m,'y');
text (1.0,0.8*wx,'15E','Color','k','FontSize',fsize,'FontWeight','bold');
plot(xt24,zero,'--k');
plot(xnoon,ytot,':k');
plot(xnoon2,ytot,':k');
ylabel('Wi (m/s)','FontSize',fsize);
xlabel('UT(h)','FontSize',fsize);
set (gca,'xlim',[0,48],'ylim',[wn,wx],'xtick',([0:2:48]),'XTickLabel',{' ';},'FontSize',fsize,'box','on');

subplot('Position',[0.10,0.06,0.85,0.22])
hold on;
xnoon = [noon105e,noon105e];
xnoon2 = [noon105e+24,noon105e+24];
plot (ut05m,wi105e2,'c');
plot (ut30m,wi105e,'k');
plot (ut30m,wi105e3,'r');
%plot (ut30m2,wi105e30m,'y');
text (1.0,0.8*wx,'105E','Color','k','FontSize',fsize,'FontWeight','bold');
plot(xt24,zero,'--k');
plot(xnoon,ytot,':k');
plot(xnoon2,ytot,':k');
ylabel('Wi (m/s)','FontSize',fsize);
xlabel('UT(h)','FontSize',fsize);
set (gca,'xlim',[0,48],'ylim',[wn,wx],'xtick',([0:2:48]),'FontSize',fsize,'box','on');
hold off;


