Homework 0


Part I: Due Thursday (Jan 24).

1. Make a personal wiki with pages where you will keep your course work (5-6 homeworks, your projects (link), and your Project).

2. On your homework 0 page, upload a figure you made in Matlab (or Python or IDL or R or ...) using any data you like (or a random number generator). Intro to matlab from last year's course.
You may use figure export (although it sometimes makes huge files), or learn the power of the humble screen capture (Cmd-ctrl-$, a 4-button action, is a favorite Mac trick!).

Include your code on the page. Explain what you're showing us.

Please use this opportunity to learn (and teach the rest of us!) something, show me where your starting skill/experience level is, and perhaps set a friendly challenge for others and your future self. We will look at them together in class on Thursday.



(a)
HW0_ptI_fig1.jpg
(b)
HW0_ptI_fig2.jpg
(c)
HW0_ptI_fig3.jpg
(d)
HW0_ptI_fig4.jpg
(e)
HW0_ptI_fig5.jpg

FIG. 1: In order to see how well each of 12 individual CMIP5 long-term current-climate "historical" global model simulations capture the precipitation spatial patterns over Florida, for the years 1901-2005, using the GPCC v5 observational precipitation (rain-gauge-based) data set as reference, two-dimensional scatter plots are created, for the region of Florida, of the two-dimensional spatial correlation coefficient versus the two-dimensional spatial centered root-mean-square (RMS) difference, in units of mm / day, plotted for each model, for each of the four seasons, and for the entire year. In addition, the 1961-2005 CanCM4, 1948-2006 NOAA CPC v1, 1998-2009 TRMM 3B42 v6, and the 1901-2005 mean of the CMIP5 models are also plotted.




clear;
 
mod_var_names={'CCSM4';'CNRM_CM5';'GFDL_CM3';'GISS_E2_H';'GISS_E2_R';'HadCM3';'HadGEM2_CC';...
'HadGEM2_ES';'IPSL_CM5B_LR';'MPI_ESM_P';'NorESM1_M';'NorESM1_ME'};
 
CMIP5_pr_map=zeros(15,4,360,720);
 
for mod=1:12
    CMIP5_pr_map(mod,:,:,:)=importdata([char(mod_var_names(mod,1)),'_h_1901_2005_sea_maps_reg.mat']);
end
CMIP5_pr_map(13,:,:,:)=importdata('CanCM4_h_1961_2005_sea_maps_reg.mat');
CMIP5_pr_map(14,:,:,:)=importdata('CPC_1948_2006_sea_maps_reg.mat');
CMIP5_pr_map(15,:,:,:)=importdata('f3B42_1998_2009_sea_maps_reg.mat');
 
CMIP5_pr_map=CMIP5_pr_map(:,:,119:125,185:200);
 
CMIP5_pr_map2=zeros(15,5,7,16);
CMIP5_pr_map2(:,1:4,:,:)=CMIP5_pr_map;
CMIP5_pr_map2(:,5,:,:)=nanmean(CMIP5_pr_map,2);
CMIP5_pr_map=CMIP5_pr_map2;
 
CMIP5_pr_map2=zeros(16,5,7,16);
CMIP5_pr_map2(1:15,:,:,:)=CMIP5_pr_map;
CMIP5_pr_map2(16,:,:,:)=nanmean(CMIP5_pr_map(1:12,:,:,:),1);
CMIP5_pr_map=CMIP5_pr_map2;
 
clear CMIP5_pr_map2;
 
load GPCC_FL_LSmask.mat;
for mod=1:16
    for sea=1:5
        CMIP5_pr_map(mod,sea,:,:)=squeeze(CMIP5_pr_map(mod,sea,:,:)).*FL_mask;
    end
end
 
GPCC_pr_map=importdata('GPCC_1901_2005_sea_maps.mat');
GPCC_pr_map=GPCC_pr_map(:,119:125,185:200);
GPCC_pr_map2=zeros(5,7,16);
GPCC_pr_map2(1:4,:,:)=GPCC_pr_map;
GPCC_pr_map2(5,:,:)=nanmean(GPCC_pr_map,1);
GPCC_pr_map=GPCC_pr_map2;
clear GPCC_pr_map2;
 
for sea=1:5
    GPCC_pr_map(sea,:,:)=squeeze(GPCC_pr_map(sea,:,:)).*FL_mask;
end
 
