/[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.1 - (hide annotations) (download)
Fri Mar 20 23:20:31 2015 UTC (10 years, 4 months ago) by gforget
Branch: MAIN
- example_bin_average.m : remove old comment
- added : example_remap.m and prep_remap.m

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

  ViewVC Help
Powered by ViewVC 1.1.22