load('EDBRAMS_data_EDdata_published.mat')

Lv=2.25e6;



%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
%----------------------Figure 1, Precipitation in obs and model
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%



%-- Plot modeled precip against TRMM

%------%
% Seasons
% Dry Season: May - October
% Wet Season: Nov - March
% 5:10, [11 12 1:4]


%-------------------------------------------------------------------------%
%-------------------------May-Oct
%-------------------------------------------------------------------------%
% 
%---------------------Panel A---------------------------------%
% cbmax=300;
% %----Observations (TRMM)
% fig_abby, colormap(blues)
% mth = 5:10;
% mapdata = squeeze((mean(trmm_pcp_a(mth,:,:),1)));
% set(gca,'FontSize',14);
% axm=axesm('mapprojection','pcarree','fontsize',14, ...
% 		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
% pcolorm(trmm_lat, trmm_lon,mapdata);
% plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
% tightmap;
% caxis([0 cbmax]);
% cmap = colormap;
% %colormap(flipud(cmap));
% cb=colorbar;
% title(['Precipitation (mm/month), TRMM Observations, May-Oct'])
% filename = ['precip_TRMM_MayOct'];
% print('-dpng',filename);
% 


%---------------------Panel C---------------------------------%
cbmax = 300;
%----Control
fig_abby, colormap(blues)
mth = 5:10;
mapdata = 30.*(mean(precip_CLU_a(:,mth),2));
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');
plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([0 cbmax]);
cmap = colormap;
%colormap(flipud(cmap));
cb=colorbar;
title(['Precipitation (mm/month), CLU, May-Oct'])
filename = ['precip_CLU_MayOct'];
print('-dpng',filename);

%---------------------Panel E---------------------------------%
%----Delta
cbmax = 15;
fig_abby, colormap(thermal6)	
mth = 5:10;
mapdata = 30.*(mean(precip_LU_a(:,mth),2)-mean(precip_CLU_a(:,mth),2));
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');
plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
colormap(flipud(cmap));
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);
title(['\Delta Precipitation (mm/month), LU-CLU, May-Oct'])
filename = ['precip_LUmCLU_MayOct'];
print('-dpng',filename);




%-------------------------------------------------------------------------%
%---------------------------Nov-Apr
%-------------------------------------------------------------------------%

% 
% 
%---------------------Panel B---------------------------------%
% cbmax=300;
% %----Observations (TRMM)
% fig_abby, colormap(blues)
% mth = [11 12 1:4];
% mapdata = squeeze((mean(trmm_pcp_a(mth,:,:),1)));
% set(gca,'FontSize',14);
% axm=axesm('mapprojection','pcarree','fontsize',14, ...
% 		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
% pcolorm(trmm_lat, trmm_lon,mapdata);
% plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
% tightmap;
% caxis([0 cbmax]);
% cmap = colormap;
% %colormap(flipud(cmap));
% cb=colorbar;
% title(['Precipitation (mm/month), TRMM Observations, Nov-Apr'])
% filename = ['precip_TRMM_NovApr'];
% print('-dpng',filename);
% 
% 

%---------------------Panel D---------------------------------%
cbmax = 300;
%----Control
fig_abby, colormap(blues)
mth = [11 12 1:4];
mapdata = 30.*(mean(precip_CLU_a(:,mth),2));
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');
plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([0 cbmax]);
cmap = colormap;
%colormap(flipud(cmap));
cb=colorbar;
title(['Precipitation (mm/month), CLU, Nov-Apr'])
filename = ['precip_CLU_NovApr'];
print('-dpng',filename);

%---------------------Panel F---------------------------------%
%----Delta
cbmax = 15;
fig_abby, colormap(thermal6)	
mth = [11 12 1:4];
mapdata = 30.*(mean(precip_LU_a(:,mth),2)-mean(precip_CLU_a(:,mth),2));
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');
plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
colormap(flipud(cmap));
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);
title(['\Delta Precipitation (mm/month), LU-CLU, Nov-Apr'])
filename = ['precip_LUmCLU_NovApr'];
print('-dpng',filename);



%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
%----------------------Figure 2, delta simAmazonia obs, map of states 
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%



%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
%----------------------Figure 3, total LAI, delta LAI delta AGB
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%

%---------------------Panel A---------------------------------%
%-----current
mth = 1:12;
mapdata = mean(laitot_CLU_a(:,mth),2);  
cbmax=6;

fig_abby
colormap(browngreen)
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
         'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');

scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');

plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
%caxis([minc1 maxc1]);
title(['LAI (m^2/m^2) CLU, Annual Mean'],'FontSize',14);


caxis([0 cbmax]);
cb=colorbar;

filename = ['lai_CLU_annmean'];
print('-dpng', filename);


%---------------------Panel B---------------------------------%
%-----future
mth = 1:12;
mapdata = mean(laitot_LU_a(:,mth),2);  
cbmax=6;

fig_abby
colormap(browngreen)
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
         'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');

scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');

plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
%caxis([minc1 maxc1]);
title(['LAI (m^2/m^2) LU, Annual Mean'],'FontSize',14);


caxis([0 cbmax]);
cb=colorbar;

filename = ['lai_LU_annmean'];
print('-dpng', filename);



%---------------------Panel C---------------------------------%
%-----delta
mth = 1:12;
mapdata = mean(laitot_LU_a(:,mth),2)-mean(laitot_CLU_a(:,mth),2);  
cbmax=2;

fig_abby
colormap(browngreen)
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
         'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');

scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');

plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
%caxis([minc1 maxc1]);
title(['\Delta LAI (m^2/m^2) LU-CLU, Annual Mean'],'FontSize',14);


caxis([-cbmax cbmax]);
cb=colorbar;

filename = ['lai_LUmCLU_annmean'];
print('-dpng', filename);




%---------------------Panel D---------------------------------%
%--- delta AGBtot
mapdata = mean(agbtot_LU_a-agbtot_CLU_a,2);
cbmax=10;

fig_abby
colormap(browngreen)
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');

scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');

plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
title(['\Delta AGB (kgC/m^2) LU-CLU'],'FontSize',14);


caxis([-cbmax cbmax]);
cb=colorbar;

filename = ['agb_LUmCLU'];
print('-dpng', filename);


%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
%----------------------Figure 4, Latent heat flux components
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%

%--------------------------------------------------------------------
%----------panel A-----------------------------------------------------
%-- total lhflx (vapor_ac)
% converted to W/m2 by 2.25e6.  1mm water column = 1kg/m2, 2260 J/kg LH of

cbmax=15;
fig_abby, colormap(thermal6)

mth = 1:12;
mapdata = -Lv.*((mean(vapor_ac_LU_a(:,mth),2)-mean(vapor_ac_CLU_a(:,mth),2)));

set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');

scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');

plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
colormap(flipud(cmap));
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);
title(['\Delta Total Latent Heat Flux (vaporac)(W/m^2) Annual Mean'])

%---save the figure
filename = ['vapor_ac_LUmCLU_annmean'];
print('-dpng', filename);


%--------------------------------------------------------------------
%-----------panel B ---------------------------------------------------------
%-- canopy evaporation (vapor_lc)
% converted to W/m2 by 2.25e6.  1mm water column = 1kg/m2, 2260 J/kg LH of
% vap

cbmax=15;
fig_abby, colormap(thermal6)

mth = 1:12;
mapdata = Lv.*((mean(vapor_lc_LU_a(:,mth),2)-mean(vapor_lc_CLU_a(:,mth),2)));

set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');

scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');

plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
colormap(flipud(cmap));
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);
title(['\Delta Canopy Evaporation (W/m^2) Annual Mean'])

%---save the figure
filename = ['vapor_lc_LUmCLU_annmean'];
print('-dpng', filename);


%------------panel C--------------------------------------------------------
%--transpiration fluxes
%--------------------------------------------------------------------

cbmax=15;
fig_abby, colormap(thermal6)

mth = 1:12;
mapdata = Lv.*((mean(transp_LU_a(:,mth),2)-mean(transp_CLU_a(:,mth),2)));

