%
% Analyse predictions of future temperatures based on persistence of model-forced trend
% + forward projection of internal variability (AMO, PMO & NMO modes)
% modes
%
% (C) Michael Mann, 2015.
%
%
% FIGURE 1 
%
% Zonal temperature fingerprint 
%
figure(1)
h1=subplot(2,2,1); % zonal temperature profiles for PWR-favorable vs. climatological mean
p(1)=0.09;
p(2)=0.56;
p(3)=0.38;
p(4)=0.40;
set(h1,'pos',p);
load AllForcingRun
hold
title('T_{zonal mean}')
set(gca,'FontSize',14);
hline1=plot(lat0,T_clim_JJA_NH_ERA,'k','Linewidth',2);
hline2=plot(lat0,T_QRA_JJA_NH_ERA,'k--','Linewidth',2);
set(gca,'YLim',[272 303])
set(gca,'XLim',[0 90])
ylabel('Temperature(^oC)');
xlabel('Latitude(^o)'); 
legend([hline1,hline2],'climatology','QRA conditions');
%
h2=subplot(2,2,2); % diff between QRA-favorable and climatological zonal temps
p(1)=0.54;
p(2)=0.56;
p(3)=0.38;
p(4)=0.40;
set(h2,'pos',p);
hold
title('T_{diff}')
set(gca,'FontSize',14);
Tzone_anom=T_QRA_JJA_NH_ERA-T_clim_JJA_NH_ERA;
hline1=plot(lat0,Tzone_anom,'b','Linewidth',2);
set(gca,'YLim',[-0.1 1.0])
set(gca,'XLim',[0 90])
ylabel('Temperature Diff(^oC)');
xlabel('Latitude(^o)'); 
legend([hline1],'QRA minus climatology');
%
h3=subplot(2,2,3); % QRA fingerprint
p(1)=0.09;
p(2)=0.08;
p(3)=0.38;
p(4)=0.40;
set(h3,'pos',p);
hold
title('T_{diff}')
set(gca,'FontSize',14);
hline1=plot(lat,Tprof,'b','Linewidth',2);
set(gca,'YLim',[-0.5 0.55])
set(gca,'XLim',[0 90])
ylabel('Temperature Diff(^oC)');
xlabel('Latitude(^o)'); 
legend([hline1],'QRA Fingerprint');
%
h4=subplot(2,2,4); % zonal temp gradient extrop NH
p(1)=0.54;
p(2)=0.08;
p(3)=0.38;
p(4)=0.40;
set(h4,'pos',p);
hold
title('T_{grad}')
set(gca,'FontSize',14);
hline1=plot(lat,Tgrad,'b','Linewidth',2);
set(gca,'YLim',[-0.2 0.2])
set(gca,'XLim',[0 90])
ylabel('Temp Gradient(^oC/^o lat)');
xlabel('Latitude(^o)'); 
legend([hline1],'Temp Gradient');
%
%
% FIGURE 2 
%
% CMIP5 zonal mean temperature changes 
%
figure(2)
%
h1=subplot(2,2,1); % CMIP5 multimodel zonal means - all forcing
p(1)=0.09;
p(2)=0.56;
p(3)=0.38;
p(4)=0.40;
set(h1,'pos',p);
clear
load AllForcingRun
hold
title('Zonal Temps (all-forcing)')
set(gca,'FontSize',14);
for i=1:nlats
    if (i==1)
        xx=1.0; yy=0.0; zz=1.0; % magenta
    end 
    if (i==2) 
        xx=0; yy=0; zz=0.5; % dark blue
    end
    if (i==3)
        xx=0; yy=0; zz=1.0; % light blue
    end
    if (i==4)
        xx=0; yy=1; zz=1; % cyan
    end
    if (i==5)
        xx=0; yy=0.5; zz=0; % dark green
    end
    if (i==6)
        xx=0; yy=1.0; zz=0.0; % light green
    end
    if (i==7) 
        xx=1.0; yy=1.0; zz=0.0; % yellow
    end
    if (i==8)
        xx=1.0; yy=0.687; zz=0.387; % light orange
    end
    if (i==9)
        xx=1.0; yy=0.4; zz=0.0; % dark orange
    end
    if (i==10)
        xx=1.0; yy=0.0; zz=0; % light red
    end
    if (i==11)
        xx=0.5; yy=0.0; zz=0.0; % dark red
    end        
    hd(i)=plot(yearmmm,zonalmmmave(:,i));
    set(hd(i),'color',[xx yy zz])
