Matlab script to generate movie for globe
Sample Matlab Script
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This is a sample script to generate image files from SST data. %
% These can then be combined into a movie file which will run on the %
% globe display in the Meteorology Department, University of Reading.%
% %
% Written by Maria Broadbridge, m.b.broadbridge@reading.ac.uk %
% Version 1.0, 16/01/2017 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOAD DATA
% Using monthly mean 1x1 degree gridded COBE SST (1891 - near present) as an example.
% The dataset is freely available from NOAA (https://www.esrl.noaa.gov/psd/data/gridded/data.cobe.html)
clear
sst=ncread('sst.mon.mean.nc','sst');
lat=ncread('sst.mon.mean.nc','lat');
lon=ncread('sst.mon.mean.nc','lon');
time=ncread('sst.mon.mean.nc','time');
% replace land placeholder values in the dataset with NaNs
ind=find(sst>1e15);
sst(ind)=NaN;
clear ind
%% PLOT DATA
% This creates a simple contour plot of the SST fields.
% plot contourlines with 2 degree C spacing
c_intervals=[-2:2:32];
% setup base name of files
basename='pngfiles/sst_'
%counter for numbering in filenames
count=0
% plotting loop (only do 40 years (1977-2016) in this example, too many frames otherwise)
for i=1033:length(time)
% count files
count=count+1
% setup filename
filename=[basename,num2str(count,'%04.0f'),'.png'];
close all
figure(1)
contourf(lon,lat,sst(:,:,i)',c_intervals)
%colorbar
caxis([-2 32])
set(gcf,'Colormap',jet)
% borderless figure, don't want a grid box or axis labels
box off
set(gca,'visible','off')
% fill entire figure
set(gca,'position',[0 0 1 1],'units','normalized')
% setup 2:1 axis ratio in figure
set(gcf,'Paperunits','points','Papersize',[1400 700],'Paperposition',[0 0 1400 700])
% -r sets figure resolution in dpi, test for filesize!
print('-dpng','-r100',filename)
end