Skip to content

senclimate/xspharm

Repository files navigation

xspharm: Xarray Interface for Spherical Harmonic Transform

PyPI Version Documentation Status

Overview

xspharm is an xarray-compatible library that facilitates spherical harmonic transforms. It leverages the computational efficiency of pyspharm and the convenience of xarray data structures to provide an intuitive interface for processing geospatial data on a spherical domain.

Quick Start

To install xspharm, run this command in your terminal:

$ pip install xspharm

This is the preferred method to install xspharm, as it will always install the most recent stable release.

from xspharm import xspharm
xsp = xspharm(grid_ds, grid_type='regular')

# convert u anv v to streamfunction and velocity potential
sfvp_ds = xsp.uv2sfvp(u_ds, v_ds, ntrunc=24)

# tri_truncate the fields (can be xarray DataArray or Dataset in same spatial coordinates with grid_ds)
trunc_ds = xsp.truncate(field_ds, ntrunc=42)

Documentation

xspharm provides a suite of methods to manipulate and transform geospatial datasets:

  • truncate: Reduces the resolution of a data variable or an entire dataset to a specified spherical harmonic wavenumber.
  • exp_taper: Applies tapering to mitigate the Gibbs phenomenon in spherical harmonic coefficients.
  • uv2sfvp: Transforms zonal (u) and meridional (v) wind components into streamfunction (sf) and velocity potential (vp).
  • uv2vordiv: Converts zonal (u) and meridional (v) wind components to vorticity and divergence fields.
  • uv2absvor: Changes zonal (u) and meridional (v) wind components to absolute vorticity.
  • sf2uv: Derives rotational wind components from a given streamfunction.
  • vp2uv: Obtains divergent wind components from velocity potential.
  • sfvp2uv: Integrates streamfunction and velocity potential to produce zonal (u) and meridional (v) wind components.

Acknowledgments

Special thanks to Jeff Whitaker for sharing the pyspharm library, which forms the foundation of this package's capabilities; and to Andrew Dawson for inspiring with the windspharm library.

License

Distributed under the BSD License.