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

Annotation of /MITgcm_contrib/gael/matlab_class/sample_processing/example_bin_average.m

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


Revision 1.17 - (hide annotations) (download)
Sun Jan 24 14:32:33 2016 UTC (9 years, 6 months ago) by gforget
Branch: MAIN
Changes since 1.16: +8 -35 lines
- example_bin_average: switch to gcmfaces_sphere for plots,
  rename variables, remove format conversion demo, output
  result (fld) and pass fld as argument to example_smooth
- example_smooth: make a function with argument fld,
  switch to gcmfaces_sphere for plots, rename variables

1 gforget 1.17 function [fld]=example_bin_average(doSmooth);
2 gforget 1.8 %object: a bin average example within gcmfaces
3 gforget 1.14 %inputs: doSmooth; if set to 1, follow on with smoothing example
4 gforget 1.1
5     %%%%%%%%%%%%%%%%%
6 gforget 1.16 %load grid:
7 gforget 1.1 %%%%%%%%%%%%%%%%%
8    
9 gforget 1.16 p = genpath('gcmfaces/'); addpath(p);
10     p = genpath('MITprof/'); addpath(p);
11    
12 gforget 1.10 gcmfaces_global;
13 gforget 1.1
14 gforget 1.16 mygrid=[]; grid_load;
15 gforget 1.13
16 gforget 1.11 if myenv.verbose>0;
17     gcmfaces_msg('===============================================');
18     gcmfaces_msg(['*** entering example_bin_average that will first define ' ...
19     'randomly distributed variable (position and value), ' ...
20     'then bin average it to the chosen grid, ' ...
21     'and finally apply a smoothing filter to it '],'');
22 gforget 1.8 end;
23 gforget 1.1
24 gforget 1.11 warning('off','MATLAB:dsearch:DeprecatedFunction');
25     warning('off','MATLAB:delaunay:DuplicateDataPoints');
26 gforget 1.1
27     %%%%%%%%%%%%%%%%%%%%%%%
28     %generate random data
29    
30 gforget 1.11 if myenv.verbose>0;
31     gcmfaces_msg('* generate random data');
32     end;
33 gforget 1.17 nn=1e6;
34     lat=(rand(nn,1)-0.5)*2*90;
35     lon=(rand(nn,1)-0.5)*2*180;
36 gforget 1.11 %needed for 0-360 longitude convention
37     if mygrid.nFaces==1;
38     xx=find(lon<0);lon(xx)=lon(xx)+360;
39     end;
40 gforget 1.17 sample=(rand(nn,1)-0.5)*2;
41 gforget 1.11
42     %%%%%%%%%%%%%%%%%%%%%%%
43     %generate delaunay triangulation
44    
45     if myenv.verbose>0;
46     gcmfaces_msg('* call gcmfaces_bindata : generate delaunay triangulation');
47     end;
48     gcmfaces_bindata;
49 gforget 1.1
50     %%%%%%%%%%%%%%%%%%%%%%%%
51     %bin average random data
52    
53 gforget 1.11 if myenv.verbose>0;
54     gcmfaces_msg('* call gcmfaces_bindata : bin average data');
55     end;
56 gforget 1.17 fld=gcmfaces_bindata(lon,lat,sample);
57 gforget 1.11
58     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59     %quick display
60     if myenv.verbose>0;
61     gcmfaces_msg('* crude display of results in array format');
62     end;
63 gforget 1.17 figureL; gcmfaces_sphere(fld); axis xy; caxis([-1 1]*0.4); colorbar;
64 gforget 1.11 title('bin averaged data');
65 gforget 1.1
66 gforget 1.8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67     %now illustrate the smoothing filter
68 gforget 1.11 if myenv.verbose>0;
69     gcmfaces_msg('* entering example_smooth : apply smoother to gridded data');
70     end;
71 gforget 1.17 if doSmooth; example_smooth(fld); end;
72 gforget 1.11 if myenv.verbose>0;
73     gcmfaces_msg('* leaving example_smooth');
74     end;
75    
76     if myenv.verbose>0;
77     gcmfaces_msg('*** leaving example_bin_average');
78     gcmfaces_msg('===============================================');
79     end;
80    
81    
82 gforget 1.1
83    

  ViewVC Help
Powered by ViewVC 1.1.22