Class using SHTns (fluidsht.sht2d.with_shtns)

class fluidsht.sht2d.with_shtns.SHT2DWithSHTns(nlat=None, nlon=None, lmax=15, mmax=None, mres=1, norm=None, cs_phase=False, flags=0, polar_opt=1e-08, nl_order=2, radius=1, grid_type='gaussian')[source]

Bases: fluiddyn.calcul.sphericalharmo.EasySHT

Simple possibilities of shtns.

Less possibilities but very simple to use… It has been written specially for atmospheric applications.

Creation of a default instance:

esh = EasySHT(lmax=15)
lmaxnumber {15}

Truncation degree.

mmax{None, int}

If is None, triangular truncation.


Azimutal symmetry coefficient (see shtns documentation).


For SH with quadratic mean equal to unity.

nlat{None, int}

If None, computed by shtns to avoid aliasing.

nlon{None, int}

If None, computed by shtns to avoid aliasing.

flags{sht_quick_init|SHT_PHI_CONTIGUOUS|SHT_SOUTH_POLE_FIRST, int}

Option flag for shtns.

polar_opt{1.0e-8, float}

Polar optimization threshold.

nl_order{2, int}

Nonlinear order of the equations (used to compute nlat and nlon).

radius{radius_earth, number}

Radius of the sphere (in meters)


In contrast as with shtns, with easypysht the meridional unit vector points towards the North if shtns.SHT_SOUTH_POLE_FIRST is used (this is the default) and it points towards the South if shtns.SHT_SOUTH_POLE_FIRST is not given in flags (thus there is a change of sign in the meridional velocity).

easypysht has been written for atmospheric applications thus some usual notations are used.

Here are some definitions useful to understand the code:

  • l denotes the degree of the spherical harmonic functions

  • m denotes the order of the spherical harmonic functions

  • SH denotes spherical harmonic (spectral array)

  • spat denotes spatial array

  • lat denotes latitude

  • lon denotes longitude

  • kh denotes horizontal wavenumber

  • u denotes longitudinal velocity

  • v denotes meridional velocity (the sign depends on the used base)

  • hdiv denotes horizontal divergence

  • hrot denotes vertical vorticity (curl on the sphere)

  • grad denotes the horizontal gradient

Variables and functions about spectral space array: lmax, mmax, mres, nlm, idx_lm(), l_idx, m_idx, l2_idx

Variables about grid and real space array: nlat, nlon, lats, lons, sin_lats, LATS, LONS

Variables for spectra: l2_l, kh_l

self.sh is the instance of the class sht defined in shtns.py. All functions and variables of this class can be used directly from this instance, for example:

esh.sh.sh_to_point(f_lm, cost, phi)

where t is the colatitude and phi is the longitude.

  • grid_type : str, {“gaussian”, “regular”}

  • cs_phase : bool, optional, default = False

    Default = do not apply the Condon-Shortley phase factor to the associated Legendre functions;

vec_from_vsh(self, uD_lm, uR_lm, u=None, v=None)[source]

Compute velocities u, v from vector spherical harmonics uD, uR (u and v are overwritten).

vsh_from_vec(self, u, v, uD_lm=None, uR_lm=None)[source]

Compute vector spherical harmonics uD_lm, uR_lm from from velocities u, v (uD_lm and uR_lm are overwritten).

gradf_from_fsh(self, f_lm, gradf_lon=None, gradf_lat=None)[source]

Compute the gradient of a function f from its spherical harmonic coeff f_lm (gradf_lon and gradf_lat are overwritten)

create_array_sh_random(self, dtype=<class 'complex'>)


SHT2DWithSHTns([nlat, nlon, lmax, mmax, …])

Simple possibilities of shtns.


alias of fluidsht.sht2d.with_shtns.SHT2DWithSHTns