WavePackage#
- class fridom.nonhydro.initial_conditions.wave_package.WavePackage(mset: ModelSettings, mask_pos: tuple[float | None], mask_width: tuple[float | None], k: tuple[int], s: int = 1, phase: float = 0)[source]#
Bases:
StateWave package initial condition.
Description#
Creates a polarized single wave (
nh.initial_conditions.SingleWave) and applies a mask to it. The mask is a Gaussian function centered at mask_pos with a width of mask_width:\[M(\boldsymbol x) = \prod_{i=1}^{3} \exp\left(-\frac{(x_i - p_i)^2}{w_i^2}\right)\]where \(p_i\) is the position and \(w_i\) is the width of the mask in the \(i\)-th direction. The final wave package is given by:
\[z = \mathbf{P}_s \cdot \left( S(\boldsymbol{x}) M(\boldsymbol{x}) \right)\]where \(S(\boldsymbol{x})\) is the single wave and \(\\mathbf{P}_s\) is the projection operator onto the mode s.
Parameters#
- msetModelSettings
The model settings.
- mask_postuple[float | None]
The position of the mask in the x, y, and z directions. If None, the mask is not applied in that direction.
- mask_widthtuple[float | None]
The width of the mask in the x, y, and z directions. If None, the mask is not applied in that direction.
- kxint
The wavenumber in the x-direction.
- kyint
The wavenumber in the y-direction.
- kzint
The wavenumber in the z-direction.
- sint
The mode (0, 1, -1) 0 => geostrophic mode 1 => positive inertia-gravity mode -1 => negative inertia-gravity mode
- phasereal
The phase of the wave. (Default: 0)
Attributes#
- omegacomplex
The frequency of the wave (only for inertia-gravity modes).
- periodfloat
The period of the wave (only for inertia-gravity modes).
- __init__(mset: ModelSettings, mask_pos: tuple[float | None], mask_width: tuple[float | None], k: tuple[int], s: int = 1, phase: float = 0) None[source]#
Methods
__init__(mset, mask_pos, mask_width, k[, s, ...])dot(other)Calculate the dot product of the state with another state.
fft([padding])Calculate the Fourier transform of the state.
from_netcdf(mset, path)Read the state from a NetCDF file.
has_nan()Check if the state contains NaN values.
ifft([padding])Calculate the inverse Fourier transform of the state.
norm_l2()Calculate the L2 norm of the state.
norm_of_diff(other)The norm of the difference between two states.
project(p_vec, q_vec)Project the state on a (spectral) vector.
sync()Synchronize the state.
to_netcdf(path)Write the state to a NetCDF file.
Attributes
arr_dictReturn the dictionary of arrays (not FieldVariables).
bBuoyancy
cflThe CFL number.
ekinThe kinetic energy
epotThe potential energy
etotThe total energy
field_listReturn the list of fields.
gridReturn the grid of the model.
linear_pot_vortLinearized potential vorticity
local_RoLocal Rossby number
pot_vortScaled potential vorticity field.
rel_vortThe relative vorticity
rel_vort_xX-component of the relative vorticity
rel_vort_yY-component of the relative vorticity
rel_vort_zZ-component of the relative vorticity (Horizontal Vorticity)
uVelocity in the x-direction.
vVelocity in the y-direction.
wVelocity in the z-direction.
xrState as xarray dataset
xrsState of sliced domain as xarray dataset
Examples using
fridom.nonhydro.initial_conditions.WavePackage#