end
hd12=plot(yearmmm,globe,'k');
set(gca,'YLim',[-0.9 1.0])
set(gca,'XLim',[1860 2006])
ylabel('Temperature(^oC)');
xlabel('Year'); 
%legend([hd12],'25N-75N mean');
%
h2=subplot(2,2,2); % CMIP5 multimodel zonal means - anthro-only forcing
p(1)=0.54;
p(2)=0.56;
p(3)=0.38;
p(4)=0.40;
set(h2,'pos',p);
clear
load AnthroOnlyRun
hold
title('Zonal Temps (anthro-only)')
set(gca,'FontSize',14);
for i=1:nlats
    xx=i/(nlats+1);
    yy=1-abs(i-6)/6;
    zz=1.0-xx;
    hd(i)=plot(yearmmm,zonalmmmave(:,i));
    set(hd(i),'color',[xx yy zz])
end
hd12=plot(yearmmm,globe,'k');
set(gca,'YLim',[-0.65 1.25])
set(gca,'XLim',[1860 2006])
%ylabel('Temperature Anomaly (^oC)');
xlabel('Year'); 
%
h3=subplot(2,2,3); % CMIP5 multimodel extrop NH mean - all forcing (all realizations)
p(1)=0.09;
p(2)=0.08;
p(3)=0.38;
p(4)=0.40;
set(h3,'pos',p);
clear
load AllForcingRun
hold
title('25-75N mean (all-forcing)')
set(gca,'FontSize',14);
for k=1:nmodels
    hd(i)=plot(yearmmm,globemod(:,k));
end
hd12=plot(yearmmm,globe,'k');
set(gca,'YLim',[-1.5 1.85])
set(gca,'XLim',[1860 2006])
%legend([hd12],'multimodel mean');
ylabel('Temperature Anomaly (^oC)');
xlabel('Year'); 
%
h4=subplot(2,2,4); % CMIP5 multimodel extrop NH mean - anthro-only forcing (all realizations)
p(1)=0.54;
p(2)=0.08;
p(3)=0.38;
p(4)=0.40;
set(h4,'pos',p);
clear
load AnthroOnlyRun
hold
title('25-75N mean (anthro-only)')
set(gca,'FontSize',14);
for k=1:nmodels
    hd(i)=plot(yearmmm,globemod(:,k));
end
hd12=plot(yearmmm,globe,'k');
set(gca,'YLim',[-1.5 1.85])
set(gca,'XLim',[1860 2006])
%ylabel('Temperature Anomaly (^oC)');
xlabel('Year'); 
%
%
% FIGURE 3 
%
% CMIP5 Fingerprint series 
%
figure(3)
%
h1=subplot(2,2,1); % CMIP5 individual and MMM fingerprint series - all forcing
p(1)=0.09;
p(2)=0.56;
p(3)=0.38;
p(4)=0.40;
set(h1,'pos',p);
clear
load AllForcingRun
hold
set(gca,'FontSize',14);
title('QRA fingerprint (all-forcing)')
set(gca,'FontSize',14);
for k=1:nmodels
    hd(i)=plot(yearmmm,bfingermodel(:,k));
