GDP1990_ADJ=GDP1990*1.81;



for i=1:6
    MaskGDPEI1990=nan(139,231);
    MaskGDPEI2015=nan(139,231);
    MaskGDPEI1990(GDPEI1990>(i*1-1))=1;
    MaskGDPEI2015(GDPEI2015>(i*1-1))=1;
    GDPEISUM(1,i)=nansum(nansum(GDP1990_ADJ.*MaskGDPEI1990));
    GDPEISUM(2,i)=nansum(nansum(GDP2015.*MaskGDPEI2015));
    AGDPEISUM(1,i)=nansum(nansum(MaskGDPEI1990))*770.0625;
    AGDPEISUM(2,i)=nansum(nansum(MaskGDPEI2015))*770.0625;
end


for i=1:6
    MaskGDPEI21990=nan(139,231);
    MaskGDPEI22015=nan(139,231);
    MaskGDPEI21990(GDPEI21990>(i*0.4-0.4))=1;
    MaskGDPEI22015(GDPEI22015>(i*0.4-0.4))=1;
    GDPEI2SUM(1,i)=nansum(nansum(GDP1990_ADJ.*MaskGDPEI21990));
    GDPEI2SUM(2,i)=nansum(nansum(GDP2015.*MaskGDPEI22015));
    AGDPEI2SUM(1,i)=nansum(nansum(MaskGDPEI21990))*770.0625;
    AGDPEI2SUM(2,i)=nansum(nansum(MaskGDPEI22015))*770.0625;
end


 [ha, pos] = tight_subplot(2,4,[.1,.05],[.2 .2],[.02 .02])
% for ii = 1:8; axes(ha(ii)); plot(randn(10,ii)); end
% set(ha(1:2),'XTickLabel',''); set(ha,'YTickLabel','')
axes(ha(1))
    m_proj('Lambert','lon',NEWLONLIMS,'lat',NEWLATLIMS)
    m_pcolor(trmm_pos(:,:,1), trmm_pos(:,:,2),GDPEI1990);shading flat;
    m_grid('linewi',0.5,'tickdir','out')
    % hold on
    % m_plot(bndlon4(:)-0.125,bndlat4(:)+0.125,'x','color','k');
    caxis([0 6.3])
    for k=1:length(M.ncst)
    m_line(M.ncst{k}(:,1),M.ncst{k}(:,2),'color','k','linewidth', 0.5);
    end
    title('a.>100 mm TCPEI, Early Period')
    colormap(gca,'jet')
    set(gca,'fontsize',12);
    h1=colorbar;
    colorTitleHandle = get(h1,'Title');
    titleString = 'TCPEI';
    set(colorTitleHandle ,'String',titleString);


axes(ha(2))
    m_proj('Lambert','lon',NEWLONLIMS,'lat',NEWLATLIMS)
    m_pcolor(trmm_pos(:,:,1), trmm_pos(:,:,2),GDPEI2015);shading flat;
    m_grid('linewi',0.5,'tickdir','out')
    % hold on
    % m_plot(bndlon4(:)-0.125,bndlat4(:)+0.125,'x','color','k');
     caxis([0 6.3])
    for k=1:length(M.ncst)
    m_line(M.ncst{k}(:,1),M.ncst{k}(:,2),'color','k','linewidth', 0.5);
    end
    title('b. >100 mm TCPEI, Late Period')
    colormap(gca,'jet')
    set(gca,'fontsize',12);
    h2=colorbar;
    colorTitleHandle = get(h2,'Title');
    titleString = 'TCPEI';
    set(colorTitleHandle ,'String',titleString);

