Documentation of pac_setup_old


Global Index (short | long) | Local contents | Local Index (short | long)


Help text

  Average sst to make computations a little more reasonable

Cross-Reference Information

This script calls

Listing of script pac_setup_old


clear
cd /home/disk/hayes2/dvimont/csm/300yr/srf
load sst1-150.mat
load oro1-150.mat
load lims1-150.mat
whos
lims = [122 290 -60 60];
sst = subset(sst, nxa(keepnx), nya(keepny), lims);
oro = subset(oro, nxa(keepnx), nya(keepny), lims);
[ntstp,m,n]=size(sst);
sstave = zeros(ntstp, m/2, n/2);
for i=1:1800;
  for j=1:m/2
    for k=1:n/2
      sstave(i,j,k) = mean(mean(sst(i,(2*(j-1)+(1:2)),(2*(k-1)+(1:2)))));
    end
  end
end

save sstave.mat sstave

oromean = mean(oro);
whos

oroave = zeros(1,m/2,n/2);
nyaave = zeros(1,m/2);
for j=1:m/2
  for k=1:n/2
    oroave(1,j,k) = mean(mean(oromean(1,(2*(j-1)+(1:2)),(2*(k-1)+(1:2)))));
  end
  nyaave(1,j) = mean(nya(keepny(2*(j-1)+(1:2)),:));
end

nxaave=zeros(1,n/2);
for k=1:n/2
  nxaave(1,k) = mean(nxa(keepnx(2*(j-1)+(2:3)),:));
end
%
%  Notice:  on the above, (2:3) is used due to the lims being changed (line 8)
%

%  THE FOLLOWING ANALYSIS IS USED FOR AVERAGED DATA

clear
cd /home/disk/hayes2/dvimont/csm/300yr/srf
load sstave.mat
load newlims.mat
load lims1-150.mat
lims = [122 290 0 60];

sst = subset(sstave, nxaave, nyaave, lims);
oro = subset(oroave, nxaave, nyaave, lims);

[ntmstp, m, n] = size(sst);
oro = reshape(oro,1,m*n);
sst = reshape(sst,1800,m*n);
keepave = find(oro~=0.);
sst(:,keepave) = zeros(1800,length(keepave));
keepave = find(oro == 0.);

%save newlims.mat nxaave nyaave oroave keepave
%clear sstave

[sst, clim] = annave(sst);
sst = cosweight(sst, nyaave);
sst = sst(:,keepave);

%  Average sst to make computations a little more reasonable
[tm2, len2] = size(sst);
c = sst' * sst ./ tm2;
[lam, loads, per] = eof(c);

loadnorm = loads * inv(diag(sqrt(lam)));
pc = (sst * loadnorm / tm2) * inv(diag(sqrt(lam)));


temp = zeros(10,m*n);
temp(1:10,keepave) = loads(:,1:10)';
%contour(squeeze(reshape(temp,1,m,n)));
figure(1)
subplot(2,1,1)
gcont(squeeze(reshape(temp(1,:),1,m,n)),lims,[-250:5:250])
dc
subplot(2,1,2)
gcont(squeeze(reshape(temp(2,:),1,m,n)),lims,[-20:5:110])
dc

temp = reshape(tsnew,768,m,n);
tempa = reshape(tsa,768,m,n);
tempc = reshape(clim,12,m,n);
gcont(squeeze(TS(1,:,:)))
gcont(squeeze(temp(400,:,:)), lims)
gcont(squeeze(tempa(400,:,:)), lims)
gcont(squeeze(clim(1,:,:), lims)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  The following is for previously averaged data
%

clear
cd /home/disk/hayes2/dvimont/csm/300yr/srf
load sst1-150.mat
load oro1-150.mat
load lims1-150.mat
whos

lims = [0 360 -90 90];
sst = subset(sst, nxa, nya, lims);
oro = subset(oro, nxa, nya, lims);
nxkeep = nxa(find(nxa >= lims(1) & nxa <= lims(2)));
nykeep = nya(find(nya >= lims(3) & nya <= lims(4)));
[ntmstp, nypts, nxpts] = size(sst);
whos

sst = reshape(sst, ntmstp, nypts*nxpts);
oro = reshape(oro, ntmstp, nypts*nxpts);
oro = mean(oro);
dokeep = find(oro == 0);
sst = sst(:,dokeep);

%
%  Alter sst for ice points.  Notice, the annual cycle feature was
%    not included for figures 1 and 2 in ~dvimont/pacific
%

noelim = [];
for i = 1:length(dokeep);
  noelimtmp = [];
  for j = 1:12
    icept = (find(sst(j:12:ntmstp,i) <= 273.14)-1).*12 + j;
    noice = (find(sst(j:12:ntmstp,i) >= 273.14)-1).*12 + j;
    if (~isempty(icept) & ~isempty(noice));
      sst(icept,i) = mean(sst(noice,i)) * ones(length(icept),1);
    end
    if ~isempty(noice);
      noelimtmp = [noelimtmp j];
    else
      sst(icept,i) = mean(sst(icept,i)) * ones(length(icept),1);
    end
  end
  if ~isempty(noelimtmp);
    noelim = [noelim i];
  end
end
sst = sst(:,noelim);
dokeep = dokeep(noelim);

%  Remove climatology

[sst, clim] = annave(sst);

sstemp = zeros(ntmstp, nxpts*nypts);
sstemp(:,dokeep) = sst;
sst = sstemp;
clear sstemp

sst = cosweight(sst, nya);
sst = sst(:, dokeep);

%  Running Mean

sst3yr = myrunning_ave(sst, 36);

%  This might make things faster

sst3yr = sst3yr(1:3:ntmstp,:);

%  Take EOF's.  (Might alter the dimensions if need be...)

c = sst3yr * sst3yr' / (length(dokeep));
[lam, pc, per] = eof(c);
pc = pc * diag(1./sqrt(lam));
loads = pc'*sst3yr;

pc1 = pc(:,1:10) * diag(1 ./ std(pc(:,1:10)));
loads1 = (loads(1:10,:)' * diag(std(pc(:,1:10))))'; 

temp = zeros(10, nypts*nxpts);
temp(1:10,dokeep) = loads1(1:10,:);

%
%  The following command can be used to get a general idea
%  of what the loadings and pc's look like.  For graphics, 
%  refer to the file in graphics/pac_plot.m
%

%contour(squeeze(reshape(temp,1,m,n)));
figure(1)
%subplot(2,1,1)
gcont(squeeze(reshape(temp(1,:),1,nypts,nxpts)),lims,10)
dc