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

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

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

  ViewVC Help
Powered by ViewVC 1.1.22