The Simulation Model¶
Usage¶
Setters to be used to configure the lens and the simulator
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 imageOther image getters
getSource()getActual()getApparent()
Other parameter getters (used in CosmoSimPy)
getXi()getTrueXi()getNu()
Attributes¶
Private variables in
SimulatorModeleta() is the actual position of the source in the source plane.setters
SimulatorModel::setXYorSimulatorModel::setPolarthese should be called by the user interface
RaytraceModel uses a local corresponding to the pixel currently being evaluated, but this is local to that single method.
nu() is the apparent position of the source in the source plane.setter
SimulatorModel::setNu()this also sets
referenceXiandetaOffset
updateApparentAbs()calculates and callssetNu().To calculate for a given ,
Lens::getXi()is used.
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 usereferenceXito refer to the reference point around which the roulettes are expanded.This is updated by
SimulatorModel::setNu, as .setter
setXi()this also sets
etaOffset
etaOffset() is so that is the image of ; i.e.This is protected and accessed in
RouletteRegenerator
Consistency¶
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.First it calls
lens->updatePsi(im.size())to make sure the lens is consistentThen it sets the apparent position using as calculated by
lens->getXi()Overriding subclasses:
RotatedModelwhere the image is rotated for calculationRouletteRegeneratorwhere it does nothing
updateApparentAbsis only called byupdate()below.
updaterecalculates the distorted imagecalculateAlphaBetacalculates the roulete amplitudes if required.In most classes, this is empty and does nothing.
In
RouletteModel(but notRouletteRegenerator) it callslens->calculateAlphaBetato compute the amplitudes.It is called only from the
distort()method which is never overridden.
The Update Procedure¶
The
update()function is non-virtual; there are two update procedures that need to be overriddenupdateApparentAbs()which is called byupdate()calculateAlphaBeta()which is called bydistort()
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 usesgetDistortedPos()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 ofRotatedModel()and byRouletteModel(). All of these classes have been designed using the roulette co-ordinate system.getDistortedPos(r,theta)calculates the source plane position in the local co-ordinate system centred ateta, given a polar co-ordinates centred on\xiin the lens plane.etaOffsetis added to the output to compensate if is not the apparent position
This could possibly be simplified
SimulatorModel flowchart¶
Technical Design¶
Components¶
C++ components¶
Simulation Models
SimulatorModel.cppis the abstract base class.Modular Lens Models
RouletteModel.cppRaytrace.cpp
Semi-Modular Models using
RotatedModel.cppas a superclass. It overrides functions to rotate the image and make all calculations assuming the source placed on the -axis. The subclasses overridegetDistortedPos()to hardcode the actual distortion, and thus assume a specific lens model, but they still delegategetXi()to a Lens Object.PointMassExact.cppsimulates the point mass model using the exact formulationPointMassRoulette.cppsimulates the point mass model using the Roulette formalism
Monolithic Lens/Simulation Models
RouletteRegenerator.cppis for simulation from roulette amplitudes without any concrete lens model.
Lens Models
SIS.cppSIE.cppPointMass.cppis incomplete and so far used only with theRotateModelmodels.
Source Models
Source.cppis the abstract base class.SphericalSource.cppis standard Guassian modelEllipsoidSource.cppis an ellipsoid Guassian modelTriangleSource.cppis a three colour triangle source, intended for debugging
simaux.cppis auxiliary functionsCosmoSim.cppdefines theCosmoSimPyclass with python bindigs. This class operates as a facade to the library, and does not expose the individual classes.
Python Components¶
CosmoSimis a wrapper aroundCosmoSimPyfromCosmoSim.cpp, defining theCosmoSimclass.CosmoGUIis a tkinter desktop application, providing a GUI to the simulatorCosmoSim.Viewis a tkinter widget displaying the source and distorted image forCosmoGUI.CosmoSim.Controlleris a tkinter widget to interactively set the simulator parameters forCosmoGUI.CosmoSim.Imageprovides post-processing functions for the images.datagen.pyis a batch script to generate distorted images.
Simulator Model Class¶
Virtual Functions¶
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 and 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 and .
Getters¶
Getters are provided for the three images.
getActual()getApparent()getDistorted()
Update¶
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()anddistort()which runs the main steps in parallel.drawParallel()anddrawSource()which draws the source image.