The idea behind roulette resimulation is to recover the roulette amplitudes and simulate the lens distortion using only the amplitudes and no other information about the lens.
The end goal is to use roulette amplitudes recovered from observed images
by machine learning, but immediate tests can be made using exact roulette
amplitudes calculated from the lens. This can be done by specifying an
output file for roulette amplitudes using datagen.py --outfile:
python3 CosmoSimPy/datagen.py --csvfile Dataset/debug.csv \
--outfile roulette.csvThe resulting CSV file (roulette.csv) can be fed to the resimulator.
Below, we will try to explain briefly how the roulette output file work. See the Roulette Formalism for a more detailed mathematical model.
There are two critical options for the simulation
--centrewhich centres the image at the centre of light after calculation. This is important in machine learning applications, to avoid leaking information through the choice of co-ordinate system.--no-xireferencewhich calculates roulette amplitudes at the centre of light in the distorted image, rather than the apparent position of the centre of the undistorted image.
This is not recommended, but the reader should be aware of its existence because it used to be the default and some of the documentation may still refer to it.
(This is under construction)
The Roulette Output file¶
The output file has most of the familiar columns from the input, giving the lens parameters. Additional it has
alpha[][],beta[][]for the roulette amplitudescentreX,centreY: Centre pointIf
--centreis not used, this is .If
--centreis used the image has been translated bycentreX,centryY; i.e. (centreX,centreY) is the coordinates of the centre of light prior to centring the image.
reletaX,reletaYis the source positionIf
--centreis not used, it is equal to (x,y)If
--centreis used, it is relative to the new origin, i.e. equal to (x-centreX,y-centreY)
offsetX,offsetYis difference between the source position corresponding to the centre pointcentreX,centryYand the actual source centre.This may only be relevant when
--no-xireferenceis used.
xiX,xiY: apparent position of the source, relative to the origincentreX,centryY.
Roulette Amplitude Recovery (roulettegen.py)¶
The purpose is to make a new CSV file, alongside the distorted images, including roulette amplitudes. This entails the following steps.
Regular simulation, generating distorted images, and other images if desired.
Centre the image, recording the centre point in the distorted image, and an image file with a shifted version.
Set in the simulator.
TODO verify
Get the roulette amplitudes from the simulator
These are not the roulette amplitudes that would have been used to produce the distorted image in a Roulette model.
It is critical that the reference point can be recovered from the image even if it has been cropped and shifted.
Write the CSV file, including all the original parameters and also the roulette amplitudes.
Note we need the source position relative to the new centre point.
Training a machine learning model on the output CSV and the centred distorted images, it should be possible to recover roulette amplitudes from unknown images.
Simulation from roulette amplitudes.¶
We need to be able to generate distorted images from tentative roulette amplitudes, knowing nothing else about the lens. We obviously need a source model though, including its position relative to the roulette reference point.