end
hd12=plot(yearmmm,bfingermean,'k');
set(gca,'YLim',[-2.5 2.5])
set(gca,'XLim',[1860 2006])
%legend([hd12],'multimodel mean');
ylabel('Regression Coefficient (unitless)');
xlabel('Year'); 
%legend([hd12],'Multimodel mean');
%
h2=subplot(2,2,2); % CMIP5 individual and MMM fingerprint series - all forcing
p(1)=0.54;
p(2)=0.56;
p(3)=0.38;
p(4)=0.40;
set(h2,'pos',p);
clear
load AnthroOnlyRun
hold
set(gca,'FontSize',14);
title('QRA fingerprint (anthro-only)')
set(gca,'FontSize',14);
for k=1:nmodels
    hd(i)=plot(yearmmm,bfingermodel(:,k));
end
hd12=plot(yearmmm,bfingermean,'k');
set(gca,'YLim',[-2.5 2.5])
set(gca,'XLim',[1860 2006])
xlabel('Year'); 
%
h3=subplot(2,2,3); % CMIP5 fingerprint series vs. mean temp - all-forcing
p(1)=0.09;
p(2)=0.08;
p(3)=0.38;
p(4)=0.40;
set(h3,'pos',p);
clear
load AllForcingRun
hold
title('QRA fingerprint (all-forcing)')
set(gca,'FontSize',14);
hd12=plot(yearmmm,bfingermean,'k','Linewidth',1.5);
hd22=plot(yearmmm,globerescaled,'b','Linewidth',1.5);
plot(year2,trendM,'r','Linewidth',2.0);
legend([hd12,hd22],'QRA fingerprint','rescaled 25-75N mean');
set(gca,'YLim',[-0.35 0.35])
set(gca,'XLim',[1860 2006])
ylabel('Regression Coefficient (unitless)');
xlabel('Year'); 
%
h4=subplot(2,2,4); % CMIP5 fingerprint series vs. mean temp - anthro-only
p(1)=0.54;
p(2)=0.08;
p(3)=0.38;
p(4)=0.40;
set(h4,'pos',p);
clear
load AnthroOnlyRun
hold
title('QRA fingerprint (anthro-only)')
set(gca,'FontSize',14);
hd12=plot(yearmmm,bfingermean,'k','Linewidth',1.5);
hd22=plot(yearmmm,globerescaled,'b','Linewidth',1.5);
plot(year2,trendM,'r','Linewidth',2.0);
set(gca,'YLim',[-0.5 0.55])
set(gca,'XLim',[1860 2006])
xlabel('Year'); 
%
%
%
% FIGURE 4 
%
% Projection of MMM fingerprint onto MMM 300mb U field
%
figure(4)
h1=subplot(2,1,1); % projection - all forcing
p(1)=0.09;
p(2)=0.56;
p(3)=0.38;
p(4)=0.40;
set(h1,'pos',p);
load AllForcingRun
hold
title('All Forcing')
set(gca,'FontSize',14);
for k=1:nmodels
    plot(lat,uprojectm(1:11,k));
end
plot(lat,uprojectmean(1:11),'k','Linewidth',2);
%plot(lat,uproject(1:11),'k--','Linewidth',2);
set(gca,'YLim',[-1.4 2.0])
set(gca,'XLim',[25 75])
ylabel('U anomaly (m/s)');
xlabel('Latitude(^o)'); 
%legend([hline1,hline2],'all forcing');
%
h2=subplot(2,1,2); % projection - anthro only
p(1)=0.09;
p(2)=0.08;
p(3)=0.38;
p(4)=0.40;
set(h2,'pos',p);
load AnthroOnlyRun
hold
title('Anthropogenic-Only')
set(gca,'FontSize',14);
for k=1:nmodels
    plot(lat,uprojectm(1:11,k));
