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

Contents of /MITgcm_contrib/gael/matlab_class/gcmfaces_calc/regrid_sum.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 [trP]=regrid_sum(P,tracer,trGrid);
2 %object : add 3rd dimension elements of extensive variable P,
3 % according to values of a tracer field collocated with P,
4 % to the tracer grid defined by trGrid (1D vector)
5 %input : P is the extensive variable of interest
6 % tracer is the associated tracer field
7 % trGrid is the vector of tracer values at
8 % bins center of the tracer grid bins.
9 %output : trP is the counterpart to P on the tracer grid
10
11 trP=NaN*repmat(P(:,:,1),[1 1 length(trGrid)-1]);
12 trBounds=[-Inf (trGrid(1:end-1)+trGrid(2:end))/2 Inf];
13 for kk=1:length(trGrid);
14 tmp1=P.*(tracer>=trBounds(kk)).*(tracer<trBounds(kk+1));
15 trP(:,:,kk)=nansum(tmp1,3);
16 end;

  ViewVC Help
Powered by ViewVC 1.1.22