easyclimate.core.spec

Submodules

Functions

calc_gaussian_latitudes(nlat)

Calculate the gaussian latitudes (in degrees) and quadrature weights.

calc_gaussian_latitudes_rs(nlat)

Calculate the gaussian latitudes (in degrees) and quadrature weights by Rust backend.

calc_geodesic_points(m)

Calculate the lat/lon values of the points on the surface of the sphere

calc_geodesic_points_rs(m)

Calculate the lat/lon values of the points on the surface of the sphere

calc_spherical_harmonic_coefficients(ntrunc)

Calculate indices of zonal wavenumber (indxm) and degree (indxn) for complex spherical harmonic coefficients.

calc_spherical_harmonic_coefficients_rs(ntrunc)

Calculate indices of zonal wavenumber (indxm) and degree (indxn) for complex spherical harmonic coefficients by Rust backend.

calc_legendre_functions(→ xarray.DataArray)

Calculate associated legendre functions for triangular truncation T(ntrunc), at a given latitude.

calc_legendre_functions_rs(→ xarray.DataArray)

Calculate associated legendre functions for triangular truncation T(ntrunc), at a given latitude by Rust backend.

transfer_grid2spectral_transform(→ xarray.DataArray)

Transform grid data to spectral representation (spherical harmonic analysis).

transfer_grid2spectral_transform_rs(→ xarray.DataArray)

Transform grid data to spectral representation (spherical harmonic analysis) by Rust backend.

transfer_spectral_transform2grid(→ xarray.DataArray)

Transform spectral data back to grid space representation (spherical harmonic synthesis)

transfer_spectral_transform2grid_rs(→ xarray.DataArray)

Transform spectral data back to grid space representation (spherical harmonic synthesis) by Rust backend.

calc_wind_speed(→ xarray.DataArray)

Calculate the wind speed (magnitude of vector wind).

calc_wind_speed_rs(→ xarray.DataArray)

Calculate the wind speed (magnitude of vector wind) by Rust backend.

calc_relative_vorticity_and_horizontal_divergence(...)

Calculate relative vorticity and horizontal divergence.

calc_relative_vorticity_and_horizontal_divergence_rs(...)

Calculate relative vorticity and horizontal divergence by Rust backend.

calc_relative_vorticity(→ xarray.DataArray)

Calculate relative vorticity.

calc_relative_vorticity_rs(→ xarray.DataArray)

Calculate relative vorticity by Rust backend.

calc_divergence(→ xarray.DataArray)

Calculate horizontal divergence.

calc_divergence_rs(→ xarray.DataArray)

Calculate horizontal divergence by Rust backend.

calc_planetary_vorticity(→ xarray.DataArray)

Calculate planetary vorticity (Coriolis parameter).

calc_planetary_vorticity_rs(→ xarray.DataArray)

Calculate planetary vorticity (Coriolis parameter) by Rust backend.

calc_absolute_vorticity(→ xarray.DataArray)

Calculate absolute vorticity (sum of relative and planetary vorticity).

calc_absolute_vorticity_rs(→ xarray.DataArray)

Calculate absolute vorticity (sum of relative and planetary vorticity) by Rust backend.

calc_streamfunction_and_velocity_potential(...)

Calculate stream function and velocity potential.

calc_streamfunction_and_velocity_potential_rs(...)

Calculate stream function and velocity potential by Rust backend.

calc_streamfunction(→ xarray.DataArray)

Calculate stream function.

calc_streamfunction_rs(→ xarray.DataArray)

Calculate stream function by Rust backend.

calc_velocity_potential(→ xarray.DataArray)

Calculate velocity potential.

calc_velocity_potential_rs(→ xarray.DataArray)

Calculate velocity potential by Rust backend.

calc_helmholtz(→ xarray.Dataset)

Calculate irrotational and non-divergent components of the vector wind.

calc_helmholtz_rs(→ xarray.Dataset)

Calculate irrotational and non-divergent components of the vector wind by Rust backend.

calc_irrotational_component(→ xarray.Dataset)

Calculate irrotational (divergent) component of the vector wind.

calc_irrotational_component_rs(→ xarray.Dataset)

Calculate irrotational (divergent) component of the vector wind by Rust backend.

calc_nondivergent_component(→ xarray.Dataset)

