1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 |
% Master function: |
%% SUB-FUNCTIONS %% |
3 |
|
%% USED BY: SURFBET2OUTCROPS %% |
4 |
|
%% INTBET2OUTCROPS %% |
5 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
6 |
|
% USE DIRECTLY AT YOUR OWN RISK ! % |
7 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
8 |
|
|
9 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
10 |
|
% Master sub-function: |
11 |
function varargout = subfct_getsurf(CHP,Y,X,LIMITS) |
function varargout = subfct_getsurf(CHP,Y,X,LIMITS) |
12 |
|
|
13 |
% Limits: |
% Limits: |
37 |
% This function computes the surface limited southward by |
% This function computes the surface limited southward by |
38 |
% 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), |
39 |
% eastward by MX(1), westward by MX(2) |
% eastward by MX(1), westward by MX(2) |
40 |
|
% |
41 |
|
% Updates: |
42 |
|
% 20060615: add a default meridional gradient (negative) |
43 |
|
% test on x,y limits |
44 |
|
% |
45 |
function varargout = getsurf(Y,X,O,MY,MX,CHP) |
function varargout = getsurf(Y,X,O,MY,MX,CHP) |
46 |
|
|
47 |
%% Dim: |
%% Dim: |
48 |
ny = length(Y); |
ny = length(Y); |
49 |
nx = length(X); |
nx = length(X); |
50 |
%disp(num2str([ny nx])); |
%disp(num2str([ny nx])); |
51 |
|
|
52 |
%% Indices: |
%% Indices: |
53 |
iymin = min( find( Y>=MY(1) ) ); |
iymin = max( find( Y<MY(1) ) ); if isempty(iymin),iymin=1; end; |
54 |
iymax = min( find( Y>=MY(2) ) ); |
iymax = min( find( Y>MY(2) ) ); if isempty(iymax),iymax=ny;end; |
55 |
ixmin = min( find( X>=MX(1) ) ); |
ixmin = max( find( X<MX(1) ) ); if isempty(ixmin),ixmin=1; end; |
56 |
ixmax = min( find( X>=MX(2) ) ); |
ixmax = min( find( X>MX(2) ) ); if isempty(ixmax),ixmax=nx;end; |
57 |
%disp(num2str([iymin iymax ixmin ixmax])); |
%disp(num2str([iymin iymax ixmin ixmax])); |
58 |
|
|
59 |
%% 1- determine the 2D matrix of surface elements defined by |
%% 1- determine the 2D matrix of surface elements defined by |
74 |
CHPsouth = nanmean(nanmean(squeeze(CHP(iymin:iymin+fix(N/2),ixmin:ixmax)))); |
CHPsouth = nanmean(nanmean(squeeze(CHP(iymin:iymin+fix(N/2),ixmin:ixmax)))); |
75 |
CHPnorth = nanmean(nanmean(squeeze(CHP(iymin+fix(N/2):iymax,ixmin:ixmax)))); |
CHPnorth = nanmean(nanmean(squeeze(CHP(iymin+fix(N/2):iymax,ixmin:ixmax)))); |
76 |
SNgrad = (CHPnorth - CHPsouth)./abs(CHPnorth - CHPsouth); |
SNgrad = (CHPnorth - CHPsouth)./abs(CHPnorth - CHPsouth); |
77 |
|
if isnan(SNgrad), SNgrad=-1; end % Assume negative gradient by default |
78 |
%disp(strcat('Northward gradient sign is:',num2str(SNgrad))); |
%disp(strcat('Northward gradient sign is:',num2str(SNgrad))); |
79 |
switch SNgrad |
switch SNgrad |
80 |
case 1, testype = 'le'; % Less than or equal |
case 1, testype = 'le'; % Less than or equal |