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

Contents of /MITgcm_contrib/gael/matlab_class/sample_processing/example_remap.m

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


Revision 1.8 - (show annotations) (download)
Mon Jan 25 19:02:59 2016 UTC (9 years, 6 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.7: +8 -3 lines
- example_interp: recycle to demo gcmfaces_interp_2d and gcmfaces_remap_2d.
- gcmfaces_demo: replace call to example_remap with example_interp.

1 function []=example_remap(doRemap3d);
2 % EXAMPLE_REMAP maps a lon-lat field to gcmfaces that in the
3 % three-dimensional case (when doRemap3d=1) with or without
4 % extrapolation (both cases are illustrated)
5 %
6 % Note: activating example_remap requires the following input file
7 % mkdir sample_input
8 % wget ftp://mit.ecco-group.org/gforget/testcase_remap.mat
9 % mv testcase_remap.mat sample_input/.
10
11 gcmfaces_global;
12
13 fil=fullfile(pwd,filesep,'sample_input',filesep,'testcase_remap.mat');
14 if isempty(dir(fil));
15 help gcmfaces_demo;
16 warning('skipping example_remap (missing sample_input/testcase_remap.mat)');
17 return;
18 end;
19
20 if isempty(whos('doRemap3d')); doRemap3d=0; end;
21
22 %%%%%%%%%%%%%%%%%
23 %load grid:
24 %%%%%%%%%%%%%%%%%
25
26 if isempty(mygrid);
27 grid_load;
28 end;
29 nF=mygrid.nFaces;
30
31 %%%%%%%%%%%%%%%%%
32 %load test case:
33 %%%%%%%%%%%%%%%%%
34
35 load(fil);
36
37 if myenv.verbose>0;
38 gcmfaces_msg('===============================================');
39 gcmfaces_msg(['*** entering example_remap: demonstrate ' ...
40 'the use of gcmfaces_remap_2d '],'');
41 end;
42
43 warning('off','MATLAB:dsearch:DeprecatedFunction');
44 warning('off','MATLAB:delaunay:DuplicateDataPoints');
45
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 %map lon-lat field to gcmfaces
48
49 if myenv.verbose>0;
50 gcmfaces_msg('* map lon-lat field to gcmfaces');
51 end;
52
53 kk=20;%choice of output depth level
54 kkIn=max(find(depth<-mygrid.RC(kk)));% corresponding choice of input level
55
56 %without extrapolation (note: shallow regions are blank in FLD)
57 % ref_remap2d=FLD1(:,:,kkIn);
58 ref_remap2d=fld1(:,:,kk);
59 fld_remap2d=gcmfaces_remap_2d(lon,lat,FLD2(:,:,kkIn),3);
60 fld_remap2d_extrap=gcmfaces_remap_2d(lon,lat,FLD2(:,:,kkIn),3,mygrid.mskC(:,:,kk));
61
62 %extrapolate to fill 3D model domain (note: extrapolation is often a bad idea)
63 if doRemap3d;
64 ref_remap3d=fld1(:,:,kk);
65 fld_remap3d=gcmfaces_remap_3d(lon,lat,depth(kkIn+[-2:2]),FLD2(:,:,kkIn+[-2:2]));
66 fld_repmat3d_kk=fld_remap3d(:,:,kk);
67 end;
68
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 %quick display
71 cc=[0.4:0.05:1.1];
72 %
73 if myenv.verbose>0;
74 gcmfaces_msg('* gcmfaces_remap_2d result (without extrapolation)');
75 end;
76 figureL; gcmfaces_sphere(fld_remap2d,cc,[],'N',1); title('gcmfaces_remap_2d result ');
77 if myenv.verbose>0;
78 gcmfaces_msg('* gcmfaces_remap_2d result (with extrapolation)');
79 end;
80 figureL; gcmfaces_sphere(fld_remap2d_extrap,cc,[],'N',1); title('gcmfaces_remap_2d result (extrapolated)');
81 %
82 if doRemap3d;
83 if myenv.verbose>0;
84 gcmfaces_msg('* original field');
85 end;
86 figureL; gcmfaces_sphere(ref_remap2d,cc,[],'N',1); title('original field (slightly different level)');
87 if myenv.verbose>0;
88 gcmfaces_msg('* gcmfaces_remap_3d result (involves extrapolation)');
89 end;
90 figureL; gcmfaces_sphere(fld_repmat3d_kk,cc,[],'N',1); title('gcmfaces_remap_3d result');
91 end;
92
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94 if myenv.verbose>0;
95 gcmfaces_msg('*** leaving example_remap');
96 gcmfaces_msg('===============================================');
97 end;
98
99
100
101

  ViewVC Help
Powered by ViewVC 1.1.22