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

Annotation 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.1 - (hide annotations) (download)
Mon Aug 29 16:49:04 2011 UTC (13 years, 11 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65r, checkpoint65p, checkpoint65q, checkpoint65t
>> clean up and speed up transport computations.

- added routines
gcmfaces_edge_mask		infer edge masks associated with an interior subdomain mask
gcmfaces_subset			extract subset of unmasked points from field (e.g. for transports)

- modified routines
gcmfaces_lines_zonal	use gcmfaces_edge_mask and make field names in
						LATS_MASKS more explicit (mskCint, mskCedge, etc.)
gcmfaces_lines_transp	same thing for section masks; also remove the
						longer arc masks (we only use the shorter arcs)
calc_zonmean_T			use new names (see gcmfaces_lines_zonal)
calc_zonmedian_T		use new names (see gcmfaces_lines_zonal)
calc_overturn			use new names (see gcmfaces_lines_zonal) and gcmfaces_subset
calc_MeridionalTransport use new names (see gcmfaces_lines_zonal) and gcmfaces_subset
calc_transports			use new names (see gcmfaces_lines_transp) and gcmfaces_subset
disp_transport			fix case of a single record

1 gforget 1.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=convert2vector(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