Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Implementation

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.

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.

Here ξ\xi' is the origin of the new co-ordinate system, so that xi? and releta? are ν\nu and η\eta in the the new frame.

The (offsetX,offsetY) pair places referenceXi. It is the difference between the actual source position η\eta and the source position corresponding to observed position ξ\xi' (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.