Due to a shift in policy, from 0900 GMT on Wednesday 14th July 2021, we will be disabling ssh access to the server for external users. External users who wish to continue to access code repositories on the server will need to switch to using https. This can be accomplished in the following way: 1) On the repo on gitlab, use the clone dialogue and select ‘Clone with HTTPS’ to get the address of the repo; 2) From within the checkout of your repo run: $ git remote set-url origin HTTPS_ADDRESS. Here, replace HTTPS_ADDRESS with the address you have just copied from GitLab. Pulls and pushes will now require you to enter a username and password rather than using a ssh key. If you would prefer not to enter a password each time, you might consider caching your login credentials.

Commit 8db8fdb5 authored by Pierre Cazenave's avatar Pierre Cazenave

New function (based on the new code in show_sigma.m) to extract sigma levels...

New function (based on the new code in show_sigma.m) to extract sigma levels for every node in a mesh structure
parent cd407895
function Mobj = read_sigma(Mobj, sigmafile)
% Read an FVCOM sigma layers file and output z values into Mobj.sigmaz.
% Mobj = read_sigma(Mobj, sigmafile)
% Read a sigma file and calculate the sigma layer depths
% Mobj: Mesh object which must contain Mobj.h (depths).
% sigmafile : Full path to an FVCOM sigma.dat file.
% Mobj: Mesh object with a new field (sigmaz) which contains the
% depths of the sigma layers at each grid node.
% read_sigma(Mobj, 'sigma.dat')
% Author(s):
% Pierre Cazenave (Plymouth Marine Laboratory)
% Revision history
% 2013-01-08 Based on the code in show_sigma.m but instead of calculating
% sigma layers along a user-defined line, the depths are calculated for
% each node in the unstructured grid.
subname = 'read_sigma';
global ftbverbose;
if ftbverbose
fprintf(['begin : ' subname '\n'])
fid = fopen(sigmafile,'r');
if(fid < 0)
error(['file: ' sigmafile ' does not exist']);
while ~feof(fid)
line = fgetl(fid);
if isempty(line) || strncmp(line, '!', 1) || ~ischar(line)
key = lower(line(1:3));
C = strtrim(regexpi(line, '=', 'split'));
switch key
case 'num'
nlev = str2double(C{2});
case 'sig'
sigtype = C{2};
case 'du '
du = str2double(C{2});
case 'dl '
dl = str2double(C{2});
case 'min'
min_constant_depth = str2double(C{2});
case 'ku '
ku = str2double(C{2});
case 'kl '
kl = str2double(C{2});
case 'zku'
s = str2double(regexp(C{2}, ' ', 'split'));
zku = zeros(ku, 1);
for i = 1:ku
zku(i) = s(i);
case 'zkl'
s = str2double(regexp(C{2}, ' ', 'split'));
zkl = zeros(kl, 1);
for i = 1:kl
zkl(i) = s(i);
if ftbverbose
fprintf('nlev %d\n',nlev)
fprintf('sigtype %s\n',sigtype)
fprintf('du %d\n',du)
fprintf('dl %d\n',dl)
fprintf('min_constant_depth %f\n',min_constant_depth)
fprintf('ku %d\n',ku)
fprintf('kl %d\n',kl)
fprintf('zku %d\n',zku)
fprintf('zkl %d\n',zkl)
% calculate the sigma distributions at each grid node
switch lower(sigtype)
case 'generalized'
z = sigma_gen(nlev, dl, du, kl, ku, zkl, zku, ...
Mobj.z(i), min_constant_depth);
case 'uniform'
z = 0:-1/double(nlev-1):-1;
error('Can''t do that sigtype')
Mobj.sigmaz = repmat(Mobj.h, 1, nlev) .* repmat(z, Mobj.nVerts, 1);
if ftbverbose;
fprintf(['end : ' subname '\n'])
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment