/[MITgcm]/MITgcm_contrib/gael/matlab_class/ecco_v4/gcmfaces_remap.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/ecco_v4/gcmfaces_remap.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (hide annotations) (download)
Mon Apr 30 19:53:47 2012 UTC (13 years, 2 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65r, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.3: +2 -123 lines
- remove accessory functions that are now in the separate toutine gcmfaces_remap_2d.m

1 gforget 1.3 function []=gcmfaces_remap(dirIn,fileIn,gridIn,dirOut,fileOut);
2 gforget 1.1 %object: use bin average to remap a lat-lon grid product to a gcmfaces grid
3     %inputs: dirIn is the input directory
4     % fileIn is the input file name without the final four year characters
5     % (e.g. 'SST_monthly_r2_' to process 'SST_monthly_r2_1992' etc.)
6 gforget 1.3 % gridIn states the originating grid. It can be set to
7     % 1 implying that the grid is [0.5:359.5] & [-89.5:89.5]
8 gforget 1.2 % 2 implying that the grid is [0.5:359.5] & [-79.5:79.5]
9 gforget 1.3 % 3 implying that the grid is [.125:.25:360-.125] & [-90+.125:.25:90-.125]
10 gforget 1.2 % {x,y} where x and y are the position arrays
11 gforget 1.3 % dirOut and filOut are the corresponding output names
12 gforget 1.1 %
13     %assumption: mygrid has been read using grid_load
14 gforget 1.4 % for the input grid, lon must be 0-360 (see gcmfaces_remap_2d)
15 gforget 1.1
16     global mygrid mytri;
17     %create triangulation
18     gcmfaces_bindata;
19     %list files to be processed
20     listFiles=dir([dirIn fileIn '*']);
21 gforget 1.2
22     %case of user defined grid
23 gforget 1.3 if iscell(gridIn); x=gridIn{1}; y=gridIn{2}; [nx,ny]=size(x); mis=0;
24     else;
25 gforget 1.2 %standard cases
26 gforget 1.3 if gridIn==1;%gloabl 1 degree grid
27 gforget 1.1 x=[0.5:359.5]'*ones(1,180);
28     y=ones(360,1)*[-89.5:89.5];
29     [nx,ny]=size(x);
30     mis=0;
31 gforget 1.3 elseif gridIn==2;%ECCO 1 degree grid
32 gforget 1.1 x=[0.5:359.5]'*ones(1,160);
33     y=ones(360,1)*[-79.5:79.5];
34     [nx,ny]=size(x);
35     mis=0;
36 gforget 1.3 elseif gridIn==3;%1/4 degree grid (e.g. REMSS)
37     x=[.125:.25:360-.125]'*ones(1,180*4);
38     y=ones(360*4,1)*[-90+.125:.25:90-.125];
39     [nx,ny]=size(x);
40     mis=-9999;
41     else;
42     error('unknown grid');
43     end;
44 gforget 1.1 end;
45    
46 gforget 1.2 %process one file after the other
47 gforget 1.1 for ii=1:length(listFiles);
48     yy=listFiles(ii).name(end-3:end); fprintf(['processing ' fileIn ' for year ' yy '\n']);
49     nt=listFiles(ii).bytes/nx/ny/4; if round(nt)~=nt; error('inconsistent sizes'); end;
50     %read data
51     fld=reshape(read2memory([dirIn listFiles(ii).name],[nx*ny*nt 1]),[nx ny nt]);
52     %mask land
53     fld(fld==mis)=NaN;
54     %map to v4 grid
55     FLD=convert2array(zeros(360,360,nt));
56 gforget 1.4 for tt=1:nt; FLD(:,:,tt)=gcmfaces_remap_2d(x,y,fld(:,:,tt),3); end;
57 gforget 1.1 %set missing value
58     FLD(find(isnan(FLD)))=mis;
59     %write data
60     write2file([dirOut fileOut yy],convert2gcmfaces(FLD));
61     end;
62    

  ViewVC Help
Powered by ViewVC 1.1.22