grale.contourfinder
This module defines a ContourFinder
class, with which
you can look for specific contour levels in a NumPy grid. This code
is used to look for critical lines for example, as the contour where
the inverse magnification is zero. It can also be used to search for
specific contour levels in the mass map of a gravitational lens.
- class grale.contourfinder.ContourFinder
After initialization with a specific grid, you can use the
findContour()
member function to calculate a specific contour.- __init__(values, bottomleft, topright)
Initializes the instance so that a specific grid is used to look for contours.
Arguments:
values: a 2D NumPy grid of values, which will be interpreted as a height map.
bottomLeft: the value at [0,0] in values will correspond to this (X,Y) coordinate.
topRight: if the shape of values is (Ny, Nx), then this is the (X,Y) coordinate of the pixel [Ny-1, Nx-1]
- findContour(level)
Within the height map as specified during initialization, look for the contours that correspond to the height level. As several distinct lines may be found, the function returns a list of lists, where the second list contains the consecutive coordinates of a part of the contour.
- findMultipleContours(levels, numThreads=-1)
Similar to
findContour()
, but for several levels. If numThreads is positive, this is the amount of contours that will be calculated in parallel, speeding things up if you have multiple cores. If set to 0 or a negative value, the number of threads will be set to the value detected by the multiprocessing.cpucount function.
- exception grale.contourfinder.ContourFinderException
An exception that will be raised if something goes wrong when looking for a contour.