Calculate non-divergent (rotational) component of the vector wind.

calc_nondivergent_component_rs(→ xarray.Dataset)

Calculate non-divergent (rotational) component of the vector wind by Rust backend.

calc_rossby_wave_source(→ xarray.DataArray)

Calculate Rossby wave sources (RWS).

calc_rossby_wave_source_rs(→ xarray.DataArray)

Calculate Rossby wave sources (RWS) by Rust backend.

calc_gradient(→ xarray.Dataset)

Computes the vector gradient of a scalar field on the sphere.

calc_gradient_rs(→ xarray.Dataset)

Computes the vector gradient of a scalar field on the sphere by Rust backend.

spectral_coefficients_to_matrix(→ xarray.DataArray)

Convert packed triangular spectral coefficients to an (m, n) matrix.

spectral_power_by_total_wavenumber(→ xarray.DataArray)

Sum spectral power over zonal wavenumber for each total wavenumber.

plot_spectral_power(spec[, ax, logy, grid])

Plot spectral power as a function of total wavenumber.

plot_spectral_matrix(spec[, value, ax, cmap, add_colorbar])

Plot a packed triangular spectral coefficient field as an m-n matrix.

plot_spectral_real_imag(spec[, figsize, cmap])

Plot real and imaginary parts of packed triangular spectral coefficients.

Package Contents

easyclimate.core.spec.calc_gaussian_latitudes(nlat: int)

Calculate the gaussian latitudes (in degrees) and quadrature weights.

Parameters

nlat: int.

Number of gaussian latitudes desired.

Returns

The gaussian latitudes (in degrees north) and gaussian quadrature weights (xarray.Dataset).

Tools for Spherical Harmonics

Tools for Spherical Harmonics
easyclimate.core.spec.calc_gaussian_latitudes_rs(nlat: int)

Calculate the gaussian latitudes (in degrees) and quadrature weights by Rust backend.

Parameters

nlat: int.

Number of gaussian latitudes desired.

Returns

The gaussian latitudes (in degrees north) and gaussian quadrature weights (xarray.Dataset).

Tools for Spherical Harmonics

Tools for Spherical Harmonics
easyclimate.core.spec.calc_geodesic_points(m: int)

Calculate the lat/lon values of the points on the surface of the sphere corresponding to a twenty-sided (icosahedral) geodesic.

Parameters

m: int.

The number of points on the edge of a single geodesic triangle. There are \(10(m-1)^2+2\) total geodesic points, including the poles.

Returns

The latitudes and longitudes of the geodesic points (in degrees). These points are nearly evenly distributed on the surface of the sphere. (xarray.Dataset).

Tools for Spherical Harmonics

Tools for Spherical Harmonics
easyclimate.core.spec.calc_geodesic_points_rs(m: int)

Calculate the lat/lon values of the points on the surface of the sphere corresponding to a twenty-sided (icosahedral) geodesic by Rust backend.

Parameters

m: int.

The number of points on the edge of a single geodesic triangle. There are \(10(m-1)^2+2\) total geodesic points, including the poles.

Returns

The latitudes and longitudes of the geodesic points (in degrees). These points are nearly evenly distributed on the surface of the sphere. (xarray.Dataset).

Tools for Spherical Harmonics

Tools for Spherical Harmonics
easyclimate.core.spec.calc_spherical_harmonic_coefficients(ntrunc: int)

Calculate indices of zonal wavenumber (indxm) and degree (indxn) for complex spherical harmonic coefficients.

Parameters

ntrunc: int.

The spherical harmonic triangular truncation limit, i.e, truncation wavenumber (e.g., T42).

Returns

The latitudes and longitudes of the geodesic points (in degrees). These points are nearly evenly distributed on the surface of the sphere. (xarray.Dataset).

Tools for Spherical Harmonics

Tools for Spherical Harmonics
easyclimate.core.spec.calc_spherical_harmonic_coefficients_rs(ntrunc: int)

Calculate indices of zonal wavenumber (indxm) and degree (indxn) for complex spherical harmonic coefficients by Rust backend.

Parameters

ntrunc: int.

The spherical harmonic triangular truncation limit, i.e, truncation wavenumber (e.g., T42).

Returns

