shxarray.core
shxarray.core.admin
- shxarray.core.admin.defaultcache(subdir=None)
shxarray.core.cf
- class shxarray.core.cf.CoordInfo(min, max, step, var)
Bases:
tuple- max
Alias for field number 1
- min
Alias for field number 0
- step
Alias for field number 2
- var
Alias for field number 3
- shxarray.core.cf.find_coord(coordvars, names)
- shxarray.core.cf.find_lat(coordvars)
- shxarray.core.cf.find_lon(coordvars)
- shxarray.core.cf.get_cfatts(standard_name)
Return CF attributes for certain coordinate types
shxarray.core.logging
- shxarray.core.logging.debugging()
- shxarray.core.logging.setDebugLevel()
Set logging level for both python and c++ to DEBUG severity
- shxarray.core.logging.setErrorLevel()
Set logging level for both python and c++ to WARNING severity
- shxarray.core.logging.setInfoLevel()
Set logging level for both python and c++ to INFO severity
- shxarray.core.logging.setWarningLevel()
Set logging level for both python and c++ to WARNING severity
shxarray.core.sh_indexing
- class shxarray.core.sh_indexing.SHindexBase
Bases:
object- static mi_fromarrays(nm)
Generate a MultiIndex of degree and order from an array of degree and order [[n..],[..m]]
In the case of real spherical harmonic, orders m < 0 denote Sine coefficients
- Parameters:
nm (array-like) – An array which hold a vector of degrees and orders
- Returns:
A MultiIndex with degrees “n” and orders “m”
- Return type:
pandas.MultiIndex
- static mi_fromtuples(nm)
Generate a MultiIndex of degree and order from a list of (degree,order) tuples
In the case of real spherical harmonic, orders m < 0 denote Sine coefficients
- Parameters:
nm (list) – A list of tuples with degree and order
- Returns:
A MultiIndex with degrees “n” and orders “m”
- Return type:
pandas.MultiIndex
- static mi_toggle(mi, ending='')
Rename the levels of a (nm)-multindex so that they can be use as alternative coordinates (e.g. transposed versions)
The levels will be swicthed back and fort between the following formats oldname <-> oldname_[ending]
- Parameters:
mi (pandas.MultiIndex) – A MultiIndex with degree and orders
ending (str, optional) – A string which can be additionally appended
- Returns:
A MultiIndex with renamed levels
- Return type:
pandas.MultiIndex
- name = 'nm'
- name_t = 'nm_'
- static nm(nmax, nmin=0)
Convenience function which returns a dictionary which can be used as input for xarray constructors
- Parameters:
nmax (int) – maximum spherical harmonic degree
nmin (int, optional) – minimum spherical harmonic degree
- Returns:
A dictionary specifying the degree and orders and corresponding dimension names in the form of {dim:(dim,nm)}
- Return type:
dictionary
- static nm_mi(nmax, nmin=0)
Generate a MultiIndex of degree and order which span a spherical harmonic degree range
In the case of real spherical harmonic, orders m < 0 denote Sine coefficients
- Parameters:
nmax (int) – maximum spherical harmonic degree
nmin (int, optional) – minimum spherical harmonic degree
- Returns:
A MultiIndex with degrees “n” and orders “m”
- Return type:
pandas.MultiIndex
- static nsh(nmax, nmin=0, squeeze=True)
Compute the total amount of spherical harmonic coefficients for a given range
- Parameters:
nmax (int) – maximum spherical harmonic degree
nmin (int, optional) – minimum spherical harmonic degree
squeeze (bool,optional) – Legacy option used when Sine coefficients which have m=0 need to be included
- Returns:
The amount of spherical harmonic coefficients in this range
- Return type:
int
shxarray.core.shcomputebase
shxarray.core.shxarbase
- class shxarray.core.shxarbase.ShXrBase(xarray_obj)
Bases:
object- build_nmindex()
- drop_nmindex()
- property gravtype
Returns the registered gravitational type of the content
- property nmax
maximum degree of the spherical harmonic dataset :return: maximum degree :rtype: int
- property nmin
Minimum degree of the spherical harmonic data :return: minimum degree :rtype: int
- truncate(nmax=None, nmin=None, dims=['nm'])
Truncate the maximum and/or minimum degree of the spherical harmonic coordinate and corresponding variables :param nmax: (int) maximum spherical harmonic degree to keep :param nmin: (int) minimum spherical harmonic degree to keep :param dims: list of SH dimensions to truncate over default [‘shi’]. Alternatively specify [’shi_’] or both :return: A new truncated data array :rtype: xarray.DataArray
shxarray.core.time
- shxarray.core.time.decyear2dt(decyear)
Convert a decimal year to a datetime object
- shxarray.core.time.dt2decyear(dt)
Convert a datetime object to a decimal year
shxarray.core.xr_accessor
- class shxarray.core.xr_accessor.SHDaAccessor(xarray_obj)
Bases:
ShXrBase- analysis(nmax=100, method='integrate', engine='shlib')
Apply spherical harmonic analysis from the given ints :param nmax : Spherical harmonic truncation degree of output :param method: Method to use for the analysis :return: A datarray with spherical harmonic coefficients derived from the input dataArray
Depending on the method applied different scenarios can be handled method == ‘integrate’ input is given on an equidistant longitude, latitude grid (but may be different step size in lon and lat direction)
- convolve(kernel)
Execute a convolution of the dataarray with a given kernel/filter: :param kernel: Kernel object (see e.g shxarray.kernels)
- degvar(mean=False)
Compute the degree variances of spherical harmonic data :param mean: Take the average power per degree instead of the sum (divide by 2n+1) :return: A Dataarray with the degree variances
- filter(filtername, **kwargs)
Apply well known filters to Spherical harmonic data :param filtername: currently ‘DDKX’ or ‘Gauss’ :param **kwargs:
transpose (default=False): apply he transpose of the filter (only makes sense for anisotropic filters halfwidth (int): specify the halfwidth in km’s for the Gaussian filter, alternatively specify in the format Gauss300 truncate (bool) (default=True): Truncate low degree coefficients which fall outside the filter. Set to False to keep unfiltered input
- static gaunt(n2, n3, m2, m3, engine='shlib')
- static gauntReal(n2, n3, m2, m3, engine='shlib')
- static ones(nmax, nmin=0, name='cnm', auxcoords={}, order='C')
1-Initialize an spherical harmonic DataArray based on nmax and nmin
- synthesis(lon=None, lat=None, grid=True, engine='shlib')
Apply spherical harmonic synthesis on a set of longitude, latitude points :param lon: Longitude in degrees East :param lat: Latitude in degrees North :param grid: Set to false if lon,lat pairs represent individual points :param engine: Spherical harmonic compute engine to use for the computation :return: A datarray for which the spherical harmonic coefficient dimension is mapped to set of points The following scenarios can be handled:
1: lon, lat are Xarray coordinate variables sharing the same dimension mension. Map to a list of points (SH dimension is mapped to a single dimension) 2: lon, lat are Xarray coordinate variables with different dimensions: Map tot a grid spanned by lon,lat 3 lon, lat are list-like objects with the same length: Map to a grid unless (grid=False) 4. lon,lat are list-like objects of different lengths: Map to a grid
- tws(**kwargs)
- static wigner3j(j2, j3, m2, m3, engine='shlib')
- static zeros(nmax, nmin=0, name='cnm', auxcoords={}, order='C')
0-Initialize an spherical harmonic DataArray based on nmax and nmin
- class shxarray.core.xr_accessor.SHDsAccessor(xarray_obj)
Bases:
ShXrBase- static ones(nmax, nmin=0, squeeze=True, name='cnm', auxcoords={}, order='C')
1-Initialize an spherical harmonic Dataset based on nmax and nmin
- synthesis(lon=None, lat=None, grid=True, engine='shlib')
Calls the spherical harmonic synthesis operation on all DataArrays which have a ‘nm’ index
- static zeros(nmax, nmin=0, squeeze=True, name='cnm', auxcoords={}, order='C')
0-Initialize an spherical harmonic Dataset based on nmax and nmin