Documentation of read_z3


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


Function Synopsis

[z, nxa, nya]=read_z3;

Help text


  [z, nxa, nya]=read_z3;

  This function reads the history files in the directory:

       /home/disk/hayes2/dvimont/csm/300yr/srf

  and eliminates monthly climatology from the data set.  It saves
  four files:

       z.mat         The monthly data
       nxa.mat         X-coordinates of the data
       nya.mat         Y-coordinates of the data


Listing of function read_z3

function [z, nxa, nya]=read_z3;
clear

period = [1 12];

%  Define frames

lim=[0 360 -90 90];

%  Set file inputs

file_id1='/home/disk/hayes2/dvimont/csm/300yr/tz/';
file_id2='_tz.nc';

%  Read defaults

file_in=[file_id1, '0000', file_id2];
[x,nxa,nya,nti,nday,xa,ya,time,xdim,xid]=readnc(file_in,lim);

%  Redefine nxa, nya, limits

lim = [0 360 -90 90];
keepnx = find(nxa >= lim(1) & nxa <= lim(2));
keepny = find(nya >= lim(3) & nya <= lim(4));
limind = [keepnx(1) keepnx(length(keepnx)) keepny(1) keepny(length(keepny))];

%  Initialize output variables

z = [];
%oro = [];

%  Read data

%i = 0
for i = 0:99

%  Define input file

  hns = round((i-49.5)/100);
  tns = round((i-4.5)/10) - 10*hns;
  ons = rem(i,10);
  file_num = ['0' int2str(hns) int2str(tns) int2str(ons)];
  file_in  = [file_id1 file_num file_id2]

  nc = netcdf(file_in, 'nowrite');
  Z3 = nc{'Z3'}(:,11,limind(3):limind(4),limind(1):limind(2));
%  ORO = nc{'ORO'}(:,limind(3):limind(4),limind(1):limind(2),1);
  nc = close(nc);
  Z3 = squeeze(Z3);

%  Average TS to make computations a little more reasonable

  [ntmstp, m, n] = size(Z3);
  tstmp = zeros(ntmstp, m/2, n/2);
%  orotmp = zeros(ntmstp, m/2, n/2);

  for j = 1:ntmstp;
    for k = 1:m/2;
      for l = 1:n/2;
        tstmp(j,k,l)  = mean(mean(Z3(j,(2*(k-1)+(1:2)),(2*(l-1)+(1:2)))));
%        orotmp(j,k,l) = mean(mean(ORO(j,(2*(k-1)+(1:2)),(2*(l-1)+(1:2)))));
      end
    end
  end

  z = [z; tstmp];
%  oro = [oro; orotmp];

end

save yrs0-99.mat z;
clear z;

z = [];
%oro = [];

%  Read data

%i = 100
for i = 100:159

%  Define input file

  hns = round((i-49.5)/100);
  tns = round((i-4.5)/10) - 10*hns;
  ons = rem(i,10);
  file_num = ['0' int2str(hns) int2str(tns) int2str(ons)];
  file_in  = [file_id1 file_num file_id2]

  nc = netcdf(file_in, 'nowrite');
  Z3 = nc{'Z3'}(:,11,limind(3):limind(4),limind(1):limind(2));
%  ORO = nc{'ORO'}(:,limind(3):limind(4),limind(1):limind(2),1);
  nc = close(nc);
  Z3 = squeeze(Z3);

%  Average TS to make computations a little more reasonable

  [ntmstp, m, n] = size(Z3);
  tstmp = zeros(ntmstp, m/2, n/2);
%  orotmp = zeros(ntmstp, m/2, n/2);

  for j = 1:ntmstp;
    for k = 1:m/2;
      for l = 1:n/2;
        tstmp(j,k,l)  = mean(mean(Z3(j,(2*(k-1)+(1:2)),(2*(l-1)+(1:2)))));
%        orotmp(j,k,l) = mean(mean(ORO(j,(2*(k-1)+(1:2)),(2*(l-1)+(1:2)))));
      end
    end
  end

  z = [z; tstmp];
%  oro = [oro; orotmp];

end

save yrs100-159.mat z;
z;

nyaave = zeros(1, m/2);
for j = 1:m/2
  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*(k-1)+(1:2)),:)));
end;

nxa = nxaave;
nya = nyaave; 

save lims1-150.mat nxa nya