Python version - Base object
- class glow.time_domain.ItGeneral(Lens, y, p_prec={})
Base class for the time-domain integral.
- Parameters:
- LensPsiGeneral subclass
Lens object.
- yfloat
Impact parameter (defined to be aligned with the \(x_1\) axis).
- p_precdict, optional
Precision parameters.
- Attributes:
- lensPsiGeneral subclass
Lens object.
- yfloat
Impact parameter.
- p_precdict
Default precision parameters updated with the input. Default keys:
eval_mode
(str) – Computation of \(I(\tau)\), i.e. behaviour of the methodeval_It()
. Options:'interpolate'
: Precompute a grid and then evaluate an interpolation function.'exact'
: Compute \(I(\tau)\) for each point requested.
Nt
(int) – Number of points in the grid.tmin
(float) – Minimum \(\tau\) in the grid.tmax
(float) – Maximum \(\tau\) in the grid.interp_fill_value
– Behaviour of the interpolation function outside the interpolation range. Options:None: Raise an error if extrapolation is attempted.
float: Extrapolate with a constant value.
'extrapolate'
: Linear extrapolation.
interp_kind
(str) – Interpolation method. Any kind recognized by Scipy is allowed. In particular:'linear'
'cubic'
sampling
(str) – Sampling options for the grid. Options:'linear'
'log'
'oversampling'
: Theoversampling_
parameters below control the properties of the oversampling grid. In this mode, the grid is sampled logarithmically (as with'log'
) and then the region betweenoversampling_tmin
andoversampling_tmax
is oversampled withoversampling_n
times more points. The total number of points is stillNt
.
oversampling_n
(int)oversampling_tmin
(float)oversampling_tmax
(float)
- t_grid, It_gridarray
(subclass defined) Grid of points where \(I(\tau)\) has been computed.
- eval_Itfunc(float or array) -> float or array
(subclass defined) Final function to evaluate \(I(\tau)\).
- namestr
(subclass defined) Name of the method.
- tminfloat
(subclass defined) Minimum of the Fermat potential, \(t_\text{min}=\phi(\boldsymbol{x}_\text{min})\).
- I0float
(subclass defined) Value of \(I(\tau)\) at \(\tau=0\).
- p_critslist of dict
(subclass defined) Dictionaries with all the images found. Keys for each image:
type
(str) – Type of image (critical point of the Fermat potential):'min'
,'max'
,'saddle'
– Minimum, maximum and saddle point.'sing/cusp max'
,'sing/cusp min'
– When the derivative of the Fermat potential is discontinuous or singular, these points may behave like critical points for the computation of the contours. Examples include the center of the point lens and the SIS.
t
(float) – Time delay \(t=\phi(\boldsymbol{x}_\text{im})\) (Note: the relative time delay is \(\tau = t - t_\text{min}\)).x1
,x2
(float) – Position of the image.mag
(float) – Magnification \(\mu\).
Methods
__call__
(tau)Call
eval_It()
.Check the input upon initialization.
(subclass defined, optional) Check the input of the implementation.
compute
(t)(subclass defined) Internal function to compute \(I(\tau)\).
Compute the final function needed to evaluate \(I(\tau)\).
Evaluate \(I(\tau)\) on a grid.
Fill the default parameters.
(subclass defined) Initialize the default parameters.
Print the critical points of the Fermat potential in human-readable form.
Print internal information in human-readable form.
eval_Gt
(t[, dt])Green function defined as \(G(\tau) = 1/2\pi\ \text{d}I/\text{d}\tau\).
eval_low_tau
(t, tmin, Imin)Linear interpolation to evaluate \(I(\tau)\) at low \(\tau\).
find_tmin_bounds
(x1_max[, x2_max, x1_min, ...])Find the minimum time delay through direct minimization of the Fermat potential.
find_tmin_root
(x1_guess[, x2_guess])Find the minimum time delay of a lens by finding the root of the derivative of the Fermat potential.
interpolate
(xs, ys)Construct an interpolation function using the options in
p_prec
.phi_Fermat
(x1, x2)Fermat potential with the minimum set to zero.
- default_general_params()
Fill the default parameters.
Update the precision parameters common for all methods and then call
default_params()
(subclass defined).- Returns:
- p_precdict
Default precision parameters.
- check_general_input()
Check the input upon initialization.
It first calls
check_input()
(subclass defined) to perform any checks that the user desires. It then checks that the input only updates existing keys inp_prec
, otherwise throws a warning.The idea is that we do not use a wrong name that is then ignored.
- Warns:
- TimeDomainWarning
Warning
If the subclass will add a new parameter without an entry in
default_params()
, it must be manually added toself.p_prec_default_keys
incheck_input()
withself.p_prec_default_keys.add(new_key)
.
- display_info()
Print internal information in human-readable form.
- display_images()
Print the critical points of the Fermat potential in human-readable form.
- interpolate(xs, ys)
Construct an interpolation function using the options in
p_prec
.- Parameters:
- xs, ysfloat or array
Values to interpolate.
- Returns:
- interp_funcfunc(float) -> float
Interpolation function.
- eval_low_tau(t, tmin, Imin)
Linear interpolation to evaluate \(I(\tau)\) at low \(\tau\).
The formula used is
\[I(\tau) = I(0) - \big(I(0)-I(\tau_\text{min})\big)\frac{\tau}{\tau_\text{min}}\]where \(I(0)\) corresponds to the class attribute
I0
.- Parameters:
- tfloat or array
\(\tau\)
- tminfloat
\(\tau_\text{min}\)
- Iminfloat
\(I(\tau_\text{min})\)
- Returns:
- Itfloat or array
\(I(\tau)\) at low tau.
- compute_grid()
Evaluate \(I(\tau)\) on a grid.
The behaviour of this function is controlled by the precision parameter
p_prec['sampling']
.- Returns:
- t_grid, It_gridfloat or array
Result.
- interp_Itfunc(float) -> float
Interpolation function constructed with
interpolate()
.
- compute_all()
Compute the final function needed to evaluate \(I(\tau)\).
- Returns:
- t_grid, It_gridarray
If
p_prec['eval_mode'] == 'interpolate'
, they contain the grids computed incompute_grid()
. Otherwise, empty arrays.- eval_Itfunc(float) -> float
Final function to evaluate \(I(\tau)\).
- eval_Gt(t, dt=0.0001)
Green function defined as \(G(\tau) = 1/2\pi\ \text{d}I/\text{d}\tau\).
It is computed using a (2nd order) finite difference approximation
\[G(\tau) \simeq \frac{1}{4\pi}\left(I(\tau+\Delta\tau) - I(\tau-\Delta\tau)\right)\]- Parameters:
- tfloat or array
\(\tau\).
- dtfloat
\(\Delta\tau\).
- Returns:
- Gtfloat or array
\(G(\tau)\).
- phi_Fermat(x1, x2)
Fermat potential with the minimum set to zero.
\[\tau = \tilde{\phi}(\boldsymbol{x}) = \phi(\boldsymbol{x}) - t_\text{min}\]- Parameters:
- x1, x2float or array
Lens plane coordinates.
- Returns:
- phifloat or array
\(\tilde{\phi}\)
- find_tmin_root(x1_guess, x2_guess=0)
Find the minimum time delay of a lens by finding the root of the derivative of the Fermat potential.
The algorithm starts with an initial guess x1_guess (x2_min=0 always for axisymmetric lenses).
- Caveats:
Derivatives of the lens required.
Not implemented for non-axisymmetric lenses.
At the moment, it can only be used when there is only one critical point (hence a minimum). No checks are perfomed in this function.
- Parameters:
- x1_guess, x2_guessfloat
Initial points to start the search.
- Returns:
- tmin, x1_min, x2_min(float, float, float)
Minimum time delay and position of the minimum.
- find_tmin_bounds(x1_max, x2_max=0, x1_min=None, x2_min=None, x1_guess=None, x2_guess=None)
Find the minimum time delay through direct minimization of the Fermat potential.
Both algorithms (axisymmetric and non-axisymmetric case) require the bounds x1_max, x2_max of the optimization region (if x1_min and x2_min are not given, the region is assumed to be symmetric). The 2d algorithm for non-axisymmetric lenses also needs an initial guess (x1_guess, x2_guess) (default: (y, 0))
- Caveats:
No derivatives are required, but if present they could be used to improve convergence
- compute(t)
(subclass defined) Internal function to compute \(I(\tau)\).
- Parameters:
- tfloat or array
\(\tau\).
- Returns:
- Itfloat or array
\(I(\tau)\).
- check_input()
(subclass defined, optional) Check the input of the implementation.
- default_params()
(subclass defined) Initialize the default parameters.