Jammy2211 / autolens_workspace

The PyAutoLens workspace: contains example scripts, datasets and more
https://pyautolens.readthedocs.io/
24 stars 16 forks source link

Problem whit pointsource model #12

Closed felavila closed 2 years ago

felavila commented 3 years ago

Hello, i have a problem whit a point source model for a double lens system B0218+357(https://lweb.cfa.harvard.edu/castles/Individual/B0218.html), the problem come whit the resulting Einstein ring because the program estimate a Einstein ring of 6.4arcsec when the distance between image it more or less 0.3arcsec, maybe the problem is just the program need more points to make a good model, but for others doubles it works pretty fine, so i didn't understand the main reason. I also stay making a something like a check of the results using a lenstronomy SIE. I am using these parameters in the estimation, shape_native=(25,25), pixel_scales=(0.05, 0.05)) positions_solver = al.PositionsSolver(grid=grid, pixel_scale_precision=0.0025), and using a point_0=al.ps.PointFlux My other idea is try to reduce the posible extension of the lens like a new constrain, something like maximum 1 in Einstein ring but truly i dont know how to do dat. I hope not beginning rude whit my basic English but i asked these whit the mayor respect i can. Cheers Felipe

Jammy2211 commented 3 years ago

Can you send me the positions of the data you are giving autolens? Will experiment myself to see the issue.

felavila commented 3 years ago

Sure, here is the .json file i am using for these system. thank you for your quick response. ####### [ { "name": "point_0", "positions": [ [ -0.046, -0.178 ], [ 0.08, 0.129

        ]
    ],
    "positions_noise_map": [
        0.003,
        0.003
    ],
    "fluxes": [
            21.83,
            19.39
    ],
    "fluxes_noise_map": [
        0.5,
        0.5
    ]
}

]

Jammy2211 commented 3 years ago

Using your code set up I get the following solution (which is probably similar to yours):

Bayesian Evidence                                                                         -27.05803404
Maximum Log Likelihood                                                                    -6.84013730
Maximum Log Posterior                                                                     982871.73624649

model                                                                                     CollectionPriorModel (N=8)
    galaxies                                                                              CollectionPriorModel (N=8)
        lens                                                                              Galaxy (N=5)
            mass                                                                          EllIsothermal (N=5)
        source                                                                            Galaxy (N=3)
            point_0                                                                       PointFlux (N=3)

Maximum Log Likelihood Model:

galaxies
    lens
        mass
            centre
                centre_0                                                                  0.022
                centre_1                                                                  -0.013
            elliptical_comps
                elliptical_comps_0                                                        0.477
                elliptical_comps_1                                                        0.540
            einstein_radius                                                               7.781
    source
        point_0
            centre
                centre_0                                                                  -0.377
                centre_1                                                                  -0.138
            flux                                                                          1446.910

Summary (3.0 sigma limits):

galaxies
    lens
        mass
            centre
                centre_0                                                                  0.0230 (-0.0032, 0.0310)
                centre_1                                                                  -0.0268 (-0.0862, -0.0054)
            elliptical_comps
                elliptical_comps_0                                                        0.4894 (0.3905, 0.5901)
                elliptical_comps_1                                                        0.5309 (0.4167, 0.6288)
            einstein_radius                                                               6.9427 (5.1333, 7.9642)
    source
        point_0
            centre
                centre_0                                                                  -0.0778 (-0.4557, 0.3000)
                centre_1                                                                  -0.1050 (-0.6086, 0.5265)
            flux                                                                          1.2657e+03 (9.7967e+02, 1.5164e+03)

Summary (1.0 sigma limits):

