GLAMERDOC++
Gravitational Lensing Code Library
Public Member Functions | Friends | List of all members
GridMap Struct Reference

A simplified version of the Grid structure for making non-adaptive maps of the lensing quantities (kappa, gamma, etc...) More...

#include <gridmap.h>

Public Member Functions

 GridMap (LensHndl lens, unsigned long N1d, const double center[2], double range)
 Constructor for initializing square grid. More...
 
 GridMap (LensHndl lens, unsigned long Nx, const PosType center[2], PosType rangeX, PosType rangeY)
 Constructor for initializing rectangular grid. More...
 
 GridMap (unsigned long N1d, const double center[2], double range)
 this makes a dumy GridMap that has no lensing More...
 
GridMap ReInitialize (LensHndl lens)
 reshoot the rays for example when the source plane has been changed
 
void deLens ()
 resets to state without lensing
 
double RefreshSurfaceBrightnesses (SourceHndl source)
 Recalculate surface brightness at every point without changing the positions of the gridmap or any lens properties. More...
 
double AdaptiveRefreshSurfaceBrightnesses (Lens &lens, Source &source)
 
double AddSurfaceBrightnesses (SourceHndl source)
 Recalculate surface brightness just like GridMap::RefreshSurfaceBrightness but the new source is added to any sources that were already there. More...
 
Point_2d image_point (size_t index)
 get the image point for a index number
 
Point_2d source_point (size_t index)
 get the image point for a index number
 
void ClearSurfaceBrightnesses ()
 
void assertNAN ()
 
size_t getNumberOfPoints () const
 
int getInitNgrid () const
 return initial number of grid points in each direction
 
double getXRange () const
 return initial range of gridded region. This is the distance from the first ray in a row to the last (unlike PixelMap)
 
double getYRange () const
 
double getResolution () const
 resolution in radians, this is range / (N-1)
 
PixelMap writePixelMap (LensingVariable lensvar)
 make pixel map of lensing quantities at the resolution of the GridMap More...
 
void writeFits (LensingVariable lensvar, std::string filensame)
 fits output of lensing quantities at the resolution of the GridMap More...
 
void writePixelMapUniform (PixelMap &map, LensingVariable lensvar)
 
void writeFitsUniform (const PosType center[], size_t Nx, size_t Ny, LensingVariable lensvar, std::string filename)
 
PixelMap writePixelMapUniform (const PosType center[], size_t Nx, size_t Ny, LensingVariable lensvar)
 Make a Pixel map of the without distribution the pixels. More...
 
void writeFitsUniform (LensingVariable lensvar, std::string filename)
 this will make a fits map of the grid as is. More...
 
PixelMap getPixelMapFlux (int res) const
 returns a PixelMap with the flux in pixels at a resolution of res times the original resolution More...
 
void getPixelMapFlux (PixelMap &map) const
 surface brightness map More...
 
PosType EinsteinArea () const
 returns the area (radians^2) of the region with negative magnification at resolution of fixed grid
 
Point_2d centroid () const
 returns centroid of flux on the grid More...
 
Point_2d getCenter ()
 
Pointoperator[] (size_t i)
 
 GridMap (GridMap &&grid)
 
 GridMap (GridMap &grid)
 
GridMapoperator= (GridMap &&grid)
 
std::list< RAYfind_images (std::vector< Point_2d > &ys, std::vector< int > &multiplicity) const
 
void find_images (Point_2d y, std::vector< Point_2d > &image_points, std::vector< Triangle > &triangles) const
 
void find_boundaries_of_caustics (std::vector< std::vector< Point_2d > > &boundaries, std::vector< bool > &hits_edge)
 finds the boundary of the region on the source plane where there are more than one image More...
 
PosType magnificationFlux (Source &source) const
 
double magnificationTr () const
 calculate the LOCAL magnification by triangel method weighted by interpolated surface brightness More...
 
double magnificationTr (std::vector< size_t > &pixels) const
 Same as magnificationTr() but for a limited number of cells. Problematic when cell is intersected by critical curve.
 
double AreaCellOnSourcePlane (size_t k) const
 area of a cell (pixel size region with its lower left at point k) on source plane - calculated by triangal method
 
double AddPointSource (const Point_2d &y, double flux)
 add flux to the rays that are nearest to the source on the source plane for each image More...
 
