/[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.16 - (hide annotations) (download)
Mon Jan 25 19:02:59 2016 UTC (9 years, 6 months ago) by gforget
Branch: MAIN
Changes since 1.15: +48 -33 lines
- example_interp: recycle to demo gcmfaces_interp_2d and gcmfaces_remap_2d.
- gcmfaces_demo: replace call to example_remap with example_interp.

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.16 %remap to gcmfaces grid:
42 gforget 1.1
43 gforget 1.16 if myenv.verbose>0;
44     gcmfaces_msg('* remap interpolated field to gcmfaces grid');
45 gforget 1.1 end;
46    
47 gforget 1.16 fld_remap=gcmfaces_remap_2d(lon,lat,fld_interp,0,m);
48    
49 gforget 1.1 %%%%%%%%%%%%%%%%%%%%%%%
50 gforget 1.16 %illustrate results:
51 gforget 1.1
52 gforget 1.12 figureL;
53 gforget 1.16 subplot(3,1,1); set(gca,'FontSize',14);
54     [X,Y,FLD]=convert2pcol(mygrid.XC,mygrid.YC,fld);
55     pcolor(X,Y,FLD); axis([-180 180 -90 90]); shading flat;
56     title('original field');
57     subplot(3,1,2); set(gca,'FontSize',14);
58     pcolor(lon,lat,fld_interp); axis([-180 180 -90 90]); shading flat;
59     title('interpolated field');
60     subplot(3,1,3); set(gca,'FontSize',14);
61     [X,Y,FLD]=convert2pcol(mygrid.XC,mygrid.YC,fld_remap);
62 gforget 1.12 pcolor(X,Y,FLD); axis([-180 180 -90 90]); shading flat;
63 gforget 1.16 title('remapped field');
64    
65    
66     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67     if myenv.verbose>0;
68     gcmfaces_msg('*** leaving example_interp');
69     gcmfaces_msg('===============================================');
70     end;
71 gforget 1.1
72    

  ViewVC Help
Powered by ViewVC 1.1.22