Creating mock lens samples

In recent theory projects I have often worked with samples of mock lenses produced by some given mass distribution. Gravlens has several tools for automatically generating mock lens samples.

Fixed number of sources (mock1)

The basic idea is to place sources randomly and uniformly behind the lens and solve the lens equation for each. If we are primarily interested in multiply-imaged systems, we want to place sources inside the caustic(s). The code finds the smallest circle enclosing the caustic(s), and distributes some number of sources in that region. One approach is to choose a certain number of sources to distribute, without regard to the size of the caustic. This can be done with the mock1 command. This example shows how to do it for two galaxies with different masses.

set omitcore = 1.0e-4
set plotmode = 2
set gridhi1 = 5.0
set ngrid1 = 50
set ngrid2 = 50
set seed = -21
#
setlens 1 1
  alpha 1.0 0 0 0.3 0 0.1 25.0 0 0 1
  0 0 0 0 0 0 0 0 0 0
plotcrit mock1a.crit
mock1 mock1a.dat 200 2
#
setlens 1 1
  alpha 0.5 0 0 0.3 0 0.1 25.0 0 0 1
  0 0 0 0 0 0 0 0 0 0
plotcrit mock1b.crit
mock1 mock1b.dat 200 2
#
quit

Notice the seed variable. This is a negative integer that seeds the random number generator. You can obtain independent realizations by choosing different seeds.

Here are the resulting mock lenses, shown in the image (left) and source (right) planes. The lenses are color coded so doubles are blue while quads are red. First, here is case "a" with the more massive galaxy.

Here is case "b" with the less massive galaxy. Notice that everything looks much the same, just scaled down in length by a factor of 2.

Here are the summary statistics for case "a". Column 2 gives the number of mock lenses with each image configuration. (Since the sources are distributed in a circle circumscribing the caustics, there are some singly-imaged sources. They are not plotted above.) Column 3 gives the cross sectional area inferred from the number of lenses. Column 4 gives an estimate of the biased cross section, using the magnification bias parameters specified in the mock1 command (in this case, the default values).

Nimg #lenses area B*area
0 0 0.000000e+00 0.000000e+00
1 28 4.983966e-01 1.235791e+00
2 159 2.830180e+00 8.720656e+00
3 0 0.000000e+00 0.000000e+00
4 13 2.313984e-01 3.563755e+00
5 0 0.000000e+00 0.000000e+00
6 0 0.000000e+00 0.000000e+00
7 0 0.000000e+00 0.000000e+00
8 0 0.000000e+00 0.000000e+00
9 0 0.000000e+00 0.000000e+00
10 0 0.000000e+00 0.000000e+00
11 0 0.000000e+00 0.000000e+00

Click here for the full data file showing all the mock lenses.


Fixed density of sources (mock2)

In other cases we may want the number of sources to scale with the size of the caustic region, but fixing the number density of sources. This can be done with the mock2 command.

set omitcore = 1.0e-4
set plotmode = 2
set gridhi1 = 5.0
set ngrid1 = 50
set ngrid2 = 50
set seed = -21
#
setlens 1 1
  alpha 1.0 0 0 0.3 0 0.1 25.0 0 0 1
  0 0 0 0 0 0 0 0 0 0
plotcrit mock2a.crit
mock2 mock2a.dat 60 2
#
setlens 1 1
  alpha 0.5 0 0 0.3 0 0.1 25.0 0 0 1
  0 0 0 0 0 0 0 0 0 0
plotcrit mock2b.crit
mock2 mock2b.dat 60 2
#
quit

Here are the results for the more massive galaxy.

And here are the results for the less massive galaxy.

Now you see that the smaller galaxy is not as well sampled as the bigger galaxy.


mock1 vs. mock2

To summarize, if you are most interested in the cross sections of individual galaxies, you probably want the same fractional precision for every galaxy. In this case you should use the same number of sources for each galaxy with mock1.

By contrast, if you want to produce a set of mock lenses in which different galaxies are represented according to their cross sections, you want to use a fixed density of sources with mock2.


Creating data for lensmodel (mock3)

The mock1 and mock2 commands write a file containing all the lenses. However, if you plan to model the lenses, you can have the code automatically produce lensmodel data files using the mock3 command.

set omega = 0.3
set lambda = 0.7
set hval = 0.7
set zsrc = 2.0
set zlens = 0.3
#
set omitcore = 1.0e-4
set plotmode = 2
set gridhi1 = 5.0
set ngrid1 = 50
set ngrid2 = 50
set seed = -21
#
setlens 1 1
  alpha 1.0 0 0 0.3 0 0.1 25.0 0 0 1
  0 0 0 0 0 0 0 0 0 0
mock3 mock3/mock3 100 -0.003 -0.003 -0.05 0.0
#
quit

The arguments indicate the size of the errorbars for the: galaxy position, image positions, image fluxes (fractional uncertainty), and image time delays. If the errorbars are negative the code will just take the amplitude and use it as the errorbar in the lensmodel data file. However, if the errorbars are positive the code will add random Gaussian noise before writing the data.

Here are sample results: