GLAMERDOC++
Gravitational Lensing Code Library
Functions
ImageFinding Namespace Reference

The ImageFinding namespace is for functions related to finding and mapping images. More...

Functions

void find_images_kist (LensHndl lens, PosType *y_source, PosType r_source, GridHndl grid, int *Nimages, std::vector< ImageInfo > &imageinfo, unsigned long *Nimagepoints, PosType initial_size, bool splitimages, short edge_refinement, bool verbose=false)
 Finds images given a source position and size. More...
 
void find_images_microlens (LensHndl lens, double *y_source, double r_source, GridHndl grid, int *Nimages, std::vector< ImageInfo > &imageinfo, unsigned long *Nimagepoints, double initial_size, double mu_min, bool splitimages, short edge_refinement, bool verbose)
 Finds images given a source position and size. More...
 
void find_images_microlens_exper (LensHndl lens, PosType *y_source, PosType r_source, GridHndl grid, int *Nimages, std::vector< ImageInfo > &imageinfo, unsigned long *Nimagepoints, PosType initial_size, PosType mu_min, bool splitimages, short edge_refinement, bool verbose)
 experimental version of find_image_microlens() More...
 
void image_finder_kist (LensHndl lens, PosType *y_source, PosType r_source, GridHndl grid, int *Nimages, std::vector< ImageInfo > &imageinfo, unsigned long *Nimagepoints, short splitparities, short true_images)
 Finds images for a given source position and size. Not meant for high level user. More...
 
void find_crit (LensHndl lens, GridHndl grid, std::vector< CriticalCurve > &crtcurve, int *Ncrits, double resolution, double invmag_min=0.0, bool verbose=false, bool test=false)
 Finds critical curves and caustics. More...
 
void find_crit (Lens &lens, GridMap &gridmap, std::vector< CriticalCurve > &crtcurves, bool verbose=false)
 
CritType find_pseudo (ImageInfo &pseudocurve, ImageInfo &negimage, PosType pseudolimit, LensHndl lens, GridHndl grid, PosType resolution, Kist< Point > &paritypoints, bool TEST=false)
 
void find_contour (LensHndl lens, GridHndl grid, std::vector< CriticalCurve > &contour, int *Ncrits, PosType resolution, bool *orderingsuccess, bool ordercurve, bool dividecurves, double contour_value, LensingVariable contour_type, bool verbose=false)
 Finds iso kappa contours. More...
 
void printCriticalCurves (std::string filename, const std::vector< ImageFinding::CriticalCurve > &critcurves)
 
PixelMap mapCriticalCurves (const std::vector< ImageFinding::CriticalCurve > &critcurves, int Nx)
 Makes an image of the critical curves. The map will encompose all curves found. The pixel values are the caustic type + 1 ( 2=radial,3=tangential,4=pseudo ) More...
 
PixelMap mapCausticCurves (const std::vector< ImageFinding::CriticalCurve > &critcurves, int Nx)
 Makes an image of the caustic curves. The map will encompose all curves found. The pixel values are the caustic type + 1 ( 2=radial,3=tangential,4=pseudo ) More...
 
void map_images (LensHndl lens, Source *source, GridHndl grid, int *Nimages, std::vector< ImageInfo > &imageinfo, double xmax, double xmin, double initial_size, ExitCriterion criterion, bool FindCenter, bool divide_images)
 
void map_images_fixedgrid (Source *source, GridHndl grid, int *Nimages, std::vector< ImageInfo > &imageinfo, double xmax, bool divide_images, bool find_borders)
 Find the images without any additional grid refinement or ray shooting. More...
 
void map_imagesISOP (LensHndl lens, Source *source, GridHndl grid, int *Nimages, std::vector< ImageInfo > &imageinfo, double rmax, double res_min, double initial_size, ExitCriterion criterion, bool divide_images, bool int_on=true, bool verbos=false)
 Find images and refine them based on their surface brightness distribution. More...
 
short find_peaks (LensHndl lens, GridHndl grid, PosType rEinsteinMin, PosType kappa_max, std::vector< ImageInfo > &imageinfo, int *Nimages)
 Refines the grid based on the convergence so that high density regions have high resolution. More...
 