The latitudes and longitudes of the geodesic points (in degrees). These points are nearly evenly distributed on the surface of the sphere. (xarray.Dataset).

Tools for Spherical Harmonics

Tools for Spherical Harmonics
easyclimate.core.spec.calc_legendre_functions(lat: float, ntrunc: int) xarray.DataArray

Calculate associated legendre functions for triangular truncation T(ntrunc), at a given latitude.

Parameters

lat: float.

The latitude (in degrees) to compute the associate legendre functions.

ntrunc: int.

The spherical harmonic triangular truncation limit, i.e, truncation wavenumber (e.g., T42).

Returns

\((\mathrm{ntrunc} + 1) (\mathrm{ntrunc} + 2) /2\) associated legendre functions at latitude lat.

Tools for Spherical Harmonics

Tools for Spherical Harmonics
easyclimate.core.spec.calc_legendre_functions_rs(lat: float, ntrunc: int) xarray.DataArray

Calculate associated legendre functions for triangular truncation T(ntrunc), at a given latitude by Rust backend.

Parameters

lat: float.

The latitude (in degrees) to compute the associate legendre functions.

ntrunc: int.

The spherical harmonic triangular truncation limit, i.e, truncation wavenumber (e.g., T42).

Returns

\((\mathrm{ntrunc} + 1) (\mathrm{ntrunc} + 2) /2\) associated legendre functions at latitude lat.

Tools for Spherical Harmonics

Tools for Spherical Harmonics
easyclimate.core.spec.transfer_grid2spectral_transform(grid_data: xarray.DataArray, grid_data_type: Literal['regular', 'gaussian'], lon_dim: str = 'lon', lat_dim: str = 'lat', ntrunc: int = None) xarray.DataArray

Transform grid data to spectral representation (spherical harmonic analysis).

Parameters

grid_data: xarray.DataArray.

Input grid data, must contain longitude and latitude dimensions

grid_data_type:

Type of grid (‘regular’ or ‘gaussian’)

lon_dim: str.

Name of longitude dimension, default is 'lon'.

lat_dim: str.

Name of latitude dimension, default is 'lat'.

ntrunc: int.

Spectral truncation wavenumber, defaults to nlat-1.

Returns

xarray.DataArray containing complex spherical harmonic coefficients with triangular spectral dimension

Visualization for Spherical Harmonics

