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