CMIP5_pr_map_c=zeros(16,5,7,16);
for mod=1:16
    for sea=1:5
        gmean=squeeze(nanmean(nanmean(CMIP5_pr_map(mod,sea,:,:))));
        CMIP5_pr_map_c(mod,sea,:,:)=squeeze(CMIP5_pr_map(mod,sea,:,:)) - gmean;
    end
end
 
GPCC_pr_map_c=zeros(5,7,16);
for sea=1:5
    gmean=squeeze(nanmean(nanmean(GPCC_pr_map(sea,:,:))));
    GPCC_pr_map_c(sea,:,:)=squeeze(GPCC_pr_map(sea,:,:)) - gmean;
end
 
cdiff=zeros(16,5,7,16);
for mod=1:16
    cdiff(mod,:,:,:)=squeeze(CMIP5_pr_map_c(mod,:,:,:)) - GPCC_pr_map_c;
end
 
cdiffcdiff=cdiff.*cdiff;
 
RMScdiff=squeeze(sqrt(nanmean(nanmean(cdiffcdiff,4),3)));
 
CMIP5_GPCC_corr=zeros(16,5);
for sea=1:5
    GPCC_vect=reshape(squeeze(GPCC_pr_map(sea,:,:)).',7*16,1);
    ind=isnan(GPCC_vect);
    GPCC_vect(ind)=[];
    for mod=1:16
        CMIP5_vect=reshape(squeeze(CMIP5_pr_map(mod,sea,:,:)).',7*16,1);
        CMIP5_vect(ind)=[];
 
        CMIP5_GPCC_corr(mod,sea)=corr2(CMIP5_vect,GPCC_vect);
 
        if mod==14
            CMIP5_vect2=CMIP5_vect;
            ind2=isnan(CMIP5_vect2);
            CMIP5_vect2(ind2)=[];
 
            GPCC_vect2=GPCC_vect;
            GPCC_vect2(ind2)=[];
 
            CMIP5_GPCC_corr(mod,sea)=corr2(CMIP5_vect2,GPCC_vect2);
        end
    end
end
 
sea_labels={'DJF ';'MAM ';'JJA ';'SON ';''};
 
mod_labels={'CCSM4';'CNRM-CM5';'GFDL-CM3';'GISS-E2-H';...
    'GISS-E2-R';'HadCM3';'HadGEM2-CC';'HadGEM2-ES';'IPSL-CM5B-LR';...
    'MPI-ESM-P';'NorESM1-M';'NorESM1-ME';'CanCM4';'CPC';'3B42v6';...
    'CMIP5 Mean'};
 
legend_labels=cat(1,mod_labels(1:12,1),...
    {'CanCM4 (1961-2005)';'NOAA CPC (1948-2006)';'TRMM 3B42v6 (1998-2009)';'CMIP5 Mean'});
 
xtick=0:0.17:1.7;
ytick=-1:0.2:1;
limx=[0 1.7];
limy=[-1 1];
 
ColorSet = colorcube(17);
 
k=1;
 
for sea=1:5
    % Create figure
    figure('Name',[char(sea_labels(sea,1)),'1901-2005 precip'],'Color',[1 1 1],'Position',[0 40 1920 964]);
    set(gcf,'PaperPositionMode','auto');
    % Create axes
    set(gca,'YDir','normal','XTick',xtick,'YTick',ytick,'Layer','top','FontSize',18);
    % Uncomment the following line to preserve the X-limits of the axes
    xlim(limx);
    % Uncomment the following line to preserve the Y-limits of the axes
    ylim(limy);
 
    box('on');
    hold('all');
    grid('on');
 
    % Create image
    dy=0.05;
    for mod=1:16
        scatter(RMScdiff(mod,sea),CMIP5_GPCC_corr(mod,sea),110,ColorSet(mod,:),'filled');
        text(RMScdiff(mod,sea),CMIP5_GPCC_corr(mod,sea) + dy,char(mod_labels(mod,1)),...
            'FontSize',16,'Color',ColorSet(mod,:),'FontWeight','bold');
    end
    % Create title
    title({'Florida Rainfall',[char(sea_labels(sea,1)),'1901-2005'],'CMIP5 Models vs. GPCC v5 Obs.'},'FontSize',32);
    % Create xlabel
    xlabel('Centered RMS Differennce (mm/day)','FontSize',24,'FontWeight','bold');
    % Create ylabel
    ylabel('Correlation Coefficient','FontSize',24,'FontWeight','bold');
    % Create legend
    legend(legend_labels,'Location','EastOutside','FontSize',16,'FontWeight','bold');
 
    saveas(gcf,['MPO524\HW0_ptI_fig',int2str(k),'.jpg']);
    k=k+1;
end