WavePackage

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: State

Wave 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, ...])

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

b

Buoyancy.

cfl

The CFL number.

ekin

The kinetic energy.

epot

The potential energy.

etot

The total energy.

field_list

The list of scalar fields.

fields

The dictionary of scalar fields.

grid

The grid object.

info

Dictionary with information about the field.

is_constant

Flag indicating whether the field is constant.

is_spectral

Flag indicating whether the field is in spectral space.

linear_pot_vort

Linearized potential vorticity.

local_rossby_number

Local Rossby number.

mset

The model settings.

pot_vort

Scaled potential vorticity field.

rel_vort

The relative vorticity.

rel_vort_x

X-component of the relative vorticity.

rel_vort_y

Y-component of the relative vorticity.

rel_vort_z

Z-component of the relative vorticity (horizontal vorticity).

tracers

The tracer fields.

u

Velocity in the x-direction.

v

Velocity in the y-direction.

vector_dim

The vector dimension.

velocity

The velocity vector field.

w

Velocity in the z-direction.

xr

The xarray representation of the field.

xrs

Convert a slice of the field to an xarray object.

Examples using fridom.nonhydro.initial_conditions.WavePackage#

Reflecting Wave Package

Reflecting Wave Package