The SKIRT project
advanced radiative transfer for astrophysics
Public Member Functions | Private Attributes | List of all members
pts.simulation.healpix.HEALPixGrid Class Reference

This class represents a HEALPix grid. More...

Public Member Functions

def __init__ (self, HEALPixCube)
 Constructor. More...
 
def degrade (self, degradeFactor, operator=np.sum)
 This function returns a new HEALPixGrid that contains a degraded copy of this one. More...
 
def getAnnulusAroundPixel (self, centralPixel, innerRadius, outerRadius, useTree=False)
 Get a mask that selects all pixels within an annulus with the given inner and outer radius surrounding the given central pixel. More...
 
def getHEALPixAngles (self, j, i)
 This function returns the angle arrays corresponding to the given input index arrays. More...
 
def getHEALPixIndices (self, theta, phi)
 This function returns the index arrays corresponding to the given input zenith and azimuth angles for the HEALPix grid in SKIRT's modified ring order. More...
 
def getKDTree (self)
 This function returns a scipy.spatial.cKDTree containing all pixels in the grid. More...
 
def getPixel (self, j, i)
 Access the pixels corresponding to the given ring and pixel-in-ring indices. More...
 
def getPixelAngles (self)
 This function returns arrays of zenith angles theta and azimuth angles phi in the same RING order returned by getPixelIndices(). More...
 
def getPixelFromRINGIndex (self, index)
 Access the pixels corresponding to the given RING indices. More...
 
def getPixelIndices (self)
 This function returns arrays of ring indices j and pixel-in-ring indices i that, when traversed in order, traverse the HEALPix grid in RING order. More...
 
def getPositions (self)
 This function returns an array containing the position of each pixel in 3D space, assuming a celestial sphere with radius 1. More...
 
def getProjectionMap (self, nPixelY, projection="Mollweide", thetaCenter=0.0, phiCenter=0.0)
 This function returns the projection of the HEALPix data map, using the given number of vertical pixels for the resulting projection image, and the given projection transformation. More...
 
def getRINGIndex (self, theta, phi)
 This function returns the RING indices for the pixels that contain the given positions on the sky. More...
 
def printInfo (self)
 Print some information about the HEALPix grid to the console. More...
 

Private Attributes

 _HEALPixCube
 
 _i
 
 _j
 
 _NSide
 
 _order
 
 _phi
 
 _positions
 
 _theta
 
 _tree
 

Detailed Description

This class represents a HEALPix grid.

It contains a reference to the raw HEALPixSkyInstrument data cube and some additional geometrical information about the grid that is derived from it.

It offer functionality to access, manipulate and project the HEALPix pixels.

Constructor & Destructor Documentation

◆ __init__()

def pts.simulation.healpix.HEALPixGrid.__init__ (   self,
  HEALPixCube 
)

Constructor.

Responsible for initialising the geometrical information about the HEALPix grid.

Member Function Documentation

◆ degrade()

def pts.simulation.healpix.HEALPixGrid.degrade (   self,
  degradeFactor,
  operator = np.sum 
)

This function returns a new HEALPixGrid that contains a degraded copy of this one.

The degraded copy combines 2*2^degradeFactor pixels into a single pixel using the given operator (default is sum) to combine pixel values. This effectively changes the order of the HEALPixGrid by -degradeFactor.

◆ getAnnulusAroundPixel()

def pts.simulation.healpix.HEALPixGrid.getAnnulusAroundPixel (   self,
  centralPixel,
  innerRadius,
  outerRadius,
  useTree = False 
)

Get a mask that selects all pixels within an annulus with the given inner and outer radius surrounding the given central pixel.

When indexed with this mask, any grid related array will be reduced to an array that only contains values for pixels within the annulus.

When the optional argument useTree is set to True, the function will make use of a KD-tree (scipy.spatial.cKDTree) to speed up the neighbour finding. This is only useful for (many) repeated calls to this function and for large grids. In this case, the first call to this function will take a lot longer, because it will need to construct the tree. The tree is then cached for later reuse.

◆ getHEALPixAngles()

def pts.simulation.healpix.HEALPixGrid.getHEALPixAngles (   self,
  j,
  i 
)

