Fast spin spherical transforms
Project description
SSHT Python Documentation
This guide is intended to explain the python interface of SSHT. For a description of the workings of SSHT see here. The python package also offers an interface to some of the functionality from ducc0, including forward and inverse transforms.
pyssht.forward
flm = pyssht.forward(f, int L, Spin=0, Method='MW', Reality=False)
Performs the forward spherical harmonic transform.
Inputs
f
the signal on the sphere,numpy.ndarray
typecomplex
orreal
, ndim 2. NB different for'MW_pole'
sampling.L
the band limit of the signal, nonzero positive integerSpin
the spin of the signal, nonnegative integer (default = 0)Method
the sampling scheme used, string:'MW'
[McEwen & Wiaux sampling (default)]'MW_pole'
[McEwen & Wiaux sampling with the south pole as a separate double.]'MWSS'
[McEwen & Wiaux symmetric sampling]'DH'
[Driscoll & Healy sampling]'GL'
[GaussLegendre sampling]
Reality
determines if the signal is real or complex, Boolean (default = False)backend
the backend that runs the transforms:'SSHT'
this package'ducc'
interface to ducc0. "MW_pole" is not available in this backend.
nthreads
: number of threads when calling into the'ducc'
backend. Ignored otherwise.
Output
flm
the spherical harmonic transform of f
, 1D numpy.ndarray
type complex
Note on 'MW_pole'
sampling
This is the same as the 'MW'
sampling however the south pole is expressed as a double only not a vector. Therefore the size of the array is one smaller on the (\theta) direction. f
is now a tuple containing either:
(f_array, f_sp, phi_sp)
if complex transform(f_array, f_sp)
if real transform
pyssht.inverse
f = pyssht.inverse(np.ndarray[ double complex, ndim=1, mode="c"] f_lm not None, L, Spin=0, Method='MW', Reality=False)
Performs the inverse spherical harmonic transform.
Inputs
flm
the spherical harmonic transform off
,numpy.ndarray
typecomplex
, ndim 1L
the band limit of the signal, nonzero positive integerSpin
the spin of the signal, nonnegative integer (default = 0)Method
the sampling scheme used, string:'MW'
[McEwen & Wiaux sampling (default)]'MW_pole'
[McEwen & Wiaux sampling with the south pole as a separate double.]'MWSS'
[McEwen & Wiaux symmetric sampling]'DH'
[Driscoll & Healy sampling]'GL'
[GaussLegendre sampling]
Reality
determines if the signal is real or complex, Boolean (default = False)backend
the backend that runs the transforms:'SSHT'
this package'ducc'
interface to ducc0. "MW_pole" is not available in this backend.
nthreads
: number of threads when calling into the'ducc'
backend. Ignored otherwise.
Output
f
the signal on the sphere, 2D numpy.ndarray
type complex
or real
. NB different for 'MW_pole'
sampling.
Note on 'MW_pole'
sampling
This is the same as the 'MW'
sampling however the south pole is expressed as a double only not a vector. Therefore the size of the array is one smaller on the (\theta) direction. f
is now a tuple containing either:
(f_array, f_sp, phi_sp)
if complex transform(f_array, f_sp)
if real transform
pyssht.forward_adjoint
f = pyssht.forward_adjoint(np.ndarray[ double complex, ndim=1, mode="c"] f_lm not None, L, Spin=0, Method='MW', Reality=False)
Performs the adjoint of the forward spherical harmonic transform.
Inputs
flm
the spherical harmonic transform off
,numpy.ndarray
typecomplex
, ndim 1L
the band limit of the signal, nonzero positive integerSpin
the spin of the signal, nonnegative integer (default = 0)Method
the sampling scheme used, string:'MW'
[McEwen & Wiaux sampling (default)]'MWSS'
[McEwen & Wiaux symmetric sampling]
Reality
determines if the signal is real or complex, Boolean (default = False)backend
the backend that runs the transforms:'SSHT'
this package'ducc'
interface to ducc0.
nthreads
: number of threads when calling into the'ducc'
backend. Ignored otherwise.
Output
f
the signal on the sphere, 2D numpy.ndarray
type complex
or real
.
pyssht.inverse_adjoint
flm = pyssht.inverse_adjoint(f, int L, Spin=0, Method='MW', Reality=False)
Performs the adjoint of the inverse spherical harmonic transform.
Inputs
f
the signal on the sphere,numpy.ndarray
typecomplex
orreal
, ndim 2.L
the band limit of the signal, nonzero positive integerSpin
the spin of the signal, nonnegative integer (default = 0)Method
the sampling scheme used, string:'MW'
[McEwen & Wiaux sampling (default)]'MWSS'
[McEwen & Wiaux symmetric sampling]
Reality
determines if the signal is real or complex, Boolean (default = False)backend
the backend that runs the transforms:'SSHT'
this package'ducc'
interface to ducc0.
nthreads
: number of threads when calling into the'ducc'
backend. Ignored otherwise.
Output
flm
the spherical harmonic transform of f
, 1D numpy.ndarray
type complex
pyssht.elm2ind
index = pyssht.elm2ind( int el, int m)
Computes the index in the flm
array of a particular harmonic coefficient (\ell ) and (m).
Inputs
el
the scale parameter of the spherical harmonic coefficients, integer from (0) to (L1), where (L) is the band limit.em
the azimuthal parameter, integer from el to el.
Output
Index of the coefficient in flm
array, integer
pyssht.ind2elm
(el, em) = pyssht.ind2elm(int ind)
Computes harmonic coefficient (\ell ) and (m) from the index in the flm
array.
Inputs
ind
index of theflm
array
Output
Tuple containing (el, em)
el
the scale parameter of the spherical harmonic coefficients, integer from (0) to (L1), where (L) is the band limit.em
the azimuthal parameter, integer from el to el.
pyssht.theta_to_index
p = pyssht.theta_to_index(double theta, int L, str Method="MW")
Outputs the (\theta) index (the first) in the 2 dimensional array used to store spherical images. The index returned is that of the closest (\theta) sample smaller then the angle given on input.
Inputs
theta
the angle (\theta)L
the band limit of the signal, nonzero positive integerMethod
the sampling scheme used, string:'MW'
[McEwen & Wiaux sampling (default)]'MW_pole'
[McEwen & Wiaux sampling with the south pole as a separate double.]'MWSS'
[McEwen & Wiaux symmetric sampling]'DH'
[Driscoll & Healy sampling]'GL'
[GaussLegendre sampling]
Output
Int p
of corresponding to the angle (\theta).
pyssht.phi_to_index
q = pyssht.phi_to_index(double phi, int L, str Method="MW")
Outputs the (\phi) index (the second) in the 2 dimensional array used to store spherical images. The index returned is that of the closest (\phi) sample smaller then the angle given on input.
Inputs
phi
the angle (\phi)L
the band limit of the signal, nonzero positive integerMethod
the sampling scheme used, string:'MW'
[McEwen & Wiaux sampling (default)]'MW_pole'
[McEwen & Wiaux sampling with the south pole as a separate double.]'MWSS'
[McEwen & Wiaux symmetric sampling]'DH'
[Driscoll & Healy sampling]'GL'
[GaussLegendre sampling]
Output
Int q
of corresponding to the angle (\phi).
pyssht.sample_length
n = pyssht.sample_length(int L, Method = 'MW')
Outputs a size of the array used for storing the data on the sphere for different sampling schemes.
Inputs
L
the band limit of the signal, nonzero positive integerMethod
the sampling scheme used, string:'MW'
[McEwen & Wiaux sampling (default)]'MW_pole'
[McEwen & Wiaux sampling with the south pole as a separate double.]'MWSS'
[McEwen & Wiaux symmetric sampling]'DH'
[Driscoll & Healy sampling]'GL'
[GaussLegendre sampling]
Output
Int n
equal to the collapsed 1 dimensional size of the 2 dimensional array used to store data on the sphere.
pyssht.sample_shape
(n_theta, n_phi) = pyssht.sample_shape(int L, Method='MW')
Outputs a tuple with the shape of the array used for storing the data on the sphere for different sampling schemes.
Inputs
L
the band limit of the signal, nonzero positive integerMethod
the sampling scheme used, string:'MW'
[McEwen & Wiaux sampling (default)]'MW_pole'
[McEwen & Wiaux sampling with the south pole as a separate double.]'MWSS'
[McEwen & Wiaux symmetric sampling]'DH'
[Driscoll & Healy sampling]'GL'
[GaussLegendre sampling]
Output
Tuple containing (n_theta, n_phi)
n_theta
the number of samples in the (\theta) direction, integern_phi
the number of samples in the (\phi) direction, integer
pyssht.sample_positions
(thetas, phis) = pyssht.sample_positions(int L, Method = 'MW', Grid=False)
Computes the positions on the sphere of the samples.
Inputs
L
the band limit of the signal, nonzero positive integerMethod
the sampling scheme used, string:'MW'
[McEwen & Wiaux sampling (default)]'MW_pole'
[McEwen & Wiaux sampling with the south pole as a separate double.]'MWSS'
[McEwen & Wiaux symmetric sampling]'DH'
[Driscoll & Healy sampling]'GL'
[GaussLegendre sampling]
Grid
describes if the output is a vector of the sample positions or a 2D array the same shape as the signal on the sphere, defaultFalse
Outputs
Tuple containing (thetas, phis)
thetas
positions of the samples in the (\theta) directionphis
positions of the samples in the (\theta) direction
pyssht.s2_to_cart
(x, y, z) = pyssht.s2_to_cart(theta, phi)
Computes the (x), (y), and (z) coordinates from (\theta) and (\phi) on the sphere.
Inputs
theta
(\theta) values, typenumpy.ndarray
phi
(\phi) values, typenumpy.ndarray
Output
Tuple containing (x, y, z)
x
the (x) coordinate of each point, typenumpy.ndarray
y
the (y) coordinate of each point, typenumpy.ndarray
z
the (z) coordinate of each point, typenumpy.ndarray
pyssht.cart_to_s2
thetas, phis = cart_to_s2(x, y, z)
Computes the (\theta) and (\phi) on the coordinates on the sphere from (x), (y), and (z) coordinates.
Inputs
x
(x) values, typenumpy.ndarray
y
(y) values, typenumpy.ndarray
z
(z) values, typenumpy.ndarray
Output
Tuple containing (theta, phi)
theta
the (\theta) coordinate of each point, typenumpy.ndarray
phi
the (\phi) coordinate of each point, typenumpy.ndarray
pyssht.spherical_to_cart
(x, y, z) = pyssht.spherical_to_cart(r, theta, phi)
Computes the (x), (y), and (z) coordinates from the spherical coordinates (r), (\theta) and (\phi).
Inputs
r
(r) values, typenumpy.ndarray
theta
(\theta) values, typenumpy.ndarray
phi
(\phi) values, typenumpy.ndarray
Output
Tuple containing (x, y, z)
x
the (x) coordinate of each point, typenumpy.ndarray
y
the (y) coordinate of each point, typenumpy.ndarray
z
the (z) coordinate of each point, typenumpy.ndarray
pyssht.cart_to_spherical
r, theta, phi = pyssht.cart_to_spherical(x, y, z)
Computes the (\r), (\theta) and (\phi) on the spherical coordinates from (x), (y), and (z) coordinates.
Inputs
x
(x) values, typenumpy.ndarray
y
(y) values, typenumpy.ndarray
z
(z) values, typenumpy.ndarray
Output
Tuple containing (r, theta, phi)
r
the (r) coordinate of each point, typenumpy.ndarray
theta
the (\theta) coordinate of each point, typenumpy.ndarray
phi
the (\phi) coordinate of each point, typenumpy.ndarray
pyssht.theta_phi_to_ra_dec
(dec, ra) = pyssht.theta_phi_to_ra_dec(theta, phi, Degrees=False)
Computes the Right Assension and declination from an array of (\theta) and (\phi) values.
Inputs
theta
(\theta) values, typenumpy.ndarray
phi
(\phi) values, typenumpy.ndarray
Degrees
defines if the output is in degrees or radians
Output
Tuple containing (dec, ra)
dec
the declination angle,numpy.ndarray
ra
the Right Assension,numpy.ndarray
pyssht.ra_dec_to_theta_phi
(theta, phi) = pyssht.ra_dec_to_theta_phi(ra, dec, Degrees=False)
Computes the (\theta) and (\phi) values from an array of Right Assension and declination values.
Inputs
dec
the declination angle,numpy.ndarray
ra
the Right Assension,numpy.ndarray
Degrees
defines if the input is in degrees or radians, if degrees they are converted
Output
Tuple containing (theta, phi])
theta
(\theta) values, typenumpy.ndarray
phi
(\phi) values, typenumpy.ndarray
pyssht.make_rotation_matrix
rot_much = pyssht.make_rotation_matrix(list rot)
Computes the 3 by 3 rotation matrix from the Euler angles given on input
Inputs
rot
List of length 3. Each element are the Euler angles[alpha, beta, gamma]
Output
3 by 3 rot_matrix
the rotation matrix type ndarray
dtype float
pyssht.rot_cart
x_p, y_p, z_p = pyssht.rot_cart(x, y, z, list rot)
Computes the rotations of the cartesian coordinates given a set of Euler angles. The inputs can be any shape ndarray
s. For speed if the arrays are 1 or 2 dimensional it is recommended to use pyssht.rot_cart_1D
or pyssht.rot_cart_2D
.
Inputs
x
(x) values, typenumpy.ndarray
y
(y) values, typenumpy.ndarray
z
(z) values, typenumpy.ndarray
rot
List of length 3. Each element are the Euler angles[alpha, beta, gamma]
Output
Tuple containing (x_p, y_p, z_p)
the rotated coordinates the same shape and type as the inputs.
pyssht.rot_cart_1d and pyssht.rot_cart_2d
(x_p, y_p, z_p) = pyssht.rot_cart_1d(np.ndarray[np.float_t, ndim=1] x, np.ndarray[np.float_t, ndim=1] y, np.ndarray[np.float_t, ndim=1] z, list rot)
(x_p, y_p, z_p) = pyssht.rot_cart_2d(np.ndarray[np.float_t, ndim=2] x, np.ndarray[np.float_t, ndim=2] y, np.ndarray[np.float_t, ndim=2] z, list rot)
Computes the rotations of the cartesian coordinates given a set of Euler angles. The inputs can be any shape ndarray
s. Same as pyssht.rot_cart
except optimised for arrays that are 1 or 2 dimensional.
Inputs
x
(x) values, typenumpy.ndarray
, dtypefloat
, ndim 1 or 2y
(y) values, typenumpy.ndarray
, dtypefloat
, ndim 1 or 2z
(z) values, typenumpy.ndarray
, dtypefloat
, ndim 1 or 2rot
List of length 3. Each element are the Euler angles[alpha, beta, gamma]
Output
Tuple containing (x_p, y_p, z_p)
the rotated coordinates the same shape and type as the inputs.
pyssht.plot_sphere
pyssht.plot_sphere( f, L, Method='MW', Close=True, Parametric=False, Parametric_Scaling=[0.0,0.5], Output_File=None, Show=True, Color_Bar=True, Units=None, Color_Range=None, Axis=True )
Plots data on to a sphere. It is really slow and not very good!
Inputs
f
the signal on the sphere,numpy.ndarray
typecomplex
orreal
, ndim 2. NB different for'MW_pole'
sampling.L
the band limit of the signal, nonzero positive integerMethod
the sampling scheme used, string:'MW'
[McEwen & Wiaux sampling (default)]'MW_pole'
[McEwen & Wiaux sampling with the south pole as a separate double.]'MWSS'
[McEwen & Wiaux symmetric sampling]'DH'
[Driscoll & Healy sampling]'GL'
[GaussLegendre sampling]
Close
if true the full sphere is plotted (without a gap after the last (\phi) position), defaultTrue
Parametric
the radius of the object at a certain point is defined by the function (not just the color), defaultFalse
Parametric_Saling
used ifParametric=True
, defines the radius of the shape at a particular angler = norm(f)*Parametric_Saling[1] + Parametric_Saling[0]
, default[0.0,0.5]
Output_File
if set saves the plot to a file of that nameShow
ifTrue
shows you the plot, defaultFalse
Color_Bar
ifTrue
shows the color bar, defaultTrue
Units
is set puts a label on the color barColor_Range
if set saturates the color bar in that range, else the function min and max is usedAxis
ifTrue
shows the 3d axis, defaultTrue
Outputs
None
pyssht.mollweide_projection
f_plot, mask = pyssht.mollweide_projection( f, L, resolution=500, rot=None, zoom_region=[np.sqrt(2.0)*2,np.sqrt(2.0)], Method="MW" )
Creates an ndarray
of the mollweide projection of a spherical image and a mask array. This is useful for plotting results, not to be used for analysis on the plane. Elements in the signal f
that are NaN
s are marked in the mask. This allows one to plot these regions the color of their choice.
Here is an example of using the function to plot real spherical data.
f_plot, mask = pyssht.mollweide_projection(f, L, Method="MW") # make projection plt.figure() # start figure imgplot = plt.imshow(f_real_plot,interpolation='nearest') # plot the projected image plt.colorbar(imgplot,fraction=0.025, pad=0.04) # plot color bar (these extra keywords make the bar a reasonable size) plt.imshow(mask_real, interpolation='nearest', cmap=cm.gray, vmin=1., vmax=1.) # plot the NaN regions in grey plt.gca().set_aspect("equal") # ensures the region is the correct proportions plt.axis('off') # removes axis (looks better) plt.show()
Inputs
f
the signal on the sphere,numpy.ndarray
typecomplex
orreal
, ndim 2.L
the band limit of the signal, nonzero positive integerresolution
size of the projected image, default 500rot
If the image should be rotated before projecting, None.rot
should be a list of length 1 or 3. If 1 then the image is rotated around the (z) axis by that amount. If 3 then the image is rotated by the Euler angles given in the list.zoom_region
the region of the sphere to be plotted, default[np.sqrt(2.0)*2,np.sqrt(2.0)]
is the full sphere.Method
the sampling scheme used, string:'MW'
[McEwen & Wiaux sampling (default)]'MWSS'
[McEwen & Wiaux symmetric sampling]'DH'
[Driscoll & Healy sampling]'GL'
[GaussLegendre sampling]
Outputs
If the input is real:
Tuple containing:
f_plot
the projection of the image as a 2 dimensionalndarray
of typefloat
. Masked regions and regions not in the sphere areNaN
s to make them clear when plottedmask
the projection of the masked regions (NaN
s in inputf
) as a 2 dimensionalndarray
of typefloat
. Masked regions have a value0.0
and regions not in the sphere areNaN
s to make them clear when plotted.
If the input is complex:
Tuple containing:
f_plot_real
the projection of the real part of the image as a 2 dimensionalndarray
of typefloat
. Masked regions and regions not in the sphere areNaN
s to make them clear when plottedmask_real
the projection of the masked regions (NaN
s in inputf.real
) as a 2 dimensionalndarray
of typefloat
. Masked regions have a value0.0
and regions not in the sphere areNaN
s to make them clear when plotted.f_plot_imag
the projection of the imaginary part of the image as a 2 dimensionalndarray
of typefloat
. Masked regions and regions not in the sphere areNaN
s to make them clear when plottedmask_imag
the projection of the masked regions (NaN
s in inputf.imag
) as a 2 dimensionalndarray
of typefloat
. Masked regions have a value0.0
and regions not in the sphere areNaN
s to make them clear when plotted.
pyssht.equatorial_projection
f_proj_real, mask_real, (f_proj_imag, mask_imag)\ = pyssht.equatorial_projection(f, int L, int resolution=500,\ rot=None, list zoom_region=[1,1], str Method="MW", \ str Projection="MERCATOR", int Spin=0)
Creates ndarray
s of the projections of a spherical image and a mask array. This is useful for plotting results and performing analysis on the plane. All the spherical samples that fall in one planar pixel is averaged, if no samples fall in a pixel then the pixel is assigned the value of the closest spherical sample. Elements in the signal f
that are NaN
s are marked in the mask. This allows one to plot these regions the color of their choice.
There are two projections supported.
 The Mercator projection often used in maps.
 The Sinusoidal projection a simple equal area projection.