set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');

scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');

plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
colormap(flipud(cmap));
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);


title(['\Delta Transpiration (W/m^2) Annual Mean'])

%---save the figure
filename = ['transp_LUmCLU_annmean'];
print('-dpng', filename);




%-------------panel D-------------------------------------------------------
%--------------------------------------------------------------------
%-- ground evaporation (vapor_gc)
% converted to W/m2 by 2.23e6.  1mm water column = 1kg/m2, 2260 J/kg LH of

cbmax=15;
fig_abby, colormap(thermal6)

mth = 1:12;
mapdata = Lv.*((mean(vapor_gc_LU_a(:,mth),2)-mean(vapor_gc_CLU_a(:,mth),2)));

set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');

scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');

plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
colormap(flipud(cmap));
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);
title(['\Delta Ground Evaporation (W/m^2) Annual Mean'])

%---save the figure
filename = ['vapor_gc_LUmCLU_annmean'];
print('-dpng', filename);





%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
%----------------------Figure 5, SW down, net SW, CanTemp, SHFLX
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%



%----------------panel A ----------------------------------------------------
%--------------------------------------------------------------------

%----rshort down
mths=1:12;
cbmax=15;
fig_abby, colormap(thermal6)

mapdata = (mean(rshortdown_LU_a(:,mths),2)-mean(rshortdown_CLU_a(:,mths),2));
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');
plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);
title(['\Delta Rshortdown (W/m^2), Annual Mean (LU-CLU)'])
%---save the figure
filename = ['rshortdown_LUmCLU_annmean'];
print('-dpng', filename);




%!!% %{ %%--COMMENTED OUT THIS FIGURE--%%
%!!% %---------------------panel B----------------------------------------------------%
%!!% %-------------------------------------------------------------------------%
%!!% % - this one requires an additional dataset
%!!% %--- Net Shortwave
%!!% 
%!!% %-Plot
%!!% cbmax=15;
%!!% mapdata = mean(rshortdown_LU_a.*(1-albedt_LU_EDformat) -rshortdown_CLU_a.*(1-albedt_CLU_EDformat),2);
%!!% 
%!!% fig_abby, colormap(thermal6)
%!!% set(gca,'FontSize',14);
%!!% axm=axesm('mapprojection','pcarree','fontsize',14, ...
%!!%          'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
%!!% 
%!!% scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');
%!!% 
%!!% plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
%!!% tightmap;
%!!% 
%!!% title(['\Delta Net Shortwave (W/m^2), Annual Mean LU-CLU'],'FontSize',14);
%!!% cmap = colormap;
%!!% colormap(flipud(cmap));
%!!% caxis([-cbmax cbmax]);
%!!% cb=colorbar;
%!!% set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);
%!!% 
%!!% filename = ['netSW_LUmCLU_annmean'];
%!!% print('-dpng', filename);
%!!%  %}


%--------------------------------------------------------------------
%---------------------Panel C-----------------------------------------------


%--- Canopy Temperature
mth = 1:12;
mapdata = mean(cantemp_LU(:,mth),2)-mean(cantemp_CLU(:,mth),2);
cbmax=1.2;

fig_abby, colormap(thermal6)
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
         'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');

scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');

plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
%caxis([minc1 maxc1]);
title('\Delta Canopy Temp LU-CLU, annual mean','FontSize',14);

caxis([-cbmax cbmax]);
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);

filename = 'cantemp_LUmCLU_annmean';
print('-dpng', filename);

%--------------------------------------------------------------------
%----------------------panel D----------------------------------------------

%----sensible heat flux
cbmax=15;
fig_abby, colormap(thermal6)

mth = 1:12;
mapdata = (mean(shflx_LU_a(:,mth),2)-mean(shflx_CLU_a(:,mth),2));

set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');

scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');

plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
%colormap(flipud(cmap));
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);

title(['Total Sensible Heat Flux (W/m^2) Annual Mean'])

%---save the figure
filename = ['shflx_LUmCLU_annmean'];
print('-dpng', filename);



