1 |
gforget |
1.1 |
function [z]=depthStretch(d,varargin) |
2 |
|
|
%object: compute stretched depth coordinate |
3 |
|
|
%inputs: d is the depth vector (>=0) |
4 |
|
|
%optional: depthStretchLim are the stretching depth limits ([0 500 6000] by default) |
5 |
|
|
% |
6 |
|
|
%this routine maps |
7 |
|
|
%[depthStretchLim(1) depthStretchLim(2)] to [1 0] |
8 |
|
|
%[depthStretchLim(2) depthStretchLim(3)] to [0 -1] |
9 |
|
|
|
10 |
|
|
if nargin>1; depthStretchLim=varargin{1}; else; depthStretchLim=[0 500 6000]; end; |
11 |
|
|
|
12 |
|
|
zStretchLim=[1 0 -1]; |
13 |
|
|
|
14 |
|
|
%make sure depth is positive |
15 |
|
|
d=abs(d); |
16 |
|
|
|
17 |
|
|
%initialize stretched vertical coordinate |
18 |
|
|
z=zeros(size(d)); |
19 |
|
|
|
20 |
|
|
%values between 0 and depthStretchLim(2) get half the range of z |
21 |
|
|
tmp1=find(d<=depthStretchLim(2)); |
22 |
|
|
tmp2=(depthStretchLim(2)-d(tmp1))./(depthStretchLim(2)-depthStretchLim(1))... |
23 |
|
|
.*(zStretchLim(1)-zStretchLim(2))+zStretchLim(2); |
24 |
|
|
z(tmp1)=tmp2; |
25 |
|
|
|
26 |
|
|
%values between depthStretchLim(2) and depthStretchLim(3) get the other half z range |
27 |
|
|
tmp1=find(d>depthStretchLim(2)); |
28 |
|
|
tmp2=(d(tmp1)-depthStretchLim(2))./(depthStretchLim(3)-depthStretchLim(2))... |
29 |
|
|
.*(zStretchLim(3)-zStretchLim(2))+zStretchLim(2); |
30 |
|
|
z(tmp1)=tmp2; |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|