/[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.17 - (hide annotations) (download)
Mon Jan 25 20:04:12 2016 UTC (9 years, 6 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65t
Changes since 1.16: +20 -5 lines
- gcmfaces_interp_2d.m: add the option to interpolate back to mygrid
- example_interp.m: illustrated the twice interpolated result
- remove: example_faces2latlon2faces.m and example_griddata.m

1 gforget 1.13 function []=example_interp();
2 gforget 1.16 % EXAMPLE_INTERP illustrates interpolation capabilities
3     % by going back and forth between gcmfaces grid and
4     % longitude-latitude arrays
5    
6     gcmfaces_global;
7    
8     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9     if myenv.verbose>0;
10     gcmfaces_msg('===============================================');
11     gcmfaces_msg(['*** entering example_interp: illustrate ' ...
12     'interpolation capabilities to get in and out of gcmfaces'],'');
13     end;
14 gforget 1.1
15     %%%%%%%%%%%%%%%%%
16 gforget 1.16 %load grid and setup test case:
17 gforget 1.1 %%%%%%%%%%%%%%%%%
18    
19 gforget 1.15 if isempty(mygrid);
20     grid_load;
21     end;
22 gforget 1.12
23 gforget 1.16 %target locations:
24     lon=[-179.75:0.5:179.75]; lat=[-89.75:0.5:89.75];
25     [lat,lon] = meshgrid(lat,lon);
26    
27     %original field:
28     m=mygrid.mskC(:,:,1);
29     fld=m.*mygrid.Depth;
30 gforget 1.1
31     %%%%%%%%%%%%%%%%%%%%%%%
32 gforget 1.16 %interpolate mygrid.Depth to lon-lat grid:
33    
34 gforget 1.12 if myenv.verbose>0;
35 gforget 1.16 gcmfaces_msg('* interpolate mygrid.Depth to lon-lat grid');
36 gforget 1.12 end;
37 gforget 1.16
38     fld_interp=gcmfaces_interp_2d(fld,lon,lat);
39 gforget 1.1
40     %%%%%%%%%%%%%%%%%%%%%%%
41 gforget 1.17 %interpolate back to mygrid.XC, mygrid.YC:
42 gforget 1.1
43 gforget 1.16 if myenv.verbose>0;
44 gforget 1.17 gcmfaces_msg('* interpolate back to gcmfaces grid');
45     end;
46    
47     fld_reinterp=gcmfaces_interp_2d(fld_interp,lon,lat);
48    
49     %%%%%%%%%%%%%%%%%%%%%%%
50     %remap to gcmfaces grid using extrapolation:
51    
52     if myenv.verbose>0;
53     gcmfaces_msg('* remap to gcmfaces grid using extrapolation');
54 gforget 1.1 end;
55    
56 gforget 1.16 fld_remap=gcmfaces_remap_2d(lon,lat,fld_interp,0,m);
57    
58 gforget 1.1 %%%%%%%%%%%%%%%%%%%%%%%
59 gforget 1.16 %illustrate results:
60 gforget 1.1
61 gforget 1.12 figureL;
62 gforget 1.17 subplot(2,1,1); set(gca,'FontSize',14);
63 gforget 1.16 [X,Y,FLD]=convert2pcol(mygrid.XC,mygrid.YC,fld);
64     pcolor(X,Y,FLD); axis([-180 180 -90 90]); shading flat;
65     title('original field');
66 gforget 1.17 subplot(2,1,2); set(gca,'FontSize',14);
67 gforget 1.16 pcolor(lon,lat,fld_interp); axis([-180 180 -90 90]); shading flat;
68     title('interpolated field');
69 gforget 1.17
70     figureL;
71     subplot(2,1,1); set(gca,'FontSize',14);
72     [X,Y,FLD]=convert2pcol(mygrid.XC,mygrid.YC,fld_reinterp);
73     pcolor(X,Y,FLD); axis([-180 180 -90 90]); shading flat;
74     title('reinterpolated field');
75     subplot(2,1,2); set(gca,'FontSize',14);
76 gforget 1.16 [X,Y,FLD]=convert2pcol(mygrid.XC,mygrid.YC,fld_remap);
77 gforget 1.12 pcolor(X,Y,FLD); axis([-180 180 -90 90]); shading flat;
78 gforget 1.16 title('remapped field');
79    
80    
81     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82     if myenv.verbose>0;
83     gcmfaces_msg('*** leaving example_interp');
84     gcmfaces_msg('===============================================');
85     end;
86 gforget 1.1
87    

  ViewVC Help
Powered by ViewVC 1.1.22