GLAMERDOC++
Gravitational Lensing Code Library
|
A class to represents a lens with multiple planes. More...
#include <lens.h>
Public Member Functions | |
Lens (long *seed, PosType z_source, CosmoParamSet cosmoset, bool verbose=false) | |
Creates an empty lens. Main halos and field halos need to be inserted by hand from the user. | |
Lens (long *seed, PosType z_source, const COSMOLOGY &cosmo, bool verbose=false) | |
int | getNplanes () const |
the total number of lens planes | |
PosType | getfov () const |
field of view in square degrees | |
void | setfov (PosType fov) |
void | resetFieldNplanes (std::size_t field_Nplanes, bool verbose=false) |
reset the number of planes, but keep the field halos and main lens | |
void | resetFieldHalos (bool verbose=false) |
void | printMultiLens () |
print the main parameters of the lens | |
PosType | getZlens () const |
Redshift of first main lens plane. | |
PosType | getAngDistLens () const |
Angular size distance (Mpc) to first main lens plane. | |
Utilities::Geometry::SphericalPoint | getCenter () const |
void | clearMainHalos (bool verbose=false) |
remove all main halos | |
template<typename HaloType > | |
void | clearMainHalo (bool verbose=false) |
remaove all main halo of given type | |
template<typename T > | |
void | insertMainHalo (const T &halo_in, bool addplanes, bool verbose=false) |
inserts a single main lens halo and adds it to the existing ones | |
template<typename T > | |
void | moveinMainHalo (T &halo_in, bool addplanes, bool verbose=false) |
This has the same effect as insertMainHalo(), but the halo is not copied, it is moved. | |
template<typename T > | |
void | replaceMainHalo (const T &halo_in, bool addplanes, bool verbose=false) |
Inserts a single main lens halo and deletes all previous ones. Then all lensing planes are updated accordingly. | |
template<typename T > | |
void | insertMainHalos (std::vector< T > &my_halos, bool addplanes, bool verbose=false) |
Inserts a sequense of main lens halos and adds them to the existing ones. Then all lensing planes are updated accordingly. If addplanes is true new planes will be added otherwise the halo is added to the nearest plane and a plane is added only if none exited on entry. | |
template<typename T > | |
void | replaceMainHalos (std::vector< T > &my_halos, bool verbose) |
Inserts a sequense of main lens halos and remove all previous ones. | |
std::size_t | getNMainHalos () const |
inserts a sequence of main lens halos and adds them to the existing ones | |
template<typename HaloType > | |
std::size_t | getNMainHalos () const |
get number of main halos of given type | |
LensHalo * | getMainHalo (std::size_t i) |
get single main halo | |
template<typename HaloType > | |
HaloType * | getMainHalo (std::size_t i) |
get single main halo of given type | |
void | rayshooter (RAY &ray) |
Using to shoot a single ray. | |
void | rayshooterInternal (unsigned long Npoints, Point *i_points, bool RSIverbose=false) |
Main routine for shooting rays in parrallel. | |
void | rayshooterInternal (unsigned long Npoints, LinkedPoint *i_points, std::vector< double > &source_zs, bool RSIverbose=false) |
Routine for shooting rays with differnt source redshifts in parrallel. | |
void | rayshooterInternal (unsigned long Npoints, RAY *rays) |
void | rayshooterInternal (RAY &ray) |
void | info_rayshooter (RAY &i_point, std::vector< Point_2d > &ang_positions, std::vector< KappaType > &kappa_on_planes, std::vector< std::vector< LensHalo * > > &halo_neighbors, LensHalo &halo_max, KappaType &kappa_max, KappaType gamma_max[], PosType rmax, int tag=0, short mode=0, bool verbose=false) |
single ray | |
void | mass_on_planes (const std::vector< RAY > &rays, std::vector< double > &masses, bool verbose=false) |
finds the mass within a curve of rays one every lens plane im Msun | |
RAY | find_image_min (Point &p, double zs, PosType ytol2, PosType &dy2, bool use_image_guess) |
Find the image position of a source without grid refinement. | |
RAY | find_image_min (const RAY &in_ray, PosType ytol2) |
RAY | find_image_min (Point &p, double zs, PosType ytol2, PosType &dy2, std::vector< Point_2d > &boundary) |
This is the same, but the image is forced to stay within boundary. | |
std::vector< RAY > | find_images (Point_2d y_source, double z_source, Point_2d center, double range, double stop_res) |
finds images by telescoping triangle method | |
std::vector< RAY > | find_images (GridMap &init_grid, Point_2d y_source, double z_source, double stop_res) |
finds images by telescoping triangle method | |
void | find_images_min_parallel (std::vector< RAY > &rays, double ytol2, std::vector< bool > &success) |
short | ResetSourcePlane (PosType z, bool nearest=false, bool verbose=false) |
reset the redshift of the source plane | |
void | FindSourcePlane (PosType zs, long &jmax, double &Dls, double &Ds) |
find information on the position of the source plane with respect to the lens planes | |
void | RevertSourcePlane () |
Revert the source redshift to the value it was when the Lens was created. | |
PosType | getSourceZ () |
PosType | getZmax () const |
void | PrintCosmology () |
print the cosmological parameters | |
PosType | getSigmaCrit (PosType zsource) const |
returns the critical density at the main lens in Msun/ Mpc^2 for a source at zsource | |
const COSMOLOGY & | getCosmo () |
returns a const reference to the cosmology so that constant functions can be used, but the cosmological parameters cannot be changed. | |
void | TurnFieldOff () |
set flag_switch_field_off, turn the field On/Off : | |
void | TurnFieldOn () |
PosType | getFieldMinMass () const |
get the field min mass : | |
bool | getfieldOff () const |
Lens & | operator= (Lens &&lens) |
Lens (Lens &&lens) | |
std::vector< PosType > | get_plane_redshifts () |
Public Attributes | |
bool | set |
marks if the lens has been setup. | |
Protected Attributes | |
PosType | fieldofview |
field of view in square degrees | |
A class to represents a lens with multiple planes.
The rays are traced through multiple deflections. On each plane there is a deflection solver. An LensHaloAnaNSIE or LensHaloMassMap can be put on one of the planes. The other planes can be populated with random field_halos drawn from a mass function or they can be retrieved from an extern&al catalog. Input Parameters (variable names): main_halo_on -- 0: no major lens present; 1: there is a major lens present main_halo_type -- profile type for the main DM lens halo 0 or nolens, 1 or NFW, 2 or PseudoNFW, 3 or PowerLaw, 4 or NSIE, 5 or AnaLens, 6 or UniLens, 7 or MOKALens, 8 or DummyLens main_galaxy_halo_type -- profile typ for the main galaxy lens halo 0 or none, 1 or NSIE redshift_planes_file -- asci file with the redshifts of the lensing planes, if not set then created internaly flag_switch_field_off -- false: field halos are created, true: no field halos are created; default is false if field_off == false, i.e. there are field halos then also the following are used: field_Nplanes -- number of field planes field_fov -- field of view of the light cone, filled with field halos field_internal_profile -- profile type of the DM field lens halos 0 or nolens, 1 or NFW, 2 or PseudoNFW, 3 or PowerLaw, 4 or NSIE, 5 or AnaLens, 6 or UniLens, 7 or MOKALens, 8 or DummyLens, 9 or Hernquist, 10 or Jaffe field_prof_internal_slope_pl -- slope of the surface density for power law field_prof_internal_slope_pnfw -- slope of the surface density for pseudo nfw profiles field_internal_profile_galaxy -- profile type of the galaxy field halos; if not set, no galaxies are used 0 or none, 1 or NSIE field_input_sim_file -- filename of the Millennium simulation data to be read in and used to populate the light cone with field halos if field_input_sim_file is _not_ set, then the field halos are generated from a mass function and the following are used: field_mass_func_type -- type of the halo mass function PS (0), ST (1), and power law (2) mass_func_PL_slope -- slope of the mass function in the power law case; default is -1/6 field_min_mass -- minimum mass for the generated field halos field_buffer -- a constant physical size buffer, padding every lens plane to increase its surface zsource -- source redshift flag_switch_deflection_off -- false: deflection is on, but kappa and gamma may be calculated, true: deflection is off; default is false flag_switch_lensing_off -- false: lensing is on, true: lensing is off (no alpha, kappa or gamma); default is false # Cosmology - Any cosmological parameters that are not set will have default values Omega_matter -- Total mass (baryons + dark matter) in the units of the critical density, optional Omega_lambda -- Density in a cosmological constant, if not set it will be = 1 - Omega_matter Omega_baryon -- Density in baryons Omega_neutrino -- Density in neutrinos hubble -- Hubble parameter in units of 100 km/s/Mpc sigm_8 -- normalization of power spectrum
this version uses the redshift stored in the ray,
Tthe ray is replaced with the best guess so the source position is replaced.
in_ray | p.y[] should be set to source position |
ytol2 | target tolerance in source position squared |
RAY Lens::find_image_min | ( | Point & | p, |
double | zs, | ||
PosType | ytol2, | ||
PosType & | dy2, | ||
bool | use_image_guess ) |
Find the image position of a source without grid refinement.
This uses Powell's algorithm to minimise the distance between the source point of an image and the desired source point. No grid is necessary. This should be fast, but will miss multiple images. This is useful for finding the position of weakly lensed images or the rough region where a grid should be put down for a strong lens.
Find the image position of a source without grid refinement.
This finds an image position given a source postion. No grid is necessary.
If use_image_guess=true the input image position will be used as a first guess and the output image will be guarenteed to have the same pairity.
This is useful for finding the position of weakly lensed images or for refining the image positions that are found on a finite grid.
p | p.image->x should be set to source position |
zs | redhsift of source |
ytol2 | target tolerance in source position squared |
dy2 | final value of Delta y ^2 |
use_image_guess | if true p.x[] will be used as a guess for the image position |
RAY Lens::find_image_min | ( | Point & | p, |
double | zs, | ||
PosType | ytol2, | ||
PosType & | dy2, | ||
std::vector< Point_2d > & | boundary ) |
This is the same, but the image is forced to stay within boundary.
p | p[] is |
zs | source redshift |
ytol2 | target tolerance in source position squared |
dy2 | final value of Delta y ^2 |
boundary | image will be limited to within this boundary |
std::vector< RAY > Lens::find_images | ( | GridMap & | init_grid, |
Point_2d | y_source, | ||
double | z_source, | ||
double | stop_res ) |
finds images by telescoping triangle method
find rays using telescoping triangle method starting with a GridMap init_grid
Meant for refining the image positions to higher resolution than the initial grid
std::vector< RAY > Lens::find_images | ( | Point_2d | y_source, |
double | z_source, | ||
Point_2d | center, | ||
double | range, | ||
double | stop_res ) |
finds images by telescoping triangle method
find rays using telescoping triangle method
void Lens::FindSourcePlane | ( | PosType | zs, |
long & | jmax, | ||
double & | Dls, | ||
double & | Ds ) |
find information on the position of the source plane with respect to the lens planes
zs | redshift of implanted source |
jmax | index of last plane at lower redshift |
Dls | coordinate distance between last plane and source plane |
Ds | total coordinate distance to source plane |
|
inline |
inserts a sequence of main lens halos and adds them to the existing ones
replaces existing main halos with a single main halo replaces existing main halos with a sequence of main halos
This function will randomize the substructure without changing the region, mass function, etc.
The Lens::insertSubstructures() function must have been called on this instance of the Lens before. get number of main halos
void Lens::info_rayshooter | ( | RAY & | ray, |
std::vector< Point_2d > & | ang_positions, | ||
std::vector< KappaType > & | kappa_on_planes, | ||
std::vector< std::vector< LensHalo * > > & | halo_neighbors, | ||
LensHalo & | halo_max, | ||
KappaType & | kappa_max, | ||
KappaType | gamma_max[], | ||
PosType | rmax, | ||
int | tag = 0, | ||
short | mode = 0, | ||
bool | verbose = false ) |
single ray
Collects information about the halos and kappa contributions along the light path.
Information on the nearest halos is collected where nearest is defined by rmax and mode. When mode == 2 the unlensed angular coordinates are used to evaluate proximity not the lensed ones.
ray | ray, ray.x needs to be set, all other quantities will be calculated |
ang_positions | angular positions on each plane |
kappa_on_planes | convergence on each plane |
halo_neighbors | neighboring halos within rmax of ray on each plane |
halo_max | halo with the larges kappa |
kappa_max | the kappa from that halo |
gamma_max | shear from that halo |
rmax | distance from ray on each plane, units depend on mode parameter |
tag | i f not 0, information on halos with this tag are gathered |
mode | 0:physical distance, 1: comoving distance, 2: angular distance |
|
inline |
Inserts a sequense of main lens halos and adds them to the existing ones. Then all lensing planes are updated accordingly. If addplanes is true new planes will be added otherwise the halo is added to the nearest plane and a plane is added only if none exited on entry.
The angular position of the halo should be preserved, but the x coordinates may change The halos are copied so the input halos can be destoyed without affecting the Lens.
void Lens::mass_on_planes | ( | const std::vector< RAY > & | rays, |
std::vector< double > & | masses, | ||
bool | verbose = false ) |
finds the mass within a curve of rays one every lens plane im Msun
rays | ray, ray.x needs to be set |
masses | mass within curve on each lens plane |
|
inline |
This has the same effect as insertMainHalo(), but the halo is not copied, it is moved.
The Lens will take possession of the halo and will destroy it when it is destroyed. This is to avoid copying halos that take up a lot of memory and require a lot of time to copy like LensHaloParticles().
void Lens::rayshooter | ( | RAY & | ray | ) |
Using to shoot a single ray.
This function calculates the deflection, shear, convergence, rotation and time-delay of rays in parallel. The source redshift must be set for the ray.
ray.x should be set to the image position. The kappa,gamma,deflection, time-delay and source position will be calculated at that image point.
void Lens::rayshooterInternal | ( | unsigned long | Npoints, |
LinkedPoint * | i_points, | ||
std::vector< double > & | source_zs, | ||
bool | RSIverbose = false ) |
Routine for shooting rays with differnt source redshifts in parrallel.
i_points[].x must be set to the image postion in angular radians.
Npoints | number of points to be shot |
i_points | poinst on the image plane |
source_zs | source redshifts |
RSIverbose | verbose option |
void Lens::rayshooterInternal | ( | unsigned long | Npoints, |
Point * | i_points, | ||
bool | RSIverbose = false ) |
Main routine for shooting rays in parrallel.
i_points[].x must be set to the image postion in angular radians.
i_points must have linked image points. LinkedPoint
s could be used, but for its internal use this is not done.
Npoints | number of points to be shot |
i_points | points on the image plane |
RSIverbose | verbose option |
void Lens::rayshooterInternal | ( | unsigned long | Npoints, |
RAY * | rays ) |
Npoints | number of points to be shot |
rays | points on the image plane |
|
inline |
Inserts a single main lens halo and deletes all previous ones. Then all lensing planes are updated accordingly.
Note that this does delete all the halos that were there.
|
inline |
Inserts a sequense of main lens halos and remove all previous ones.
Note that this does delete the halos that were there. Then all lensing planes are updated accordingly.
void Lens::resetFieldHalos | ( | bool | verbose = false | ) |
keep the main lens and the number of planes constant, but generate new field halos.
short Lens::ResetSourcePlane | ( | PosType | z, |
bool | nearest = false, | ||
bool | verbose = false ) |
reset the redshift of the source plane
Changes the maximum redshift that the rays are shot to. Warning: Grids that have already been made with this Lens will not have this new source redshift.
The multilens must have been initially constructed with a source redshift that is higher than this redshift. This is used to rayshoot to a source whose line of sight passes through the simulation volume. The source can be at higher redshift than the simulation volume.
To revert the source redshift to its original value use Lens::RevertSourcePlane().
z | redshift of implanted source |
nearest | If true, set the source plane to the nearest (in coordinate distance) lensing plane that was created already. This can be used to avoid self-lensing by the halo of the source. If the source is at higher redshift than the simulation volume the source will be at its real redshift. |