easyclimate.core.spharm

Easy climate top interface for the Pyspharm

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_geodesic_points(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_legendre_functions(→ xarray.DataArray)

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

transfer_grid2spectral_transform(→ xarray.DataArray)

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

transfer_spectral_transform2grid(→ xarray.DataArray)

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

Module Contents

easyclimate.core.spharm.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).

easyclimate.core.spharm.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).

easyclimate.core.spharm.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).

easyclimate.core.spharm.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.

easyclimate.core.spharm.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

easyclimate.core.spharm.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