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 (Source *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 (Source *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
 
RAY ray (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)
 
template<typename T >
PixelMap< T > writePixelMap (LensingVariable lensvar)
 make pixel map of lensing quantities at the resolution of the GridMap More...
 
template<typename T >
void writeFits (LensingVariable lensvar, std::string filensame, bool flipX=false)
 fits output of lensing quantities at the resolution of the GridMap More...
 
template<typename T >
void writePixelMapUniform (PixelMap< T > &map, LensingVariable lensvar, bool flipX=false)
 
template<typename T >
void writeFitsUniform (const PosType center[], size_t Nx, size_t Ny, LensingVariable lensvar, std::string filename, bool flipX=false)
 
template<typename T >
PixelMap< T > writePixelMapUniform (const PosType center[], size_t Nx, size_t Ny, LensingVariable lensvar)
 Make a Pixel map of the without distribution the pixels. More...
 
template<typename T >
void writeFitsUniform (LensingVariable lensvar, std::string filename, bool xflip=false)
 this will make a fits map of the grid as is. More...
 
template<typename T >
PixelMap< T > getPixelMapFlux () const
 returns a PixelMap with the flux in pixels at a resolution of res times the original resolution More...
 
template<typename T >
void getPixelMapFlux (PixelMap< T > &map) const
 Flux in pixels 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 () const
 
Point * operator[] (size_t i)
 
 GridMap (GridMap &&grid)
 
 GridMap (GridMap &grid)
 
GridMap & operator= (GridMap &&grid)
 
bool touch (const Rectangle &tr1, const Rectangle &tr2) const
 
std::vector< Rectangle > merge_boxes (std::list< Triangle > &triangles) const
 
std::vector< Rectangle > merge_boxes (std::vector< Triangle > &triangles) const
 
std::list< RAY > find_images (std::vector< Point_2d > &ys, std::vector< int > &multiplicity) const
 Returns a list of RAYs from a set of source positions. More...
 
void find_images (Point_2d y, std::vector< Point_2d > &image_points, std::vector< Triangle > &triangles) const
 Find all images by triangle method. More...
 
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...
 
Point_2d 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...
 
void find_magnification_contour (std::vector< std::vector< Point_2d > > &curves, std::vector< bool > &hits_boundary, double invmag)
 Find image-plane contours of magnification.
This is usually only used within ImageFinding:: functions where it will also find the contours on the source plane.
 
void border_area (double &source_area, double &image_area) const
 Returns the area in square radians within the border of the GridMap on both the source and image planes. More...
 
int getNx ()
 
int getNy ()
 

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 ( Source *  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

◆ border_area()

void GridMap::border_area ( double &  source_area,
double &  image_area 
) const

Returns the area in square radians within the border of the GridMap on both the source and image planes.

NOTE : That that this uses points that are on the border of the image plane which is a rectangle. These points on the source plane are not necessarily the boundary of all points on the source plane, i.e. some source points can be outside of this border.

◆ 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 more reliable than find_caustics() when no radial caustic is found.

This uses the triangle method to determine 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() [1/2]

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

Find all images by triangle method.

No new rays are shot so the accuracy is limited to the resolution of the GridMap.

See also Lens::find_images()

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

◆ find_images() [2/2]

std::list< RAY > GridMap::find_images ( std::vector< Point_2d > &  ys,
std::vector< int > &  multiplicity 
) const

Returns a list of RAYs from a set of source positions.

The image positions are found in parallel by the triangle method. The order of the output rays will be the same as the sources with multiple images consecutive. The number of images for each source position is given by the multiplicity array.

No new rays are shot. The image positions and magnification matrix are interpolated from the nearest image points already in the GridMap.

See also Lens::find_images()

◆ getPixelMapFlux() [1/2]

template<typename T >
PixelMap< T > GridMap::getPixelMapFlux

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]

template<typename T >
void GridMap::getPixelMapFlux ( PixelMap< T > &  map) const

Flux in pixels map.

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

◆ magnificationFlux()

Point_2d GridMap::magnificationFlux ( Source &  source) const

Calculate two estimates of the magnification of a source.

Flux in the images that are outside of the grid region is not included in the magnification.

The first estimate is the ratio of the flux of the lensed images on the grid to the flux of the unlensed source taken from the source object.

The second one is the ratio of the flux of the lensed images on the grid to the flux of the unlensed source evaluated at each point on the grid. If the unlensed source position is outside of the grid region

◆ 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 ( Source *  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()

template<typename T >
void GridMap::writeFits ( LensingVariable  lensvar,
std::string  filename,
bool  xflip = false 
)

fits output of lensing quantities at the resolution of the GridMap

Parameters
lensvarwhich quantity is to be displayed
filenameoutput files
xflipflip the x axis

◆ writeFitsUniform() [1/2]

template<typename T >
void GridMap::writeFitsUniform ( const PosType  center[],
size_t  Nx,
size_t  Ny,
LensingVariable  lensvar,
std::string  filename,
bool  xflip = false 
)
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
xflipflip the x axis

◆ writeFitsUniform() [2/2]

template<typename T >
void GridMap::writeFitsUniform ( LensingVariable  lensvar,
std::string  filename,
bool  xflip = false 
)
inline

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

Parameters
lensvarquantity to be output
filenamename of output fits file
xflipflip the x axis

◆ writePixelMap()

template<typename T >
PixelMap< T > 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]

template<typename T >
PixelMap< T > 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]

template<typename T >
void GridMap::writePixelMapUniform ( PixelMap< T > &  map,
LensingVariable  lensvar,
bool  flipX = false 
)
Parameters
lensvarwhich quantity is to be displayed
flipXflip the x axis

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