The Roulette Formalism¶
Computation of the Roulette Amplitudes¶
The reference points are calculated in the following order
is the actual source position as given by the problem.
is the apparent position in the lens plane. This is calculated by inverting the ratrace equation.
is the apparent position in the source plane.
is the centre of light in the distorted image. This is calculated from the output image, and it serves as an objective reference point which can be recalculated from the image regardless of shifts and cropping.
scales the centre point back to the lens plane.
is the source point corresponding to according to the raytrace equation. In principle, any simulator model can compute this, but raytrace is most efficient and there is no reason not to use this.
RouletteModel: Forward Simulation in the Roulette Formalism¶
updateApparentAbs()calculates inferred parameters when all input parameters have been set.It calls
lens-<updatePsi()to make the lens consistentit gets (
referenceXi) fromlens->getXi()
getXi()is implemented differently inThe superclass
Lens, using raytrace logic\xi = \chi\eta + \nabla\psi(\chi\eta)
SampledLenswhich uses fix point iterationPointMass, but this needs review (TODO)
RouletteRegenerator: Simulation from Roulette Amplitudes¶
To make the reconstruction work, we need the following geometrical points.
is the apparent position and the reference point for the roulette model in the original formulation. Unfortunately it cannot easily be recovered from a distorted image.
is the centre of luminence in the distorted image, and can be recovered from the image. Thus this will be used as the reference point and the centre of the image in the regeneration. This is stored in the CSV file as (
centreX,centreY).and are the source position corresponding respectively to and .
is input to the original simulation, but it cannot be recovered without knowledge of
is computed from using raytracing.
is the difference between the centre of the source () and the reference point corresponding to the centre of the roulette convergence ring. It is calculated by
LensModel::getOffsetand stored in the CSV output fromdatagen.pyas (offsetX,offsetY).is the source position () in the co-ordinate system centred at . This is calculated by
LensModel::getRelativeEta, and stored in the CSV output fromdatagen.pyas (reletaX,reletaY).
Concepts in the original co-ordinate system centred at the lens.
| Concept (Ray) | Lens Plane | Source Plane | Data file |
|---|---|---|---|
| Apparent source position | |||
| Actual source position | () | ||
| Centre of light | (centreX,centreY) | ||
| Source of Centre of light | () | ||
| Offset | (offsetX,offsetY) |
Concepts in the image co-ordinate system. We assume here that the image has been centred at . If the image is not centred, then for the purpose of calculation.
| Concept (Ray) | Image Plane | Data file |
| :- | :- | :- | :- |
| Apparent source position | | (xiX,xiY) |
| Actual source position | | (reletaX,reletaY) |
Note that and are defined in the source plane and and in the lens plane. Working in the source image, which is also in scale with the images, we have and .
Generate the Roulette Data Set¶
The datagen.py script generates the data set.
Normal image generation
Centre the image and record the image centre .
Find
Find the roulette amplitudes in using
getAlphaandgetBetaGet from
getRelativeEta()Get from
getOffset()Write CSV
original data
amplitudes
Reconstruction from the Roulette Data Set¶
Reconstruction is different from the regular roulette simulation.
Both and are set explicitly and the lens location is unknown.
In theory the lens location could be inferred, but as a free variable it leaves
and to be set independently.
This is implemented in RouletteRegenerator which does not use a separate lens
model.
The
setCentre()method will(centre of distorted image); consequently
Set as read from the CSV file.
set the
etaOffsetto as read from the CSV file
The roulette amplitudes are set using
setAlphaXiandsetBetaXi.Now the simulation can be run using standard methods inherited from
LensModelandRouletteModel.
Functions¶
Masking methods
setLens()getDistortedPos(r,theta)The
distort()function is inherited from LensModel.It uses
etaOffset+getDistortedPos(r,theta)to find the source pixel
updateApparentAbs()uses as stored in the model object itself, and requests a to be calculated by the Lens object.
then it calls
setNu()which is inherited from LensModelthis also sets
etaOffset = 0
setXi(xi1)set to the given value
calculate corresponding to using raytrace
set
Special for resimulation from roulette amplitudes:
setXiEta()to be implemented
Masking¶
Masking is important for the Roulette Simulator, because computation is expensive. The current code is wrangled with technical debt, and masking is done twice.
For Roulette Models, the
distort()function only calculates pixels inside the convergence ring, ifmaskModeis set. This speeds up calculation.The
maskImage()functions allows masking after calculation. It takes an optional scale parameter, and the radius of the mask is scale times the radius of the convergence ring.RouletteRegenerator has a default masking radius of zero, but the radius can be explicitly set with
setMaskRadius(), which will give masking as for other Roulette Models.Raytrace does not mask during computation, but
maskImage()works as it does for Roulette Models. This is done to facilitate comparison between Raytrace and Roulette, and the mask is only meaningful in relation to Roulette.
TODO¶
When are the roulette amplitudes calculated?