1 |
function [FLD]=diffsmooth2D(fld,dxCsm,dyCsm); |
2 |
%object: diffusive smoother (after Weaver and Courtier 2001) |
3 |
% |
4 |
%input: fld field to be smoothed (masked with NaN) |
5 |
% dxCsm,dyCsm scale in first/second grid direction |
6 |
%output:FLD smoothed field |
7 |
% |
8 |
%asumption: dxCsm/dyCsm are given at U/V points (as DXC/DYC are) |
9 |
|
10 |
global mygrid; |
11 |
|
12 |
%scale the diffusive operator: |
13 |
dxC=mygrid.DXC; dyC=mygrid.DYC; |
14 |
|
15 |
tmp0=dxCsm./dxC; tmp0(isnan(fld))=NaN; tmp00=nanmax(tmp0); |
16 |
tmp0=dyCsm./dyC; tmp0(isnan(fld))=NaN; tmp00=max([tmp00 nanmax(tmp0)]); |
17 |
nbt=tmp00; |
18 |
nbt=ceil(1.1*2*nbt^2); |
19 |
|
20 |
dt=1; |
21 |
T=nbt*dt; |
22 |
|
23 |
%diffusion operator: |
24 |
Kux=dxCsm.*dxCsm/T/2; |
25 |
Kvy=dyCsm.*dyCsm/T/2; |
26 |
|
27 |
%setup problem: |
28 |
myOp.dt=1; |
29 |
myOp.nbt=nbt; |
30 |
myOp.Kux=Kux; |
31 |
myOp.Kvy=Kvy; |
32 |
|
33 |
%time step problem: |
34 |
FLD=gcmfaces_timestep(myOp,fld); |