/[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.20 - (hide annotations) (download)
Sun Jan 24 17:45:32 2016 UTC (9 years, 6 months ago) by gforget
Branch: MAIN
Changes since 1.19: +2 -2 lines
- improve displayed comments

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.10 gcmfaces_global;
11 gforget 1.1
12 gforget 1.19 if isempty(mygrid);
13     grid_load;
14     end;
15 gforget 1.13
16 gforget 1.11 if myenv.verbose>0;
17     gcmfaces_msg('===============================================');
18 gforget 1.20 gcmfaces_msg(['*** entering example_bin_average: generate ' ...
19 gforget 1.18 'randomly distributed data samples (position and value), ' ...
20 gforget 1.20 'and bin average this data set to a gcmfaces grid'],'');
21 gforget 1.8 end;
22 gforget 1.1
23 gforget 1.11 warning('off','MATLAB:dsearch:DeprecatedFunction');
24     warning('off','MATLAB:delaunay:DuplicateDataPoints');
25 gforget 1.1
26     %%%%%%%%%%%%%%%%%%%%%%%
27     %generate random data
28    
29 gforget 1.11 if myenv.verbose>0;
30     gcmfaces_msg('* generate random data');
31     end;
32 gforget 1.17 nn=1e6;
33     lat=(rand(nn,1)-0.5)*2*90;
34     lon=(rand(nn,1)-0.5)*2*180;
35 gforget 1.11 %needed for 0-360 longitude convention
36     if mygrid.nFaces==1;
37     xx=find(lon<0);lon(xx)=lon(xx)+360;
38     end;
39 gforget 1.17 sample=(rand(nn,1)-0.5)*2;
40 gforget 1.11
41     %%%%%%%%%%%%%%%%%%%%%%%
42     %generate delaunay triangulation
43    
44     if myenv.verbose>0;
45     gcmfaces_msg('* call gcmfaces_bindata : generate delaunay triangulation');
46     end;
47     gcmfaces_bindata;
48 gforget 1.1
49     %%%%%%%%%%%%%%%%%%%%%%%%
50     %bin average random data
51    
52 gforget 1.11 if myenv.verbose>0;
53     gcmfaces_msg('* call gcmfaces_bindata : bin average data');
54     end;
55 gforget 1.17 fld=gcmfaces_bindata(lon,lat,sample);
56 gforget 1.11
57     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58     %quick display
59     if myenv.verbose>0;
60 gforget 1.18 gcmfaces_msg('* display results on sphere');
61 gforget 1.11 end;
62 gforget 1.17 figureL; gcmfaces_sphere(fld); axis xy; caxis([-1 1]*0.4); colorbar;
63 gforget 1.11 title('bin averaged data');
64 gforget 1.1
65 gforget 1.11 if myenv.verbose>0;
66     gcmfaces_msg('*** leaving example_bin_average');
67     gcmfaces_msg('===============================================');
68     end;
69    
70    
71 gforget 1.1
72    

  ViewVC Help
Powered by ViewVC 1.1.22