One of the critical challenges in CosmoSim is to represent the lens potential and to compute the distortion in both the raytrace model and the roulette model.
Notation in the Implementation¶
While the implementation aims to stay true to the mathematical models, the notation sometimes differs. Some discrepancies are part of the technical debt, where the code has not been updated to match evolving notation. Other discrepancies are due to ambiguities, reused symbols, and subscripts which are hard to represent in ASCII. We will try to define the mapping between the two systems of notation.
alphaandbetarefer to the roulette amplitudes.The actual source position is denoted
etain the C++ code.the value is retrieved as
SimulatorModel::getEta().
einsteinrationrefers to the Einstein radius .thetarefers to the rotation of an elliptic source.
The actual position is denoted
nuusing angular co-ordinates, we identify and with , and variables and functions are not consistently named.
nuis computed byLens::getXi()(which may be overridden) as a function ofeta().
referenceXiis the point in which the roulette amplitudes are computed.In the standard mode of operation, this is equal to
nu(), but it is possible to set it arbitrarily.
xiis often used as a local variable, referring to an observed point where the light intensity is being computed. It is not fixed point in the model.
Coordinate system¶
Applying machine learning, it is important to view the coordinate system as arbitrary. If, say, the lens is fixed at origin, information is leaked. For this reason, the images are translated to have the origin at the centre of visible light.
As a consequence, CosmoSim has to consider at least two co-ordinate
systems: one for calculation and one for presentation.
The critical points in the simulator are
,
referenceXiwhich is the reference point for the roulett formalism. This is normally equal to , but may be set arbitrarily.The lens position which defaults to the origin
The CSV outfile gives
centreX,centreY()reletaX,reletaY()xiX,xiY(xioffsetinternally):offsetX,offsetY()
Here is the origin of the new co-ordinate system, so that
xi? and releta? are and in the the new frame.
The (offsetX,offsetY) pair places referenceXi.
It is the difference between the actual source position and the
source position corresponding to observed position (relativeXi).
This is used in the distort() function in the simulator to get light
from the right pixel in the source image.
Image coordinates¶
It is important to note that images are indexed as matrices, and not with standard Cartesian co-ordinates. The distortion models are implemented in Cartesian co-ordinates, following the mathematical model, and needs to be converted to image co-ordinates whenever images are references.
This looks like this:
xi = pointCoordinate( cv::Point2d( row, col ), dst ) ;
ij = imageCoordinate( xi, src ) ;Here xi is the geometric point corresponding to index (row,col)
in the image array, and ij is the index (row,col).
Both image and Cartesian co-ordinates are represented as cv::Point2d
objects.
The second arguments src and dst are the images to which the co-ordinates
refer. In reality, only the size of these images is relevant, but it is
important because the origin of the Cartesian system is the centre of the image
and not the corner.