pygetm.tracer module

class pygetm.tracer.Tracer(grid: Grid, data: ndarray | None = None, source: Array | None = None, surface_flux: Array | None = None, source_scale: float = 1.0, vertical_velocity: Array | None = None, rivers_follow_target_cell: bool = False, precipitation_follows_target_cell: bool = False, molecular_diffusivity: float = 0.0, **kwargs)[source]

Bases: Array

A tracer transported by advection and diffusion, with optional source term, surface flux and vertical velocity (e.g., sinking, floating)

Parameters:
  • grid – the grid on which the tracer is defined

  • data – a NumPy array that will hold the values of the tracer. If not provided, a new one will be created.

  • source – array with source terms that after multiplication with source_scale must have tracer units per time, multiplied by layer thickness. Defaults to 0.

  • surface_flux – array with surface flux values that after multiplication with source_scale must have tracer units per time, multiplied by layer thickness. Defaults to 0.

  • source_scale – scale factor for source terms and surface flux

  • vertical_velocity – array with vertical velocities (m s-1) describing movement through the water, not water movement itself. Positive for upward movement (e.g. floating), negative for downward movement (e.g. sinking). Defaults to 0 (no movement independent of the water).

  • rivers_follow_target_cell – tracer values in river water are assumed equal to those in the cell into which the river flows. This can be customized further for individual rivers by setting pygetm.rivers.RiverTracer.follow_target_cell and/or calling pygetm.rivers.RiverTracer.set().

  • precipitation_follows_target_cell – tracer values in precipitation are assumed equal to surface values in the cell into which the precipitation falls. If not set, tracer values in precipitation are assumed to be 0. This can be adjusted afterwards with precipitation_follows_target_cell

  • molecular_diffusivity – molecular diffusivity (m2 s-1)

  • **kwargs – keyword arguments to be passed to pygetm.core.Array

molecular_diffusivity: float
open_boundaries: ArrayOpenBoundaries
precipitation_follows_target_cell: bool
river_follow: np.ndarray
river_values: np.ndarray
rivers: Mapping[str, rivers.RiverTracer]
source: core.Array | None
source_scale: float
surface_flux: core.Array | None
vertical_velocity: core.Array | None
class pygetm.tracer.TracerCollection(grid: Grid, logger: Logger, advection_scheme: AdvectionScheme = AdvectionScheme.SUPERBEE, cnpar: float = 1.0)[source]

Bases: Sequence[Tracer]

Collection of all tracers that are subject to advection and diffusion.

add(name: str, **kwargs) Tracer[source]

Add a tracer that will be subject to advection and diffusion.

Parameters:
  • name – short name for the tracer (letters, digits, underscores only)

  • **kwargs – keyword arguments to be passed to Tracer

Returns:

tracer instance

advance(timestep: float, u: Array, v: Array, w: Array, diffusivity: Array)[source]

Advance tracers through advection, diffusion and time integration of optional source terms and/or surface fluxes.

Parameters:
  • timestep – time step (s)

  • u – velocity in x-direction (m s-1)

  • v – velocity in y-direction (m s-1)

  • w – velocity in z-direction (m s-1)

  • diffusivity – vertical turbulent diffusivity (m2 s-1)

This uses operator splitting: advection and horizontal diffusion is done first, vertical diffusion (and sources and surface fluxes, if provided) after.

Velocities u, v, w are expected to be positioned halfway in time between the old and new tracer values (i.e., they should be 1/2 a timestep ahead of the tracers upon entry). diffusivity is expected to be positioned at the same time as the new tracer values, and should thus be 1/2 a timestep ahead of the advection velocities.

start()[source]
class pygetm.tracer.TracerTotal(array, scale_factor, offset, units, long_name, per_mass)[source]

Bases: NamedTuple

Create new instance of TracerTotal(array, scale_factor, offset, units, long_name, per_mass)

array: Array

Alias for field number 0

long_name: str | None

Alias for field number 4

offset: float

Alias for field number 2

per_mass: bool

Alias for field number 5

scale_factor: float

Alias for field number 1

units: str | None

Alias for field number 3