Here is an example of using the function to plot real spherical data using the Mercator projection.
f_proj, mask \ = pyssht.equatorial_projection(f, L, resolution=500, Method="MW", \ Projection="MERCATOR") plt.figure() # start figure imgplot = plt.imshow(f_proj,interpolation='nearest')# plot the projected image (north part) plt.colorbar(imgplot) # plot color bar plt.imshow(mask, interpolation='nearest', cmap=cm.gray, vmin=1., vmax=1.) # plot the NaN regions in grey plt.axis('off') # removes axis plt.show()
Inputs
f
the signal on the sphere,numpy.ndarray
typecomplex
orreal
, ndim 2.L
the band limit of the signal, nonzero positive integerresolution
size of the projected image, default 500rot
If the image should be rotated before projecting, None.rot
should be a list of length 1 or 3. If 1 then the image is rotated around the (z) axis by that amount. If 3 then the image is rotated by the Euler angles given in the list.zoom_region
the region of the sphere to be plotted in radians. The first element is the angle left and right of the centre, default isnp.pi
for both projections. The second element is up and down of the equator, default isnp.pi/2
for the Sinusoidal projection and7*np.pi/16
for the Mercator projection.Method
the sampling scheme used, string:'MW'
[McEwen & Wiaux sampling (default)]'MWSS'
[McEwen & Wiaux symmetric sampling]'DH'
[Driscoll & Healy sampling]'GL'
[GaussLegendre sampling]
Projection
string describing which of the projections to use. Use"MERCATOR"
for the Mercator projection and"SINE"
for the Sinusoidal projection, default is"MERCATOR"
Spin
the spin of the signal. If the signal has nonzero spin then on projection the signal must be rotated to account for the changing direction of the definition of the signal. By setting this to a nonzero integer will ensure this rotation is performed.
Outputs
If the input is real:
Tuple containing:
f_plot
the projection of the image as a 2 dimensionalndarray
of typefloat
. Masked regions and regions not in the sphere areNaN
s to make them clear when plottedmask
the projection of the masked regions (NaN
s in inputf
) as a 2 dimensionalndarray
of typefloat
. Masked regions have a value0.0
and regions not in the sphere areNaN
s to make them clear when plotted.
If the input is complex:
Tuple containing:
f_plot_real
the projection of the real part of the image as a 2 dimensionalndarray
of typefloat
. Masked regions and regions not in the sphere areNaN
s to make them clear when plottedmask_real
the projection of the real part of the masked regions (NaN
s in inputf
) as a 2 dimensionalndarray
of typefloat
. Masked regions have a value0.0
and regions not in the sphere areNaN
s to make them clear when plotted.f_plot_imag
the projection of the imaginary part of the image as a 2 dimensionalndarray
of typefloat
. Masked regions and regions not in the sphere areNaN
s to make them clear when plottedmask_imag
the projection of the imaginary part of the masked regions (NaN
s in inputf
) as a 2 dimensionalndarray
of typefloat
. Masked regions have a value0.0
and regions not in the sphere areNaN
s to make them clear when plotted.
pyssht.polar_projection
f_proj_north_real, mask_north_real, f_proj_south_real, mask_south_real,\ (f_proj_north_imag, mask_north_imag, f_proj_south_imag, mask_south_imag\ ) = pyssht.polar_projection(f, int L, int resolution=500, rot=None,\ float zoom_region=1, str Method="MW", str Projection="OP",int Spin=0):
Creates an two ndarray
s of the polar projection of a spherical image and a mask array. This is useful for plotting results and performing analysis on the plane. All the spherical samples that fall in one planar pixel is averaged, if no samples fall in a pixel then the pixel is assigned the value of the closest spherical sample. Elements in the signal f
that are NaN
s are marked in the mask. This allows one to plot these regions the color of their choice.
All the projections are centred around a pole. There are three projections supported.
 The Gnomic projection, defined by drawing a line from the centre of the circle trough the sphere on to the plane.
 The Stereographic projection, defined by drawing a line starting at the opposite pole through the sphere to the plane.
 The Orthographic, defined by a vertical projection on the plane.
