grale.multiplanecuda

This is a Python wrapper for CUDA based multi-plane code [1]. The code itself was written with the inversion algorithm in mind, but this Python wrapper can still be used to do basic multiplane calculations using your GPU (tracing image plane vectors, but no magnifications at the moment).

[1] MultiplaneLensing @ Github

MultiPlaneCUDAException

exception grale.multiplanecuda.MultiPlaneCUDAException

This exception is raised if something goes wrong in the MultiPlaneCUDA class.

MultiPlaneCUDA

class grale.multiplanecuda.MultiPlaneCUDA
__init__(lensesAndRedshifts, thetasAndSourceRedshifts, cosmology='default', libraryPath=None)

Initialize this instance for multi-plane calculations on the GPU. For a fixed set of image plane positions, this will allow you to calculate the source plane positions for various weights of the specified basis functions.

Arguments:
  • lensesAndRedshifts: this is an array of (lens, redshift) tuples, corresponding to the number of lens planes and their distances. The lens model should consist of a number of Plummer basis functions, and optionally a mass-sheet basis function. Using calculateSourcePositionsForInitialLens() you can calculate the mapping from image planes to source planes for these specific lenses. Using calculateSourcePositions() it is possible to change the weights of these Plummer basis functions, as well as the densities of the mass sheets.

  • thetasAndSourceRedshifts: an array of tuples (image plane vectors, source redshift), specifying the points in the image plane that can be projected back onto the source plane, as well as the redshifts of these source planes. These positions are fixed for this instance, they can no longer be adjusted afterwards.

  • cosmology: either a Cosmology instance, or "default" if a default cosmological model has been specified.

  • libraryPath: can be None if the library of the MultiplaneLensing project should be located automatically, or the full path to this library. In case of an automatic search, the path stored in environment variable GRALE_MPCUDA_LIBRARY is used if available, or else the library name will try to be located in the directories in the PATH environment variable.

  • deviceIdx: specify a specific device, or set to -1 to let the next device be chosen automatically each time.

calculateSourcePositions(massFactors, sheetDensities=None)

For the image plane vectors and redshifts specified at construction time, the source plane vectors are calculated. The Plummer basis functions specified during initialization are re-weighted using the mass factors specified here, and for each lens plane a mass sheet density can be specified.

Arguments:
  • massFactors: the factors with which the initial Plummer basis functions should be weighted. To obtain a list of these initial basis functions for each lens plane, you can use the function getPlummerParameters(). To use the initial basis functions, you simply need to specify a weight of 1 for each one.

  • sheetDensities: for each lens plane, a mass sheet with a specific density (in kg/m^2) can be specified. If set to None, a value of zero is used for each sheet. The function getInitialSheetDensities() can be used to obtain the sheet densities specified in the constructor.

calculateSourcePositionsForInitialLens()

This is a convenience function to be able to calculate the image plane to source plane mapping for the lenses specified in the constructor, without changing the weights of the basis functions, and without modifying the mass sheet densities.

getInitialSheetDensities()

Returns the mass sheet densities that were found in the lenses specified in the constructor, one density for each lens plane.

getPlummerParameters()

Returns the Plummer parameters that were derived from the lenses specified in the constructor. This is a list (one entry for each lens plane) of lists (one entry for each Plummer basis function), where each entry is a dictionary with keys mass, width and position, specifying the mass of the Plummer lens, its angular width, and its position in the lens plane.

getSourcePositions(srcIdx)

For the image plane vectors with index srcIdx that were specified in the constructor, return the source positions that have been calculated. This only makes sense if calculateSourcePositions() has been called first.