/[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.2 - (hide annotations) (download)
Fri Mar 20 23:56:22 2015 UTC (10 years, 4 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65r, checkpoint65p, checkpoint65q
Changes since 1.1: +7 -4 lines
- warning messages: report help gcmfaces_demo

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

  ViewVC Help
Powered by ViewVC 1.1.22