2.5.2.6. data.misc.sigma
– Sigma coordinates¶
Attributes: | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Functions: | |||||||||||||||||
Classes: | |||||||||||||||||
Inheritance diagram: | |||||||||||||||||
-
class
NcSigma
(ncfile, levelvars=None, formula_terms=None)[source]¶ Bases:
object
Abstract class for sigma coordinates interface to Netcdf files
See
NcSigmaStandard
andNcSigmaGeneralized
for more informationAttributes: -
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
-
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: sigma:
None
or one of the following instance:NcSigmaStandard
: Ocean sigma-coordinatesNcSigmaGeneralized
: Ocean s-coordinates
-
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
-
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
-
gridvars
= {'all': ['eta', 'depth', 'oro', 'altitude', 'depthu', 'depthv'], 't': ['eta', 'depth', 'oro', 'altitude'], 'u': ['depthu'], 'v': ['depthv']}¶
-
horiz_terms
= ['depth', 'eta', 'height', 'oro']¶
-
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
(ors
) 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']}
-
-
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']¶
-
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.
-
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']}¶
-
RE_SN2LOC_SEARCH
()¶ 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
-
-
class
SigmaStandard
(sigma, depth, stype='standard')[source]¶ Bases:
object
Standard or ocean sigma coordinates converters
-
sigma
¶ [array] Sigma coordinates
-
depth
¶ [array] Bottom depth
-
-
exception
SigmaWarning
[source]¶ Bases:
exceptions.UserWarning
-
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"
or0
: Standard."atmosphere"
or1
: Ocean standard."generalized"
or2
: 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"
or0
: Standard."ocean"
or1
: Ocean standard."generalized"
or2
: 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.