end
plot(lat,uprojectmean(1:11),'k','Linewidth',2);
%plot(lat,uproject(1:11),'k--','Linewidth',2);
set(gca,'YLim',[-1.4 2.0])
set(gca,'XLim',[25 75])
ylabel('U anomaly (m/s)');
xlabel('Latitude(^o)'); 
%legend([hline1,hline2],'all forcing');
%
%
% FIGURE 5 
%
% Observational Series 
%
figure(5)
h1=subplot(2,3,1); % historical zonal means - GISTEMP
p(1)=0.09;
p(2)=0.56;
p(3)=0.25;
p(4)=0.40;
set(h1,'pos',p);
clear
load AllForcingRun
hold
title('Zonal Temps (GISTEMP)')
set(gca,'FontSize',14);
for i=1:nlats
    if (i==1)
        xx=1.0; yy=0.0; zz=1.0; % magenta
    end 
    if (i==2) 
        xx=0; yy=0; zz=0.5; % dark blue
    end
    if (i==3)
        xx=0; yy=0; zz=1.0; % light blue
    end
    if (i==4)
        xx=0; yy=1; zz=1; % cyan
    end
    if (i==5)
        xx=0; yy=0.5; zz=0; % dark green
    end
    if (i==6)
        xx=0; yy=1.0; zz=0.0; % light green
    end
    if (i==7) 
        xx=1.0; yy=1.0; zz=0.0; % yellow
    end
    if (i==8)
        xx=1.0; yy=0.687; zz=0.387; % light orange
    end
    if (i==9)
        xx=1.0; yy=0.4; zz=0.0; % dark orange
    end
    if (i==10)
        xx=1.0; yy=0.0; zz=0; % light red
    end
    if (i==11)
        xx=0.5; yy=0.0; zz=0.0; % dark red
    end         
    hd(i)=plot(yeargiss,zonalobsGISS(:,i));
    set(hd(i),'color',[xx yy zz])
end
hd12=plot(yeargiss,globeGISS,'k');
set(gca,'YLim',[-1.8 1.95])
set(gca,'XLim',[1880 2016])
ylabel('Temperature(^oC)');
xlabel('Year'); 
%legend([hd12],'25N-75N mean');
%
%
h2=subplot(2,3,2); % historical zonal means - HadCRUT4
p(1)=0.4;
p(2)=0.56;
p(3)=0.25;
p(4)=0.40;
set(h2,'pos',p);
load AnthroOnlyRun
hold
set(gca,'FontSize',14);
title('Zonal Temps (HadCRUT4)')
for i=1:nlats
    if (i==1)
        xx=1.0; yy=0.0; zz=1.0; % magenta
    end 
    if (i==2) 
        xx=0; yy=0; zz=0.5; % dark blue
    end
    if (i==3)
        xx=0; yy=0; zz=1.0; % light blue
    end
    if (i==4)
        xx=0; yy=1; zz=1; % cyan
    end
    if (i==5)
        xx=0; yy=0.5; zz=0; % dark green
    end
    if (i==6)
        xx=0; yy=1.0; zz=0.0; % light green
    end
    if (i==7) 
        xx=1.0; yy=1.0; zz=0.0; % yellow
    end
    if (i==8)
        xx=1.0; yy=0.687; zz=0.387; % light orange
    end
    if (i==9)
        xx=1.0; yy=0.4; zz=0.0; % dark orange
    end
    if (i==10)
        xx=1.0; yy=0.0; zz=0; % light red
    end
    if (i==11)
        xx=0.5; yy=0.0; zz=0.0; % dark red
    end         
    hd(i)=plot(yearhad,zonalobsHAD(j1:j2,i));
    set(hd(i),'color',[xx yy zz])