void find_crit (std::vector< std::vector< Point_2d > > &points, std::vector< bool > &hits_boundary, std::vector< CritType > &crit_type)
 Find critical curves. This is usually not used outside of ImageFinding::find_crit() More...
 

Friends

class Lens
 

Detailed Description

A simplified version of the Grid structure for making non-adaptive maps of the lensing quantities (kappa, gamma, etc...)

GripMap is faster and uses less memory than Grid. It does not construct the tree structures for the points and thus cannot be used for adaptive mapping or image finding.

The distance between the left (lower) most and right (upper) most ray is range so the resolution is range/(N-1). The lower left pixel is at center[]-0.5*range and the upper right is at center[]+0.5*range

Constructor & Destructor Documentation

◆ GridMap() [1/3]

GridMap::GridMap ( LensHndl  lens,
unsigned long  N1d,
const double  center[2],
double  range 
)

Constructor for initializing square grid.

Note: Deflection solver must be specified before creating a GridMap.

Parameters
lenslens model for initializing grid
N1dInitial number of grid points in each dimension.
centerCenter of grid.
rangeFull width of grid in whatever units will be used.

◆ GridMap() [2/3]

GridMap::GridMap ( LensHndl  lens,
unsigned long  Nx,
const PosType  my_center[2],
PosType  rangeX,
PosType  rangeY 
)

Constructor for initializing rectangular grid.

Cells of grid will always be square with initial resolution rangeX/(Nx-1). The Y range may not be exactly rangeY, but will be the nearest value that is a whole number of cells.

Note: Deflection solver must be specified before creating a GridMap.

Parameters
lenslens model for initializing grid
NxInitial number of grid points in X dimension.
my_centerCenter of grid.
rangeXFull width of grid in x direction in whatever units will be used.
rangeYFull width of grid in y direction in whatever units will be used.

◆ GridMap() [3/3]

GridMap::GridMap ( unsigned long  N1d,
const double  center[2],
double  range 
)

this makes a dumy GridMap that has no lensing

Parameters
N1dInitial number of grid points in each dimension.
centerCenter of grid.
rangeFull width of grid in whatever units will be used.

Member Function Documentation

◆ AdaptiveRefreshSurfaceBrightnesses()

double GridMap::AdaptiveRefreshSurfaceBrightnesses ( Lens lens,
Source source 
)

Oversample some pixels where the usrface brightness is not smooth and update surface brighnesses to be the average inside the pixel.

May be slow.

◆ AddPointSource()

double GridMap::AddPointSource ( const Point_2d y,
double  flux 
)

add flux to the rays that are nearest to the source on the source plane for each image

This uses GridMap::find_images to find the images. It then finds the point that is closest to the source position. The flux is added to one point per image. The total flux added is returned. No further refinement of the grid is done so it is limited by the resolution of the GridMap. Some spurious low magnification images can be found.

◆ AddSurfaceBrightnesses()

double GridMap::AddSurfaceBrightnesses ( SourceHndl  source)

Recalculate surface brightness just like GridMap::RefreshSurfaceBrightness but the new source is added to any sources that were already there.

returns total flux from the new source

◆ centroid()

Point_2d GridMap::centroid ( ) const

returns centroid of flux on the grid

flux weighted local magnification with current surface brightness averaged on the image plane,

◆ find_boundaries_of_caustics()

void GridMap::find_boundaries_of_caustics ( std::vector< std::vector< Point_2d > > &  boundaries,
std::vector< bool > &  hits_edge 
)
inline

finds the boundary of the region on the source plane where there are more than one image

Warning : slow but perhaps reliable than find_caustics() when no radial caustic is found.

This uses the triangle method to determin which points in a source plane grid of the same size and resolution as the image plane grid have multiple images. This boundary will surround all caustics unlike for GridMap::find_crit.

This should not be as susceptible to missing the radial caustic because of resolution in the image plane.

◆ find_crit()

void GridMap::find_crit ( std::vector< std::vector< Point_2d > > &  points,
std::vector< bool > &  hits_boundary,
std::vector< CritType > &  crit_type 
)

Find critical curves. This is usually not used outside of ImageFinding::find_crit()