This function returns the angle arrays corresponding to the given input index arrays.

The index array j contains the ring indices, the index array i contains the pixel-in-ring indices. The return arrays contain the centers of the corresponding pixels.

This function is the inverse of getHEALPixIndices(). No checks are done on the input values to ensure that they are actually valid indices.

◆ getHEALPixIndices()

def pts.simulation.healpix.HEALPixGrid.getHEALPixIndices (   self,
  theta,
  phi 
)

This function returns the index arrays corresponding to the given input zenith and azimuth angles for the HEALPix grid in SKIRT's modified ring order.

For each pair of input angles, the returned pair of output indices points to the pixel that contains those angles. Using those indices to access the raw HEALPix data will return the corresponding pixel value.

Note that the code here is (and always should be) identical to the implementation used internally by SKIRT to guarantee consistency. We do however make use of NumPy arrays and NumPy array indexing for increased efficiency.

◆ getKDTree()

def pts.simulation.healpix.HEALPixGrid.getKDTree (   self)

This function returns a scipy.spatial.cKDTree containing all pixels in the grid.

This tree can be used to perform spatial queries on the pixels (in Cartesian 3D space).

The tree is cached fro improved efficiency.

◆ getPixel()

def pts.simulation.healpix.HEALPixGrid.getPixel (   self,
  j,
  i 
)

Access the pixels corresponding to the given ring and pixel-in-ring indices.

◆ getPixelAngles()

def pts.simulation.healpix.HEALPixGrid.getPixelAngles (   self)

This function returns arrays of zenith angles theta and azimuth angles phi in the same RING order returned by getPixelIndices().

These values are cached internally for improved efficiency.

◆ getPixelFromRINGIndex()

def pts.simulation.healpix.HEALPixGrid.getPixelFromRINGIndex (   self,
  index 
)

Access the pixels corresponding to the given RING indices.

◆ getPixelIndices()

def pts.simulation.healpix.HEALPixGrid.getPixelIndices (   self)

This function returns arrays of ring indices j and pixel-in-ring indices i that, when traversed in order, traverse the HEALPix grid in RING order.

These values are cached internally for improved efficiency.

◆ getPositions()

def pts.simulation.healpix.HEALPixGrid.getPositions (   self)

This function returns an array containing the position of each pixel in 3D space, assuming a celestial sphere with radius 1.

These values are cached internally for improved efficiency.

◆ getProjectionMap()

def pts.simulation.healpix.HEALPixGrid.getProjectionMap (   self,
  nPixelY,
  projection = "Mollweide",
  thetaCenter = 0.0,
  phiCenter = 0.0 
)

This function returns the projection of the HEALPix data map, using the given number of vertical pixels for the resulting projection image, and the given projection transformation.

The optional parameters thetaCenter and phiCenter allow to select a different central position than the original crosshair of the HEALPixSkyInstrument.

The function first sets up the linear coordinates for the projection image and then converts them to the appropriate zenith and azimuth angles using the appropriate projection. These angles are then rotated according to thetaCenter and phiCenter so that they point to the correct angles on the rotated HEALPix sphere. Finally, the angles are passed on to getHEALPixIndices() to get the corresponding HEALPix pixels.

Because of the nature of the Mollweide projection, some pixels in the four corners of the output image are unused. The values in these pixels are set to zero.

The angles thetaCenter and phiCenter lead to vertical and horizontal rotations respectively. The horizontal rotation is simply to the right. The vertical rotation goes upward in the left part of the image and downward in the right part. Pixels that rotate through the pole move from the left part to the right part. Due to the projection, thetaCenter can go through a full 360 degrees rotation before the projection image is the same; thetaCenter angles larger than 180 degrees correspond to projection images for smaller thetaCenter values that are seen upside down.

◆ getRINGIndex()

def pts.simulation.healpix.HEALPixGrid.getRINGIndex (   self,
  theta,
  phi 
)

This function returns the RING indices for the pixels that contain the given positions on the sky.

◆ printInfo()

def pts.simulation.healpix.HEALPixGrid.printInfo (   self)

Print some information about the HEALPix grid to the console.


The documentation for this class was generated from the following file: