spherical.modes

Source: spherical/modes/__init__.py

Submodule providing the Modes object

Class Modes

Modes(input_array, *args, **kwargs)

Source: spherical/modes/__init__.py

Object to store SWHS modes This class subclasses numpy's ndarray object, so that it should act like a numpy array in many respects, even with functions like np.zeros_like. NOTE: The functions np.copy(modes) and np.array(modes, copy=True) return ndarray objects; they lose information about the SWSH attributes, and have different ufuncs. If you wish to keep this information, use modes.copy(). Also note that pickling works as expected, as do copy.copy and copy.deepcopy. The number of dimensions is arbitrary as long as it is at least 1, but the modes must be stored in the last axis. For example, a SWSH function of time may be stored as a 2-d array where the first axis represents different times, and the second axis represents the mode weights at each instant of time. This class also does three important things that are unlike numpy arrays: 1) It tracks the spin weight and minimum and maximum ell values stored in this data. 2) It provides additional convenience methods, like index to find the index of a particular (ell, m) mode; a grid method to convert modes to the SWSH values on a grid over the sphere (while correctly handling additional dimensions); and the various derivative operators, including ð and ð̄. 3) It overrides most of numpy's "universal functions" (ufuncs) to work appropriately for spin-weighted functions. Specifically, these ufuncs are interpreted as acting on the spin-weighted function itself, rather than just the mode weights. Most importantly, we have these overriden methods: a) Conjugating a Modes object will result in a new Modes object that represents the conjugated spin-weighted function, rather than simply conjugating the mode-weights of the function. b) Multiplying two Modes objects will result in a new Modes object that represents the pointwise product of the functions themselves (and will correctly have spin weight given by the sum of the spin weights of the first two functions), rather than the product of the mode weights. Division is only permitted when the divisor is a constant. c) Addition (and subtraction) is permitted for functions of the same spin weight, but it does not make sense to add (or subtract) functions with different spin weights, so any attempt to do so raises a ValueError. [Note that adding a constant is equivalent to adding a function of spin weight zero, and is treated in the same way.] d) The "absolute" ufunc does not return the absolute value of each mode weight (which is almost certainly meaningless); it returns the L2 norm of spin-weighted function over the sphere -- which happens to equal the sum of the squares of the absolute values of the mode weights. Numerous other ufuncs -- such as log, exp, trigonometric ufuncs, bit-twiddling ufuncs, and so on -- are disabled because they don't make sense when applied to functions. It is possible to treat the underlying data of a Modes object modes as an ordinary numpy array by taking modes.view(np.ndarray). However, it is hoped that this class already performs all reasonable operations. If you find a missing feature that requires you to resort to this, please feel free to open an issue in this project's github page to discuss it. Also, be aware that ndarrays also have various built-in methods that cannot be overridden very easily, such as max, copysign, etc. If you try to use -- even indirectly -- those functions that don't have any clear interpretation for spin-weighted functions, things will likely break.

Attributes

Methods

bar

bar

Source: spherical/modes/algebra.py

Return Modes object corresponding to conjugated function The operations of conjugation and decomposition into mode weights do not commute. That is, the modes of a conjugated function do not equal the conjugated modes of a function. So, rather than simply returning the conjugate of the data from this Modes object, this function returns a Modes object containing the data for the conjugated function. If inplace is True, then the operation is performed in place, modifying this Modes object itself. Note that some copying is still needed, but only for 2 modes at a time, and those copies are freed after this function returns. Here is the derivation: f = sum(f{s, l,m} * {s}Y{l,m} for l, m in LM) conjugate(f) = sum(conjugate(f{s, l,m}) * conjugate({s}Y{l,m})) = sum(conjugate(f{s, l,m}) * (-1)(s+m) * {-s}Y{l,-m}) = sum((-1)(s+m) * conjugate(f{s, l, -m}) * {-s}Y{l,m}) conjugate(f){s', l',m'} = integral( sum((-1)(s+m) * conjugate(f{s,l,-m}) * {-s}Y{l,m}) * {s'}Y{l',m'}, dR # integration over rotation group ) = sum((-1)(s+m) * conjugate(f{s,l,-m}) * delta_{-s, s'} * delta_{l, l'} * delta_{m, m'}) = (-1)(s'+m') * conjugate(f{-s', l', -m'}) The result is this: conjugate(f){s, l, m} = (-1)(s+m) * conjugate(f{-s, l, -m})

ell_max

ell_max

Source: spherical/modes/__init__.py

Largest ell value stored in data

ell_min

ell_min

Source: spherical/modes/__init__.py

Smallest ell value stored in data [need not equal abs(s)]

eth

eth

Source: spherical/modes/derivatives.py

Spin-raising derivative operator defined by Newman and Penrose The operator ð was originally defined in https://dx.doi.org/10.1063/1.1931221, but is more completely defined in https://dx.doi.org/10.1063/1.4962723.

Note

This operator is identical to Rminus. By definition, the spin-raising operator satisfies [S, ð] = ð (where S is the spin operator, which just multiplies the function by its spin). In terms of the SWSHs, we can write the action of eth as ð {s}Y{l,m} = sqrt((l-s)(l+s+1)) {s+1}Y{l,m} Consequently, the modes of a function are affected as {ð f} {s,l,m} = sqrt((l+s)(l-s+1)) f{s-1,l,m}

ethbar

ethbar

Source: spherical/modes/derivatives.py

Spin-lowering conjugate-derivative operator defined by Newman and Penrose The operator ð̄ was originally defined in https://dx.doi.org/10.1063/1.1931221, but is more completely defined in https://dx.doi.org/10.1063/1.4962723.

Note

This operator is identical to Rplus, except with an opposite sign, to follow the conventions laid out by Newman and Penrose. By definition, the spin-lowering operator satisfies [S, ð̄] = -ð̄ (where S is the spin operator, which just multiplies the function by its spin). In terms of the SWSHs, we can write the action of ethbar as ð̄ {s}Y{l,m} = -sqrt((l+s)(l-s+1)) {s-1}Y{l,m} Consequently, the modes of a function are affected as {ð̄ f} {s,l,m} = -sqrt((l-s)(l+s+1)) f{s+1,l,m}

imag

imag

Source: spherical/modes/algebra.py

n_modes

n_modes

Source: spherical/modes/__init__.py

Number of elements along the last axis

ndarray

ndarray

Source: spherical/modes/__init__.py

View this array as a numpy ndarray

real

real

Source: spherical/modes/algebra.py

s

s

Source: spherical/modes/__init__.py

Spin weight of this Modes object

spin_weight

spin_weight

Source: spherical/modes/__init__.py

Spin weight of this Modes object

LM_deduce_ell_max

LM_deduce_ell_max(size, ell_min=0)

Source: spherical/modes/__init__.py