This will find all the resolved tangential and radial critical curves. If a radial critical curve is not found within a tangential one, curves around the maxima are used to estimate a radial or pseudo caustic. These are labeled CritType::pseudo. The out put is ordered so that the radia/pseudo curves within a tangent curve imediately follow it.

◆ find_images()

void GridMap::find_images ( Point_2d  y,
std::vector< Point_2d > &  image_points,
std::vector< Triangle > &  triangles 
) const

find all images by triangle method

Parameters
image_pointspositions of the images limited by resolution of the gridmap
trianglesindex's of the points that form the triangles that the images are in

◆ getPixelMapFlux() [1/2]

PixelMap GridMap::getPixelMapFlux ( int  res) const

returns a PixelMap with the flux in pixels at a resolution of res times the original resolution

Output a PixelMap of the surface brightness with same res as the GridMap.

◆ getPixelMapFlux() [2/2]

void GridMap::getPixelMapFlux ( PixelMap map) const

surface brightness map

update a PixelMap with the flux in pixels at a resolution of res times the original resolution. The map must have precisely the right size and center to match or an exception will be thrown. Constructing the map with PixelMap getPixelMapFlux(int res) will insure that it does.

◆ magnificationFlux()

PosType GridMap::magnificationFlux ( Source source) const

Calculate the magnification of one source by adding up its flux for the lensed image and an image made on an unlensed regulare grid

◆ magnificationTr()

double GridMap::magnificationTr ( ) const

calculate the LOCAL magnification by triangel method weighted by interpolated surface brightness

This is done by finding the area of every half cell triangle on the source plane and multiplying by the surface bightness interpolated to the center of the triangle on the image plane. This does not use the point-wise magnification calculated by the rayshooter beacuse this can be highly unstable.

NOTE: This will not equal the ratio of the lensed flux to the unlensed flux except in the case of one image (assuming the source is well resolved).

◆ RefreshSurfaceBrightnesses()

double GridMap::RefreshSurfaceBrightnesses ( SourceHndl  source)

Recalculate surface brightness at every point without changing the positions of the gridmap or any lens properties.

Recalculate the surface brightness at all points on the gridmap. This is useful when changing the source model while preserving changes in the grid. Both i_tree and s_tree are both changed although only s_tree shows up here.

returns the sum of the surface brightnesses

◆ writeFits()

void GridMap::writeFits ( LensingVariable  lensvar,
std::string  filename 
)

fits output of lensing quantities at the resolution of the GridMap

Parameters
lensvarwhich quantity is to be displayed
filenameoutput files

◆ writeFitsUniform() [1/2]

void GridMap::writeFitsUniform ( const PosType  center[],
size_t  Nx,
size_t  Ny,
LensingVariable  lensvar,
std::string  filename 
)
Parameters
centercenter of image
Nxnumber of pixels in image in on dimension
Nynumber of pixels in image in on dimension
lensvarwhich quantity is to be displayed
filenamefile name for image -- .kappa.fits, .gamma1.fits, etc will be appended

◆ writeFitsUniform() [2/2]

void GridMap::writeFitsUniform ( LensingVariable  lensvar,
std::string  filename 
)
inline

this will make a fits map of the grid as is.

Parameters
lensvarquantity to be output
filenamename of output fits file

◆ writePixelMap()

PixelMap GridMap::writePixelMap ( LensingVariable  lensvar)

make pixel map of lensing quantities at the resolution of the GridMap

Parameters
lensvarwhich quantity is to be displayed

◆ writePixelMapUniform() [1/2]

PixelMap GridMap::writePixelMapUniform ( const PosType  center[],
size_t  Nx,
size_t  Ny,
LensingVariable  lensvar 
)

Make a Pixel map of the without distribution the pixels.

This will be faster than Grid::writePixelMap() and Grid::writeFits(). But it puts each grid pixel in one pixelmap pixel and if there are two grid pixels in one pixelmap pixel it uses one at random. This is meant for uniform maps to make equal sized PixelMaps.

Parameters
centercenter of image
Nxnumber of pixels in image in on dimension
Nynumber of pixels in image in on dimension
lensvarwhich quantity is to be displayed

◆ writePixelMapUniform() [2/2]

void GridMap::writePixelMapUniform ( PixelMap map,
LensingVariable  lensvar 
)
Parameters
lensvarwhich quantity is to be displayed

The documentation for this struct was generated from the following files: