Global Index (short | long) | Local contents | Local Index (short | long)
[sst, oro, nxa, nya]=read_sst2;
[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
function [sst, oro, nxa, nya]=read_sst2; 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 = [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 sst = []; oro = []; % Read data %for i = 151:200 % Define input file % hns = round((i-50)/100); % tns = round((i-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'); % 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; tstmp]; % oro = [oro; orotmp]; %end %save yrs151-200.mat sst oro; %clear sst oro; %sst = []; %oro = []; % Read data %for i = 201:250 % Define input file % hns = round((i-50)/100); % tns = round((i-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'); % 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; tstmp]; % oro = [oro; orotmp]; %end %save yrs201-250.mat sst oro; %clear sst oro; %sst = []; %oro = []; % Read data for i = 251:299 % Define input file hns = round((i-50)/100); tns = round((i-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'); 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; tstmp]; oro = [oro; orotmp]; end save yrs251-300.mat sst oro; clear sst oro; 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