% % S = surfbet2outcrops(TRACER,LIMITS,LAT,LONG) % % This function computes the horizontal surface between two outcrops, % given fixed limits eastward, westward and southward. % % TRACER = TRACER(LAT,LONG) : surface tracer variable in 2D % LIMITS = [OUTCROP1 OUTCROP2 MAX_LAT1 MAX_LAT2 MAX_LONG1 MAX_LONG2] % : limit's values (MAX_LAT2 is used only if % the outcrop's surfaces reach them). % LAT : latitude axis (1D), degrees northward % LONG : longitude axis (1D), degrees east % S : single surface value (m^2) % % 06/14/2006 % gmaze@mit.edu % function varargout = surfbet2outcrops(TRACER,LIMITS,LAT,LONG) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PRE-PROCESS and ERROR CHECK % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% pv_checkpath % Check number of input: if nargin ~= 4 help surfbet2outcrops.m error('surfbet2outcrops.m : Wrong number of parameters') return end %if % Check dimensions: n = size(TRACER); if length(n)==2 [ny nx] = size(TRACER); if ny~=length(LAT) | nx~=length(LONG) help surfbet2outcrops.m error('surfbet2outcrops.m : Axis must have same dimensions than TRACER field'); return end %if else help surfbet2outcrops.m error('surfbet2outcrops.m : TRACER must be a 2D field') return end %if % Ensure that axis are of dim: (1,N) and well sorted (increasing values): a=size(LAT); if a(1) ~= 1, LAT=LAT'; end S = sort(LAT); if S ~= LAT help surfbet2outcrops.m error('surfbet2outcrops.m : LAT must be increasing values') return end %if a=size(LONG); if a(1) ~= 1, LONG=LONG'; end S = sort(LONG); if S ~= LONG help surfbet2outcrops.m error('surfbet2outcrops.m : LONG must be increasing values') return end %if % LIMITS definition: if length(LIMITS) ~= 6 help surfbet2outcrops.m error('surfbet2outcrops.m : LIMITS must contains 6 values') return end %if OUTCROPS = sort( LIMITS(1:2) ); LAT_MAX = sort( LIMITS(3:4) ); LONG_MAX = sort( LIMITS(5:6) ); %%%%%%%%%%%%%%%%%%% % COMPUTE SURFACE % %%%%%%%%%%%%%%%%%%% % It's computed as the difference between the northern outcrop surface % and the southern outcrop one. [S1 S1mat dS1] = subfct_getsurf(TRACER,LAT,LONG,[OUTCROPS(1) LAT_MAX LONG_MAX]); [S2 S2mat dS2] = subfct_getsurf(TRACER,LAT,LONG,[OUTCROPS(2) LAT_MAX LONG_MAX]); % Then: S = max(S1,S2)-min(S1,S2); % Last we determine the outcrop surface limits: S1mat = abs(S1mat - 1); Smat = (S1mat + S2mat)./2; Smat(find(Smat<1)) = 0; Smat = logical(Smat); %%%%%%%%%%% % OUTPUTS % %%%%%%%%%%% switch nargout case {0 , 1} varargout(1) = {S}; case 2 varargout(1) = {S}; varargout(2) = {Smat}; case 3 varargout(1) = {S}; varargout(2) = {Smat}; varargout(3) = {dS1}; end %switch nargout