2.5.2.6. data.misc.sigma – Sigma coordinates

Attributes:
Functions:
Classes:
Inheritance diagram:
 
digraph inheritancebf4b2eb3db { rankdir=TB; ratio=compress; size="6.0, 8.0"; "vacumm.data.misc.sigma.NcSigma" [URL="#vacumm.data.misc.sigma.NcSigma",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Abstract class for sigma coordinates interface to Netcdf files"]; "vacumm.data.misc.sigma.NcSigmaGeneralized" [URL="#vacumm.data.misc.sigma.NcSigmaGeneralized",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Ocean s coordinates converter for netcdf files"]; "vacumm.data.misc.sigma.NcSigma" -> "vacumm.data.misc.sigma.NcSigmaGeneralized" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.sigma.NcSigmaStandard" [URL="#vacumm.data.misc.sigma.NcSigmaStandard",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Ocean standard coordinates converter for netcdf files"]; "vacumm.data.misc.sigma.NcSigma" -> "vacumm.data.misc.sigma.NcSigmaStandard" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.sigma.SigmaError" [URL="#vacumm.data.misc.sigma.SigmaError",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top"]; "vacumm.data.misc.sigma.SigmaGeneralized" [URL="#vacumm.data.misc.sigma.SigmaGeneralized",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Ocean generalized (s) coordinates converters"]; "vacumm.data.misc.sigma.SigmaStandard" [URL="#vacumm.data.misc.sigma.SigmaStandard",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Standard or ocean sigma coordinates converters"]; "vacumm.data.misc.sigma.SigmaWarning" [URL="#vacumm.data.misc.sigma.SigmaWarning",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top"]; }
class NcSigma(ncfile, levelvars=None, formula_terms=None)[source]

Bases: object

Abstract class for sigma coordinates interface to Netcdf files

See NcSigmaStandard and NcSigmaGeneralized for more information

Attributes:
f

cdms2 file object.

levelvar

Variable whose standard_name is of type “ocean_XX_coordinate”

formula_terms

Dictionary to find formula variables

standard_names

List of useful standard names

names

Netcdf names of some variables

dzt

Layer thickness at T point

dzu

Layer thickness at U point

dzw

Layer thickness at W point

clean_cache()[source]
close()[source]

Closed opened file

dz_to_depths(selector=None, at='t', copyaxes=True, zerolid=False, lons=None, lats=None, times=None)[source]

Get depths from layer thicknesses

Params:
classmethod factory(f, **kwargs)[source]

Get a sigma instance by scaning the standard name of axes and variables in a netcdf file

Parameters:
  • ncfile: A netcdf file name or descriptor.
  • Other keywords are used to initialize the output instance.
Return:
get_depth(selector=None, lons=None, lats=None, times=None, at='t', mode='error')[source]

Read bottom depth at T, U or V points

get_dz(selector=None, lons=None, lats=None, times=None, at='t')[source]

Load thickness at T or W if availables

Params:
  • selector: Global selector.
  • at: ‘t’ or ‘w’
Return:

The variable if available or None

get_eta(selector=None, lons=None, lats=None, times=None, mode='error')[source]

Scan variables to find eta and read it

get_height(mode='error')[source]

Scan variables to find height and read it

classmethod get_levelvars(f, getcls=False, atlocs=True, levelids=None)[source]

Find de level variables that have a standard name like ocean_XX_coordinate

Params:
  • f: cdms2 file object or netcdf file name.
  • getcls, optional: Get the associated sigma class too.
  • levelids, optional: Restrict search to theses ids.
Return:

Variables as a dictionary whose keys at point positions such as ‘t’, ‘w’. If position is not properly estimated from the standard_name (using standard_name_to_location()), ‘t’ is assumed.

  • if not getcls: {'t': levelt, 'w':levelw, ...}
  • else: {'t': levelt, 'w':levelw, ...}, sigcls
get_oro(selector=None, lons=None, lats=None, times=None, mode='error')[source]

Scan variables to find oro and read it

classmethod get_sigma_class(var)[source]

Return the sigma class as identified in var or None

gridvars = {'all': ['eta', 'depth', 'oro', 'altitude', 'depthu', 'depthv'], 't': ['eta', 'depth', 'oro', 'altitude'], 'u': ['depthu'], 'v': ['depthv']}
has_t()[source]

Check if W sigma coordinates are available

has_w()[source]

Check if W sigma coordinates are available

horiz_terms = ['depth', 'eta', 'height', 'oro']
classmethod is_sigma(*args, **kwargs)[source]
load_formula_terms(formula_terms=None, at=None, mode='noerr')[source]

Read formula terms at T and W points and store them in the dictionary attribute formula_terms whose keys are ‘t’ and ‘w’

load_sigma(selector=None, at=None)[source]

Scan variables to find sigma (or s), and set sigma (or s) attributes

names = {}
sigma_name = None
standard_names = {'altitude': ['atmosphere_layer_altitude', 'atmosphere_layer_altitude_at_t_location', 'atmosphere_layer_altitude_at_u_location', 'atmosphere_layer_altitude_at_v_location', 'atmosphere_layer_altitude_at_w_location'], 'depth': ['model_sea_floor_depth_below_sea_level', 'model_sea_floor_depth_below_geoid', 'sea_floor_depth_below_geoid', 'model_sea_floor_depth_below_sea_level_at_t_location', 'model_sea_floor_depth_below_geoid_at_t_location', 'sea_floor_depth_below_geoid_at_t_location'], 'depthu': [], 'depthv': [], 'dz': ['ocean_layer_thickness', 'ocean_layer_thickness_at_t_location', 'ocean_layer_thickness_at_u_location', 'ocean_layer_thickness_at_v_location', 'ocean_layer_thickness_at_w_location'], 'dzu': ['ocean_layer_thickness_at_u_location'], 'dzv': ['ocean_layer_thickness_at_v_location'], 'dzw': ['ocean_layer_thickness_at_w_location'], 'eta': ['sea_surface_height_above_sea_level', 'sea_surface_height_above_geoid'], 'height': ['maximum_height'], 'oro': ['orography']}
update_file(newncfile, close=False)[source]

Change the netcdf file

class NcSigmaGeneralized(ncfile, levelvars=None, formula_terms=None)[source]

Bases: vacumm.data.misc.sigma.NcSigma

Ocean s coordinates converter for netcdf files

Parameters:
  • ncfile: A netcdf file name or descriptor.
  • levelvar: Variable name of levels.
Attributes:
s

[array] S coordinates

depth

[array] Bottom depth

depth_c

[array] Surface limit depth

a

Surface control parameter

b

Bottom control parameter

csu_standard_name

Standard name of stretching at mid-layer

csw_standard_name

Standard name of stretching at top-layer

csu

Stretching at mid-layer

csw

Stretching at top-layer

get_depth_c(selector=None, lons=None, lats=None, times=None, mode='error')[source]

Scan file for limit depth and read it

horiz_terms = ['depth', 'eta', 'height', 'oro', 'depth_c']
load_controls(at='t', mode='noerr')[source]

Load control parameters a and b

load_stretchings()[source]

Load stretching at mid and top layer and store them in cs dict

sigma_name = 's'
sigma_to_depths(selector=None, lons=None, lats=None, times=None, at='t', mode=None, copyaxes=True, eta=None, zerolid=False, depth=None, depth_c=None)[source]

Get depths for the current state

Params:
  • selector: cdms selector or dict of selection specs.
  • at, optional: Where to compute them (T or Z).
  • mode, optional: Computational mode: “auto”/None, “sigma” or “dz”.
  • eta: Sea surface elevation. A scalar, False, an array or defaults file’s eta.
standard_names = {'altitude': ['atmosphere_layer_altitude', 'atmosphere_layer_altitude_at_t_location', 'atmosphere_layer_altitude_at_u_location', 'atmosphere_layer_altitude_at_v_location', 'atmosphere_layer_altitude_at_w_location'], 'cst': 'ocean_s_coordinate_function_at_midlayer', 'csw': ['ocean_s_coordinate_function_at_toplayer', 'ocean_s_coordinate_function_at_interface'], 'depth': ['model_sea_floor_depth_below_sea_level', 'model_sea_floor_depth_below_geoid', 'sea_floor_depth_below_geoid', 'model_sea_floor_depth_below_sea_level_at_t_location', 'model_sea_floor_depth_below_geoid_at_t_location', 'sea_floor_depth_below_geoid_at_t_location'], 'depthu': [], 'depthv': [], 'dz': ['ocean_layer_thickness', 'ocean_layer_thickness_at_t_location', 'ocean_layer_thickness_at_u_location', 'ocean_layer_thickness_at_v_location', 'ocean_layer_thickness_at_w_location'], 'dzu': ['ocean_layer_thickness_at_u_location'], 'dzv': ['ocean_layer_thickness_at_v_location'], 'dzw': ['ocean_layer_thickness_at_w_location'], 'eta': ['sea_surface_height_above_sea_level', 'sea_surface_height_above_geoid'], 'height': ['maximum_height'], 'oro': ['orography'], 's': ['ocean_s_coordinate', 'ocean_s_coordinate_g1', 'ocean_s_coordinate_g2', 'ocean_s_coordinate_g1_at_t_location'], 'sw': ['ocean_s_coordinate_at_w_location', 'ocean_s_coordinate_g1_at_w_location', 'ocean_s_coordinate_g2_at_w_location']}
class NcSigmaStandard(ncfile, levelvars=None, formula_terms=None)[source]

Bases: vacumm.data.misc.sigma.NcSigma

Ocean standard coordinates converter for netcdf files

Parameters:
  • ncfile: A netcdf file name or descriptor.
  • levelvar, optional: Variable or axis of levels.
Attributes:
sigma

[array] Sigma coordinates

depth

[array] Bottom depth

sigma_name = 'sigma'
sigma_to_altitudes(selector=None, at='t', mode=None, copyaxes=True, oro=None, zerolid=None)[source]

Get depths for the current state

Params:
  • selector: cdms selector or dict of selection specs.
  • at, optional: Where to compute them (T or Z).
  • mode, optional: Computational mode: “auto”/None, “sigma” or “dz”.
  • eta: Sea surface elevation. A scalar, False, an array or defaults file’s eta.
sigma_to_depths(selector=None, lons=None, lats=None, times=None, at='t', mode=None, copyaxes=True, eta=None, zerolid=None, depth=None)[source]

Get depths for the current state

Params:
  • selector: cdms selector or dict of selection specs.
  • at, optional: Where to compute them (T or Z).
  • mode, optional: Computational mode: “auto”/None, “sigma” or “dz”.
  • eta: Sea surface elevation. A scalar, False, an array or defaults file’s eta.
sigma_to_levels(selector=None, at='t', mode=None, copyaxes=True, zerolid=None)[source]
standard_names = {'altitude': ['atmosphere_layer_altitude', 'atmosphere_layer_altitude_at_t_location', 'atmosphere_layer_altitude_at_u_location', 'atmosphere_layer_altitude_at_v_location', 'atmosphere_layer_altitude_at_w_location'], 'depth': ['model_sea_floor_depth_below_sea_level', 'model_sea_floor_depth_below_geoid', 'sea_floor_depth_below_geoid', 'model_sea_floor_depth_below_sea_level_at_t_location', 'model_sea_floor_depth_below_geoid_at_t_location', 'sea_floor_depth_below_geoid_at_t_location'], 'depthu': [], 'depthv': [], 'dz': ['ocean_layer_thickness', 'ocean_layer_thickness_at_t_location', 'ocean_layer_thickness_at_u_location', 'ocean_layer_thickness_at_v_location', 'ocean_layer_thickness_at_w_location'], 'dzu': ['ocean_layer_thickness_at_u_location'], 'dzv': ['ocean_layer_thickness_at_v_location'], 'dzw': ['ocean_layer_thickness_at_w_location'], 'eta': ['sea_surface_height_above_sea_level', 'sea_surface_height_above_geoid'], 'height': ['maximum_height'], 'oro': ['orography'], 'sigma': ['ocean_sigma_coordinate', 'ocean_sigma_coordinate_at_t_location', 'atmosphere_sigma_coordinate', 'atmosphere_sigma_coordinate_at_t_location'], 'sigmaw': ['ocean_sigma_coordinate_at_w_location', 'atmosphere_sigma_coordinate_at_w_location']}

search(string[, pos[, endpos]]) –> match object or None. Scan through string looking for a match, and return a corresponding match object instance. Return None if no position in the string matches.

exception SigmaError[source]

Bases: exceptions.Exception

class SigmaGeneralized(s, depth, depth_c, a, b)[source]

Bases: object

Ocean generalized (s) coordinates converters

s

[array] S coordinates

depth

[array] Bottom depth

depth_c

[array] Surface limit depth

a

Surface control parameter

b
Bottom control parameter
sigma_to_depths(eta=None, selector=None, copyaxes=True, zerolid=False)[source]
class SigmaStandard(sigma, depth, stype='standard')[source]

Bases: object

Standard or ocean sigma coordinates converters

sigma

[array] Sigma coordinates

depth

[array] Bottom depth

sigma_to_depths(eta=None, selector=None, copyaxes=True, zerolid=False)[source]
exception SigmaWarning[source]

Bases: exceptions.UserWarning

as_selector(select=None)[source]

Convert select to a cdms2.selectors.Selector object

sigma2altitudes(sigma, height, oro, stype='standard', cs=None, depth_c=None, a=None, b=None, copyaxes=True, zerolid=False)[source]

Conversion from standard or ocean sigma coordinates to depths

Params:
  • sigma: Sigma levels (abs(sigma)<1) as an 1D array.

  • height: Top altitude.

  • eta: Orography (with a time axis or not).

  • stype, optional: Sigma coordinates type

    • "standard" or 0: Standard.
    • "atmosphere" or 1: Ocean standard.
    • "generalized" or 2: Generalized (s) coordinates.

cval A completer avec sleve coordinates - cs, optional: Stretching function (s coords only).

If not provided, it is computed from stretching parameters.

  • depth_c, optional: Surface limit depth (s coords only).
  • a, optional: Surface control parameter (s coords only).
  • b, optional: Bottom control parameter (s coords only).
  • zerolid, optional: The surface is put at a zero depth to simulate observed depths. This makes the bottom to change with time if the sea level is varying.
sigma2depths(sigma, depth, eta=None, stype='standard', cs=None, depth_c=None, a=None, b=None, copyaxes=True, zerolid=False)[source]

Conversion from standard or ocean sigma coordinates to depths

Params:
  • sigma: Sigma levels (abs(sigma)<1) as an 1D array.

  • depth: Bottom depth.

  • eta, optional: Sea surface elevation (with a time axis or not).

  • stype, optional: Sigma coordinates type

    • "standard" or 0: Standard.
    • "ocean" or 1: Ocean standard.
    • "generalized" or 2: Generalized (s) coordinates.
  • cs, optional: Stretching function (s coords only). If not provided, it is computed from stretching parameters.

  • depth_c, optional: Surface limit depth (s coords only).

  • a, optional: Surface control parameter (s coords only).

  • b, optional: Bottom control parameter (s coords only).

  • zerolid, optional: The surface is put at a zero depth to simulate observed depths. This makes the bottom to change with time if the sea level is varying.

standard_name_to_location(standard_name)[source]