% % V = volbet2iso(TRACER,LIMITS,DEPTH,LAT,LONG) % % This function computes the ocean volume between two 2 iso surfaces, % given fixed limits eastward, westward and southward. % % TRACER = TRACER(DEPTH,LAT,LONG) : surface tracer variable in 3D % LIMITS = [OUTCROP1 OUTCROP2 MAX_DEPTH MAX_LAT1 MAX_LAT2 MAX_LONG1 MAX_LONG2] % : limit's values (MAX_DEPTH and MAX_LAT2 are used only if % the iso-outcrop's surfaces reach them). % DEPTH : vertical axis (1D), m downward, positive % LAT : latitude axis (1D), degrees northward % LONG : longitude axis (1D), degrees east % V : single volume value (m^3) % % 06/12/2006 % gmaze@mit.edu % function varargout = volbet2iso(TRACER,LIMITS,DEPTH,LAT,LONG) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PRE-PROCESS and ERROR CHECK % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Check number of input: if nargin ~= 5 help volbet2iso.m error('volbet2iso.m : Wrong number of parameters') return end %if % Check dimensions: n = size(TRACER); if length(n)==3 [nz ny nx] = size(TRACER); if nz~=length(DEPTH) | ny~=length(LAT) | nx~=length(LONG) help volbet2iso.m error('volbet2iso.m : Axis must have same dimensions than TRACER field'); return end %if else help volbet2iso.m error('volbet2iso.m : TRACER must be a 3D field') return end %if % Ensure that axis are of dim: (1,N) and well sorted (increasing values): a=size(DEPTH); if a(1) ~= 1, DEPTH=DEPTH'; end S = sort(DEPTH); if S ~= DEPTH help volbet2iso.m error('volbet2iso.m : DEPTH must be increasing values') return end %if a=size(LAT); if a(1) ~= 1, LAT=LAT'; end S = sort(LAT); if S ~= LAT help volbet2iso.m error('volbet2iso.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 volbet2iso.m error('volbet2iso.m : LONG must be increasing values') return end %if % LIMITS definition: if length(LIMITS) ~=7 help volbet2iso.m error('volbet2iso.m : LIMITS must contains 7 values') return end %if OUTCROPS = sort( LIMITS(1:2) ); H_MAX = LIMITS(3); LAT_MAX = sort( LIMITS(4:5) ); LONG_MAX = sort( LIMITS(6:7) ); %%%%%%%%%%%%%%%%%% % COMPUTE VOLUME % %%%%%%%%%%%%%%%%%% % It's computed as the difference between the northern outcrop volume % and the southern outcrop one. [V1 V1mat dV1] = subfct_getvol(TRACER,DEPTH,LAT,LONG,[OUTCROPS(1) H_MAX LAT_MAX LONG_MAX]); [V2 V2mat dV2] = subfct_getvol(TRACER,DEPTH,LAT,LONG,[OUTCROPS(2) H_MAX LAT_MAX LONG_MAX]); % Then: V = max(V1,V2)-min(V1,V2); %%%%%%%%%%% % OUTPUTS % %%%%%%%%%%% switch nargout case 1 varargout(1) = {V}; case 2 varargout(1) = {V}; varargout(2) = {V1mat}; case 3 varargout(1) = {V}; varargout(2) = {V1mat}; varargout(3) = {dV1}; end %switch nargout