This page describes how to use the matlab routine invert to invert "observations" of gravitational lenses. This routine accompanies the article Inverting Gravitational Lenses by Peter R. Newbury and Raymond J. Spiteri.
The Figure below is a 128-by-128 pixel simulation showing two gravitationally lensed arcs of light. The arcs are highly distorted images of a uniformly bright, elliptical disks of light hidden behind the lens. The colour of the arcs is a measure of the magnification, with high magnification at the red end of the spectrum and low magnification at the blue end of the spectrum.
| Downloading the software | Inverting the lens | Changing the routine |
|---|
matlab>> lens('SIS2')
Use the 'w -- write image to file' command to save the observations. The observations will be stored in the data file "SIS2.mat" (in general, "parameterfile.mat") using matlab's internal data storage format.
matlab>> invert('SIS2')
The routine 'invert' reads the observation parameters (the center of the field-of-view, the size of the observation, and the size of the pixels) from the parameter file, SIS2. No, invert does not "cheat" and read the unknown model parameters...
set(gcf,'Position',[300 300 800 400]);
which generates a 800-by-400 pixel figure window starting 300 pixels over and 300 pixels up from the bottom left of the screen. The Figure window should have a 2:1 width:height ratio to best display the graphics.
matlab>> invert('SIS2')
Inverting lens
==================
Initial lens mass is sigma=600 km/s.
Left-click on the observations for the initial
location of the lens centre.
Move the centre of the SIS with the n, e, s, w keys.
Use +/- keys to increase/decrease lens mass.
Press q to quit.
Left-click on the observations plot to locate the center of the SIS. If you've played with the forward modeling routine lens, you'll recognize the circular symmetry of these lenses. A good initial guess is some point on the diagonal between the two lensed arcs, closer to the small arc. For example, left-click near the point (2.0,2.0).
Each pixel in the observations is traced back to the source plane (via the lens equation) and marked with a dot. Then the ellipse with the smallest area which encloses all the points is found. This ellipse is drawn in magenta in both Figures. As well, the Einstein Ring of the SIS lens is drawn in red over the observations.
Current misfit = ###.######
Note: previous versions of invert use the up, right, down, left arrow keys on the number pad. This was changed when we tried, painfully, to run invert on a laptop with an embedded numpad.+ / - Increase or decrease the mass parameter of the SIS, in increments of 50 km/s. (This can be changed in the code for finer adjustment.)
After each keystroke, a computation is performed and the two Figures will be updated and the new value for the misfit will be displayed in the matlab console.
For the example described in the article, first press the '+' to increase the mass from 600 km/s up to 750 km/s (3 keystrokes). You'll notice a big drop in the misfit. Then move the mass center towards (2.5,1.4), which will "fine-tune" the solution.
...
Current misfit = 3.722799
Solution:
Information about deflector:
Lens centre ( 2.563, 1.373)
SIS mass, sigma=750.000
Information about the source:
Source centre ( 0.997, 0.301)
Source semi-major axis a= 1.978
Source semi-minor axis b= 0.599
Source ellipticity e=1-b/a=0.697
Source orientation phi=119.7
Your results may be slightly different than these because of differences in the initial guess in Step 3.