/[MITgcm]/MITgcm_contrib/gmaze_pv/volbet2iso.m
ViewVC logotype

Annotation of /MITgcm_contrib/gmaze_pv/volbet2iso.m

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


Revision 1.3 - (hide annotations) (download)
Fri Jun 16 21:09:16 2006 UTC (19 years, 1 month ago) by gmaze
Branch: MAIN
Changes since 1.2: +11 -3 lines
Directory tree udpate

1 gmaze 1.1 %
2     % V = volbet2iso(TRACER,LIMITS,DEPTH,LAT,LONG)
3     %
4 gmaze 1.2 % This function computes the ocean volume between two iso surfaces,
5 gmaze 1.1 % given fixed limits eastward, westward and southward.
6     %
7     % TRACER = TRACER(DEPTH,LAT,LONG) : surface tracer variable in 3D
8     % LIMITS = [OUTCROP1 OUTCROP2 MAX_DEPTH MAX_LAT1 MAX_LAT2 MAX_LONG1 MAX_LONG2]
9     % : limit's values (MAX_DEPTH and MAX_LAT2 are used only if
10     % the iso-outcrop's surfaces reach them).
11     % DEPTH : vertical axis (1D), m downward, positive
12     % LAT : latitude axis (1D), degrees northward
13     % LONG : longitude axis (1D), degrees east
14     % V : single volume value (m^3)
15     %
16     % 06/12/2006
17     % gmaze@mit.edu
18     %
19    
20    
21     function varargout = volbet2iso(TRACER,LIMITS,DEPTH,LAT,LONG)
22    
23    
24     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25     % PRE-PROCESS and ERROR CHECK %
26     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 gmaze 1.3 pv_checkpath
28 gmaze 1.1
29     % Check number of input:
30     if nargin ~= 5
31     help volbet2iso.m
32     error('volbet2iso.m : Wrong number of parameters')
33     return
34     end %if
35    
36     % Check dimensions:
37     n = size(TRACER);
38     if length(n)==3
39     [nz ny nx] = size(TRACER);
40     if nz~=length(DEPTH) | ny~=length(LAT) | nx~=length(LONG)
41     help volbet2iso.m
42     error('volbet2iso.m : Axis must have same dimensions than TRACER field');
43     return
44     end %if
45     else
46     help volbet2iso.m
47     error('volbet2iso.m : TRACER must be a 3D field')
48     return
49     end %if
50    
51     % Ensure that axis are of dim: (1,N) and well sorted (increasing values):
52     a=size(DEPTH);
53     if a(1) ~= 1, DEPTH=DEPTH'; end
54     S = sort(DEPTH);
55     if S ~= DEPTH
56     help volbet2iso.m
57     error('volbet2iso.m : DEPTH must be increasing values')
58     return
59     end %if
60     a=size(LAT);
61     if a(1) ~= 1, LAT=LAT'; end
62     S = sort(LAT);
63     if S ~= LAT
64     help volbet2iso.m
65     error('volbet2iso.m : LAT must be increasing values')
66     return
67     end %if
68     a=size(LONG);
69     if a(1) ~= 1, LONG=LONG'; end
70     S = sort(LONG);
71     if S ~= LONG
72     help volbet2iso.m
73     error('volbet2iso.m : LONG must be increasing values')
74     return
75     end %if
76    
77     % LIMITS definition:
78     if length(LIMITS) ~=7
79     help volbet2iso.m
80     error('volbet2iso.m : LIMITS must contains 7 values')
81     return
82     end %if
83     OUTCROPS = sort( LIMITS(1:2) );
84     H_MAX = LIMITS(3);
85     LAT_MAX = sort( LIMITS(4:5) );
86     LONG_MAX = sort( LIMITS(6:7) );
87    
88    
89    
90     %%%%%%%%%%%%%%%%%%
91     % COMPUTE VOLUME %
92     %%%%%%%%%%%%%%%%%%
93     % It's computed as the difference between the northern outcrop volume
94     % and the southern outcrop one.
95     [V1 V1mat dV1] = subfct_getvol(TRACER,DEPTH,LAT,LONG,[OUTCROPS(1) H_MAX LAT_MAX LONG_MAX]);
96     [V2 V2mat dV2] = subfct_getvol(TRACER,DEPTH,LAT,LONG,[OUTCROPS(2) H_MAX LAT_MAX LONG_MAX]);
97    
98    
99     % Then:
100     V = max(V1,V2)-min(V1,V2);
101    
102    
103 gmaze 1.3 % Last we determine the iso-0 volume limits:
104     V1mat = abs(V1mat - 1);
105     Vmat = (V1mat + V2mat)./2;
106     Vmat(find(Vmat<1)) = 0;
107     Vmat = logical(Vmat);
108    
109    
110 gmaze 1.1
111     %%%%%%%%%%%
112     % OUTPUTS %
113     %%%%%%%%%%%
114     switch nargout
115 gmaze 1.3 case {0,1}
116 gmaze 1.1 varargout(1) = {V};
117     case 2
118     varargout(1) = {V};
119 gmaze 1.3 varargout(2) = {Vmat};
120 gmaze 1.1 case 3
121     varargout(1) = {V};
122 gmaze 1.3 varargout(2) = {Vmat};
123 gmaze 1.1 varargout(3) = {dV1};
124     end %switch nargout
125    
126    
127    

  ViewVC Help
Powered by ViewVC 1.1.22