State#
- class fridom.nonhydro.State(mset: ModelSettings, **kwargs: any)[source]#
Bases:
VectorFieldThe state vector class for the nonhydrostatic model.
Description#
The default scalar fields of the state vector are:
u: Velocity in the x-direction.
v: Velocity in the y-direction.
w: Velocity in the z-direction.
b: Buoyancy.
A variety of diagnostic fields can be calculated from the state vector, such as the kinetic energy, potential energy, total energy, relative vorticity, potential vorticity, and the local Rossby number.
- __init__(mset: ModelSettings, **kwargs: any) None[source]#
Methods
__init__(mset, **kwargs)abs()Map the field by taking the absolute value (\(|f|\)).
apply_elementwise(vector_field, op)Apply an operation elementwise to the vector field.
apply_water_mask()Apply a water mask to the field.
conj()Compute the complex conjugate.
cumulative_integral(axis[, direction])Compute the cumulative integral along an axis.
diff(axis[, order])Compute the partial derivative along an axis.
div()Compute the divergence.
dot(other)Compute the dot product with another field.
extend(topo)Extend the field in the specified directions.
fft([padding])Perform a Fast Fourier Transform (FFT) on the field.
from_netcdf(mset, path)Create a field from a NetCDF file.
from_xarray(mset, ds)Create a field from an xarray object.
grad([axes])Compute the gradient.
has_nan()Check if the field contains NaN values.
ifft([padding])Perform an Inverse Fast Fourier Transform (IFFT) on the field.
integrate([axes])Global integral of the Field in specified axes.
laplacian([axes])Compute the Laplacian.
max([axes])Maximum value of the Field over the whole domain.
mean([axes])Global mean of the Field in specified axes.
min([axes])Minimum value of the Field over the whole domain.
norm_l2()Calculate the L2 norm of the field.
norm_of_diff(other)Norm of difference between two vector fields.
project(p_vec, q_vec)Project a Vector Field onto a (spectral) vector.
set_random([seed])Set the field to random values.
sum([axes])Sum of the Field over the whole domain in the specified axes.
sync()Synchronize the field across all MPI ranks and apply boundary conditions.
to_netcdf(path)Save the field to a NetCDF file.
Attributes
Buoyancy.
The CFL number.
The kinetic energy.
The potential energy.
The total energy.
field_listThe list of scalar fields.
fieldsThe dictionary of scalar fields.
gridThe grid object.
infoDictionary with information about the field.
is_constantFlag indicating whether the field is constant.
is_spectralFlag indicating whether the field is in spectral space.
Linearized potential vorticity.
Local Rossby number.
msetThe model settings.
Scaled potential vorticity field.
The relative vorticity.
X-component of the relative vorticity.
Y-component of the relative vorticity.
Z-component of the relative vorticity (horizontal vorticity).
The tracer fields.
Velocity in the x-direction.
Velocity in the y-direction.
vector_dimThe vector dimension.
The velocity vector field.
Velocity in the z-direction.
xrThe xarray representation of the field.
xrsConvert a slice of the field to an xarray object.
Examples using
fridom.nonhydro.State#- property u: ScalarField#
Velocity in the x-direction.
- property v: ScalarField#
Velocity in the y-direction.
- property w: ScalarField#
Velocity in the z-direction.
- property b: ScalarField#
Buoyancy.
- property velocity: VectorField#
The velocity vector field.
- property tracers: VectorField#
The tracer fields.
- property ekin: ScalarField#
The kinetic energy.
\[E_{kin} = \frac{1}{2} (u^2 + v^2 + \delta^2 w^2)\]
- property epot: ScalarField#
The potential energy.
If the background stratification is set, the potential energy is calculated as:
\[E_{pot} = \frac{1}{2} \frac{b^2}{N^2}\]If the background stratification is not set, the potential energy is calculated as:
\[E_{pot} = b z\]where \(z\) is the vertical coordinate.
- property etot: ScalarField#
The total energy.
\[E_{tot} = E_{kin} + E_{pot}\]
- property rel_vort: VectorField#
The relative vorticity.
\[\boldsymbol{\zeta} = \nabla \times \boldsymbol{u}\]
- property rel_vort_x: ScalarField#
X-component of the relative vorticity.
\[\zeta_x = \delta^2 \partial_y w - \partial_z v\]
- property rel_vort_y: ScalarField#
Y-component of the relative vorticity.
\[\zeta_y = \partial_z u - \delta^2 \partial_x w\]
- property rel_vort_z: ScalarField#
Z-component of the relative vorticity (horizontal vorticity).
\[\zeta_z = \partial_x v - \partial_y u\]
- property pot_vort: ScalarField#
Scaled potential vorticity field.
\[Q = \left( f \boldsymbol{k} + Ro\,\boldsymbol{\zeta} \right) \cdot \nabla \left( Ro\,b + N^2 z \right)\]where \(\boldsymbol{k}\) is the vertical unit vector, \(f\) is the Coriolis parameter, \(\boldsymbol{\zeta}\) is the relative vorticity, \(b\) is the buoyancy field, and \(N^2\) is the buoyancy frequency.
- property linear_pot_vort: ScalarField#
Linearized potential vorticity.
\[Q = Ro \left( \frac{f}{N^2} \partial_z b + \zeta_z \right)\]where \(Ro\) is the Rossby number, \(f\) is the Coriolis parameter, \(N^2\) is the buoyancy frequency, \(b\) is the buoyancy field, and \(\zeta_z\) is the vertical component of the relative vorticity.
- property local_rossby_number: ScalarField#
Local Rossby number.
\[Ro_\text{local} = Ro \, \frac{\zeta_z}{f_0}\]where \(Ro\) is the Rossby number, \(\zeta_z\) is the vertical component of the relative vorticity, and \(f_0\) is the Coriolis parameter.
- property cfl: ScalarField#
The CFL number.
\[CFL = \max\left\{ \frac{u}{\Delta x}, \frac{v}{\Delta y}, \frac{w}{\Delta z} \right\} \Delta t\]where \(\Delta t\) is the time step and \(\Delta x\) is the grid spacing.
- Returns:
cfl (ScalarField) : Horizontal CFL number.