CosmoSim is a simulator for gravitational lensing.
setLens()
- lens parameters are set in the lens objectsetCentred()
setMaskMode()
setBGColour()
setXY()
setPolar()
setCHI()
setNterms()
setSource()
update()
has to be called to recalculate the imagegetDistorted()
returns the distorted imagegetSource()
getActual()
getApparent()
getXi()
getTrueXi()
getNu()
SimulatorModel
eta
($\eta$) is the actual position of the source in the source plane.
SimulatorModel::setXY
or SimulatorModel::setPolar
nu
($\nu$) is the apparent position of the source in the source plane.
SimulatorModel::setNu(
$\nu$)
referenceXi
and etaOffset
updateApparentAbs()
calculates $\nu$ and calls setNu(
$\nu$)
.Lens::getXi(
$\chi\eta$)
is
used.xi
($\xi$) refers to a reference point in the lens plane.
It appears in many local scopes, typically referring to the point
being calculated.
In the Roulette Model, we use referenceXi
to refer to the reference
point around which the roulettes are expanded.
SimulatorModel::setNu
, as $\xi=\chi\nu$.setXi()
etaOffset
etaOffset
($\Delta\eta$) is so that $\xi$ is the image of
$\eta+\Delta\eta$; i.e. $\Delta\eta=\xi/\chi-\eta$
RouletteRegenerator
It is important to note that the setters do not ensure a consistent state. Hence, after setting parameters, the model must be updated to ensure consistency.
updateApparentAbs
(protected) calculates inferred variables to ensure a
consistent state.
lens->updatePsi(im.size())
to make sure the lens
is consistentlens->getXi(
$\chi\eta$ )
RotatedModel
where the image is rotated for calculationRouletteRegenerator
where it does nothingupdateApparentAbs
is only called by update()
below.update
recalculates the distorted imagecalculateAlphaBeta
calculates the roulete amplitudes if required.
RouletteModel
(but not RouletteRegenerator
) it calls
lens->calculateAlphaBeta
to compute the amplitudes.distort()
method which is never overridden.update()
function is non-virtual; there are two update procedures
that need to be overridden
updateApparentAbs()
which is called by update()
calculateAlphaBeta()
which is called by distort()
getDistorted()
calculates the distorted image.
It is also non-virtual, and there are two approaches to override its
behaviour.
distort()
calculates the distorted image. By default it uses
getDistortedPos()
which works in the local co-ordinate system
of the roulette formalism.
The RaytraceModel overrides it, because it relies on global
positioning.getDistortedPos()
is provided by the subclasses of RotatedModel()
and by RouletteModel()
. All of these classes have been designed
using the roulette co-ordinate system.
getDistortedPos(r,theta)
calculates the source plane position $\eta’$
in the local co-ordinate system centred at eta
, given a polar
co-ordinates $(r,\theta)$ centred on \xi
in the lens plane.etaOffset
is added to the output to compensate if $\xi$ is not
the apparent positionThis could possibly be simplified
SimulatorModel.cpp
is the abstract base class.RouletteModel.cpp
Raytrace.cpp
RotatedModel.cpp
as a superclass.
It overrides functions to rotate the image and make all calculations
assuming the source placed on the $x$-axis.
The subclasses override getDistortedPos()
to hardcode the actual
distortion, and thus assume a specific lens model, but they still
delegate getXi()
to a Lens Object.
PointMassExact.cpp
simulates the point mass model
using the exact formulationPointMassRoulette.cpp
simulates the point mass model using
the Roulette formalismRouletteRegenerator.cpp
is for simulation from roulette amplitudes
without any concrete lens model.SIS.cpp
SIE.cpp
PointMass.cpp
is incomplete and so far used only with the RotateModel
models.Source.cpp
is the abstract base class.SphericalSource.cpp
is standard Guassian modelEllipsoidSource.cpp
is an ellipsoid Guassian modelTriangleSource.cpp
is a three colour triangle source,
intended for debuggingsimaux.cpp
is auxiliary functionsCosmoSim.cpp
defines the CosmoSimPy
class with python bindigs.
This class operates as a facade to the library, and does not
expose the individual classes.CosmoSim
is a wrapper around CosmoSimPy
from CosmoSim.cpp
,
defining the CosmoSim
class.CosmoGUI
is a tkinter desktop application, providing a GUI to the
simulatorCosmoSim.View
is a tkinter widget displaying the source and
distorted image for CosmoGUI
.CosmoSim.Controller
is a tkinter widget to interactively set
the simulator parameters for CosmoGUI
.CosmoSim.Image
provides post-processing functions for the images.datagen.py
is a batch script to generate distorted images.The following virtual functions have to be overridden by most subclasses. They are called from the main update function and overriding them, the entire lens model changes.
calculateAlphaBeta()
pre-calculates $\alpha$ and $\beta$ in the distortion equation.getDistortedPos()
calculates the distortion equation for a give pixel.The constructor typically has to be overridden as well, to load the formulæ for $\alpha$ and $\beta$.
Getters are provided for the three images.
getActual()
getApparent()
getDistorted()
The main routine of the Simulator
is update()
which recalculates the
three images: actual, apparent, and distorted. This is called by the setters.
In addition to the virtual functions mentioned above, it depends on
parallelDistort()
and distort()
which runs the main steps in parallel.drawParallel()
and drawSource()
which draws the source image.