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

Contents 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.8 - (show annotations) (download)
Mon Jan 25 21:13:56 2016 UTC (9 years, 6 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.7: +6 -4 lines
- add missing titles, units, axes labels

1 function []=example_smooth(fld);
2 % EXAMPLE_SMOOTH(fld) applies smoothing filters to fld
3 %
4 % Example:
5 % fld=example_bin_average;
6 % example_smooth(fld);
7
8 gcmfaces_global;
9
10 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 if myenv.verbose>0;
18 gcmfaces_msg('* apply land mask (1/NaN) to gridded before smoothing');
19 end;
20 fld=fld.*mygrid.mskC(:,:,1);
21
22 %%%%%%%% isotropic diffusion %%%%%%%%
23
24 %choose smoothing scale: here 3 X grid spacing
25 if myenv.verbose>0;
26 gcmfaces_msg('** set the smoothing scale to 3 grid points');
27 end;
28 distXC=3*mygrid.DXC; distYC=3*mygrid.DYC;
29
30 %do the smoothing:
31 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 'and convergence computations (using calc_UV_conv).']);
37 end;
38 fld_smooth=diffsmooth2D(fld,distXC,distYC);
39
40 %display results:
41 if myenv.verbose>0;
42 gcmfaces_msg('* display results on sphere');
43 end;
44
45 figureL; set(gca,'FontSize',16);
46 gcmfaces_sphere(fld_smooth); caxis([-1 1]*0.4); colorbar;
47 title('smoothed bin averaged data')
48
49 %%%%%%%% rotated diffusion %%%%%%%%
50
51 %choose smoothing scale: here 3 X grid spacing
52 if myenv.verbose>0;
53 gcmfaces_msg('** set anisotropic and rotated smoothing');
54 end;
55 distLarge=3*sqrt(mygrid.RAC); distSmall=1*sqrt(mygrid.RAC);
56 fldRef=mygrid.YC;
57
58 %do the smoothing:
59 if myenv.verbose>0;
60 gcmfaces_msg(['* call diffsmoth2Drotated : apply anisotropic smoothing operator ' ...
61 'that acts preferentially along contours of a reference field (here latitude).']);
62 end;
63 fld_smooth2=diffsmooth2Drotated(fld,distLarge,distSmall,mygrid.YC);
64
65 %display results:
66 if myenv.verbose>0;
67 gcmfaces_msg('* display results on sphere');
68 end;
69
70 figureL; set(gca,'FontSize',16);
71 gcmfaces_sphere(fld_smooth2); caxis([-1 1]*0.4); colorbar;
72 title('anisotropic smoother result')
73
74
75 if myenv.verbose>0;
76 gcmfaces_msg('*** leaving example_smooth');
77 gcmfaces_msg('===============================================');
78 end;
79

  ViewVC Help
Powered by ViewVC 1.1.22