/[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.14 - (hide annotations) (download)
Mon Jan 11 17:30:11 2016 UTC (9 years, 6 months ago) by gforget
Branch: MAIN
Changes since 1.13: +10 -12 lines
- revise handing of path, grid and input files, warnings and messages:

1 gforget 1.13 function []=example_interp();
2 gforget 1.8 %object: a interp2 example within gcmfaces
3 gforget 1.1
4     %%%%%%%%%%%%%%%%%
5 gforget 1.14 %load grid:
6 gforget 1.1 %%%%%%%%%%%%%%%%%
7    
8 gforget 1.14 p = genpath('gcmfaces/'); addpath(p);
9     p = genpath('MITprof/'); addpath(p);
10    
11 gforget 1.12 gcmfaces_global;
12 gforget 1.13
13 gforget 1.14 mygrid=[]; grid_load;
14 gforget 1.12
15 gforget 1.14 if myenv.verbose>0;
16     gcmfaces_msg(['* call example_interp : will define ' ...
17     'a 2x2 gridded variable (an bathymetry field here), and then ' ...
18     'use interp2 to map it to the chosen grid. '],'');
19     end;
20 gforget 1.1
21     %%%%%%%%%%%%%%%%%%%%%%%
22 gforget 1.12 %get sample data: subsampled mygrid.Depth
23     if myenv.verbose>0;
24     gcmfaces_msg('* define test case : subsampled bathymetry');
25     end;
26     lon=mygrid.XC; lat=mygrid.YC;
27     original_Depth=mygrid.Depth;
28     original_Depth(original_Depth==0)=NaN;
29     %
30     [lon,lat,original_Depth]=convert2pcol(lon,lat,original_Depth);
31     nn=[62:239]; lon=lon(:,nn); lat=lat(:,nn);
32     original_Depth=original_Depth(:,nn);
33     [lon,lat]=meshgrid(lon(:,1),lat(1,:));
34     original_Depth=original_Depth';
35 gforget 1.1
36     %%%%%%%%%%%%%%%%%%%%%%%
37     %do the interpolation:
38    
39 gforget 1.12 interp2_depth=gcmfaces(5);
40 gforget 1.8 for ii=1:mygrid.nFaces;
41 gforget 1.12 xi=mygrid.XC{ii}; yi=mygrid.YC{ii};
42     zi = interp2(lon,lat,original_Depth,xi,yi);
43     interp2_depth{ii}=zi;
44 gforget 1.1 end;
45    
46     %%%%%%%%%%%%%%%%%%%%%%%
47     %illustrate the result:
48    
49 gforget 1.12 figureL;
50     subplot(2,1,1); set(gca,'FontSize',14);
51     pcolor(lon,lat,original_Depth); axis([-180 180 -90 90]); shading flat;
52     title('input to interp2');
53     subplot(2,1,2); set(gca,'FontSize',14);
54     [X,Y,FLD]=convert2pcol(mygrid.XC,mygrid.YC,interp2_depth);
55     pcolor(X,Y,FLD); axis([-180 180 -90 90]); shading flat;
56     title('output of interp2');
57 gforget 1.1
58    

  ViewVC Help
Powered by ViewVC 1.1.22