/[MITgcm]/MITgcm_contrib/gael/profilesMatlabProcessing/profiles_misc/MITprof_subset.m
ViewVC logotype

Contents of /MITgcm_contrib/gael/profilesMatlabProcessing/profiles_misc/MITprof_subset.m

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


Revision 1.1 - (show annotations) (download)
Mon Nov 8 19:46:01 2010 UTC (14 years, 8 months ago) by gforget
Branch: MAIN
- MITprof_load.m same as MITprof_read.m but different...
- MITprof_concat.m concatenate two MITprof objects in memory.
- MITprof_subset.m extracts a subset of MITprof.
- MITprof_bin.m bin averages MITprof to a grid.
- MITprof_stats.m does a few stats over MITprof.

1 function [MITprofSub]=MITprof_subset(MITprof,varargin);
2 % [MITprofSub]=MITprof_subset(MITprof,'depth',[50 150]);
3 % returns the subset of MITprof that has prof_depth>=50 and <150
4 % [MITprofSub]=MITprof_subset(MITprof,'depth',[50 150],'descr',platformName);
5 % ... and prof_descr=platformName;
6
7 MITprofSub=MITprof;
8 fldNames=fieldnames(MITprof);
9
10 nSub=(nargin-1)/2;
11 for iSub=1:nSub;
12 eval(['prof_sub=MITprof.prof_' varargin{(iSub-1)*2+1} ';']);
13 range_sub=varargin{(iSub-1)*2+2};
14 if strcmp('descr',varargin{(iSub-1)*2+1});
15 KK=find(strcmp(prof_sub,range_sub));
16 elseif strcmp('depth',varargin{(iSub-1)*2+1});
17 KK=find(prof_sub>=range_sub(1)&prof_sub<range_sub(2));
18 else;
19 KK=find(prof_sub>=range_sub(1)&prof_sub<range_sub(2));
20 end;
21 % [varargin{(iSub-1)*2+1} ' -- ' num2str(length(KK))]
22 for iFld=1:length(fldNames);
23 eval(['tmp1=MITprofSub.' fldNames{iFld} ';']);
24 if strcmp('depth',varargin{(iSub-1)*2+1}) & strcmp(fldNames{iFld},'prof_depth');
25 tmp1=tmp1(KK);
26 elseif strcmp('depth',varargin{(iSub-1)*2+1});
27 if size(tmp1,2)==length(MITprof.prof_depth); tmp1=tmp1(:,KK); end;
28 else;
29 if size(tmp1,1)==size(prof_sub,1); tmp1=tmp1(KK,:); end;
30 end;
31 eval(['MITprofSub.' fldNames{iFld} '=tmp1;']);
32 end;
33
34 end;
35
36 %add a couple things:
37 %--------------------
38 MITprofSub.np=length(MITprofSub.prof_lon);
39 MITprofSub.nr=length(MITprofSub.prof_depth);
40

  ViewVC Help
Powered by ViewVC 1.1.22