/[MITgcm]/MITgcm_contrib/gael/matlab_class/sample_processing/example_interp.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/sample_processing/example_interp.m

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


Revision 1.9 - (hide annotations) (download)
Fri Aug 19 17:36:11 2011 UTC (13 years, 11 months ago) by gforget
Branch: MAIN
Changes since 1.8: +4 -4 lines
- use gcmfaces_global and myenv

1 gforget 1.8 function []=example_interp(choiceV3orV4);
2     %object: a interp2 example within gcmfaces
3     %inputs: choiceV3orV4 ('v3' or 'v4') selects the sample GRID
4 gforget 1.1
5     %%%%%%%%%%%%%%%%%
6     %load parameters:
7     %%%%%%%%%%%%%%%%%
8    
9 gforget 1.9 gcmfaces_global;
10     dir0=[myenv.gcmfaces_dir '/sample_input/'];
11 gforget 1.8 dirGrid=[dir0 '/GRID' choiceV3orV4 '/'];
12     dirIn=[dir0 '/SAMPLE' choiceV3orV4 '/'];
13     if strcmp(choiceV3orV4,'v4'); nF=5; fileFormat='compact'; else; nF=1; fileFormat='straight'; end;
14     global mygrid; mygrid=[]; grid_load(dirGrid,nF,fileFormat);
15 gforget 1.1
16     %%%%%%%%%%%%%%%%%%%%%%%
17 gforget 1.2 %get sample data: V3 SSH
18 gforget 1.9 dirV3=[myenv.gcmfaces_dir '/sample_input/SAMPLEv3/'];
19 gforget 1.2 etan=rdmds([dirV3 'DDetan'],0); etan(etan==0)=NaN;
20 gforget 1.9 dirV3=[myenv.gcmfaces_dir '/sample_input/GRIDv3/'];
21 gforget 1.2 lon=rdmds([dirV3 'XC']); lat=rdmds([dirV3 'YC']);
22 gforget 1.1
23     %%%%%%%%%%%%%%%%%%%%%%%
24     %do the interpolation:
25     x=[lon-360;lon]; y=[lat;lat]; z=[etan;etan];
26    
27     z_interp=gcmfaces(5);
28 gforget 1.8 for ii=1:mygrid.nFaces;
29 gforget 1.1 xi=mygrid.XC{ii}; yi=mygrid.YC{ii};
30     zi = interp2(x',y',z',xi,yi);
31     z_interp{ii}=zi;
32     end;
33    
34     %%%%%%%%%%%%%%%%%%%%%%%
35     %illustrate the result:
36    
37     figure; set(gcf,'Units','Normalized','Position',[0.1 0.3 0.4 0.6]);
38     x=[lon-360;lon]; y=[lat;lat]; z=[etan;etan];
39     pcolor(x,y,z); axis([-180 180 -90 90]); shading flat; caxis([-2 1]); colorbar;
40    
41     figure; set(gcf,'Units','Normalized','Position',[0.5 0.3 0.4 0.6]);
42     [X,Y,FLD]=convert2pcol(mygrid.XC,mygrid.YC,z_interp);
43     pcolor(X,Y,FLD); axis([-180 180 -90 90]); shading flat; caxis([-2 1]); colorbar;
44    
45    
46    

  ViewVC Help
Powered by ViewVC 1.1.22