-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_depths.m
More file actions
92 lines (91 loc) · 2.16 KB
/
get_depths.m
File metadata and controls
92 lines (91 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
function [z]=get_depths(fname,gname,tindex,type);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Get the depths of the sigma levels
%
% Further Information:
% http://www.croco-ocean.org
%
% This file is part of CROCOTOOLS
%
% CROCOTOOLS is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published
% by the Free Software Foundation; either version 2 of the License,
% or (at your option) any later version.
%
% CROCOTOOLS is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston,
% MA 02111-1307 USA
%
% Copyright (c) 2002-2006 by Pierrick Penven
% e-mail:Pierrick.Penven@ird.fr
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nc=netcdf(gname);
h=nc{'h'}(:);
close(nc);
%
% open history file
%
nc=netcdf(fname);
zeta=squeeze(nc{'zeta'}(tindex,:,:)); %averaged free surface
hmorph=squeeze(nc{'hmorph'}(tindex,:,:));
if ~isempty(hmorph), h=hmorph; end;
theta_s=nc.theta_s(:);
if (isempty(theta_s))
% disp('Rutgers version')
theta_s=nc{'theta_s'}(:);
theta_b=nc{'theta_b'}(:);
Tcline=nc{'Tcline'}(:);
else
% disp('AGRIF/UCLA version');
theta_b=nc.theta_b(:);
Tcline=nc.Tcline(:);
hc=nc.hc(:);
end
if (isempty(Tcline))
% disp('UCLA version');
hc=nc.hc(:);
else
hmin=min(min(h));
hc=min(hmin,Tcline);
end
N=length(nc('s_rho'));
s_coord=1;
VertCoordType = nc.VertCoordType(:);
if isempty(VertCoordType),
vtrans=nc{'Vtransform'}(:);
if ~isempty(vtrans),
s_coord=vtrans;
end
elseif VertCoordType=='NEW',
s_coord=2;
end;
if s_coord==2,
hc=Tcline;
end
close(nc)
%
%
%
if isempty(zeta)
zeta=0.*h;
end
vtype=type;
if (type=='u')|(type=='v')
vtype='r';
end
z=zlevs(h,zeta,theta_s,theta_b,hc,N,vtype,s_coord);
if type=='u'
z=rho2u_3d(z);
end
if type=='v'
z=rho2v_3d(z);
end
return