/[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.18 - (hide annotations) (download)
Sun Jan 24 15:12:34 2016 UTC (9 years, 6 months ago) by gforget
Branch: MAIN
Changes since 1.17: +9 -19 lines
- improve comment displays and add help section in example_smooth
- move example_smooth call from example_bin_average.m to gcmfaces_demo

1 gforget 1.18 function [fld]=example_bin_average();
2     % EXAMPLE_BIN_AVERAGE generates a sample of random
3     % numbers distributed over the globe and
4     % bin averages to the default grid.
5    
6 gforget 1.1 %%%%%%%%%%%%%%%%%
7 gforget 1.16 %load grid:
8 gforget 1.1 %%%%%%%%%%%%%%%%%
9    
10 gforget 1.16 p = genpath('gcmfaces/'); addpath(p);
11     p = genpath('MITprof/'); addpath(p);
12    
13 gforget 1.10 gcmfaces_global;
14 gforget 1.1
15 gforget 1.16 mygrid=[]; grid_load;
16 gforget 1.13
17 gforget 1.11 if myenv.verbose>0;
18     gcmfaces_msg('===============================================');
19 gforget 1.18 gcmfaces_msg(['*** entering example_bin_average that generates ' ...
20     'randomly distributed data samples (position and value), ' ...
21     'and bin averages it to a given grid grid'],'');
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 gforget 1.18 gcmfaces_msg('* display results on sphere');
62 gforget 1.11 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.11 if myenv.verbose>0;
67     gcmfaces_msg('*** leaving example_bin_average');
68     gcmfaces_msg('===============================================');
69     end;
70    
71    
72 gforget 1.1
73    

  ViewVC Help
Powered by ViewVC 1.1.22