Computation of the Roulette Amplitudes

The reference points are calculated in the following order
- $\eta$ is the actual source position as given by the problem.
- $\xi$ is the apparent position in the lens plane.
This is calculated by inverting the ratrace equation.
- $\nu=\xi/\chi$ is the apparent position in the source plane.
- $\nu’$ 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.
- $\xi’=\chi\nu$ scales the centre point back to the lens plane.
- $\eta’$ is the source point corresponding to $\xi’$ 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.
updateApparentAbs()
calculates inferred parameters when all
input parameters have been set.
- It calls
lens-<updatePsi()
to make the lens consistent
- it gets $\xi$ (
referenceXi
) from lens->getXi(
$\chi\eta$)
getXi()
is implemented differently in
- The superclass
Lens
, using raytrace logic
\xi = \chi\eta + \nabla\psi(\chi\eta)
SampledLens
which uses fix point iteration
PointMass
, but this needs review (TODO)
RouletteRegenerator: Simulation from Roulette Amplitudes

To make the reconstruction work, we need the following geometrical
points.
- $\xi$ 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.
- $\nu’=\xi’/\chi$ 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
).
- $\eta$ and $\eta’$ are the source position corresponding respectively
to $\xi$ and $\xi’$.
- $\eta$ is input to the original simulation, but it cannot be recovered
without knowledge of $\xi$
- $\eta’$ is computed from $\xi’$ using raytracing.
- $\Delta\eta=\eta’-\eta$ is the difference between the centre of the source
($\eta$) and the reference point $\eta’$ corresponding to the centre of the
roulette convergence ring.
It is calculated by
LensModel::getOffset
$(\nu’)$
and stored in the CSV output from datagen.py
as (offsetX
,offsetY
).
- $\eta’’=\eta-\nu’$ is the source position ($\eta$) in the co-ordinate system
centred at $\nu’$. This is calculated by
LensModel::getRelativeEta
$(\nu’)$,
and stored in the CSV output from datagen.py
as
(reletaX
,reletaY
).
Note that $\eta$ and $\eta’$ are defined in the source plane and $\xi$ and $\xi’$
in the lens plane. Working in the source image, which is also in scale with the
images, we have $\nu=\xi/\chi$ and $\nu’=\xi’/\chi$.
Generate the Roulette Data Set
The datagen.py
script generates the data set.
- Normal image generation
- Centre the image and record the image centre $\nu’=\xi’/\chi$.
- Find $\xi’=\chi\nu’$
- Find the roulette amplitudes in $\xi’$ using
getAlpha
and getBeta
- Get $\eta’’$ from
getRelativeEta()
- Get $\Delta\eta$ from
getOffset()
- Write CSV
- original data
- $\eta’’$
- $\Delta\eta$
- amplitudes
Reconstruction from the Roulette Data Set
Reconstruction is different from the regular roulette simulation.
Both $\xi$ and $\eta$ are set explicitly and the lens location is unknown.
In theory the lens location could be inferred, but as a free variable it leaves
$\xi$ and $\eta$ to be set independently.
This is implemented in RouletteRegenerator
which does not use a separate lens
model.
- The
setCentre()
method will
- $\nu := 0$ (centre of distorted image); consequently $\xi=0$
- Set $\eta := \eta’’$ as read from the CSV file.
- set the
etaOffset
to $\Delta\eta$ as read from the CSV file
- The roulette amplitudes are set using
setAlphaXi
and setBetaXi
.
- Now the simulation can be run using standard methods inherited from
LensModel
and RouletteModel
.
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 $\eta$ as stored in the model object itself, and requests a $\xi$ to be
calculated by the Lens object.
- then it calls
setNu()
which is inherited from LensModel
- this also sets
etaOffset = 0
setXi(xi1)
- set $\xi$ to the given value
- calculate $\eta’$ corresponding to $\xi$ using raytrace
- set $\Delta\eta=\eta’-\eta$
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, if maskMode
is 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?