end
hd12=plot(yearhad,globeHAD(j1:j2),'k');
set(gca,'YLim',[-1.8 1.95])
set(gca,'XLim',[1880 2016])
%ylabel('Temperature(^oC)');
xlabel('Year'); 
%
%
h3=subplot(2,3,3); % historical historical zonal means - Cowtan & Way
p(1)=0.7;
p(2)=0.56;
p(3)=0.25;
p(4)=0.40;
set(h3,'pos',p);
load AnthroOnlyRun
hold
set(gca,'FontSize',14);
title('Zonal Temps (Cowtan & Way)')
for i=1:nlats
    if (i==1)
        xx=1.0; yy=0.0; zz=1.0; % magenta
    end 
    if (i==2) 
        xx=0; yy=0; zz=0.5; % dark blue
    end
    if (i==3)
        xx=0; yy=0; zz=1.0; % light blue
    end
    if (i==4)
        xx=0; yy=1; zz=1; % cyan
    end
    if (i==5)
        xx=0; yy=0.5; zz=0; % dark green
    end
    if (i==6)
        xx=0; yy=1.0; zz=0.0; % light green
    end
    if (i==7) 
        xx=1.0; yy=1.0; zz=0.0; % yellow
    end
    if (i==8)
        xx=1.0; yy=0.687; zz=0.387; % light orange
    end
    if (i==9)
        xx=1.0; yy=0.4; zz=0.0; % dark orange
    end
    if (i==10)
        xx=1.0; yy=0.0; zz=0; % light red
    end
    if (i==11)
        xx=0.5; yy=0.0; zz=0.0; % dark red
    end         
    hd(i)=plot(yearhad,zonalobsCOW(j1:j2,i));
    set(hd(i),'color',[xx yy zz])
end
hd12=plot(yearhad,globeCOW(j1:j2),'k');
set(gca,'YLim',[-1.8 1.95])
set(gca,'XLim',[1880 2016])
%ylabel('Temperature(^oC)');
xlabel('Year'); 
%
h4=subplot(2,3,4); % historical QRA fingerprint series - GISTEMP
p(1)=0.09;
p(2)=0.06;
p(3)=0.25;
p(4)=0.40;
set(h4,'pos',p);
clear
load AllForcingRun
hold
title('QRA fingerprint (GISTEMP)')
set(gca,'FontSize',14);
hd12=plot(yeargiss,bfingerGISS,'k','Linewidth',1.5);
%hd22=plot(yeargiss,globerescaled,'b','Linewidth',1.5);
hd22=plot(year1,trendGISS,'k--','Linewidth',1.5);
legend([hd12,hd22],'QRA fingerprint','trend (1970-2015)');
set(gca,'YLim',[-02.55 2.55])
set(gca,'XLim',[1880 2016])
ylabel('Regression Coefficient (unitless)');
xlabel('Year'); 
%
h5=subplot(2,3,5); % historical QRA fingerprint series - HadCRUT4
p(1)=0.40;
p(2)=0.06;
p(3)=0.25;
p(4)=0.40;
set(h5,'pos',p);
clear
load AllForcingRun
hold
title('QRA fingerprint (HadCRUT4)')
set(gca,'FontSize',14);
hd12=plot(yearhad,bfingerHAD,'k','Linewidth',1.5);
%hd22=plot(yeargiss,globerescaled,'b','Linewidth',1.5);
hd22=plot(year1,trendHAD,'k--','Linewidth',1.5);
set(gca,'YLim',[-02.55 2.55])
set(gca,'XLim',[1880 2016])
%ylabel('Regression Coefficient (unitless)');
xlabel('Year'); 
%
h6=subplot(2,3,6); % historical QRA fingerprint series - Cowtan & Way
p(1)=0.7;
p(2)=0.06;
p(3)=0.25;
p(4)=0.40;
set(h6,'pos',p);
clear
load AllForcingRun
hold
title('QRA fingerprint (Cowtan & Way)')
set(gca,'FontSize',14);
hd12=plot(yearhad,bfingerCOW,'k','Linewidth',1.5);
%hd22=plot(yeargiss,globerescaled,'b','Linewidth',1.5);
hd22=plot(year1,trendCOW,'k--','Linewidth',1.5);
set(gca,'YLim',[-02.55 2.55])
set(gca,'XLim',[1880 2016])
%ylabel('Regression Coefficient (unitless)');
xlabel('Year'); 