galaxies
    lens
        mass
            centre
                centre_0                                                                  0.0230 (0.0198, 0.0256)
                centre_1                                                                  -0.0268 (-0.0355, -0.0188)
            elliptical_comps
                elliptical_comps_0                                                        0.4894 (0.4478, 0.5394)
                elliptical_comps_1                                                        0.5309 (0.4871, 0.5786)
            einstein_radius                                                               6.9427 (6.0465, 7.5745)
    source
        point_0
            centre
                centre_0                                                                  -0.0778 (-0.1999, 0.0681)
                centre_1                                                                  -0.1050 (-0.2327, 0.0470)
            flux                                                                          1.2657e+03 (1.1086e+03, 1.3834e+03)

instances

galaxies
    lens
        redshift                                                                          0.5
    source
        redshift                                                                          1.0

I can force the einstein_radius to be below 1.0 as you suggest by adding the following line to my code:

lens = af.Model(al.Galaxy, redshift=0.5, mass=al.mp.EllIsothermal)
source = af.Model(al.Galaxy, redshift=1.0, point_0=al.ps.PointFlux)

model = af.Collection(galaxies=af.Collection(lens=lens, source=source))

model.galaxies.lens.mass.einstein_radius = af.UniformPrior(lower_limit=0.0, upper_limit=1.0)

This gives the following solution:

Bayesian Evidence                                                                         -30.57488783
Maximum Log Likelihood                                                                    -6.83812181
Maximum Log Posterior                                                                     979020.17429459

model                                                                                     CollectionPriorModel (N=8)
    galaxies                                                                              CollectionPriorModel (N=8)
        lens                                                                              Galaxy (N=5)
            mass                                                                          EllIsothermal (N=5)
        source                                                                            Galaxy (N=3)
            point_0                                                                       PointFlux (N=3)

Maximum Log Likelihood Model:

galaxies
    lens
        mass
            centre
                centre_0                                                                  0.039
                centre_1                                                                  -0.041
            elliptical_comps
                elliptical_comps_0                                                        -0.318
                elliptical_comps_1                                                        -0.236
            einstein_radius                                                               0.175
    source
        point_0
            centre
                centre_0                                                                  0.036
                centre_1                                                                  -0.033
            flux                                                                          7.457

Summary (3.0 sigma limits):

galaxies
    lens
        mass
            centre
                centre_0                                                                  -0.0368 (-0.0432, 0.0455)
                centre_1                                                                  -0.0025 (-0.0455, 0.0056)
            elliptical_comps
                elliptical_comps_0                                                        0.2182 (-0.3620, 0.2740)
                elliptical_comps_1                                                        0.1929 (-0.2597, 0.2636)
            einstein_radius                                                               0.2291 (0.1746, 0.2476)
    source
        point_0
            centre
                centre_0                                                                  -0.0677 (-0.0854, 0.0383)
                centre_1                                                                  0.0103 (-0.0333, 0.0219)
            flux                                                                          1.0437e+01 (7.2846e+00, 1.1993e+01)

Summary (1.0 sigma limits):

galaxies
    lens
        mass
            centre
                centre_0                                                                  -0.0368 (-0.0396, -0.0304)
                centre_1                                                                  -0.0025 (-0.0060, 0.0006)
            elliptical_comps
                elliptical_comps_0                                                        0.2182 (0.1595, 0.2372)
                elliptical_comps_1                                                        0.1929 (0.1551, 0.2133)
            einstein_radius                                                               0.2291 (0.2195, 0.2386)
    source
        point_0
            centre
                centre_0                                                                  -0.0677 (-0.0769, -0.0568)
                centre_1                                                                  0.0103 (0.0040, 0.0164)
            flux                                                                          1.0437e+01 (8.9189e+00, 1.0884e+01)

instances

galaxies
    lens
        redshift                                                                          0.5
    source
        redshift                                                                          1.0

This will therefore give the "correct" solution.

For now, I recommend you adjust priors when the solution clear goes to an incorrect model.

Why does the model with an einstein radius of 7.781 (which is clearly incorrect) produce as good of a fit as the model with 0.2291?

I think this is due to a bug in PyAutoLens, I will look into this in more detail.

felavila commented 3 years ago

Thanks a lot for your answer, i stay alert. Cheers Felipe Avila