easyclimate.core.spec.tool

Tools for spherical harmonics analysis

This is the top layer of packaging for the Pyspharm package.

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.

Module Contents

easyclimate.core.spec.tool.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.tool.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.tool.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.tool.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.tool.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.tool.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.tool.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.tool.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.tool.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.tool.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.tool.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.tool.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