clear;

load -ASCII D:\wrk\paper\coastline.mat;

load data/en_inst_michael_dat.mat;

x1=min(s_LON(:));
x2=max(s_LON(:));
y1=min(s_LAT(:));
y2=max(s_LAT(:));

colormap('jet');

k1=subplot(2,2,1);
contourf(s_LON,s_LAT,s_qct_500,[0.:0.25:3.5],'edgecolor','none');
caxis([0. 3.5]);
%contourf(b_LON,b_LAT,b_cref,[20:2.5:55],'edgecolor','none');
%caxis([20 55]);
c1=colorbar;
hold on;
plot(coastline(:,1),coastline(:,2),'color',[0.7 0.7 0.7]);
set(gca,'xtick',[-90:1:-82],'ytick',[24:1:34]);
axis([x1,x2,y1,31]);
h=title('(a) $q_{c}$ (g/kg) at p=500 hPa, HAFS','interpreter','latex'); 
set(h,'fontweight','normal');
xlabel('Longitude');
ylabel('Latitude');
%h=text(-88.5,33.2,'Composite reflectivity (dBZ) of the entire atmosphere at 12 UTC Oct. 10, 2018');
%set(h,'fontsize',9); 
hold off;

k2=subplot(2,2,2);
contourf(s_LON,s_LAT,s_qct_500,[0:0.25:3.5],'edgecolor','none');
caxis([0 3.5]);
%contourf(b_LON,b_LAT,b_cref,[20:2.5:55],'edgecolor','none');
%caxis([20 55]);
hold on;
plot(s_LON(141,146),s_LAT(141,146),'k*','markersize',4);
plot(s_LON(140,146),s_LAT(140,146),'g*','markersize',4);
plot(s_LON(139,146),s_LAT(139,146),'r*','markersize',4);
plot(coastline(:,1),coastline(:,2),'color',[0.7 0.7 0.7]);
set(gca,'xtick',[-90:1:-82],'ytick',[24:1:34]);
%xlabel('Longitude');
%ylabel('Latitude');
axis([-86.28,-86.0,28.0,28.27]);
set(gca,'xtick',[-87:0.1:-86],'ytick',[27.5:0.1:28.5],'ycolor',[0.99 0.99 0.99],'xcolor',[0.99 0.99 0.99],'fontsize',5,'box','on');
hold off;

k4=subplot(2,3,4);
h=plot(p_qvi*1e3,p0/100,'k');
hold on;
h=plot(p_qvm*1e3,p0/100,'g');
h=plot(p_qvo*1e3,p0/100,'r');
h=legend('at black *','at green *','at red *');
set(h,'box','off','fontsize',9);
set(gca,'ydir','reverse');
axis([5,25,400,1000]);
h=title('(b) $q_{t}$ profile at the edge of eyewall','interpreter','latex'); 
set(h,'fontweight','normal');
xlabel('(g/kg)');
ylabel('Pressure (hPa)');
hold off;

k5=subplot(2,3,5);
h=plot(p_thei,p0/100,'k');
hold on;
h=plot(p_them,p0/100,'g');
h=plot(p_theo,p0/100,'r');
h=legend('at black *','at green *','at red *');
set(h,'box','off','position',[0.2607 0.263 0.1661 0.1024],'fontsize',8);
xlabel('(K)');
ylabel('Pressure (hPa)');
h=title('(c) $\theta_{e}$ profile at the edge of eyewall','interpreter','latex'); 
set(h,'fontweight','normal');
set(gca,'ydir','reverse');
axis([345,360,400,1000]);
hold off;

k6=subplot(2,3,6);
den1=(p_them-p_thei)-(p_qvm-p_qvi).*(p_thi+p_thm);
den2=(p_theo-p_them)-(p_qvo-p_qvm).*(p_tho+p_thm);
den3=(p_theo-p_thei)-(p_qvo-p_qvi).*(p_tho+p_thi);

h1=plot(den1,p0/100,'b');
hold on;
h2=plot(den2,p0/100,'b--');
h3=plot(den3,p0/100,'b:');
plot([0 0],[400 1000],'g--');
set(gca,'ydir','reverse');
axis([-10,1,400,1000]);
xlabel('(K)');
ylabel('Pressure (hPa)');
title('(d) $\Delta \theta_{e} - \overline{\theta}\Delta q_{t}/\alpha$','interpreter','latex'); 
h=legend([h1 h2 h3],'green * - black *','red * - green *','red * - black *');
set(h,'box','off','location','southwest');
hold off;

set(k1,'position',[0.10 0.58 0.34 0.38],'fontsize',8);
set(c1,'position',[0.45 0.58 0.02 0.38],'fontsize',8);
set(k2,'position',[0.13 0.61 0.11 0.15],'fontsize',5);
set(k4,'position',[0.60 0.58 0.34 0.38],'fontsize',8);
set(k5,'position',[0.10 0.07 0.34 0.38],'fontsize',8);
set(k6,'position',[0.60 0.07 0.34 0.38],'fontsize',8);

print -dpng en_inst_HAFS_plot