Detailed Description

The ImageFinding namespace is for functions related to finding and mapping images.

Function Documentation

◆ find_contour()

void ImageFinding::find_contour ( LensHndl  lens,
GridHndl  grid,
std::vector< CriticalCurve > &  crtcurve,
int *  Ncrits,
PosType  resolution,
bool *  orderingsuccess,
bool  ordercurve,
bool  dividecurves,
double  contour_value,
LensingVariable  contour_type,
bool  verbose = false 
)

Finds iso kappa contours.

Finding

Parameters
lensThe lens model.
gridThe grid. It must be initialized.
crtcurveStructure to hold critical curve. Must be pre-allocated with maxNcrit elements. Stored in critcurve[i].imagekist.
NcritsThe number of critical curves found.
resolutionThe target resolution that the critical curve is mapped on the image plane.
orderingsuccesstrue if ordering was successful.
ordercurveOrder the curve so that it can be drawn or used to find the winding number.
dividecurvesDivide the critical curves into seporate curves by whether they are attached
contour_valuevalue at which the contour is wanted
contour_typeKAPPA, INVMAG or DELAYT

◆ find_crit() [1/2]

void ImageFinding::find_crit ( Lens lens,
GridMap gridmap,
std::vector< CriticalCurve > &  critcurves,
bool  verbose = false 
)
Parameters
lensThe lens model.
gridmapThe grid. It must be initialized.
critcurvesStructure to hold critical curve.

◆ find_crit() [2/2]

void ImageFinding::find_crit ( LensHndl  lens,
GridHndl  grid,
std::vector< CriticalCurve > &  crtcurve,
int *  Ncrits,
double  resolution,
double  invmag_min = 0.0,
bool  verbose = false,
bool  TEST = false 
)

Finds critical curves and caustics.

Finding

The critical curve is found by refining the edges of regions of negative magnification. If there are no regions of negative magnification in the original grid the grid is refined around the point of highest kappa. If there are other points of high kappa that are not of interest one should be careful that the region of interest is not missed. For this reason critical curves that are smaller than the grid resolution (could be un-uniform) are not guaranteed to be found.

After the borders of the negative regions are found the code looks for radial and pseudo caustics within the island. It usually finds at least one, but if there are more than one per island some might be missed.

All the critical curve / caustic pairs are classified as radial, tangential or pseudo. small enough radial critical curve could be miss classified as a pseudo caustic.

Structure to hold critical curve. Must be pre-

make some figures

make some figures

make some figures

make some figures

Parameters
lensThe lens model.
gridThe grid. It must be initialized.
crtcurveStructure to hold critical curve.
NcritsThe number of critical curves found.
resolutionThe target resolution that the critical curve is mapped on the image plane.
invmag_minfinds regions with 1/magnification < invmag_min, set to zero for caustics

◆ find_images_kist()

void ImageFinding::find_images_kist ( LensHndl  lens,
PosType *  y_source,
PosType  r_source,
GridHndl  grid,
int *  Nimages,
std::vector< ImageInfo > &  imageinfo,
unsigned long *  Nimagepoints,
PosType  initial_size,
bool  splitimages,
short  edge_refinement,
bool  verbose = false 
)

Finds images given a source position and size.

Finding

find_images_kist returns finite refined images in images[0...*Nimages-1].imagekist It starts with a large source and reduces down to the right size refining at each step. It should not miss any image larger than ~ munin*r_source linear size, but seems to do much better than that. It does nothing with the surface brightnesses.

The routine can follow three different strategies for refining each image controlled by edge_refinement.

edge_refinement

  • 0 does not do edge refinement, Every pixel in every image is refined until the criterion is met. The image(s) are found again after each refinement which can make it slower.
  • 1 uses refine_edge(). After an initial refinement of all the pixels in the image(s) the code switches to refining only the edges of the images. The images are found after each refinement.
  • 2 uses refine_edge2() Same as 1, but the images are not found after each refinement. This can make the
  • any other number does no additional refinement after telescoping routine run much faster, but has the disadvantage that the number of images will not change during the final stage of refinement. This is the setting generally recommended.
