Documentation of read_np


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


Function Synopsis

[sst, oro, nxa, nya]=read_sst2;

Help text


  [sst, oro, nxa, nya]=read_sst2;

  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:

       sst.mat         The monthly data
       nxa.mat         X-coordinates of the data
       nya.mat         Y-coordinates of the data
       oro.mat         Orography


Listing of function read_np

function [sst, oro, nxa, nya]=read_sst2;

cd /home/disk/hayes2/dvimont/csm/300yr/data

period = [1 12];

%  Define frames

lim=[0 360 -90 90];

%  Set file inputs

file_id1='/home/disk/hayes2/dvimont/csm/300yr/srf/';
file_id2='_srf.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 = [120 260 20 70];
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

sst = [];
oro = [];

%  Read data

for i = 0:299

%  Define input file

  hns = floor(i/100);
  tns = floor(i/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');
  TS = nc{'TS'}(:,limind(3):limind(4),limind(1):limind(2),1);
  ORO = nc{'ORO'}(:,limind(3):limind(4),limind(1):limind(2),1);
  nc = close(nc);

%  Average TS to make computations a little more reasonable

%  [ntmstp, m, n] = size(TS);
%  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(TS(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

  sst = [sst; TS];
  oro = [oro; ORO];

end

save sst_np.mat sst oro;
clear sst oro;

save lims_np.mat nxa nya