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