%%%%%%%%%%%%%%%%%%%%%% Plot reconstructed picture %%%%%%%%%%%%%%%%%%%%%%%% % Reconstruct the island picture, using a subset of the PCs % % To run this program, execute the following two lines (change the value % around for 'last_eof': % % last_eof = 1; % plot_island_demo; % % last_eof: is the last EOF to use in the reconstruction. % ind = 1:last_eof; y2 = pcs(:,ind)*lds(:,ind)'; % Reconstruct by summing over EOF's % and PC's y2 = reshape(y2, ntim, nlat, nlon); % Reshape back to picture format % Plot the reconstructed data global_axes(6.4*.6, 4.8*.6, .5, .75, 1.5); subplot2(1,2) image(uint8(y2)); title(['\bfModes 1 through ' num2str(last_eof) ': ' ... num2str(round(10000*sum(per(ind)))/100) '% Var Expl.'], ... 'fontsize', 14); % Plot the Principal Components: global_axes(1.25, 4.8*.6, 6.4*.6+.5, .75, 1.5); subplot2(2,4); cla; pp = plot(pcs(:,last_eof), ntim:-1:1, 'k'); % If we're plotting the first PC, make it look good (remember, we % haven't removed the mean) if last_eof == 1; set(gca, 'XLim', [0 8000]); end; % Make it pretty: set(pp, 'linewidth', 2); set(gca, 'YTickLabel', [], 'YLim', [1 ntim]); grid on; t1 = title(['\bfPC' num2str(last_eof)], 'fontsize', 14); % And, plot the EOF's. Remember that the EOF's are 2-dimensional: row % dimension by color dimension. So, plot three lines that correspond to % the three colors: global_axes(6.4*.6, 1.25, .5, .5, 2*.6*4.8+0.5+0.5+1.5); subplot2(1,1); cla; tem = squeeze(reshape(lds(:,last_eof), nlat, nlon)); pp = plot(1:nlat, tem); set(pp(1), 'color', 'r'); set(pp(2), 'color', 'g'); set(pp(3), 'color', 'b'); % If we're plotting the first EOF, make it look good (remember, we % haven't removed the mean) if last_eof == 1; set(gca, 'YLim', [0 0.03]); end; % Make it pretty: set(pp, 'linewidth', 2); set(gca, 'XLim', [1 nlat]); grid on xl = xlabel(['\bfEOF' num2str(last_eof) ... ', ' num2str(round(10000*per(last_eof))/100) '% Var Expl.'], ... 'fontsize', 14);