GLAMERDOC++
Gravitational Lensing Code Library
|
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. | |
GridMap (LensHndl lens, unsigned long Nx, const PosType center[2], PosType rangeX, PosType rangeY) | |
Constructor for initializing rectangular grid. | |
GridMap (unsigned long N1d, const double center[2], double range) | |
this makes a dumy GridMap that has no lensing | |
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. | |
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. | |
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) | |
template<typename T > | |
PixelMap< T > | writePixelMap (LensingVariable lensvar) |
make pixel map of lensing quantities at the resolution of the GridMap | |
template<typename T > | |
void | writeFits (LensingVariable lensvar, std::string filensame) |
fits output of lensing quantities at the resolution of the GridMap | |
template<typename T > | |
void | writePixelMapUniform (PixelMap< T > &map, LensingVariable lensvar) |
template<typename T > | |
void | writeFitsUniform (const PosType center[], size_t Nx, size_t Ny, LensingVariable lensvar, std::string filename) |
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. | |
template<typename T > | |
void | writeFitsUniform (LensingVariable lensvar, std::string filename) |
this will make a fits map of the grid as is. | |
template<typename T > | |
PixelMap< T > | getPixelMapFlux (int res) const |
returns a PixelMap with the flux in pixels at a resolution of res times the original resolution | |
template<typename T > | |
void | getPixelMapFlux (PixelMap< T > &map) const |
Flux in pixels map. | |
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 | |
Point_2d | getCenter () |
Point * | operator[] (size_t i) |
GridMap (GridMap &&grid) | |
GridMap (GridMap &grid) | |
GridMap & | operator= (GridMap &&grid) |
std::list< RAY > | find_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 | |
PosType | magnificationFlux (Source &source) const |
double | magnificationTr () const |
calculate the LOCAL magnification by triangel method weighted by interpolated surface brightness | |
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 | |
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() | |
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. | |
Friends | |
class | Lens |
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
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.
lens | lens model for initializing grid |
N1d | Initial number of grid points in each dimension. |
center | Center of grid. |
range | Full width of grid in whatever units will be used. |
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.
lens | lens model for initializing grid |
Nx | Initial number of grid points in X dimension. |
my_center | Center of grid. |
rangeX | Full width of grid in x direction in whatever units will be used. |
rangeY | Full width of grid in y direction in whatever units will be used. |
GridMap::GridMap | ( | unsigned long | N1d, |
const double | center[2], | ||
double | range ) |
this makes a dumy GridMap that has no lensing
N1d | Initial number of grid points in each dimension. |
center | Center of grid. |
range | Full width of grid in whatever units will be used. |
Oversample some pixels where the usrface brightness is not smooth and update surface brighnesses to be the average inside the pixel.
May be slow.
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.
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
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,
|
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.
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.
void GridMap::find_images | ( | Point_2d | y, |
std::vector< Point_2d > & | image_points, | ||
std::vector< Triangle > & | triangles ) const |
find all images by triangle method
image_points | positions of the images limited by resolution of the gridmap |
triangles | index's of the points that form the triangles that the images are in |
PixelMap< T > GridMap::getPixelMapFlux | ( | int | res | ) | const |
void GridMap::getPixelMapFlux | ( | PixelMap< T > & | map | ) | const |
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
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).
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
void GridMap::writeFits | ( | LensingVariable | lensvar, |
std::string | filename ) |
fits output of lensing quantities at the resolution of the GridMap
lensvar | which quantity is to be displayed |
filename | output files |
void GridMap::writeFitsUniform | ( | const PosType | center[], |
size_t | Nx, | ||
size_t | Ny, | ||
LensingVariable | lensvar, | ||
std::string | filename ) |
center | center of image |
Nx | number of pixels in image in on dimension |
Ny | number of pixels in image in on dimension |
lensvar | which quantity is to be displayed |
filename | file name for image – .kappa.fits, .gamma1.fits, etc will be appended |
|
inline |
this will make a fits map of the grid as is.
lensvar | quantity to be output |
filename | name of output fits file |
PixelMap< T > GridMap::writePixelMap | ( | LensingVariable | lensvar | ) |
make pixel map of lensing quantities at the resolution of the GridMap
lensvar | which quantity is to be displayed |
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.
center | center of image |
Nx | number of pixels in image in on dimension |
Ny | number of pixels in image in on dimension |
lensvar | which quantity is to be displayed |
void GridMap::writePixelMapUniform | ( | PixelMap< T > & | map, |
LensingVariable | lensvar ) |
lensvar | which quantity is to be displayed |