|
GLAMERDOC++
Gravitational Lensing Code Library
|
8 #ifndef _grid_maintenance_declare_
9 #define _grid_maintenance_declare_
16 #include <utilities_slsim.h>
17 #include "concave_hull.h"
19 class LensHaloBaseNSIE;
26 Grid(
LensHndl lens,
unsigned long N1d,
const double center[2],
double range);
27 Grid(
LensHndl lens ,
unsigned long Nx ,
const PosType center[2] ,PosType rangeX ,PosType rangeY);
52 ,std::vector<RAY> &images
63 double refine_on_surfacebrightness(
Lens &lens,
Source &source);
89 void writeFits(
const double center[],
size_t Nx,
size_t Ny,
double resolution,
LensingVariable lensvar,std::string filename);
101 ,std::string filename
103 template <
typename T>
105 template <
typename T>
107 template <
typename T>
111 template <
typename T>
121 template <
typename T>
124 template <
typename T>
129 template <
typename T>
136 ,std::vector<ImageInfo> &imageinfo
137 ,
unsigned long &Nimagepoints
144 ,std::vector<ImageInfo> &imageinfo
147 ,PosType initial_size
148 ,ExitCriterion criterion
154 *
this = std::move(grid);
157 Grid operator=(
Grid &grid) =
delete;
161 assert(&grid !=
this);
164 grid.i_tree =
nullptr;
166 grid.s_tree =
nullptr;
167 neighbors = grid.neighbors;
168 grid.neighbors =
nullptr;
172 Ngrid_init = grid.Ngrid_init;
173 Ngrid_init2 = grid.Ngrid_init2;
174 Ngrid_block = grid.Ngrid_block;
175 initialized = grid.initialized;
176 maglimit = grid.maglimit;
177 pointID = grid.pointID;
178 axisratio = grid.axisratio;
180 point_factory.clear();
181 point_factory=std::move(grid.point_factory);
188 PosType UnlensedFlux(
double sblimit=-1.0e12)
const;
189 PosType LensedFlux(
double sblimit=-1.0e12)
const;
197 void xygridpoints(
Point *points,
double range,
const double *center,
long Ngrid
198 ,
short remove_center);
210 Kist<Point> * neighbors;
213 bool uniform_mag_from_deflect(
double *a,
Point *point);
216 double mag_from_deflect(
Point *point)
const;
218 unsigned long pointID;
221 template <
typename T>
222 void writePixelMapUniform_(
Point *head,
size_t N
226 Point * NewPointArray(
size_t N){
227 Point * p = point_factory(N);
229 for(
size_t i=1; i < N ; ++i) p[i].head = 0;
233 static std::mutex grid_mutex;
262 critcurve = p.critcurve;
264 caustic_curve_outline = p.caustic_curve_outline;
265 caustic_curve_intersecting = p.caustic_curve_intersecting;
270 ellipse_curve = p.ellipse_curve;
273 z_source = p.z_source;
281 if(
this == &p)
return *
this;
283 critcurve = p.critcurve;
285 caustic_curve_outline = p.caustic_curve_outline;
286 caustic_curve_intersecting = p.caustic_curve_intersecting;
291 ellipse_curve = p.ellipse_curve;
294 z_source = p.z_source;
302 std::vector<RAY> critcurve;
303 std::vector<Point_2d> caustic_curve_outline;
304 std::vector<Point_2d> caustic_curve_intersecting;
305 std::vector<Point_2d> ellipse_curve;
337 return Utilities::inhull(x.x,caustic_curve_outline);
359 PosType DistSourceToCautic;
361 if(IsInCurve ==
true)
363 while(i<caustic_curve_outline.size())
365 DistSourceToCautic = sqrt((caustic_curve_outline[i].x[0] - x.x[0])*(caustic_curve_outline[i].x[0] - x.x[0]) + (caustic_curve_outline[i].x[1] - x.x[1])*(caustic_curve_outline[i].x[1] - x.x[1]));
366 if (DistSourceToCautic < sourceRadius)
return false ;
382 PosType DistSourceToCritCurve;
384 if(IsInCurve ==
true)
386 while(i<critcurve.size())
388 DistSourceToCritCurve = sqrt((critcurve[i].x[0] - x.x[0])*(critcurve[i].x[0] - x.x[0]) + (critcurve[i].x[1] - x.x[1])*(critcurve[i].x[1] - x.x[1]));
389 if (DistSourceToCritCurve < sourceRadius)
return false ;
402 ,std::vector<Point_2d> &y
414 ,std::vector<Point_2d> &y
427 ,std::vector<Point_2d> &y
429 ,PosType sourceRadius
430 ,PosType distSourceToCaustic
439 if(critcurve.size() < 2){
440 rave = rmax = rmin = 0.0;
447 for(
size_t ii=1; ii< critcurve.size(); ++ii){
451 if(rad < rmin) rmin = rad;
452 if(rad > rmax) rmax = rad;
455 rave /= critcurve.size();
459 if(caustic_curve_outline.size() < 2){
460 rave = rmax = rmin = 0.0;
464 rave = rmin = rmax = (
caustic_center - caustic_curve_outline[0]).length();
468 for(
size_t ii=1; ii< caustic_curve_outline.size(); ++ii){
472 if(rad < rmin) rmin = rad;
473 if(rad > rmax) rmax = rad;
476 rave /= caustic_curve_outline.size();
484 static void print(std::string filename,std::vector<ImageFinding::CriticalCurve> &critcurves) {
486 std::ofstream os(filename.c_str());
489 << (int)(CritType::tangential) <<
" - tangential "
490 << (int)(CritType::radial) <<
" - radial "
491 << (int)(CritType::pseudo) <<
" - pseudo"
494 << 0 <<
" - caustic "
495 << 1 <<
" - critical curve "
498 os <<
"caustic_num,plane,x,y,type" << std::endl;
502 for(
auto &curve : critcurves){
504 if(curve.type == CritType::tangential){
505 for(
Point_2d &p : curve.caustic_curve_outline){
506 os << i <<
",0," << p.x[0] - xo[0] <<
"," << p.x[1] - xo[1] <<
","<< (int)(curve.type) << std::endl;
509 for(
Point_2d &p : curve.caustic_curve_intersecting){
510 os << i <<
",0," << p.x[0] - xo[0] <<
","<< p.x[1] - xo[1] <<
","<< (int)(curve.type) << std::endl;
513 for(
RAY &p : curve.critcurve){
514 os << i <<
",1," << p.
x[0] - xo[0] <<
","<< p.
x[1] - xo[1] <<
","<< (int)(curve.type) << std::endl;
526 ,
int *Nimages,std::vector<ImageInfo> &imageinfo,
unsigned long *Nimagepoints
527 ,PosType initial_size,
bool splitimages,
short edge_refinement
528 ,
bool verbose =
false);
534 ,
int *Nimages,std::vector<ImageInfo> &imageinfo,
unsigned long *Nimagepoints
535 ,
double initial_size,
double mu_min,
bool splitimages,
short edge_refinement
539 ,
GridHndl grid,
int *Nimages,std::vector<ImageInfo> &imageinfo,
unsigned long *Nimagepoints,PosType initial_size ,PosType mu_min
540 ,
bool splitimages,
short edge_refinement,
bool verbose);
543 ,
int *Nimages,std::vector<ImageInfo> &imageinfo,
unsigned long *Nimagepoints
544 ,
short splitparities,
short true_images);
548 ,
double resolution,
double invmag_min = 0.0,
bool verbose =
false,
bool test=
false);
549 void find_crit(
Lens &lens,
GridMap &gridmap,std::vector<CriticalCurve> &crtcurves,
bool verbose =
false);
552 void find_magnification_contour(
556 ,std::vector<std::vector<RAY> > &contour
557 ,std::vector<bool> &hits_boundary
565 ,PosType resolution,Kist<Point> &paritypoints,
bool TEST=
false);
567 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);
574 PosType mindyfunc(PosType *x);
577 namespace IF_routines{
579 ,
int Nimages,
double res_target,
short criterion
580 ,Kist<Point> * newpointkist = NULL,
bool batch=
true);
583 void refine_crit_in_image(
LensHndl lens,
GridHndl grid,
double r_source,
double x_source[],
double resolution);
586 ,
unsigned long Nimages,
double res_target,
short criterion,
bool batch=
true);
589 ,
int Nimages,
double res_target,
short criterion
590 ,Kist<Point> * newpointkist = NULL,
bool batch=
true);
592 long refine_edges2(
LensHndl lens,
double *y_source,
double r_source,
GridHndl grid
593 ,
ImageInfo *imageinfo,
bool *image_overlap,
int Nimages,
double res_target
594 ,
short criterion,
bool batch=
true);
596 void sort_out_points(
Point *i_points,
ImageInfo *imageinfo,
double r_source,
double y_source[]);
600 void printCriticalCurves(std::string filename
601 ,
const std::vector<ImageFinding::CriticalCurve> &critcurves);
609 const std::vector<ImageFinding::CriticalCurve> &critcurves,
627 template <
typename T>
629 const PosType center[]
633 ,std::string filename
635 writeFits<T>(center,Npixels,Npixels,resolution,lensvar,filename);
638 template <
typename T>
640 const PosType center[]
645 ,std::string filename
655 tag =
".alpha1.fits";
658 tag =
".alpha2.fits";
667 tag =
".gamma1.fits";
670 tag =
".gamma2.fits";
673 tag =
".gamma3.fits";
679 tag =
".invmag.fits";
682 tag =
".surfbright.fits";
695 template <
typename T>
697 const PosType center[]
703 return writePixelMap<T>(center,Npixels,Npixels,resolution,lensvar);
706 template <
typename T>
708 const PosType center[]
720 template <
typename T>
726 double resolution = (branch->boundary_p2[0] - branch->boundary_p1[0])/Ngrid_init;
727 PixelMap<T> map(branch->center, Ngrid_init, Ngrid_init2, resolution);
733 template <
typename T>
736 int Nx = (int)( (branch->boundary_p2[0] - branch->boundary_p1[0])/resolution );
737 int Ny = (int)( (branch->boundary_p2[1] - branch->boundary_p1[1])/resolution );
747 template <
typename T>
751 ,std::string filename
756 size_t Ny = (size_t)(Nx*axisratio);
757 writeFits<T>(center.x,Nx,Ny,resolution, lensvar, filename);
769 template <
typename T>
771 const PosType center[]
775 ,std::string filename
784 tag =
".alpha1.fits";
787 tag =
".alpha2.fits";
796 tag =
".gamma1.fits";
799 tag =
".gamma2.fits";
802 tag =
".gamma3.fits";
808 tag =
".invmag.fits";
811 tag =
".surfbright.fits";
817 PixelMap<T> map = writePixelMapUniform<T>(center,Nx,Ny,lensvar);
828 template <
typename T>
830 const PosType center[]
845 std::vector<Point *> heads(Nblocks);
846 std::vector<size_t> sizes(Nblocks,0);
853 if((*i_tree_it)->level == 4){
855 heads[i] = (*i_tree_it)->points;
856 sizes[i] = (*i_tree_it)->npoints;
865 }
while(i_tree_it.
TreeWalkStep(allowDecent) && i < Nblocks);
867 std::vector<std::thread> thrs;
868 for(
int ii = 0; ii < i ;++ii){
872 thrs.push_back(std::thread(&Grid::writePixelMapUniform_<T>,
this,heads[ii],sizes[ii],&map,lensvar));
874 for(
int ii = 0; ii < i ;++ii) thrs[ii].join();
879 template <
typename T>
892 std::vector<Point *> heads(Nblocks);
893 std::vector<size_t> sizes(Nblocks,0);
900 if((*i_tree_it)->level == 4){
904 heads[i] = (*i_tree_it)->points;
905 sizes[i] = (*i_tree_it)->npoints;
912 }
while(i_tree_it.
TreeWalkStep(allowDecent) && i < Nblocks);
914 std::vector<std::thread> thr;
915 for(
int ii = 0; ii < i ;++ii){
916 thr.push_back(std::thread(&Grid::writePixelMapUniform_<T>,
this,heads[ii],sizes[ii],&map,lensvar));
918 for(
auto &t : thr) t.join();
921 template <
typename T>
927 Point *ppoint = head;
929 for(
size_t i = 0; i< N; ++i){
933 tmp2[0] = ppoint->x[0] - ppoint->image->x[0];
934 tmp2[1] = ppoint->x[1] - ppoint->image->x[1];
935 tmp = sqrt(tmp2[0]*tmp2[0] + tmp2[1]*tmp2[1]);
938 tmp = (ppoint->x[0] - ppoint->image->x[0]);
941 tmp = (ppoint->x[1] - ppoint->image->x[1]);
944 tmp = ppoint->kappa();
947 tmp2[0] = ppoint->gamma1();
948 tmp2[1] = ppoint->gamma2();
949 tmp = sqrt(tmp2[0]*tmp2[0] + tmp2[1]*tmp2[1]);
952 tmp = ppoint->gamma1();
955 tmp = ppoint->gamma2();
958 tmp = ppoint->gamma3();
961 tmp = ppoint->invmag();
967 tmp = ppoint->surface_brightness;
970 std::cerr <<
"PixelMap<T>::AddGrid() does not work for the input LensingVariable" << std::endl;
971 throw std::runtime_error(
"PixelMap<T>::AddGrid() does not work for the input LensingVariable");
977 if(index != -1)(*map)[index] = tmp;
979 ppoint = ppoint->next;
984 template <
typename T>
986 const PosType center[]
990 ,std::string filename
994 PosType range = Npixels*resolution,tmp_x[2];
1002 std::vector<PosType> tmp_sb_vec(tmp_image.
imagekist->Nunits());
1004 for(tmp_image.
imagekist->MoveToTop(),i=0;i<tmp_sb_vec.size();++i,tmp_image.
imagekist->Down()){
1005 tmp_sb_vec[i] = tmp_image.
imagekist->getCurrent()->surface_brightness;
1008 tmp_x[0] = tmp_image.
imagekist->getCurrent()->x[0]
1009 - tmp_image.
imagekist->getCurrent()->image->x[0];
1011 tmp_x[1] = tmp_image.
imagekist->getCurrent()->x[1]
1012 - tmp_image.
imagekist->getCurrent()->image->x[1];
1014 tmp_image.
imagekist->getCurrent()->surface_brightness = sqrt( tmp_x[0]*tmp_x[0] + tmp_x[1]*tmp_x[1]);
1015 tmp_image_theta.
imagekist->getCurrent()->surface_brightness = atan2(tmp_x[1],tmp_x[0]);
1017 tag =
".alphaV.fits";
1021 tmp_x[0] = tmp_image.
imagekist->getCurrent()->gamma1();
1022 tmp_x[1] = tmp_image.
imagekist->getCurrent()->gamma2();
1024 tmp_image.
imagekist->getCurrent()->surface_brightness = sqrt( tmp_x[0]*tmp_x[0] + tmp_x[1]*tmp_x[1]);
1025 tmp_image_theta.
imagekist->getCurrent()->surface_brightness = atan2(tmp_x[1],tmp_x[0])/2;
1027 tag =
".gammaV.fits";
1030 std::cout <<
"Grid::writeFitsVector() does not support the LensVariable you are using." << std::endl;
1035 PixelMap<T> map_m(center, Npixels, resolution),map_t(center,Npixels,resolution);
1038 map_m.AddImages(&tmp_image,1,-1);
1045 map_m.printFITS(filename + tag);
1047 for(tmp_image.
imagekist->MoveToTop(),i=0;i<tmp_sb_vec.size();++i,tmp_image.
imagekist->Down())
1048 tmp_image.
imagekist->getCurrent()->surface_brightness = tmp_sb_vec[i];
1051 template <
typename T>
1054 size_t N1 = (size_t)(strech*Ngrid_init);
1055 size_t N2 = (size_t)(strech*Ngrid_init2);
1057 writeFits<T>(center.x,N1,N2,
getInitRange()/N1,lensvar,filename);
Point * RefineLeaf(LensHndl lens, Point *point)
Fundamental function used to divide a leaf in the tree into nine subcells.
Definition: grid_maintenance.cpp:543
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()
Definition: image_finder_kist.cpp:1027
bool circleIntersetsCurve(const Point_2d &x, double r, const std::vector< Point_2d > &v)
returns true if a circle of radius r around the point x intersects with the curve v....
Definition: curve_routines.cpp:2759
void MapSurfaceBrightness(PixelMap< T > &map)
make image of surface brightness
Definition: grid_maintenance.h:116
PixelMap< T > writePixelMap(const double center[], size_t Npixels, double resolution, LensingVariable lensvar)
Outputs a PixelMap of the lensing quantities of a fixed grid.
Definition: grid_maintenance.h:696
int crit_id
id of the critical curve
Definition: grid_maintenance.h:332
double getInitRange()
return initial range of gridded region
Definition: grid_maintenance.h:79
void CausticRadius(PosType &rmax, PosType &rmin, PosType &rave) const
find 3 measures of the caustic curve radius
Definition: grid_maintenance.h:458
Point * RefineLeaves(LensHndl lens, std::vector< Point * > &points)
Same as RefineLeaf() but multiple points can be passed. The rays are shot all together so that more p...
Definition: grid_maintenance.cpp:681
@ GAMMA3
third component of shear
PosType critical_area
area of critical curve (radians^2)
Definition: grid_maintenance.h:319
The ImageFinding namespace is for functions related to finding and mapping images.
Definition: grid_maintenance.h:242
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.
Definition: image_finder_kist.cpp:1530
bool inCriticalCurve(Point_2d &x)
return true if x is inside or on the border of the critical curve
Definition: grid_maintenance.h:347
Kist< Point > * imagekist
Array of points in image, SHOULD NOT BE USED IN FAVOR OF imagekist! Still used by caustic finding rou...
Definition: image_info.h:47
int getInitNgrid()
return initial number of grid points in each direction
Definition: grid_maintenance.h:75
Base class for all sources.
Definition: source.h:44
@ ALPHA2
y component of deflection
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.
Definition: image_finder_kist.cpp:465
long find_index(PosType const x[], long &ix, long &iy) const
get the index for a position, returns -1 if out of map, this version returns the 2D grid coordinates
Definition: pixelmap.cpp:2522
Structure to contain both source and image trees.
Definition: grid_maintenance.h:24
double AddSurfaceBrightnesses(Source *source)
Recalculate surface brightness just like Grid::RefreshSurfaceBrightness but the new source is added t...
Definition: grid_maintenance.cpp:344
Grid ReInitialize(LensHndl lens)
Returns a new grid that has not been refined but has the same intial image grid, but calculated with ...
Definition: grid_maintenance.cpp:148
The box representing a branch of a binary tree structure. Used specifically in TreeStruct for organiz...
Definition: point.h:677
PointList pointlist
list of points
Definition: Tree.h:125
@ GAMMA
magnitude of shear
bool touches_edge
touches the edge of the gridded region
Definition: grid_maintenance.h:329
unsigned long getNumberOfPoints() const
Returns number of points on image plane.
Definition: grid_maintenance.cpp:518
Point_2d critical_center
center of critical curve
Definition: grid_maintenance.h:314
Structure to contain information and functions for critical curves and caustics.
Definition: grid_maintenance.h:245
void ClearAllMarks()
Rest all in_image markers to False.
Definition: grid_maintenance.cpp:984
void CritRange(Point_2d &p1, Point_2d &p2) const
find rectangular region enclosing critical curve
Definition: Tree.cpp:972
Point_2d RandomSourceNearCaustic(double R, Utilities::RandomNumbers_NR &rng)
Returns a random point within distance R or filly within the caustic.
Definition: Tree.cpp:930
void AddGrid(const Grid &grid, T value=1.0)
Fills in pixels where the image plane points in the grid are located with the value given.
Definition: pixelmap.cpp:2231
Point_2d RandomSourceWithinCaustic(Utilities::RandomNumbers_NR &rng)
Definition: Tree.cpp:918
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.
Definition: image_finder_kist.cpp:41
Class for representing points or vectors in 2 dimensions. Not that the dereferencing operator is over...
Definition: point.h:48
void zoom(LensHndl lens, double *center, double scale, Branch *top=NULL)
Test if point is in a region of uniform magnification using the kappa and gamma calculated from the r...
Definition: grid_maintenance.cpp:1233
bool inhull< RAY >(PosType x[], const std::vector< RAY > &H)
finds in x is within the curve discribed by the H[].x points ie image points
Definition: concave_hull.h:1164
void RandomSourcesNearCaustic(double R, int N, std::vector< Point_2d > &y, Utilities::RandomNumbers_NR &rng)
Returns a vector of random point within distance R or filly within the caustic.
Definition: Tree.cpp:922
This is a class for generating random numbers. It simplifies and fool proofs initialization and allow...
Definition: utilities_slsim.h:1068
@ ALPHA
magnitude of deflection in radians
int caustic_intersections
estimated number of intersections of the caustic, -1 if not set
Definition: grid_maintenance.h:311
void AddGridBrightness(Grid &grid)
Add an image from a the surface brightnesses of a Grid to the PixelMap.
Definition: pixelmap.cpp:685
A simplified version of the Grid structure for making non-adaptive maps of the lensing quantities (ka...
Definition: gridmap.h:31
Point_2d centroid() const
centroid of flux
Definition: grid_maintenance.cpp:456
void find_point_source_images(Point_2d y_source, PosType r_source, PosType z_source, std::vector< RAY > &images, bool verbose=false)
This function finds all the images for a circular source of radius r_source, then finds the points wi...
Definition: image_finder.cpp:1094
@ SurfBrightness
Surface brightness.
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.
Definition: find_crit.cpp:1897
A iterator class fore TreeStruct that allows for movement through the tree without changing anything ...
Definition: Tree.h:47
bool TreeWalkStep(bool allowDescent)
step for walking tree by iteration instead of recursion.
Definition: tree_maintenance.cpp:1610
void printFITS(std::string filename, bool Xflip=false, bool ctype=false, bool verbose=false)
Output the pixel map as a fits file.
Definition: pixelmap.cpp:1613
@ ALPHA1
x component of deflection
Tree: Exported struct.
Definition: Tree.h:31
Branch * getTop()
root branch
Definition: Tree.h:122
void CausticRange(Point_2d &p1, Point_2d &p2) const
find rectangular region enclosing caustic curve
Definition: Tree.cpp:987
PosType ellipse_area
area of an ellipse with axis ratio contour_ell and major axis = max distance between center (as given...
Definition: grid_maintenance.h:326
void RandomSourcesWithinCaustic(int N, std::vector< Point_2d > &y, Utilities::RandomNumbers_NR &rng)
Returns a vector of random point within the caustic. It is more efficient to call this once for many ...
Definition: Tree.cpp:904
bool intersectingCausticCurve(Point_2d &x, double r)
returns true if a circle of radius r around the point x intersects with the caustic curve
Definition: grid_maintenance.h:341
@ GAMMA2
second component of shear
PosType caustic_area
area of caustic curve (radians^2)
Definition: grid_maintenance.h:321
void writeFitsVector(const double center[], size_t Npixels, double resolution, LensingVariable lensvar, std::string filename)
Outputs a fits file for making plots of vector fields.
Definition: grid_maintenance.h:985
Simple representaion of a light path giving position on the image and source planes and lensing quant...
Definition: point.h:555
void AddImages(ImageInfo *imageinfo, int Nimages, float rescale=1.)
Add an image to the map.
Definition: pixelmap.cpp:641
double ClearSurfaceBrightnesses()
Reset the surface brightness and in_image flag in every point on image and source planes to zero (fal...
Definition: grid_maintenance.cpp:500
bool inCurve(const Ptype &x, const std::vector< Ptype > &H)
returns true if x is within the polygon H
Definition: concave_hull.h:1054
double AreaNearCaustic(double R)
returns an estimate of the area inside and within distance R of the caustic
Definition: Tree.cpp:936
bool inCausticCurve(Point_2d &x)
return true if x is inside or on the border of the caustic curve
Definition: grid_maintenance.h:336
TreeHndl i_tree
tree on image plane
Definition: grid_maintenance.h:70
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.
Definition: find_crit.cpp:37
PixelMap< T > writePixelMapUniform(const PosType center[], size_t Nx, size_t Ny, LensingVariable lensvar)
Make a Pixel map of the without distribution the pixels.
Definition: grid_maintenance.h:829
void writeFits(const double center[], size_t Npixels, double resolution, LensingVariable lensvar, std::string filename)
Outputs a fits image of a lensing variable of choice.
Definition: grid_maintenance.h:628
@ GAMMA1
first component of shear
CritType find_pseudo(ImageInfo &pseudocurve, ImageInfo &negimage, PosType pseudolimit, LensHndl lens, GridHndl grid, PosType resolution, Kist< Point > &paritypoints, bool TEST=false)
Definition: find_crit.cpp:1107
Grid(LensHndl lens, unsigned long N1d, const double center[2], double range)
Constructor for initializing square grid.
Definition: grid_maintenance.cpp:22
PixelMap< T > 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 ...
Definition: Tree.cpp:1026
@ INVMAG
inverse of magnification
int getNgrid_block()
return number of cells in each dimension into which each cell is divided when a refinement is made
Definition: grid_maintenance.h:77
PixelMap< T > 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 t...
Definition: Tree.cpp:1064
CritType type
type of caustic, 0 -not defined, 1 -radial, 2 - tangential,3 - pseudo
Definition: grid_maintenance.h:309
This is an old version that should not be used anymore in favor of ImageInfo.
Definition: image_info.h:109
bool EntirelyinCriticalCurve(Point_2d x, PosType sourceRadius)
return true if x is strictly inside (entirely) the critical curve
Definition: grid_maintenance.h:375
double RefreshSurfaceBrightnesses(Source *source)
Reshoot the rays with the same image postions.
Definition: grid_maintenance.cpp:315
void find_images(PosType *y_source, PosType r_source, int &Nimages, std::vector< ImageInfo > &imageinfo, unsigned long &Nimagepoints)
Finds images for a given source position and size. It seporates images of different pairities.
Definition: image_finder.cpp:951
bool EntirelyinCausticCurve(Point_2d &x, PosType sourceRadius)
return true if x is strictly inside (entirely) the caustic curve
Definition: grid_maintenance.h:352
A point on the source or image plane that contains a position and the lensing quantities.
Definition: point.h:459
Image structure that can be manipulated and exported to/from fits files.
Definition: pixelmap.h:42
PosType PointsWithinKist(const PosType *center, PosType rmax, Kist< Point > *neighborkist, short markpoints) const
Finds all points in tree that lie within rmax of the point ray[].
Definition: KistDriver.cpp:263
PosType magnification(double sblimit=-1.0e12) const
flux weighted local magnification that does not take multiple imaging into effect
Definition: grid_maintenance.cpp:398
LensingVariable
output lensing variables
Definition: standard.h:89
Point_2d caustic_center
center of caustic curve
Definition: grid_maintenance.h:316
PosType EinsteinArea() const
area of region with negative magnification
Definition: grid_maintenance.cpp:368
void RandomSourceStrictlyWithinCaustic(int N, std::vector< Point_2d > &y, Utilities::RandomNumbers_NR &rng, PosType sourceRadius, PosType distSourceToCaustic)
Returns a vector of random point strictly within the caustic (i.e. not touching the border)....
Definition: Tree.cpp:958
void writePixelFits(size_t Nx, LensingVariable lensvar, std::string filename)
Make a fits map that is automatically centered on the grid and has approximately the same range as th...
Definition: grid_maintenance.h:748
void writeFitsUniform(const PosType center[], size_t Nx, size_t Ny, LensingVariable lensvar, std::string filename)
Output a fits map of the without distribution the pixels.
Definition: grid_maintenance.h:770
void map_images(Lens *lens, Source *source, int *Nimages, std::vector< ImageInfo > &imageinfo, PosType xmax, PosType xmin, PosType initial_size, ExitCriterion criterion, bool FindCenter, bool divide_images)
Find images and refine them based on their surface brightness distribution.
Definition: map_images.cpp:27
Structure for storing information about images or curves.
Definition: image_info.h:20
void CriticalRadius(PosType &rmax, PosType &rmin, PosType &rave) const
find 3 measures of the critical curve radius
Definition: grid_maintenance.h:438
static void print(std::string filename, std::vector< ImageFinding::CriticalCurve > &critcurves)
print the critical curves and caustic curves to a csv file
Definition: grid_maintenance.h:484
double mark_closest_point_source_images(Point_2d y_source, PosType r_source_max, PosType luminosity, bool verbose=false)
This function finds all the images for a circular source of radius r_source, then finds the points wi...
Definition: image_finder.cpp:1061
~Grid()
Destructor for a Grid. Frees all memory.
Definition: grid_maintenance.cpp:136
Point_2d x
image position
Definition: point.h:625
A class to represents a lens with multiple planes.
Definition: lens.h:71
TreeHndl s_tree
tree on source plane
Definition: grid_maintenance.h:72
PosType contour_ell
axis ratio of a contour defined by the ratio of the max to min distance between center (as given by h...
Definition: grid_maintenance.h:324