glenco / SLsimLib

Library for Gravitational Lensing Simulations
MIT License
2 stars 1 forks source link

Added Grid::AddSurfaceBrightness() and GridMap::AddSurfaceBrightness() #151

Closed rbmetcalf closed 5 years ago

rbmetcalf commented 5 years ago

@DarthLazar you might find these new functions useful. They allow you to add multiple sources to a Grid or GridMap. They way I did it before was to have a single source added to the grid, output to a PixelMap and then use Grid::RefreshSurfaceBrightness to replace the source on the grid then add it to the PixelMap again. I think this will be a more intuitive way of doing it. Add as many sources as you want and then output to a PixelMap.

Grid(Map)::ClearSurfaceBrightness() clears add sources from the Grid.

rbmetcalf commented 5 years ago

This is a small change that should work.

alexandres-lazar commented 5 years ago

@rbmetcalf Thanks for this.

Can you perhaps provide an example code, perhaps with the context of the script found in the ParticleExample directory? I'm having a lot of trouble navigating through the documentation and writing a script to produce the critical curves and the actual images our where I place several bright sources:

Arbitrarily positioning several sources (at redshifts z1=0.8, z2=2.0, z3=6.0?) relative to the center of the host lens (given by the simulated dm particle data).

rbmetcalf commented 5 years ago

Hi @DarthLazar . Here is some code. It puts two sources in at the same redshift and another to represent a lens galaxy that is not lensed.

    COSMOLOGY cosmo(Planck18);
    long seed = 10283;

    // construct lens mass
    LensHaloRealNSIE nsie(1.0e12,0.3,300, 0, 0.3, 0, 0);

    // construct lens
    Lens lens(&seed,3);

    // insert halo into lens
    lens.insertMainHalo(nsie,true);

    Point_2d center;

    // add 2 sources at  z = 1
    lens.ResetSourcePlane(1.0);
    GridMap gridmap(&lens,500,center.x,300*arcsecTOradians);
    {
      SourceSersic source(25, 0.1, 45*degreesTOradians, 2, 0.5, 0.3);
      source.setTheta(0,0);  // set postion of source on source plane
      gridmap.AddSurfaceBrightnesses(&source);
    }
    {
      SourceSersic source(26, 0.1, 90*degreesTOradians, 1, 0.5, 0.3);
      source.setTheta(arcsecTOradians ,0);  // set postion of source on source plane
      gridmap.AddSurfaceBrightnesses(&source);
    }

    PixelMap pmap = gridmap.getPixelMap(1);

    // add a source that is not lensed
    SourceSersic source(24, 0.1, 0*degreesTOradians, 4, 0.5, 0.3);
    source.setTheta(0,0);  // set postion of source on source plane
    pmap.AddSource(source);

    pmap.printFITS("!testimage.fits");
rbmetcalf commented 5 years ago

If you want to put another lensed source in at a different redshift you need to reset the source plane in the lens and then construct a new Grid or GridMap with it.