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

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

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


Revision 1.2 - (show annotations) (download)
Sun Mar 20 15:11:55 2016 UTC (9 years, 4 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65v, checkpoint65w, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.1: +1 -1 lines
- gcmfaces_calc/calc_barostream.m: set 0 on North America rather than Antarctica
- gcmfaces_calc/gcmfaces_subset.m: use convert2array directly
- gcmfaces_convert/convert2vector.m: set new method as default method
- gcmfaces_diags/diags_set_LAYERS.m: update after convert2vector.m revision

1 function [vec]=gcmfaces_subset(msk,fld,applyMsk);
2 %object: extract the subset of points from fld(.*msk) such that msk~=0
3 %inputs: msk is the gcmfaces subdomain mask (one vertical level)
4 % fld is the complete field (gcmfaces or array version)
5 %optional: applyMsk is a flag that stated whether to multiply with
6 % msk (applyMsk==1; default) or not (applyMsk==0);
7 %output: vec is the subset field
8 %
9 %note: - if fld is an array, then it must be a result of convert2array
10 % - for velocity subsets, msk may be -1 or +1, depending on
11 % directionality, e.g. when msk delineates a transport section.
12
13 if isempty(whos('applyMsk')); applyMsk=1; end;
14
15 if isa(fld,'gcmfaces'); fld=convert2array(fld); end;
16 nn=size(fld); nn=[nn ones(1,4-length(nn))];
17 fld=reshape(fld,nn(1)*nn(2),nn(3)*nn(4));
18
19 msk=convert2array(msk); msk=msk(:);
20
21 ii=find(msk~=0&~isnan(msk)); mm=length(ii);
22 if mm==0;
23 vec=zeros(1,nn(3),nn(4));
24 else;
25 if applyMsk;
26 vec=fld(ii,:).*(msk(ii)*ones(1,nn(3)*nn(4)));
27 else;
28 vec=fld(ii,:);
29 end;
30 vec=reshape(vec,[mm nn(3) nn(4)]);
31 end;
32
33

  ViewVC Help
Powered by ViewVC 1.1.22