Parameters
y_sourcecontains the lens/es and source/sources position of source center
r_sourceradius of source
gridgrid provided to routine
Nimagesnumber of images found
imageinfoinformation on each image
Nimagepointsnumber of points in final images
initial_sizeInitial size of source for telescoping, 0 to start from the initial grid size.
splitimagestrue each image is refined to target accuracy, otherwise all images are treated as one
edge_refinementsee comment
verboseverbose

◆ find_images_microlens()

void ImageFinding::find_images_microlens ( LensHndl  lens,
double *  y_source,
double  r_source,
GridHndl  grid,
int *  Nimages,
std::vector< ImageInfo > &  imageinfo,
unsigned long *  Nimagepoints,
double  initial_size,
double  mu_min,
bool  splitimages,
short  edge_refinement,
bool  verbose 
)

Finds images given a source position and size.

Finding

ImageFinding::find_images_kist returns finite refined images in images[0...*Nimages-1].imagekist It starts with a large source and reduces down to the right size refining at each step. It should not miss any image larger than ~ munin*r_source linear size, but seems to do much better than that. It does nothing with the surface brightnesses.

The routine can follow three different strategies for refining each image controlled by edge_refinement.

edge_refinement

  • 0 does not do edge refinement, Every pixel in every image is refined until the criterion is met. The image(s) are found again after each refinement which can make it slower.
  • 1 uses refine_edge(). After an initial refinement of all the pixels in the image(s) the code switches to refining only the edges of the images. The images are found after each refinement.
  • 2 uses refine_edge2() Same as 1, but the images are not found after each refinement. This can make the routine run much faster, but has the disadvantage that the number of images will not change during the final stage of refinement. This is the setting generally recommended.

When finding a finite sized source these quantities are generally not required and slow down the routine.

Parameters
y_sourcecontains the lens/es and source/sources position of source center
r_sourceradius of source
gridgrid provided to routine
Nimagesnumber of images found
imageinfoinformation on each image
Nimagepointsnumber of points in final images
initial_sizeInitial size of source for telescoping, 0 to start from the initial grid size.
splitimagestrue each image is refined to target accuracy, otherwise all images are treated as one
edge_refinementsee comment
verboseverbose

◆ find_images_microlens_exper()

void ImageFinding::find_images_microlens_exper ( LensHndl  lens,
PosType *  y_source,
PosType  r_source,
GridHndl  grid,
int *  Nimages,
std::vector< ImageInfo > &  imageinfo,
unsigned long *  Nimagepoints,
PosType  initial_size,
PosType  mu_min,
bool  splitimages,
short  edge_refinement,
bool  verbose 
)

experimental version of find_image_microlens()

Parameters
y_sourcecontains the lens/es and source/sources position of source center
r_sourceradius of source
gridgrid provided to routine
Nimagesnumber of images found
imageinfoinformation on each image
Nimagepointsnumber of points in final images
initial_sizeInitial size of source for telescoping, 0 to start from the initial grid size.
splitimagesTRUE each image is refined to target accuracy, otherwise all images are treated as one
edge_refinementsee comment
verboseverbose

◆ find_peaks()

short ImageFinding::find_peaks ( LensHndl  lens,
GridHndl  grid,
PosType  rEinsteinMin,
PosType  kappa_max,
std::vector< ImageInfo > &  imageinfo,
int *  Nimages 
)

Refines the grid based on the convergence so that high density regions have high resolution.

Finding

No source is used in this process. The code acts as if all the mass is in SIS halos iteratively increasing the resolution and kappa threshhold until the desired resolution is found.

Parameters
lensLens model
gridGrid to be refined. It must be initialized.
rEinsteinMinthe Einstein radius of the smallest lens that should be resolved, sets resolution target
kappa_maxhighest kappa to be refined to, 1 or 2 is probably good enough
imageinfothe image
Nimagesnumber of peaks

◆ find_pseudo()

