Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)
x=cosweight(sst, nya, oro);
x=cosweight(sst, nya, oro); This function weights data in matrix 'sst' by the cosine of latitudes in matrix 'nya'. It also removes orography stored in the vector 'oro'.
function x=cosweight(sst, nya, oro);
ndim = sum(size(size(sst)))-1;
if ndim == 3;
[ntim, nlat, nlon] = size(sst);
% Assume the second dimension is y
sst = reshape(shiftdim(sst, 1), nlat, nlon*ntim);
[m,n] = size(nya);
if m == 1; nya = nya'; end;
nya = nya .* (3.1415927)/180;
sst = sst ./ cos(nya * ones(1, nlon*ntim));
sst = shiftdim(reshape(sst, nlat, nlon, ntim), 2);
else
[tmax,ngrid]=size(sst);
% sst=(-1)*(ones(tmax,1)*(oro-1)).*sst;
ny=length(nya);
nx=ngrid/ny;
for i=1:ny
sst(:,(nx*(i-1)+1):(nx*i))=sst(:,(nx*(i-1)+1):(nx*i))/cos(nya(i)*pi/180);
end
end
x=sst;