swagnercarena / paltas

Conduct simulation-based inference on strong gravitational lensing systems.
MIT License
13 stars 12 forks source link

Galaxy generation from COSMOS catalog #1

Closed JelleAalbers closed 3 years ago

JelleAalbers commented 3 years ago

This adds:

You can use this as follows:

import manada

cosmos_folder = '/path/to/COSMOS_23.5_training_sample'

catalog = manada.Sources.cosmos.COSMOSCatalog(cosmos_folder, cosmology='planck18')

for kwargs in catalog.iter_lightmodel_kwargs_samples(
        n_galaxies=42, z_new=4, min_mag=22, min_size_in_pixels=64):
    # ... Lenstronomy code here

A basic test for the generic GalaxyCatalog is included. However,

JelleAalbers commented 3 years ago

After taking out the spurious luminosity-distance scaling, this now produces arguments that cause lenstronomy to return the original image, in the same units/scale, in a setup with no lensing and the same pixel size. I added a notebook test_sources.ipynb as an example.

Note in particular that you have to call light_model.delete_interpol_caches() every time a new image is set. Much of my confusion was because I did not do this, and it seemed no change to the image had any effect at all...

sibirrer commented 3 years ago

After taking out the spurious luminosity-distance scaling, this now produces arguments that cause lenstronomy to return the original image, in the same units/scale, in a setup with no lensing and the same pixel size. I added a notebook test_sources.ipynb as an example.

Note in particular that you have to call light_model.delete_interpol_caches() every time a new image is set. Much of my confusion was because I did not do this, and it seemed no change to the image had any effect at all...

Sorry to hear that this caused confusion. Are you sure that if you are using the 'scale' argument within the kwargs_source to scale the image, you can not use the same interpolation multiple times at different scales, orientation and locations?

swagnercarena commented 3 years ago

@JelleAalbers and @swagnercarena both think the merge looks good. Deleting the branch