grale.multiplane
With the classes in this module you can simulate a multi-lensplane situation.
- class grale.multiplane.MultiLensPlane(lensesAndRedshifts, bottomLeft, topRight, numX, numY, renderer='default', feedbackObject=None, cosmology='default')
- getLensesAndRedshifts()
Returns a copy of the lens and redshift tuples that was specified during initialization.
- getRenderInfo()
Returns a dictionary with the following entries:
bottomleft
: the bottom-left corner that was specified in the constructor of this instancetopright
: the top-right corner that was specified in the constructor of this instancexpoints
: the number of points in the x-direction, between the left and right coordinates specified bybottomleft
andtopright
, at which the deflection field was sampledypoints
: the number of points in the y-direction, between the bottom and top coordinates specified bybottomleft
andtopright
, at which the deflection field was sampled
- class grale.multiplane.MultiImagePlane(multiLensPlane, sourceRedshift)
- getBetaAndDerivatives(thetas)
For each theta position in thetas, calculate the corresponding position in the source plane (beta vector) as well as the derivatives. Note that this is all calculated using a single processor core, no speedup using e.g. OpenMP will be performed.
- getCaustics(approx=False)
This returns a list describing the caustics associated with this image plane. Each entry in the list is itself a list of 2D points, describing a connected part of a caustic.
- getCriticalLines()
This returns a list describing the critical lines associated with this image plane. Each entry in the list is itself a list of 2D points, describing a connected part of a critical line.
- getInverseMagnificationApproximately(thetas)
Based on the exact inverse magnifications calculated for theta vectors on a grid, calculate the inverse magnifications approximately for arbitrary theta-vectors thetas.
- getRenderInfo()
Returns a dictionary with the following entries:
bottomleft
: the bottom-left corner that is relevant for this instance. This is taken from the LensPlane instance specified in the constructor.topright
: the top-right corner that is relevant for this instance. This is taken from the LensPlane instance specified in the constructor.xpoints
: the number of points in the x-direction, between the left and right coordinates specified bybottomleft
andtopright
, at which the deflection field was sampled. This is taken from the LensPlane instance specified in the constructor.ypoints
: the number of points in the y-direction, between the bottom and top coordinates specified bybottomleft
andtopright
, at which the deflection field was sampled. This is taken from the LensPlane instance specified in the constructor.xpixels
: based on the image plane to source plane mappings that are known atxpoints
*ypoints
grid points, a number of pixels can be defined that can contain light from the source plane, and these pixels will be used when rendering the image plane or the source plane withrenderImages()
orrenderSources()
. Thisxpixels
value specifies the number of pixels in the x-direction, and is one less thanxpoints
.ypixels
: similar toxpixels
, but for the y-direction.
- getSourceRedshift()
Returns the source redshift that was specified during initialization.
- renderImages(sourceList, plane=None, subSamples=9)
For the list of
SourceImage
derived classes in sourceList, this function calculates what the images look like based on the dimensions and number of pixels for this ImagePlane instance.The function returns a 2D NumPy array containing
ypixels
rows, each ofxpixels
pixels wide (see alsogetRenderInfo()
). If plane is specified, the results are stored in that 2D NumPy instance, which must have the same dimensions.Each pixel is sub-sampled
sqrt(subSamples)
times in x- and y- direction, to be able to roughly approximate the integration that’s needed over the surface area of a pixel.Note that a call to only imshow. will plot the 0,0 value in plane (the bottom-left value) as the top-left corner causing the result to appear mirrored in the y-direction (the y-axis will point down). A subsequent call to invert_yaxis might be useful.
- renderSources(sourceList, plane=None, subSamples=9)
For the list of
SourceImage
derived classes in sourceList, this function calculates what the sources look like based on the dimensions and number of pixels for this ImagePlane instance. This is what the image plane would look like if the gravitational lens effect could be turned off.The function returns a 2D NumPy array containing
ypixels
rows, each ofxpixels
pixels wide (see alsogetRenderInfo()
). If plane is specified, the results are stored in that 2D NumPy instance, which must have the same dimensions.Each pixel is sub-sampled
sqrt(subSamples)
times in x- and y- direction, to be able to roughly approximate the integration that’s needed over the surface area of a pixel.Note that a call to only imshow. will plot the 0,0 value in plane (the bottom-left value) as the top-left corner causing the result to appear mirrored in the y-direction (the y-axis will point down). A subsequent call to invert_yaxis might be useful.
- segment(plane, threshold=0.0)
For the image plane plane that was rendered using
renderImages()
, this function looks at all the pixels that have a value larger than threshold. These pixels are divided into regions that are coherent, and a list of these regions is returned. Each region is itself a list of 2D coordinates describing the centers of the pixels.
- traceBetaApproximately(beta)
Estimates the image plane positions to which the source plane position beta corresponds. Returns a list of 2D points.
- traceTheta(thetas)
For each theta position in thetas, calculate the corresponding position in the source plane. Note that this is all calculated using a single processor core, no speedup using e.g. OpenMP will be performed.
- traceThetaApproximately(thetas)
Use the already calculated theta/beta mapping (image plane position to source plane positions), to estimate the mapping for theta vectors that have not been calculated exactly.
- exception grale.multiplane.MultiLensPlaneException
An exception that’s generated when something goes wrong in the classes in this module.