Here is an example of using the function to plot real spherical data.
f_proj_north, mask_north, f_proj_south, mask_south \ = pyssht.polar_projection(f, L, resolution=500, Method="MW", \ Projection="OP") plt.figure() # start figure imgplot = plt.imshow(f_proj_north,interpolation='nearest')# plot the projected image (north part) plt.colorbar(imgplot) # plot color bar plt.imshow(mask_north, interpolation='nearest', cmap=cm.gray, vmin=1., vmax=1.) # plot the NaN regions in grey plt.axis('off') # removes axis (looks better) plt.figure() imgplot = plt.imshow(f_proj_south,interpolation='nearest')# plot the projected image (south part) plt.colorbar(imgplot) plt.imshow(mask_south, interpolation='nearest', cmap=cm.gray, vmin=1., vmax=1.) plt.title("orthographic projection south") plt.axis('off') plt.show()
Inputs
f
the signal on the sphere,numpy.ndarray
typecomplex
orreal
, ndim 2.L
the band limit of the signal, nonzero positive integerresolution
size of the projected image, default 500rot
If the image should be rotated before projecting, default None.rot
should be a list of length 1 or 3. If 1 then the image is rotated around the (z) axis by that amount. If 3 then the image is rotated by the Euler angles given in the list.zoom_region
the region of the sphere to be plotted in radians, defaultnp.pi/2
is the full half sphere for the orthographic and stereographic projections andnp.pi/4
for the gnomic projection as the equator is at infinity in this projection.Method
the sampling scheme used, string:'MW'
[McEwen & Wiaux sampling (default)]'MWSS'
[McEwen & Wiaux symmetric sampling]'DH'
[Driscoll & Healy sampling]'GL'
[GaussLegendre sampling]
Projection
string describing which of the projections to use. Use"GP"
for the Gnomic projection,"SP"
for the Stereographic projection and"OP"
for the Orthographic projection, default is"OP"
Spin
the spin of the signal. If the signal has nonzero spin then on projection the signal must be rotated to account for the changing direction of the definition of the signal. By setting this to a nonzero integer will ensure this rotation is performed.
Outputs
If the input is real:
Tuple containing:
f_plot_north
the projection of the north part of the image as a 2 dimensionalndarray
of typefloat
. Masked regions and regions not in the sphere areNaN
s to make them clear when plottedmask_north
the projection of the north part of the masked regions (NaN
s in inputf
) as a 2 dimensionalndarray
of typefloat
. Masked regions have a value0.0
and regions not in the sphere areNaN
s to make them clear when plotted.f_plot_south
the projection of the south part of the image as a 2 dimensionalndarray
of typefloat
. Masked regions and regions not in the sphere areNaN
s to make them clear when plottedmask_south
the projection of the south part of the masked regions (NaN
s in inputf
) as a 2 dimensionalndarray
of typefloat
. Masked regions have a value0.0
and regions not in the sphere areNaN
s to make them clear when plotted.
If the input is complex:
Tuple containing:
f_plot_north_real
the projection of the north part of the real part of the image as a 2 dimensionalndarray
of typefloat
. Masked regions and regions not in the sphere areNaN
s to make them clear when plottedmask_north_real
the projection of the north part of the real part of the masked regions (NaN
s in inputf
) as a 2 dimensionalndarray
of typefloat
. Masked regions have a value0.0
and regions not in the sphere areNaN
s to make them clear when plotted.f_plot_south_real
the projection of the south part of the real part of the image as a 2 dimensionalndarray
of typefloat
. Masked regions and regions not in the sphere areNaN
s to make them clear when plottedmask_south_real
the projection of the south part of the real part of the masked regions (NaN
s in inputf
) as a 2 dimensionalndarray
of typefloat
. Masked regions have a value0.0
and regions not in the sphere areNaN
s to make them clear when plotted.f_plot_north_imag
the projection of the north part of the imaginary part of the image as a 2 dimensionalndarray
of typefloat
. Masked regions and regions not in the sphere areNaN
s to make them clear when plottedmask_north_imag
the projection of the north part of the imaginary part of the masked regions (NaN
s in inputf
) as a 2 dimensionalndarray
of typefloat
. Masked regions have a value0.0
and regions not in the sphere areNaN
s to make them clear when plotted.f_plot_south_imag
the projection of the south part of the imaginary part of the image as a 2 dimensionalndarray
of typefloat
. Masked regions and regions not in the sphere areNaN
s to make them clear when plottedmask_south_imag
the projection of the south part of the imaginary part of the masked regions (NaN
s in inputf
) as a 2 dimensionalndarray
of typefloat
. Masked regions have a value0.0
and regions not in the sphere areNaN
s to make them clear when plotted.
pyssht.dl_beta_recurse
dl = pyssht.dl_beta_recurse(np.ndarray[ double, ndim=2, mode="c"] dl not None,\ double beta, int L, int el, \ np.ndarray[ double, ndim=1, mode="c"] sqrt_tbl not None,\ np.ndarray[ double, ndim=1, mode="c"] signs not None)
Compute the elth plane of the Wigner smalld functions (from the (el1)th plane) using Risbo's method.
Inputs
dl
the Wigner plane for all m and n, indexed dl[m][n] of size (2L1)(2*L1)beta
angle to calculate Wigner D matrix at, typedouble
L
the band limit of the signal, nonzero positive integerel
is the current harmonic degree (i.e. dl input should already be computed for el1, and dl output will be computed for el)sqrt_tbl
precomputed squareroots from (0) to (2*(L1)+1)signs
precomputed ((1)^m) signs from (m=0) to (L)
Outputs
Numpy ndarray dl
, type float_
of the Wigner plane for all m and n
pyssht.dln_beta_recurse
dl = pyssht.dln_beta_recurse(np.ndarray[ double, ndim=1, mode="c"] dl not None,\ np.ndarray[ double, ndim=1, mode="c"] dlm1 not None, double beta,\ int L, int el, int n, np.ndarray[ double, ndim=1, mode="c"] sqrt_tbl not None,\ np.ndarray[ double, ndim=1, mode="c"] signs not None)
Compute the elth line of the Wigner smalld functions for given n (from the (el1)th and (el2)th lines) using 3term recursion of Kostelec.
Inputs
dl
the Wigner line for el for nonnegative m and given n of size Ldlm1
is the line for el1 and dlp1 is the line computed for el+1beta
angle to calculate Wigner D matrix at, typedouble
L
the band limit of the signal, nonzero positive integerel
el is the current harmonic degreen
the third index in Wigner D matricessqrt_tbl
precomputed squareroots from (0) to (2*(L1)+1)signs
precomputed ((1)^m) signs from (m=0) to (L)
Outputs
Numpy ndarray dl
, type float_
the Wigner line for el for nonnegative m and given n of size
pyssht.generate_dl
dl_array = pyssht.generate_dl(double beta, int L)
Generates the small Wigner D matrices up to a given band limit for a given (\beta)
Inputs
beta
angle to calculate Wigner D matrix at, typedouble
L
the band limit of the signal, nonzero positive integer
Outputs
Numpy ndarray dl_array
, type float_
of the small Wigner D matrices
pyssht.rotate_flms
flm_rotated = pyssht.rotate_flms( np.ndarray[ double complex, ndim=1, mode="c"] f_lm not None,\ double alpha, double beta, double gamma, int L, dl_array=None,\ M=None, Axisymmetric=False, Keep_dl=False)
Function to rotate a set of spherical harmonic coefficients by the set of Euler angles (\alpha, \beta, \gamma ) using the (z,y,z) convention.
Inputs
flm
the spherical harmonic transform off
,numpy.ndarray
typecomplex
, ndim 1alpha
rotation angle (\alpha), typedouble
beta
rotation angle (\beta), typedouble
gamma
rotation angle (\gamma), typedouble
L
the band limit of the signal, nonzero positive integerdl_array
if set should be the precomputed small Wigner D matrix for angle (\beta) and harmonic band limitL
. If not set this is calculated in the function. (This parameter is ignored when using theducc
backend.)M
if set is the azimuthal band limit of the function to be rotated, defaultM=L
.Axisymmetric
set if the function is axisymmetric and axisymmetric harmonic coefficients are parsed.Keep_dl
if set the output is changed to allow one to keep the computeddl_array
. (This parameter is ignored when using theducc
backend.)backend
the backend that runs the transforms:'SSHT'
this package'ducc'
interface to ducc0
Output
If Keep_dl
is not set the output is the rotated set of spherical harmonic coefficients. If it is the output is a tuple (flm_rotated, dl_array)
, ie the rotated harmonic coefficients and the small Wigner D matrix computed for that band limit and (\alpha) value.
pyssht.guassian_smoothing
fs_lm = pyssht.guassian_smoothing(np.ndarray[ double complex, ndim=1, mode="c"] f_lm not None, int L, sigma_in=None, bl_in = None)
Smooths a set of harmonic coefficients either with a precomputed smoothing kernel bl
or with a Gaussian given on input.
Inputs
f_lm
the spherical harmonic transform off
,numpy.ndarray
typecomplex
, ndim 1L
the band limit of the signal, nonzero positive integersigma_in
the input sigma of the Gaussian to smooth the signal with, defaultNone
bl_in
the smoothing kernel to smooth the signal with, defaultNone
Output
fs_lm
the smoothed harmonic coefficients.
pyssht.create_ylm
ylm = pyssht.create_ylm(thetas, phis, int L, int Spin=0, str recursion='Kostelec')
Computes spherical harmonic functions for all el and all 0<=m<= el using various recursions.
Inputs
thetas
positions of the samples in the (\theta) directionphis
positions of the samples in the (\phi) directionL
the band limit of the signal, nonzero positive integerSpin
the spin of the signal, nonnegative integer (default = 0)recursion
the recursion scheme used, string:'Kostelec'
[3term recursion, e.g. Kostelec (default)]'Risbo'
[Risbo recursion]'NumericalRecipes'
[Numerical Recipes]
Output
ylm
the spherical harmonics indexed ylm[ind][theta][phi]
, where ind = pyssht.elm2ind(el, m)
Project details
Release history Release notifications  RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size  File type  Python version  Upload date  Hashes 

Filename, size pyssht1.5.1cp38cp38macosx_10_15_x86_64.whl (1.1 MB)  File type Wheel  Python version cp38  Upload date  Hashes View 
Filename, size pyssht1.5.1.tar.gz (78.5 kB)  File type Source  Python version None  Upload date  Hashes View 
Hashes for pyssht1.5.1cp38cp38macosx_10_15_x86_64.whl
Algorithm  Hash digest  

SHA256  f3dd89adb35db7a6b7c90db5542816042fdcbb76690524037533004a1737b6d3 

MD5  e45e091c20d3287d23b0f423854db8bd 

BLAKE2256  4b063d1e9d82643ab972441685256014a9ce15af25634fac3a032e33c942200d 