%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
%----------------------Figure 6 kg unit precip, ET, T/LAI, Runoff
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%

%----------------------panel A---------------------------------------------------%
%---Precip
mapdata = (mean(precip_LU_a(:,mth),2)-mean(precip_CLU_a(:,mth),2));

cbmax=.9;
mth = 1:12;
fig_abby, colormap(thermal6)
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');
plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
colormap(flipud(cmap));
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);
title(['\Delta Precip (kg/m2/day), LU-CLU Annual mean'])

%---save the figure
filename = ['precip_LUmCLU_annmean'];
print('-dpng', filename);


%-------------------panel B------------------------------------------------------%
%----LHFLX -plotted from vapor transfer from canopy to atm (VERY DIFFERENT
%FROM LHFLX directly!!!)
%mapdata = (60*60*24).*2.23e-6.*(mean(lhflx_CLU_a(:,mth),2));
mapdata = -(60*60*24).*(mean(vapor_ac_LU_a(:,mth),2)-mean(vapor_ac_CLU_a(:,mth),2));
cbmax=.9;
mth = 1:12;
fig_abby, colormap(thermal6)
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');
plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
colormap(flipud(cmap));
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);
title(['\Delta Vapor transer to atm (kg/m2/day), LU-CLU Annual mean'])

%---save the figure
filename = ['vapor_ac_LUmCLU_annmean_kg'];
print('-dpng', filename);


%-------------------panel C------------------------------------------------------%
%--- plot transpiration over leaf area

mth = 1:12;
mapdata = (mean(transp_LU_a(:,mth)./laitot_LU_a(:,mth),2)-mean(transp_CLU_a(:,mth)./laitot_CLU_a(:,mth),2));
cbmax=.3e-5;
fig_abby, colormap(thermal6)
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');
plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
colormap(flipud(cmap));
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);

title(['\Delta Traspiration/LAI (W/m^2leaf), LU-CLU Annual mean'])

%---save the figure
filename = ['ToLAI_LUmCLU_annmean'];
print('-dpng', filename);



%---------------------panel D----------------------------------------------------%
%---drainage
mapdata = (60*60*24).*(mean(drainage_LU_a(:,mth),2)-mean(drainage_CLU_a(:,mth),2));
cbmax=.9;
mth = 1:12;
fig_abby, colormap(thermal6)
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
scatterm(latitude_LU, longitude_LU,25,mapdata,'s','filled');
plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
colormap(flipud(cmap));
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);

title(['\Delta Drainage (kg/m2/day), LU-CLU Annual mean'])

%---save the figure
filename = ['drainage_LUmCLU_annmean'];
print('-dpng', filename);



%{ %%--COMMENTED OUT FIGURE 7 - requires a different dataset--%%
return

%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
%----------------------Figure 7, CAPE & CIN
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%

%%%---------------Panel A------------------------------------------------------%%%

mths = 9;

%---CAPE SEPT
mapdata=mean(cape_mmean_2005to2007_LU(:,:,mths)-cape_mmean_2005to2007_CLU(:,:,mths),3);

cbmax=450;
fig_abby, colormap(thermal6)
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
pcolorm(lat_BRAMS_mat, lon_BRAMS_mat,mapdata);
plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
colormap(flipud(cmap));
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);
title(['\Delta CAPE LU-CLU, September'])
filename = ['cape_LUmCLU_Sept'];
print('-dpng',filename);






%%%-----------------Panel B----------------------------------------------------%%%

%-------test significance
mths=9;
cape_CLU_std = std(squeeze(mean(cape_mmean_2005to2007m_CLU(:,:,mths,:),3)),0,3);
cape_LU_std = std(squeeze(mean(cape_mmean_2005to2007m_LU(:,:,mths,:),3)),0,3);

cape_CLU=mean(cape_mmean_2005to2007_CLU(:,:,mths),3);
cape_LU=mean(cape_mmean_2005to2007_LU(:,:,mths),3);


