/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_calc/regrid_dblres.m
ViewVC logotype

Contents of /MITgcm_contrib/gael/matlab_class/gcmfaces_calc/regrid_dblres.m

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


Revision 1.1 - (show annotations) (download)
Mon Sep 24 23:05:20 2012 UTC (12 years, 10 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65r, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
- calc_barostream.m : add list_factors argument to accomodate e.g. tracer class transports.
- calc_overturn.m : add doFlip,list_factors args to accomodate e.g. tracer class transports.
- calc_barostream.m : introduce list_factors to allow use for e.g. tracer class transports.
- layers_remap.m (new) : remap variables (e.g. transports) from depth to tracer classes.
                       Uses regrid_dblres.m and regrid_sum.m and mimics pkg/layers.
- regrid_dblres.m (new) : double the resolution (only along 3rd dimension for now)
                       for a variable P (extensive or intensive) a number of times.
- regrid_sum.m (new) : add 3rd dimension elements of extensive variable P,
                       according to values of a tracer field collocated with P,
                       to the tracer grid defined by trGrid (1D vector)

1 function [P]=regrid_dblres(P,pType,nDblRes);
2 %object : double the resolution (only along 3rd dimension for now)
3 % for a variable P (extensive or intensive) a number of times.
4 %input : P is the variable of interest
5 % pType is 'extensive' or 'intensive'
6 % nDblRes is the number of resolution doublings.
7 %output : P is the input variable but with 2^nDblRes resolution
8
9 gcmfaces_global;
10
11 for ii=1:nDblRes;
12 %start with repmat
13 tmp1=repmat(P,[1 1 2]);
14 nn=size(P{1},3);
15 tmp1(:,:,1:2:2*nn)=P;
16 tmp1(:,:,2:2:2*nn)=P;
17 %interpolate (in grid point space)
18 tmp2=NaN*tmp1;
19 tmp2(:,:,2:2:2*nn-2)=3/4*P(:,:,1:nn-1)+1/4*P(:,:,2:nn);
20 tmp2(:,:,3:2:2*nn-1)=1/4*P(:,:,1:nn-1)+3/4*P(:,:,2:nn);
21 tmp1(~isnan(tmp2))=tmp2(~isnan(tmp2));
22 %if extensive then we want to conserve the sum over grid points
23 if strcmp(pType,'extensive'); tmp1=tmp1/2; end;
24 %overwite P
25 P=tmp1;
26 end;
27

  ViewVC Help
Powered by ViewVC 1.1.22