/[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.2 - (hide annotations) (download)
Thu Jun 15 22:15:55 2006 UTC (19 years, 1 month ago) by gmaze
Branch: MAIN
Changes since 1.1: +1 -1 lines
Add function INTBET2OUTCROPS, update others

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    
28     % Check number of input:
29     if nargin ~= 5
30     help volbet2iso.m
31     error('volbet2iso.m : Wrong number of parameters')
32     return
33     end %if
34    
35     % Check dimensions:
36     n = size(TRACER);
37     if length(n)==3
38     [nz ny nx] = size(TRACER);
39     if nz~=length(DEPTH) | ny~=length(LAT) | nx~=length(LONG)
40     help volbet2iso.m
41     error('volbet2iso.m : Axis must have same dimensions than TRACER field');
42     return
43     end %if
44     else
45     help volbet2iso.m
46     error('volbet2iso.m : TRACER must be a 3D field')
47     return
48     end %if
49    
50     % Ensure that axis are of dim: (1,N) and well sorted (increasing values):
51     a=size(DEPTH);
52     if a(1) ~= 1, DEPTH=DEPTH'; end
53     S = sort(DEPTH);
54     if S ~= DEPTH
55     help volbet2iso.m
56     error('volbet2iso.m : DEPTH must be increasing values')
57     return
58     end %if
59     a=size(LAT);
60     if a(1) ~= 1, LAT=LAT'; end
61     S = sort(LAT);
62     if S ~= LAT
63     help volbet2iso.m
64     error('volbet2iso.m : LAT must be increasing values')
65     return
66     end %if
67     a=size(LONG);
68     if a(1) ~= 1, LONG=LONG'; end
69     S = sort(LONG);
70     if S ~= LONG
71     help volbet2iso.m
72     error('volbet2iso.m : LONG must be increasing values')
73     return
74     end %if
75    
76     % LIMITS definition:
77     if length(LIMITS) ~=7
78     help volbet2iso.m
79     error('volbet2iso.m : LIMITS must contains 7 values')
80     return
81     end %if
82     OUTCROPS = sort( LIMITS(1:2) );
83     H_MAX = LIMITS(3);
84     LAT_MAX = sort( LIMITS(4:5) );
85     LONG_MAX = sort( LIMITS(6:7) );
86    
87    
88    
89     %%%%%%%%%%%%%%%%%%
90     % COMPUTE VOLUME %
91     %%%%%%%%%%%%%%%%%%
92     % It's computed as the difference between the northern outcrop volume
93     % and the southern outcrop one.
94     [V1 V1mat dV1] = subfct_getvol(TRACER,DEPTH,LAT,LONG,[OUTCROPS(1) H_MAX LAT_MAX LONG_MAX]);
95     [V2 V2mat dV2] = subfct_getvol(TRACER,DEPTH,LAT,LONG,[OUTCROPS(2) H_MAX LAT_MAX LONG_MAX]);
96    
97    
98     % Then:
99     V = max(V1,V2)-min(V1,V2);
100    
101    
102    
103     %%%%%%%%%%%
104     % OUTPUTS %
105     %%%%%%%%%%%
106     switch nargout
107     case 1
108     varargout(1) = {V};
109     case 2
110     varargout(1) = {V};
111     varargout(2) = {V1mat};
112     case 3
113     varargout(1) = {V};
114     varargout(2) = {V1mat};
115     varargout(3) = {dV1};
116     end %switch nargout
117    
118    
119    

  ViewVC Help
Powered by ViewVC 1.1.22