[cape_t,cape_pval,cape_reject95flag2tail] = ttest_for_twomeans_2tail_ABBY(cape_CLU,cape_LU,cape_CLU_std,cape_LU_std,5,5,4,4);
mask = nan(size(cape_CLU));
mask(cape_pval<=0.1)=1;

%---PLOT
mapdata=(cape_LU-cape_CLU).*mask;

cbmax=500
fig_abby, colormap(thermal6)
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
pcolorm(lat_BRAMS_mat, lon_BRAMS_mat,mapdata);
plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
colormap(flipud(cmap));
cb=colorbar;
title(['\Delta CAPE LU-CLU, Sept masked for significance 90%'])
filename = ['cape_LUmCLU_Sept_maskedforsig'];
print('-dpng',filename);


%-non map
indx=find(cape_pval<=0.1);
fig_abby
plot(cape_CLU(:), cape_LU(:),'+')
plot(cape_CLU(indx),cape_LU(indx),'g+')
grid on
plot([0 5000],[0 5000],'r')
xlabel('CAPE, CLU')
ylabel('CAPE, LU')
title ('Sept mean, masked for sig 90%')
set(gca,'fontsize',14)
filename = ['cape_CLUvLU_sept_maskedforsig'];
print('-dpdf',filename);


%%%---------------------------------------------------------------------%%%
%%%-----------------Panel C----------------------------------------------------%%%

%------CINE SEPT
mapdata=mean(cine_mmean_2005to2007_LU(:,:,mths)-cine_mmean_2005to2007_CLU(:,:,mths),3);

cbmax=21
fig_abby, colormap(thermal6)
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
pcolorm(lat_BRAMS_mat, lon_BRAMS_mat,mapdata);
plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
%colormap(flipud(cmap));
cb=colorbar;
set(cb,'ytick',[-cbmax:cbmax/3:cbmax]);
title(['\Delta CINE LU-CLU, September'])
filename = ['cine_LUmCLU_Sept'];
print('-dpng',filename);



%%%-----------------Panel D ----------------------------------------------------%%%


%-------test significance
mths=9;
cine_CLU_std = std(squeeze(mean(cine_mmean_2005to2007m_CLU(:,:,mths,:),3)),0,3);
cine_LU_std = std(squeeze(mean(cine_mmean_2005to2007m_LU(:,:,mths,:),3)),0,3);

cine_CLU=mean(cine_mmean_2005to2007_CLU(:,:,mths),3);
cine_LU=mean(cine_mmean_2005to2007_LU(:,:,mths),3);


[cine_t,cine_pval,cine_reject95flag2tail] = ttest_for_twomeans_2tail_ABBY(cine_CLU,cine_LU,cine_CLU_std,cine_LU_std,5,5,4,4);
mask = nan(size(cine_CLU));
mask(cine_pval<=0.1)=1;

%---PLOT
mapdata=(cine_LU-cine_CLU).*mask;

cbmax=25
fig_abby, colormap(thermal6)
set(gca,'FontSize',14);
axm=axesm('mapprojection','pcarree','fontsize',14, ...
		 'maplatlim',[ltsouth ltnorth],'maplonlim',[lnwest lneast]); %,'Grid','on');
pcolorm(lat_BRAMS_mat, lon_BRAMS_mat,mapdata);
plotm(brazil_lat,brazil_lon,'Color','k','LineWidth',1);
tightmap;
caxis([-cbmax cbmax]);
cmap = colormap;
%colormap(flipud(cmap));
cb=colorbar;
title(['\Delta CINE LU-CLU, Sept masked for significance 90%'])
filename = ['cine_LUmCLU_sept_maskedforsig'];
print('-dpng',filename);

%-non map
indx=find(cine_pval<=0.1);
fig_abby
plot(cine_CLU(:), cine_LU(:),'+')
plot(cine_CLU(indx),cine_LU(indx),'g+')
grid on
plot([0 500],[0 500],'r')
xlabel('CINE, CLU')
ylabel('CINE, LU')
title ('Sept mean, masked for sig 90%')
set(gca,'fontsize',14)
filename = ['cine_CLUvLU_sept_maskedforsig'];
print('-dpdf',filename);


%} % end commented out figure
