pyfvcom2.sigma module

class pyfvcom2.sigma.SigmaConfig(nlev: int, sigtype: str, sigpow: float | None = None, du: float | None = None, dl: float | None = None, min_constant_depth: float | None = None, ku: int | None = None, kl: int | None = None, zku: ndarray | None = None, zkl: ndarray | None = None)[source]

Bases: NamedTuple

Named tuple containing sigma coordinate configuration parameters.

Attributes:

nlev: Number of sigma levels. sigtype: Sigma coordinate type (e.g., ‘uniform’, ‘geometric’, ‘tanh’, ‘generalized’). sigpow: Power value for geometric sigma coordinates. du: Upper depth boundary thickness. dl: Lower depth boundary thickness. min_constant_depth: Minimum water depth for generalized coordinates. ku: Number of levels in upper boundary. kl: Number of levels in lower boundary. zku: Depths of upper boundary layers. zkl: Depths of lower boundary layers.

dl: float | None

Alias for field number 4

du: float | None

Alias for field number 3

kl: int | None

Alias for field number 7

ku: int | None

Alias for field number 6

min_constant_depth: float | None

Alias for field number 5

nlev: int

Alias for field number 0

sigpow: float | None

Alias for field number 2

sigtype: str

Alias for field number 1

zkl: ndarray | None

Alias for field number 9

zku: ndarray | None

Alias for field number 8

class pyfvcom2.sigma.SigmaData(sigma_config: SigmaConfig, sigma_levels: ndarray)[source]

Bases: NamedTuple

Named tuple containing sigma coordinate data.

Attrs:

sigma_config: Sigma configuration parameters. sigma_levels: 2D array of sigma levels at each node.

sigma_config: SigmaConfig

Alias for field number 0

sigma_levels: ndarray

Alias for field number 1

pyfvcom2.sigma.hybrid_sigma_coordinate(levels: int, transition_depth: float, upper_layer_depth: float, lower_layer_depth: float, total_upper_layers: int, total_lower_layers: int, h: ndarray) SigmaData[source]

Create a hybrid vertical coordinate system.

Args:

levels: Number of vertical levels. transition_depth: Transition depth of the hybrid coordinates. upper_layer_depth: Upper water boundary thickness (metres). lower_layer_depth: Lower water boundary thickness (metres). total_upper_layers: Number of layers in the DU water column. total_lower_layers: Number of layers in the DL water column. h: Water depth at nodes.

Returns:
SigmaData: A named tuple containing:
  • sigma_config (SigmaConfig): Configuration for the sigma coordinate system.

  • sigma_levels (np.ndarray): Sigma levels at each node.

pyfvcom2.sigma.process_sigma_config(config: SigmaConfig, h: ndarray) SigmaData[source]

Read in a sigma coordinates file and generate sigma coordinate parameters.

Args:

config: Sigma configuration parameters. h: Bathymetry at nodes.

Returns:
SigmaData: A named tuple containing:
  • sigma_config (SigmaConfig): Sigma configuration as read from file.

  • sigma_levels (np.ndarray): Sigma levels at each node.

pyfvcom2.sigma.read_sigma_file(filepath: str) SigmaConfig[source]

Read in a sigma coordinates file and return parsed configuration.

Args:

filepath: Path to FVCOM sigma coordinates .dat file.

Returns:

Named tuple containing all sigma coordinate parameters.

Notes:

This is more or less a direct python translation of the original MATLAB fvcom-toolbox function read_sigma.m

pyfvcom2.sigma.sigma_generalized(levels: int, dl: float, du: float, h: float, hmin: float, kl: int, ku: int, zku: list = [], zkl: list = []) ndarray[source]

Generate a generalised sigma coordinate distribution.

Args:

levels: Number of sigma levels. dl: The lower depth boundary from the bottom, down to which the layers are uniform thickness. du: The upper depth boundary from the surface, up to which the layers are uniform thickness. h: Water depth (positive down). hmin: Minimum water depth (positive down). kl: Number of levels in lower boundary. ku: Number of levels in upper boundary. zku: Depths of upper boundary layers. Calculated evenly if not given. zkl: Depths of lower boundary layers. Calculated evenly if not given.

Returns:

Generalised vertical sigma coordinate distribution.

pyfvcom2.sigma.sigma_geometric(levels: int, p_sigma: int) ndarray[source]

Generate a geometric sigma coordinate distribution.

Args:

levels: Number of sigma levels. p_sigma: Power value. 1 for uniform sigma layers, 2 for parabolic function.

See page 308-309 in the FVCOM manual for examples.

Returns:

Geometric vertical sigma coordinate distribution.

pyfvcom2.sigma.sigma_tanh(levels: int, dl: float, du: float) ndarray[source]

Generate a hyperbolic tangent vertical sigma coordinate distribution.

Args:

levels: 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.

Returns:

Hyperbolic tangent vertical sigma coordinate distribution.

pyfvcom2.sigma.write_sigma_file(sigma_config: SigmaConfig, sigma_file: str)[source]

Write the sigma distribution to file.

Args:

sigma_config: Sigma configuration to write. sigma_file: Path to which to save sigma data.

Todo:

Add support for writing all the sigma file formats.