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

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

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


Revision 1.7 - (hide annotations) (download)
Sun Jan 24 15:12:34 2016 UTC (9 years, 6 months ago) by gforget
Branch: MAIN
Changes since 1.6: +21 -5 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.6 function []=example_smooth(fld);
2 gforget 1.7 % EXAMPLE_SMOOTH(fld) applies smoothing filters to fld
3     %
4     % Example:
5     % fld=example_bin_average;
6     % example_smooth(fld);
7 gforget 1.6
8     gcmfaces_global;
9 gforget 1.1
10 gforget 1.7 if myenv.verbose>0;
11     gcmfaces_msg('===============================================');
12     gcmfaces_msg('*** entering example_smooth : apply smoother to gridded data');
13     end;
14    
15     %%%%%%%% apply land mask %%%%%%%%
16    
17 gforget 1.2 if myenv.verbose>0;
18     gcmfaces_msg('* apply land mask (1/NaN) to gridded before smoothing');
19     end;
20 gforget 1.6 fld=fld.*mygrid.mskC(:,:,1);
21 gforget 1.1
22 gforget 1.3 %%%%%%%% isotropic diffusion %%%%%%%%
23    
24 gforget 1.1 %choose smoothing scale: here 3 X grid spacing
25 gforget 1.2 if myenv.verbose>0;
26 gforget 1.7 gcmfaces_msg('** set the smoothing scale to 3 grid points');
27 gforget 1.2 end;
28 gforget 1.1 distXC=3*mygrid.DXC; distYC=3*mygrid.DYC;
29    
30     %do the smoothing:
31 gforget 1.2 if myenv.verbose>0;
32     gcmfaces_msg(['* call diffsmoth2D : apply smoothing operator ' ...
33     'that consists in time stepping a diffusion equation ' ...
34     'with accordingly chosen diffusivity and duration. In particular ' ...
35     'diffsmoth2D illustrates gradient computations (using calc_T_grad) ' ...
36 gforget 1.4 'and convergence computations (using calc_UV_conv).']);
37 gforget 1.2 end;
38 gforget 1.6 fld_smooth=diffsmooth2D(fld,distXC,distYC);
39 gforget 1.1
40     %display results:
41 gforget 1.2 if myenv.verbose>0;
42 gforget 1.7 gcmfaces_msg('* display results on sphere');
43 gforget 1.2 end;
44 gforget 1.1
45 gforget 1.6 figureL; gcmfaces_sphere(fld_smooth); caxis([-1 1]*0.4); colorbar;
46 gforget 1.2 title('smoothed data')
47 gforget 1.3
48     %%%%%%%% rotated diffusion %%%%%%%%
49    
50     %choose smoothing scale: here 3 X grid spacing
51     if myenv.verbose>0;
52 gforget 1.7 gcmfaces_msg('** set anisotropic and rotated smoothing');
53 gforget 1.3 end;
54     distLarge=3*sqrt(mygrid.RAC); distSmall=1*sqrt(mygrid.RAC);
55     fldRef=mygrid.YC;
56    
57     %do the smoothing:
58     if myenv.verbose>0;
59     gcmfaces_msg(['* call diffsmoth2Drotated : apply anisotropic smoothing operator ' ...
60     'that acts preferentially along contours of a reference field (here latitude).']);
61     end;
62 gforget 1.6 fld_smooth2=diffsmooth2Drotated(fld,distLarge,distSmall,mygrid.YC);
63 gforget 1.3
64     %display results:
65     if myenv.verbose>0;
66 gforget 1.7 gcmfaces_msg('* display results on sphere');
67 gforget 1.3 end;
68    
69 gforget 1.6 figureL; gcmfaces_sphere(fld_smooth2); caxis([-1 1]*0.4); colorbar;
70 gforget 1.3 title('zonally smoothed data')
71    
72    
73 gforget 1.7 if myenv.verbose>0;
74     gcmfaces_msg('*** leaving example_smooth');
75     gcmfaces_msg('===============================================');
76     end;
77    

  ViewVC Help
Powered by ViewVC 1.1.22