CritType ImageFinding::find_pseudo ( ImageInfo pseudocurve,
ImageInfo negimage,
PosType  pseudolimit,
LensHndl  lens,
GridHndl  grid,
PosType  resolution,
Kist< Point > &  paritypoints,
bool  TEST = false 
)

remove all but the points below tmp_pseudolimit

◆ image_finder_kist()

void ImageFinding::image_finder_kist ( LensHndl  lens,
PosType *  y_source,
PosType  r_source,
GridHndl  grid,
int *  Nimages,
std::vector< ImageInfo > &  imageinfo,
unsigned long *  Nimagepoints,
short  splitparities,
short  true_images 
)

Finds images for a given source position and size. Not meant for high level user.

image points are put into imageinfo[].imagekist imageinfo[].points and imageinfo[].Npoints are not changed

splitparities= 0 don't split attached negative and positive parity images = 1 do split parities NOTE: this is now obsolete = -1 doesn't slit into images at all , also does not find borders or change in_image markers true_images = 1 gives just the points that are in the image = 0 if there are not enough points in images this will include close points to be refined

side-effects : Will make in_image = true for all image points if splitparities == 0

< >

◆ map_images_fixedgrid()

void ImageFinding::map_images_fixedgrid ( Source source,
GridHndl  grid,
int *  Nimages,
std::vector< ImageInfo > &  imageinfo,
double  xmax,
bool  divide_images,
bool  find_borders 
)

Find the images without any additional grid refinement or ray shooting.

Finding The images and surface brighnesses are found. This will be much faster than map_images(), but will miss images that are not resolved on the current grid.

The surface brightnesses on all of the grid are refreshed. The images centroids and gridranges are maintained.

Parameters
gridTree of grid points
Nimagesnumber of images found
imageinfoinformation on each image
xmaxMaximum size of source on image plane. The entire source must be within this distance from source->getTheta()[]. Decreasing it will make the code run faster. Making xmax much bigger than the grid boundaries will check all points for surface brightness.
divide_imagesif true will divide images.
find_bordersif true will find the inner and outer borders of each image

◆ map_imagesISOP()

void ImageFinding::map_imagesISOP ( LensHndl  lens,
Source source,
GridHndl  grid,
int *  Nimages,
std::vector< ImageInfo > &  imageinfo,
double  rmax,
double  res_min,
double  initial_size,
ExitCriterion  criterion,
bool  divide_images,
bool  int_on = true,
bool  verbose = false 
)

Find images and refine them based on their surface brightness distribution.

Finding Uses ImageFinding::find_images_kist() to initially find and refine images and then using IF_routines::IntegrateFluxInCell(). If cells cannot be integrated refiments are madebased on a surface brightness based criterion to refine the most important parts of the lens.

map_images is intended for mapping images of sources more complicated than simple circles.

Parameters
lensmodel
gridTree of grid points
Nimagesnumber of images found
imageinfoinformation on each image
rmaxMaximum size of source on souce plane. The entire source must be within this distance from source->getTheta()[]
res_minrequred resolution of image, typically the pixel size of the final image
initial_sizeInitial size of source for telescoping, 0 to start from the initial grid size. If < 0 no telescoping is used and only the already existing points are used to to initiate the image finding.
criterionsee data type
divide_imagesif true will divide images and apply the exit criterion to them separately.
int_onif true the flux in each cell is integrated, if false the surface brightness at the center point of the cell is used

◆ mapCausticCurves()

PixelMap ImageFinding::mapCausticCurves ( const std::vector< ImageFinding::CriticalCurve > &  critcurves,
int  Nx 
)

Makes an image of the caustic curves. The map will encompose all curves found. The pixel values are the caustic type + 1 ( 2=radial,3=tangential,4=pseudo )

Parameters
critcurveslist of critical curves
Nxnumber of pixels to each size

◆ mapCriticalCurves()

PixelMap ImageFinding::mapCriticalCurves ( const std::vector< ImageFinding::CriticalCurve > &  critcurves,
int  Nx 
)

Makes an image of the critical curves. The map will encompose all curves found. The pixel values are the caustic type + 1 ( 2=radial,3=tangential,4=pseudo )

Parameters
critcurveslist of critical curves
Nxnumber of pixels to each size