axes(ha(3))
Xlab = categorical({'>0','>1','>2','>3','>4','>5'});
Xlab = reordercats(Xlab,{'>0','>1','>2','>3','>4','>5'});
b1=bar(Xlab,GDPEISUM');
xtips1 =b1(1).XEndPoints;
ytips1 = b1(1).YEndPoints;
labels1 = ({'5.2t','2t','1t','455b','135b','8b'});
text(xtips1,ytips1,labels1,'HorizontalAlignment','center',...
    'VerticalAlignment','bottom','FontSize',8)
xtips2 =b1(2).XEndPoints;
ytips2 = b1(2).YEndPoints;
labels2 = ({'5.3t','4t','2t','1t','577b','169b'});
text(xtips2,ytips2,labels2,'HorizontalAlignment','center',...
    'VerticalAlignment','bottom','FontSize',8)
title('c. >100 mm TCPEI and GDP')
xlabel('TCPEI')
ylabel('GDP (USD)')
legend('Early Period','Late Period')
set(gca,'fontsize',12);

axes(ha(4))
Xlab = categorical({'>0','>1','>2','>3','>4','>5'});
Xlab = reordercats(Xlab,{'>0','>1','>2','>3','>4','>5'});
b2=bar(Xlab,AGDPEISUM');
xtips3 =b2(1).XEndPoints;
ytips3 = b2(1).YEndPoints;
labels3 = ({'967k','506k','177k','57k','7701','1540'});
text(xtips3,ytips3,labels3,'HorizontalAlignment','center',...
    'VerticalAlignment','bottom','FontSize',8)
xtips4 =b2(2).XEndPoints;
ytips4 = b2(2).YEndPoints;
labels4 = ({'1.3m','889k','428k','196k','85k','22k'});
text(xtips4,ytips4,labels4,'HorizontalAlignment','center',...
    'VerticalAlignment','bottom','FontSize',8)
title('d. >100 mm TCPEI and Area')
xlabel('TCPEI')
ylabel('Area (km^{2})')
legend('Early Period','Late Period')
set(gca,'fontsize',12);


axes(ha(5))
    m_proj('Lambert','lon',NEWLONLIMS,'lat',NEWLATLIMS)
    m_pcolor(trmm_pos(:,:,1), trmm_pos(:,:,2),GDPEI21990);shading flat;
    m_grid('linewi',0.5,'tickdir','out')
    % hold on
    % m_plot(bndlon4(:)-0.125,bndlat4(:)+0.125,'x','color','k');
    caxis([0 3.15])
    for k=1:length(M.ncst)
    m_line(M.ncst{k}(:,1),M.ncst{k}(:,2),'color','k','linewidth', 0.5);
    end
    title('e. >200 mm TCPEI, Early Period')
    colormap(gca,'jet')
    set(gca,'fontsize',12);
    h1=colorbar;
    colorTitleHandle = get(h1,'Title');
    titleString = 'TCPEI';
    set(colorTitleHandle ,'String',titleString);


axes(ha(6))
    m_proj('Lambert','lon',NEWLONLIMS,'lat',NEWLATLIMS)
    m_pcolor(trmm_pos(:,:,1), trmm_pos(:,:,2),GDPEI22015);shading flat;
    m_grid('linewi',1.5,'tickdir','out')
    % hold on
    % m_plot(bndlon4(:)-0.125,bndlat4(:)+0.125,'x','color','k');
     caxis([0 3.15])
    for k=1:length(M.ncst)
    m_line(M.ncst{k}(:,1),M.ncst{k}(:,2),'color','k','linewidth', 0.5);
    end
    title('f. >200 mm TCPEI, Late Period')
    colormap(gca,'jet')
    set(gca,'fontsize',12);
    h2=colorbar;
    colorTitleHandle = get(h2,'Title');
    titleString = 'TCPEI';
    set(colorTitleHandle ,'String',titleString);

axes(ha(7))
Xlab2 = categorical({'>0','>0.4','>0.8','>1.2','>1.6','>2'});
Xlab2 = reordercats(Xlab2,{'>0','>0.4','>0.8','>1.2','>1.6','>2'});
b3=bar(Xlab2,GDPEI2SUM');
xtips5 =b3(1).XEndPoints;
ytips5 = b3(1).YEndPoints;
labels5 = ({'581b','571b','285b','84b','6b','0'});
text(xtips5,ytips5,labels5,'HorizontalAlignment','center',...
    'VerticalAlignment','bottom','FontSize',8)
xtips6 =b3(2).XEndPoints;
ytips6 = b3(2).YEndPoints;
labels6 = ({'1.3t','1.3t','1t','638b','309m','181m'});
text(xtips6,ytips6,labels6,'HorizontalAlignment','center',...
    'VerticalAlignment','bottom','FontSize',8)
title('g. >200 mm TCPEI and GDP')
xlabel('TCPEI')
ylabel('GDP (USD)')
legend('Early Period','Late Period')
% ylim([0 35000000])
set(gca,'fontsize',12);


axes(ha(8))
Xlab2 = categorical({'>0','>0.4','>0.8','>1.2','>1.6','>2'});
Xlab2 = reordercats(Xlab2,{'>0','>0.4','>0.8','>1.2','>1.6','>2'});
b4=bar(Xlab2,AGDPEI2SUM');
xtips7 =b4(1).XEndPoints;
ytips7 = b4(1).YEndPoints;
labels7 = ({'109k','76k','26k','6931','2310','0'});
text(xtips7,ytips7,labels7,'HorizontalAlignment','center',...
    'VerticalAlignment','bottom','FontSize',8)
xtips8 =b4(2).XEndPoints;
ytips8 = b4(2).YEndPoints;
labels8 = ({'286k','246k','162k','87k','39k','15k'});
text(xtips8,ytips8,labels8,'HorizontalAlignment','center',...
    'VerticalAlignment','bottom','FontSize',8)
title('h. >200 mm TCPEI and Area')
xlabel('TCPEI')
ylabel('Area (km^{2})')
legend('Early Period','Late Period')
set(gca,'fontsize',12);
ylim([0 310000])
