Home > utilities > sigma_gen.m

sigma_gen

PURPOSE ^

Generate a generalised sigma coordinate distribution.

SYNOPSIS ^

function dist = sigma_gen(nlev,dl,du,kl,ku,zkl,zku,h,hmin)

DESCRIPTION ^

 Generate a generalised sigma coordinate distribution.

 Mobj = sigma_gen(nlev, dl, du, kl, ku, zkl, zku, h, hmin)

 DESCRIPTION:
   Generate a uniform or hybrid vertical sigma coordinate system.

 INPUT:
   nlev:       Number of sigma levels (layers + 1)
   dl:         The lower depth boundary from the bottom, down to which the
               coordinates are parallel with uniform thickness.
   du:         The upper depth boundary from the surface, up to which the
               coordinates are parallel with uniform thickness.
   kl:         ?
   ku:         ?
   zkl:        ?
   zku:        ?
   h:          Water depth.
   hmin:       Minimum water depth.

 OUTPUT:
   dist:       Generalised vertical sigma coordinate distribution.

 EXAMPLE USAGE:
   Mobj = sigma_gen(nlev, dl, du, kl, ku, zkl, zku, h, hmin)

 Author(s):
   Geoff Cowles (University of Massachusetts Dartmouth)
   Pierre Cazenave (Plymouth Marine Laboratory)

 Revision history
   2013-04-23 Added help on the function and reformatted the code.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function dist = sigma_gen(nlev,dl,du,kl,ku,zkl,zku,h,hmin)
0002 % Generate a generalised sigma coordinate distribution.
0003 %
0004 % Mobj = sigma_gen(nlev, dl, du, kl, ku, zkl, zku, h, hmin)
0005 %
0006 % DESCRIPTION:
0007 %   Generate a uniform or hybrid vertical sigma coordinate system.
0008 %
0009 % INPUT:
0010 %   nlev:       Number of sigma levels (layers + 1)
0011 %   dl:         The lower depth boundary from the bottom, down to which the
0012 %               coordinates are parallel with uniform thickness.
0013 %   du:         The upper depth boundary from the surface, up to which the
0014 %               coordinates are parallel with uniform thickness.
0015 %   kl:         ?
0016 %   ku:         ?
0017 %   zkl:        ?
0018 %   zku:        ?
0019 %   h:          Water depth.
0020 %   hmin:       Minimum water depth.
0021 %
0022 % OUTPUT:
0023 %   dist:       Generalised vertical sigma coordinate distribution.
0024 %
0025 % EXAMPLE USAGE:
0026 %   Mobj = sigma_gen(nlev, dl, du, kl, ku, zkl, zku, h, hmin)
0027 %
0028 % Author(s):
0029 %   Geoff Cowles (University of Massachusetts Dartmouth)
0030 %   Pierre Cazenave (Plymouth Marine Laboratory)
0031 %
0032 % Revision history
0033 %   2013-04-23 Added help on the function and reformatted the code.
0034 
0035 dist = nan(1, nlev);
0036 
0037 if h < hmin
0038     dist(1) = 0.0;
0039     dl2 = 0.001;
0040     du2 = 0.001;
0041     for k = 1:nlev-1
0042         x1 = dl2+du2;
0043         x1 = x1*double(nlev-1-k)/double(nlev-1);
0044         x1 = x1 - dl2;
0045         x1 = tanh(x1);
0046         x2 = tanh(dl2);
0047         x3 = x2+tanh(du2);
0048         dist(k+1) = (x1+x2)/x3-1.0;
0049     end
0050 else
0051     % I'm (Pierre Cazenave) pretty certain the code below is horribly broke in some fashion. But, I've modified the PyFVCOM version
0052     % of this function to simply return sigma_geo(nlev, 1) in here and that seems to be OK. I should probably do the
0053     % same here, but I can't afford the time to properly test it, so this note will have to do instead.
0054     %dr=(h-sum(zku)-sum(zkl))/h/double(nlev-ku-kl-1);
0055     dr = (h-du-dl)/h/double(nlev-ku-kl-1);
0056     dist(1) = 0.0;
0057 
0058     for k = 2:ku+1
0059         dist(k) = dist(k-1)-zku(k-1)/h;
0060         %     fprintf('building z %f %f %f %f \n',z(k),zku(k-1),h,zku(k-1)/h)
0061     end
0062 
0063     for k = ku+2:nlev-kl
0064         dist(k) = dist(k-1)-dr;
0065         %     fprintf('building z %f %f \n',z(k),dr)
0066     end
0067 
0068     kk = 0;
0069     for k = nlev-kl+1:nlev
0070         kk = kk+1;
0071         dist(k) = dist(k-1)-zkl(kk)/h;
0072         %     fprintf('building z %f %f \n',z(k),zkl(kk))
0073     end
0074 end

Generated on Wed 20-Feb-2019 16:06:01 by m2html © 2005