1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 |
% Master function: |
%% SUB-FUNCTIONS %% |
3 |
|
%% USED BY: VOLBET2ISO %% |
4 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
5 |
|
% USE DIRECTLY AT YOUR OWN RISK ! % |
6 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
7 |
|
|
8 |
|
|
9 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
10 |
|
% Master sub-function: |
11 |
function varargout = subfct_getvol(CHP,Z,Y,X,LIMITS) |
function varargout = subfct_getvol(CHP,Z,Y,X,LIMITS) |
12 |
|
|
13 |
% Limits: |
% Limits: |
39 |
% MY(1), northward by iso-O (or MY(2) if iso-O reaches it), |
% MY(1), northward by iso-O (or MY(2) if iso-O reaches it), |
40 |
% eastward by MX(1), westward by MX(2) and downward by iso-O |
% eastward by MX(1), westward by MX(2) and downward by iso-O |
41 |
% (or MZ if iso-O reaches it). |
% (or MZ if iso-O reaches it). |
42 |
|
% |
43 |
|
% Updates: |
44 |
|
% 20060615: add a default meridional gradient (negative) |
45 |
|
% test on x,y,z limits |
46 |
|
% |
47 |
function varargout = getvol(Z,Y,X,O,MZ,MY,MX,CHP) |
function varargout = getvol(Z,Y,X,O,MZ,MY,MX,CHP) |
48 |
|
|
49 |
%% Dim: |
%% Dim: |
51 |
ny = length(Y); |
ny = length(Y); |
52 |
nx = length(X); |
nx = length(X); |
53 |
%disp(num2str([nz ny nx])); |
%disp(num2str([nz ny nx])); |
54 |
|
|
55 |
%% Indices: |
%% Indices: |
56 |
izmax = min( find( Z>=MZ ) ); |
izmax = min( find( Z>MZ ) ); if isempty(izmax),izmax=nz;end; |
57 |
iymin = min( find( Y>=MY(1) ) ); |
iymin = max( find( Y<MY(1) ) ); if isempty(iymin),iymin=1; end; |
58 |
iymax = min( find( Y>=MY(2) ) ); |
iymax = min( find( Y>MY(2) ) ); if isempty(iymax),iymax=ny;end; |
59 |
ixmin = min( find( X>=MX(1) ) ); |
ixmin = max( find( X<MX(1) ) ); if isempty(ixmin),ixmin=1; end; |
60 |
ixmax = min( find( X>=MX(2) ) ); |
ixmax = min( find( X>MX(2) ) ); if isempty(ixmax),ixmax=nx;end; |
61 |
%disp(num2str([1 izmax iymin iymax ixmin ixmax])); |
%disp(num2str([1 izmax iymin iymax ixmin ixmax])); |
62 |
|
|
63 |
%% 1- determine the 3D matrix of volume elements defined by |
%% 1- determine the 3D matrix of volume elements defined by |
78 |
CHPsouth = nanmean(nanmean(squeeze(CHP(1,iymin:iymin+fix(N/2),ixmin:ixmax)))); |
CHPsouth = nanmean(nanmean(squeeze(CHP(1,iymin:iymin+fix(N/2),ixmin:ixmax)))); |
79 |
CHPnorth = nanmean(nanmean(squeeze(CHP(1,iymin+fix(N/2):iymax,ixmin:ixmax)))); |
CHPnorth = nanmean(nanmean(squeeze(CHP(1,iymin+fix(N/2):iymax,ixmin:ixmax)))); |
80 |
SNgrad = (CHPnorth - CHPsouth)./abs(CHPnorth - CHPsouth); |
SNgrad = (CHPnorth - CHPsouth)./abs(CHPnorth - CHPsouth); |
81 |
|
if isnan(SNgrad), SNgrad=-1; end % Assume negative gradient by default |
82 |
%disp(strcat('Northward gradient sign is:',num2str(SNgrad))); |
%disp(strcat('Northward gradient sign is:',num2str(SNgrad))); |
83 |
switch SNgrad |
switch SNgrad |
84 |
case 1, testype = 'le'; % Less than or equal |
case 1, testype = 'le'; % Less than or equal |