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

  ViewVC Help
Powered by ViewVC 1.1.22