READSST
Reads SST fileds at 500mb (Z500) for the
the region chosen
function [z,ind,fcos]=readsst(flat,flon,varargin)
choice = 1;
scaling = 'yes';
sesint=4;
for i = 1:length(varargin)
if ischar(varargin{i});
option=varargin{i};
switch option;
case 'season'
switch varargin{i+1}
case 'jfm'
choice = 1;
case 'amj'
choice = 2;
case 'jas'
choice = 3;
case 'ond'
choice = 4;
case 'all'
choice=1; sesint=1;
otherwise;
error('Wrong season specified in readsst');
end
case 'scale'
scaling = 'yes';
end
end
end
if min(flon) < 0
format='wardinv';
else
format='ward';
end
sea=infile([ ], './TS0.1.408.dat', ...
'./TS0.1.408.ctl','sst',0,format,0,34);
siz=size(sea);
lat1=sea(:,2) > flat(1);
lat2=sea(:,2) < flat(2);
lon1=sea(:,3) >= flon(1);
lon2=sea(:,3) <= flon(2);
mask=lat1.*lat2.*lon1.*lon2;
[x,y,lsm]=makeggrid('T30');
lsmmask=reshape(((1-(lsm+1)/2))',[1 96*48])';
clear x y;
mask=mask.*lsmmask;
ind=find(mask == 1 );
switch scaling
case 'yes';
fcos= cos(sea(ind,2)*pi/180.) ;
case 'no';
fcos=1;
end
z=[];
fcut=zeros(size(sea(ind,4:siz(2))));
for icos=4:siz(2)
fcut(:,icos-3)=fcos.*sea(ind,icos);
end
sizfc=size(fcut);
z= [ z fcut(:,choice:sesint:sizfc(2)) ];
return