Visualization for Spherical Harmonics
easyclimate.core.spec.transfer_grid2spectral_transform_rs(grid_data: xarray.DataArray, grid_data_type: Literal['regular', 'gaussian'], lon_dim: str = 'lon', lat_dim: str = 'lat', ntrunc: int = None, transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.DataArray

Transform grid data to spectral representation (spherical harmonic analysis) by Rust backend.

Parameters

grid_data: xarray.DataArray.

Input grid data, must contain longitude and latitude dimensions

grid_data_type:

Type of grid (‘regular’ or ‘gaussian’)

lon_dim: str.

Name of longitude dimension, default is 'lon'.

lat_dim: str.

Name of latitude dimension, default is 'lat'.

ntrunc: int.

Spectral truncation wavenumber, defaults to nlat-1.

Returns

xarray.DataArray containing complex spherical harmonic coefficients with triangular spectral dimension

Visualization for Spherical Harmonics

Visualization for Spherical Harmonics
easyclimate.core.spec.transfer_spectral_transform2grid(spec_data: xarray.DataArray, nlon: int, nlat: int, grid_data_type: Literal['regular', 'gaussian'], spec_dim: str = 'spec_dim', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.DataArray

Transform spectral data back to grid space representation (spherical harmonic synthesis)

Parameters

spec_data: xarray.DataArray.

Input spectral coefficient data, must contain the spectral dimension.

nlon: int.

Number of longitude points in output grid.

nlat: int.

Number of latitude points in output grid.

grid_data_type:

Type of output grid ('regular' or 'gaussian').

spec_dim:

Name of spectral dimension, default is 'spec_dim'.

lon_dim: str.

Name for output longitude dimension, default is 'lon'.

lat_dim: str.

Name for output latitude dimension, default is 'lat'.

Returns

xarray.DataArray in grid space representation with (lat, lon) dimensions

Visualization for Spherical Harmonics

Visualization for Spherical Harmonics
easyclimate.core.spec.transfer_spectral_transform2grid_rs(spec_data: xarray.DataArray, nlon: int, nlat: int, grid_data_type: Literal['regular', 'gaussian'], spec_dim: str = 'spec_dim', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.DataArray

Transform spectral data back to grid space representation (spherical harmonic synthesis) by Rust backend.

Parameters

spec_data: xarray.DataArray.

Input spectral coefficient data, must contain the spectral dimension.

nlon: int.

Number of longitude points in output grid.

nlat: int.

Number of latitude points in output grid.

grid_data_type:

Type of output grid ('regular' or 'gaussian').

spec_dim:

Name of spectral dimension, default is 'spec_dim'.

lon_dim: str.

Name for output longitude dimension, default is 'lon'.

lat_dim: str.

Name for output latitude dimension, default is 'lat'.

Returns

xarray.DataArray in grid space representation with (lat, lon) dimensions

Visualization for Spherical Harmonics

Visualization for Spherical Harmonics
easyclimate.core.spec.calc_wind_speed(u_data: xarray.DataArray, v_data: xarray.DataArray, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.DataArray

Calculate the wind speed (magnitude of vector wind).

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

The wind speed (xarray.DataArray).

easyclimate.core.spec.calc_wind_speed_rs(u_data: xarray.DataArray, v_data: xarray.DataArray, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.DataArray

Calculate the wind speed (magnitude of vector wind) by Rust backend.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

The wind speed (xarray.DataArray).

easyclimate.core.spec.calc_relative_vorticity_and_horizontal_divergence(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.Dataset

Calculate relative vorticity and horizontal divergence.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Relative vorticity and horizontal divergence (xarray.Dataset).

Geographic Finite Difference

Geographic Finite Difference

Divergence (Spherical Harmonics)

Divergence (Spherical Harmonics)

Relative Vorticity (Spherical Harmonics)

Relative Vorticity (Spherical Harmonics)
easyclimate.core.spec.calc_relative_vorticity_and_horizontal_divergence_rs(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.Dataset

Calculate relative vorticity and horizontal divergence by Rust backend.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Relative vorticity and horizontal divergence (xarray.Dataset).

Geographic Finite Difference

Geographic Finite Difference

Divergence (Spherical Harmonics)

Divergence (Spherical Harmonics)

Relative Vorticity (Spherical Harmonics)

Relative Vorticity (Spherical Harmonics)
easyclimate.core.spec.calc_relative_vorticity(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.DataArray

Calculate relative vorticity.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Relative vorticity (xarray.DataArray).

Geographic Finite Difference

Geographic Finite Difference

Relative Vorticity (Spherical Harmonics)

Relative Vorticity (Spherical Harmonics)
easyclimate.core.spec.calc_relative_vorticity_rs(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.DataArray

Calculate relative vorticity by Rust backend.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Relative vorticity (xarray.DataArray).

Geographic Finite Difference

Geographic Finite Difference

Relative Vorticity (Spherical Harmonics)

Relative Vorticity (Spherical Harmonics)
easyclimate.core.spec.calc_divergence(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.DataArray

Calculate horizontal divergence.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Horizontal divergence (xarray.DataArray).

Divergence (Spherical Harmonics)

Divergence (Spherical Harmonics)
easyclimate.core.spec.calc_divergence_rs(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.DataArray

Calculate horizontal divergence by Rust backend.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Horizontal divergence (xarray.DataArray).

Divergence (Spherical Harmonics)

Divergence (Spherical Harmonics)
easyclimate.core.spec.calc_planetary_vorticity(u_data: xarray.DataArray, v_data: xarray.DataArray, omega: float = 7.292e-05, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.DataArray

Calculate planetary vorticity (Coriolis parameter).

Parameters

u_data: xarray.DataArray.

The zonal component of the wind.

v_data: xarray.DataArray.

The meridional component of vector wind.

omega: float.

Earth’s angular velocity. The default value if not specified is \(7.292 \times 10^{-5} \mathrm{s^{-1}}\).

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Planetary vorticity (xarray.DataArray).

Planetary Vorticity (Spherical Harmonics)

Planetary Vorticity (Spherical Harmonics)
easyclimate.core.spec.calc_planetary_vorticity_rs(u_data: xarray.DataArray, v_data: xarray.DataArray, omega: float = 7.292e-05, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.DataArray

Calculate planetary vorticity (Coriolis parameter) by Rust backend.

Parameters

u_data: xarray.DataArray.

The zonal component of the wind.

v_data: xarray.DataArray.

The meridional component of vector wind.

omega: float.

Earth’s angular velocity. The default value if not specified is \(7.292 \times 10^{-5} \mathrm{s^{-1}}\).

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Planetary vorticity (xarray.DataArray).

Planetary Vorticity (Spherical Harmonics)

Planetary Vorticity (Spherical Harmonics)
easyclimate.core.spec.calc_absolute_vorticity(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, omega: float = 7.292e-05, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.DataArray

Calculate absolute vorticity (sum of relative and planetary vorticity).

Parameters

u_data: xarray.DataArray.

The zonal component of the wind.

v_data: xarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

omega: float.

Earth’s angular velocity. The default value if not specified is \(7.292 \times 10^{-5} \mathrm{s^{-1}}\).

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Absolute vorticity (xarray.DataArray).

Absolute Vorticity (Spherical Harmonics)

Absolute Vorticity (Spherical Harmonics)
easyclimate.core.spec.calc_absolute_vorticity_rs(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, omega: float = 7.292e-05, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.DataArray

Calculate absolute vorticity (sum of relative and planetary vorticity) by Rust backend.

Parameters

u_data: xarray.DataArray.

The zonal component of the wind.

v_data: xarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

omega: float.

Earth’s angular velocity. The default value if not specified is \(7.292 \times 10^{-5} \mathrm{s^{-1}}\).

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Absolute vorticity (xarray.DataArray).

Absolute Vorticity (Spherical Harmonics)

Absolute Vorticity (Spherical Harmonics)
easyclimate.core.spec.calc_streamfunction_and_velocity_potential(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.Dataset

Calculate stream function and velocity potential.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Stream function and velocity potential (xarray.Dataset).

Streamfunction (Spherical Harmonics)

Streamfunction (Spherical Harmonics)

Velocity Potential (Spherical Harmonics)

Velocity Potential (Spherical Harmonics)
easyclimate.core.spec.calc_streamfunction_and_velocity_potential_rs(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.Dataset

Calculate stream function and velocity potential by Rust backend.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Stream function and velocity potential (xarray.Dataset).

Streamfunction (Spherical Harmonics)

Streamfunction (Spherical Harmonics)

Velocity Potential (Spherical Harmonics)

Velocity Potential (Spherical Harmonics)
easyclimate.core.spec.calc_streamfunction(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.DataArray

Calculate stream function.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

stream function (xarray.DataArray).

Streamfunction (Spherical Harmonics)

Streamfunction (Spherical Harmonics)
easyclimate.core.spec.calc_streamfunction_rs(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.DataArray

Calculate stream function by Rust backend.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

stream function (xarray.DataArray).

Streamfunction (Spherical Harmonics)

Streamfunction (Spherical Harmonics)
easyclimate.core.spec.calc_velocity_potential(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.DataArray

Calculate velocity potential.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Velocity potential (xarray.DataArray).

Velocity Potential (Spherical Harmonics)

Velocity Potential (Spherical Harmonics)
easyclimate.core.spec.calc_velocity_potential_rs(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.DataArray

Calculate velocity potential by Rust backend.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Velocity potential (xarray.DataArray).

Velocity Potential (Spherical Harmonics)

Velocity Potential (Spherical Harmonics)
easyclimate.core.spec.calc_helmholtz(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.Dataset

Calculate irrotational and non-divergent components of the vector wind.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Irrotational and non-divergent components of the vector wind (xarray.Dataset).

Irrotational Component (Spherical Harmonics)

Irrotational Component (Spherical Harmonics)

Nondivergent Component (Spherical Harmonics)

Nondivergent Component (Spherical Harmonics)
easyclimate.core.spec.calc_helmholtz_rs(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.Dataset

Calculate irrotational and non-divergent components of the vector wind by Rust backend.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Irrotational and non-divergent components of the vector wind (xarray.Dataset).

Irrotational Component (Spherical Harmonics)

Irrotational Component (Spherical Harmonics)

Nondivergent Component (Spherical Harmonics)

Nondivergent Component (Spherical Harmonics)
easyclimate.core.spec.calc_irrotational_component(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.Dataset

Calculate irrotational (divergent) component of the vector wind.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Irrotational (divergent) component of the vector wind (xarray.Dataset).

Irrotational Component (Spherical Harmonics)

Irrotational Component (Spherical Harmonics)
easyclimate.core.spec.calc_irrotational_component_rs(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.Dataset

Calculate irrotational (divergent) component of the vector wind by Rust backend.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Irrotational (divergent) component of the vector wind (xarray.Dataset).

Irrotational Component (Spherical Harmonics)

Irrotational Component (Spherical Harmonics)
easyclimate.core.spec.calc_nondivergent_component(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.Dataset

Calculate non-divergent (rotational) component of the vector wind.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Non-divergent (rotational) component of the vector wind (xarray.Dataset).

Nondivergent Component (Spherical Harmonics)

Nondivergent Component (Spherical Harmonics)
easyclimate.core.spec.calc_nondivergent_component_rs(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.Dataset

Calculate non-divergent (rotational) component of the vector wind by Rust backend.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Non-divergent (rotational) component of the vector wind (xarray.Dataset).

Nondivergent Component (Spherical Harmonics)

Nondivergent Component (Spherical Harmonics)
easyclimate.core.spec.calc_rossby_wave_source(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.DataArray

Calculate Rossby wave sources (RWS).

\[RWS=-\nabla \cdot \left({v}_{x}\zeta \right)=-\left(\zeta \nabla \cdot {v}_{x}+{v}_{x}\cdot \nabla \zeta \right)\]

with \(\zeta\) being the absolute vorticity.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Rossby wave sources (xarray.DataArray).

Reference

  • Sardeshmukh, P. D., & Hoskins, B. J. (1988). The Generation of Global Rotational Flow by Steady Idealized Tropical Divergence. Journal of Atmospheric Sciences, 45(7), 1228-1251. https://doi.org/10.1175/1520-0469(1988)045<1228:TGOGRF>2.0.CO;2

  • James IN (1994) Low frequency variability of the circulation. Introduction to Circulating Atmospheres. Cambridge University Press, Cambridge, UK, pp 255–301

  • Trenberth, K. E., Branstator, G. W., Karoly, D., Kumar, A., Lau, N.-C., and Ropelewski, C. (1998), Progress during TOGA in understanding and modeling global teleconnections associated with tropical sea surface temperatures, J. Geophys. Res., 103(C7), 14291–14324, doi: https://doi.org/10.1029/97JC01444.

  • Nie, Y., Zhang, Y., Yang, X.-Q., & Ren, H.-L. (2019). Winter and summer Rossby wave sources in the CMIP5 models. Earth and Space Science, 6, 1831–1846. https://doi.org/10.1029/2019EA000674

  • Fuentes-Franco, R., Koenigk, T., Docquier, D. et al. Exploring the influence of the North Pacific Rossby wave sources on the variability of summer atmospheric circulation and precipitation over the Northern Hemisphere. Clim Dyn 59, 2025–2039 (2022). https://doi.org/10.1007/s00382-022-06194-4

easyclimate.core.spec.calc_rossby_wave_source_rs(u_data: xarray.DataArray, v_data: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.DataArray

Calculate Rossby wave sources (RWS) by Rust backend.

\[RWS=-\nabla \cdot \left({v}_{x}\zeta \right)=-\left(\zeta \nabla \cdot {v}_{x}+{v}_{x}\cdot \nabla \zeta \right)\]

with \(\zeta\) being the absolute vorticity.

Parameters

u_dataxarray.DataArray.

The zonal component of the wind.

v_dataxarray.DataArray.

The meridional component of vector wind.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

Rossby wave sources (xarray.DataArray).

Reference

  • Sardeshmukh, P. D., & Hoskins, B. J. (1988). The Generation of Global Rotational Flow by Steady Idealized Tropical Divergence. Journal of Atmospheric Sciences, 45(7), 1228-1251. https://doi.org/10.1175/1520-0469(1988)045<1228:TGOGRF>2.0.CO;2

  • James IN (1994) Low frequency variability of the circulation. Introduction to Circulating Atmospheres. Cambridge University Press, Cambridge, UK, pp 255–301

  • Trenberth, K. E., Branstator, G. W., Karoly, D., Kumar, A., Lau, N.-C., and Ropelewski, C. (1998), Progress during TOGA in understanding and modeling global teleconnections associated with tropical sea surface temperatures, J. Geophys. Res., 103(C7), 14291–14324, doi: https://doi.org/10.1029/97JC01444.

  • Nie, Y., Zhang, Y., Yang, X.-Q., & Ren, H.-L. (2019). Winter and summer Rossby wave sources in the CMIP5 models. Earth and Space Science, 6, 1831–1846. https://doi.org/10.1029/2019EA000674

  • Fuentes-Franco, R., Koenigk, T., Docquier, D. et al. Exploring the influence of the North Pacific Rossby wave sources on the variability of summer atmospheric circulation and precipitation over the Northern Hemisphere. Clim Dyn 59, 2025–2039 (2022). https://doi.org/10.1007/s00382-022-06194-4

easyclimate.core.spec.calc_gradient(data_input: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat') xarray.Dataset

Computes the vector gradient of a scalar field on the sphere.

Parameters

data_inputxarray.DataArray

The spatio-temporal data to be calculated.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

The zonal and meridional components of the vector gradient respectively (xarray.Dataset).

Geographical Gradient (Spherical Harmonics)

Geographical Gradient (Spherical Harmonics)
easyclimate.core.spec.calc_gradient_rs(data_input: xarray.DataArray, truncation: int = None, R: float = 6371200.0, legfunc: str = 'stored', lon_dim: str = 'lon', lat_dim: str = 'lat', transform_backend: Literal['standard', 'nogil', 'latpar'] = 'latpar') xarray.Dataset

Computes the vector gradient of a scalar field on the sphere by Rust backend.

Parameters

data_inputxarray.DataArray

The spatio-temporal data to be calculated.

truncation: int.

Truncation limit (triangular truncation) for the spherical harmonic computation.

R: float.

The radius in metres of the sphere used in the spherical harmonic computations. Default is 6371200 m, the approximate mean spherical Earth radius.

legfunc: str, ‘stored’ (default) or ‘computed’.

If ‘stored’, associated legendre functions are precomputed and stored when the class instance is created. This uses \(O(\mathrm{nlat}^3)\) memory, but speeds up the spectral transforms. If ‘computed’, associated legendre functions are computed on the fly when transforms are requested. This uses \(O(\mathrm{nlat}^2)\) memory, but slows down the spectral transforms a bit.

lon_dim: str, default: lon.

Longitude coordinate dimension name. By default extracting is applied over the lon dimension.

lat_dim: str, default: lat.

Latitude coordinate dimension name. By default extracting is applied over the lat dimension.

Returns

The zonal and meridional components of the vector gradient respectively (xarray.Dataset).

Geographical Gradient (Spherical Harmonics)

Geographical Gradient (Spherical Harmonics)
easyclimate.core.spec.spectral_coefficients_to_matrix(spec: xarray.DataArray, value: str = 'abs', eps: float = 1e-30, mode: str = 'spec_dim') xarray.DataArray

Convert packed triangular spectral coefficients to an (m, n) matrix.

The input coefficients are assumed to follow triangular spherical-harmonic ordering, where the packed dimension contains all pairs with 0 <= m <= n <= ntrunc. Cells outside the triangular domain (n < m) are filled with NaN in the returned matrix.

Parameters

specxr.DataArray

One-dimensional spectral coefficients. Select non-mode dimensions first, e.g. spec_data.isel(time=0, level=0).

value{“abs”, “logabs”, “power”, “real”, “imag”}

Which quantity to place in the matrix.

epsfloat

Small number used only for logabs.

modestr, default: “spec_dim”

Name of the packed spectral coefficient dimension.

Returns

xr.DataArray

Two-dimensional coefficient matrix with dimensions ("m", "n").

Visualization for Spherical Harmonics

Visualization for Spherical Harmonics
easyclimate.core.spec.spectral_power_by_total_wavenumber(spec: xarray.DataArray, mode: str = 'spec_dim') xarray.DataArray

Sum spectral power over zonal wavenumber for each total wavenumber.

The returned one-dimensional spectrum is \(E(n) = \sum_m |\hat{a}_{n,m}|^2\) for packed triangular spherical-harmonic coefficients.

Parameters

specxr.DataArray

One-dimensional spectral coefficients. Select non-mode dimensions first, e.g. spec_data.isel(time=0, level=0).

modestr, default: “spec_dim”

Name of the packed spectral coefficient dimension.

Returns

xr.DataArray

Spectral power indexed by total wavenumber n.

Visualization for Spherical Harmonics

Visualization for Spherical Harmonics
easyclimate.core.spec.plot_spectral_power(spec: xarray.DataArray, ax=None, logy: bool = True, grid: bool = True, **plot_kwargs)

Plot spectral power as a function of total wavenumber.

This function first sums the packed triangular spectral coefficients over zonal wavenumber m with spectral_power_by_total_wavenumber(), then draws \(E(n) = \sum_m |\hat{a}_{n,m}|^2\) against total wavenumber n.

Parameters

specxr.DataArray

One-dimensional packed triangular spectral coefficients. If the input data has time, level, or other non-spectral dimensions, select one slice before plotting, e.g. spec.isel(time=0).

axmatplotlib.axes.Axes, optional

Axes used for drawing. If None, a new figure and axes are created.

logybool, default: True

If True, draw the spectrum with a logarithmic y-axis by calling matplotlib.axes.Axes.semilogy(). If False, call matplotlib.axes.Axes.plot().

gridbool, default: True

Whether to add a light grid to the axes.

**plot_kwargs

Additional keyword arguments passed to ax.semilogy or ax.plot.

Returns

tuple

(fig, ax), where fig is the Matplotlib figure and ax is the axes containing the spectrum.

Visualization for Spherical Harmonics

Visualization for Spherical Harmonics
easyclimate.core.spec.plot_spectral_matrix(spec: xarray.DataArray, value: str = 'logabs', ax=None, cmap: str = 'viridis', add_colorbar: bool = True, **imshow_kwargs)

Plot a packed triangular spectral coefficient field as an m-n matrix.

The packed spectral dimension is reshaped to a triangular matrix whose rows are zonal wavenumber m and columns are total wavenumber n. Matrix cells with n < m are outside the triangular spectral domain and are shown as NaN.

Parameters

specxr.DataArray

One-dimensional packed triangular spectral coefficients. Select any non-spectral dimensions before plotting.

value{“abs”, “logabs”, “power”, “real”, “imag”}, default: “logabs”

Quantity to visualize:

  • "abs": coefficient magnitude.

  • "logabs": base-10 logarithm of coefficient magnitude.

  • "power": squared coefficient magnitude.

  • "real": real part of the coefficient.

  • "imag": imaginary part of the coefficient.

axmatplotlib.axes.Axes, optional

Axes used for drawing. If None, a new axes is created.

cmapstr, default: “viridis”

Matplotlib colormap used by matplotlib.axes.Axes.imshow().

add_colorbarbool, default: True

Whether to add a colorbar for the plotted matrix.

**imshow_kwargs

Additional keyword arguments passed to ax.imshow. The defaults are origin="lower" and aspect="auto" unless explicitly provided.

Returns

matplotlib.axes.Axes

Axes containing the coefficient matrix image.

Visualization for Spherical Harmonics

Visualization for Spherical Harmonics
easyclimate.core.spec.plot_spectral_real_imag(spec: xarray.DataArray, figsize: tuple[float, float] = (11, 4), cmap: str = 'viridis', **imshow_kwargs)

Plot real and imaginary parts of packed triangular spectral coefficients.

This is a convenience wrapper around plot_spectral_matrix(). It creates a two-panel figure and draws value="real" in the left panel and value="imag" in the right panel.

Parameters

specxr.DataArray

One-dimensional packed triangular spectral coefficients. Select any non-spectral dimensions before plotting.

figsizetuple of float, default: (11, 4)

Matplotlib figure size passed to matplotlib.pyplot.subplots().

cmapstr, default: “viridis”

Matplotlib colormap used for both matrix panels.

**imshow_kwargs

Additional keyword arguments passed to plot_spectral_matrix() and then to ax.imshow for both panels.

Returns

tuple

(fig, ax), where fig is the Matplotlib figure and ax is the two-element array of axes containing the real and imaginary matrices.

Visualization for Spherical Harmonics

Visualization for Spherical Harmonics