Xspharm class
- class xspharm.xspharm.xspharm(grid_ds, gridtype='regular', rsphere=6371200.0, omega=7.292e-05, legfunc='stored')[source]
Bases:
objectXarray interface to spherical harmonic transforms using pyspharm.
- nlat
Number of latitude points.
- Type:
int
- nlon
Number of longitude points.
- Type:
int
- fvor
planetary vorticity
- Type:
xarray DataArray
- s
Spharmt object for spherical harmonic operations.
- Type:
Spharmt
- uv2sfvp()[source]
Convert zonal and meridional wind components to streamfunction and velocity potential.
- sfvp2uv()[source]
Convert streamfunction and velocity potential to zonal and meridional wind components.
- exp_taper(ds_or_var, ntrunc=None, r=2)[source]
Taper (filter) the spherical harmonic coefficients using the equation provided.
Args: - ds_or_var (xr.DataArray or xr.Dataset): Input data. - ntrunc (int): Truncation wavenumber N. - r (float): User-defined parameter.
Returns: xr.DataArray or xr.Dataset: Tapered data.
- sf2uv(sf_ds, ntrunc=None)[source]
Computes the rotational wind components via spherical harmonics, given an array containing streamfunction
Inputs: sf_ds streamfunction ntrunc: Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns: u, v: zonal and meridional winds
- sfvp2uv(sf_ds, vp_ds, ntrunc=None)[source]
Computes the wind components via spherical harmonics, given streamfunction and velocity potential.
Inputs: sf_ds: streamfunction vp_ds: velocity potential ntrunc: Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns: u, v: zonal and meridional winds
- truncate(ds_or_var, ntrunc=None)[source]
Truncate a data variable or entire dataset.
Args: - ds_or_var (xr.DataArray or xr.Dataset): Input data. - ntrunc (int, optional): Truncation wavenumber. Default is None.
Returns: xr.DataArray or xr.Dataset: Truncated data.
- uv2absvor(u_ds, v_ds, ntrunc=None)[source]
Computes the absolute vorticity via spherical harmonics, given the u and v wind components
Inputs: u, v: zonal and meridional winds ntrunc: Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns: vor: The absolute vorticity
- uv2sfvp(u_ds, v_ds, ntrunc=None)[source]
Streamfunction and velocity potential.
Inputs: u, v: zonal and meridional winds ntrunc: Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns: sf, vp: The streamfunction and velocity potential respectively.
- uv2vordiv(u_ds, v_ds, ntrunc=None)[source]
Computes the vorticity and divergence via spherical harmonics, given the u and v wind components
Inputs: u, v: zonal and meridional winds ntrunc: Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns: vor, div : the vorticity and divergence respectively.
- vp2uv(vp_ds, ntrunc=None)[source]
Computes the divergent wind components via spherical harmonics, given an array containing velocity potential
Inputs: vp_ds velocity potential. ntrunc: Truncation limit (triangular truncation) for the spherical harmonic computation.
Returns: u, v: zonal and meridional winds