% ----------------------
% EPS 231 - ps 1
% Laure Zanna
% ----------------------

clear all; close all;
 
 % data [X=longitude Y=Latitude T=time] 
 % X=[124E 70W]; Y=[29S 29N]; T=[Jan 1970 Mar 2003]
 sst_1N=f77read('data.r4',[84 30 399],'real*4','b');
 
 % select along the equator at 1N
 sst_1N=squeeze(sst_1N(:,16,:));
 
 %plot [140E 90W] for the time period [Jan 1980 Jan 2003]
subplot(1,2,1);[C,h,CF]=contourf(sst_1N(8:74,121:397)',25);  
for q=1:length(h); set(h(q),'LineStyle','none'); end 
title('SST anomalies along 1N','fontsize',14); colorbar
 
 % set the axis 
 xlim([1 67]); 
 set(gca,'XTick',1:10:67);
 set(gca,'XTickLabel',{'140E','160E','180','160W','140W','120W','100W'}, ...
	 'fontsize',12);
 xlabel('Longitude','fontsize',13)
 
 ylim([1 277]);   
 set(gca,'YTick',1:36:277);
 set(gca,'YTickLabel',{'Jan 1980','Jan 1983','Jan 1986','Jan 1989',...
    'Jan 1992','Jan 1995','Jan 1998','Jan 2001'},'fontsize',12); 
 
% average
nino_3=sum(sst_1N(44:74,121:397))/31;
subplot(1,2,2); plot(nino_3); xlim([1 277]);   
 set(gca,'XTick',1:72:277);
 set(gca,'XTickLabel',{'Jan 1980','Jan 1986',...
    'Jan 1992','Jan 1998'},'fontsize',12);
ylabel('SST anomalies average [ \circ C]', 'fontsize',13);
xlabel('Time','fontsize',12)