/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_misc/depthStretch.m
ViewVC logotype

Contents of /MITgcm_contrib/gael/matlab_class/gcmfaces_misc/depthStretch.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Thu Jun 23 19:02:47 2011 UTC (14 years ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65r, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Error occurred while calculating annotation data.
gcmfaces_misc	added headers to all routines
				added depthStretch.m and depthStretchPlot.m
				> removed myverticaldeform.m, verticalplot.m
				and runmean_cycle.m
				rewritten runmean.m
				> removed nanrunmean.m, nanrunmean_cycle.m and runmean_cycle.m
gcmfaces_legacy	added nanrunmean.m, nanrunmean_cycle.m, runmean_cycle.m
				myverticaldeform.m, verticalplot.m
plot_one_field	added example of depthStretchPlot
basic_diags_display_transport	added header

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

  ViewVC Help
Powered by ViewVC 1.1.22