Base objects
- class glow.lenses.PsiGeneral(p_phys={}, p_prec={})
Base class for a generic non-axisymmetric lens.
- Parameters:
- p_physdict, optional
Physical parameters of the lens.
- p_precdict, optional
Precision parameters of the lens.
- Attributes:
- p_physdict
Default parameters updated with the input.
- p_precdict
Default parameters updated with the input.
- isAxisymbool, default=False
Allows to easily differentiate a general lens from the special axisymmetric case (instance of
PsiAxisym).- asymp_indexfloat or None, default=None
- asymp_amplitudefloat or None, default=None
If the asymptotic behaviour of the lens is
\[\psi'\sim\frac{A_\psi}{r^\gamma}\ ,\quad r\to\infty\]the asymptotic index and amplitude are defined as
\[\begin{split}\begin{align} \gamma_\text{asymp} &= (\gamma+1)/2\\ A_\text{asymp} &= A_\psi/2^{\gamma_\text{asymp}} \end{align}\end{split}\]
Methods
Check the input upon initialization.
(subclass defined, optional) Check the input of the lens implementation.
ddphi_Fermat_ddx1(x1, x2)Return only d11 from
ddphi_Fermat_vec().ddphi_Fermat_ddx2(x1, x2)Return only d22 from
ddphi_Fermat_vec().ddphi_Fermat_dx1dx2(x1, x2)Return only d12 from
ddphi_Fermat_vec().ddphi_Fermat_vec(x1, x2)Hessian of the Fermat potential.
ddpsi_ddx1(x1, x2)Return only d11 from
ddpsi_vec().ddpsi_ddx2(x1, x2)Return only d22 from
ddpsi_vec().ddpsi_dx1dx2(x1, x2)Return only d12 from
ddpsi_vec().ddpsi_vec(x1, x2)(subclass defined) Hessian of the lensing potential.
Fill the default parameters.
(subclass defined) Initialize the default parameters.
Print internal information in human-readable form.
dphi_Fermat_dx1(x1, x2, y)Return only d1 from
dphi_Fermat_vec().dphi_Fermat_dx2(x1, x2, y)Return only d2 from
dphi_Fermat_vec().dphi_Fermat_vec(x1, x2, y)Gradient of the Fermat potential.
dpsi_dx1(x1, x2)Return only d1 from
dpsi_vec().dpsi_dx2(x1, x2)Return only d2 from
dpsi_vec().dpsi_vec(x1, x2)(subclass defined) Gradient of the lensing potential.
phi_Fermat(x1, x2, y)Fermat potential.
psi(x1, x2)(subclass defined) Lensing potential.
shear(x1, x2)Magnification matrix.
- default_general_params()
Fill the default parameters.
Update the parameters common for all lenses (none in this case). Then call
default_params()(subclass defined).- Returns:
- p_physdict
Default physical parameters.
- 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_physandp_prec, otherwise throws a warning.The idea is that we do not use a wrong name that is then ignored.
- Warns:
- LensWarning
Warning
If the subclass will add a new parameter without an entry in
default_params(), it must be manually added toself.p_phys_default_keysorself.p_prec_default_keysincheck_input()withself.p_phys_default_keys.add(new_key).
- display_info()
Print internal information in human-readable form.
- phi_Fermat(x1, x2, y)
Fermat potential.
Defined without setting the minimum time-delay to zero
\[\phi_F(x_1, x_2, y) = \frac{1}{2}(x_1^2+x_2^2+y^2) -x_1y -\psi(x_1, x_2)\]- Parameters:
- x1float or array
Coordinate x1 (x1 is defined aligned with y).
- x2float or array
Coordinate x2.
- yfloat or array
Impact parameter.
- Returns:
- phifloat or array
- dphi_Fermat_vec(x1, x2, y)
Gradient of the Fermat potential.
- Parameters:
- x1float or array
Coordinate x1 (x1 is defined aligned with y).
- x2float or array
Coordinate x2.
- yfloat or array
Impact parameter.
- Returns:
- d1float or array
Derivative of the Fermat potential wrt x1.
- d2float or array
Derivative of the Fermat potential wrt x2.
- ddphi_Fermat_vec(x1, x2)
Hessian of the Fermat potential.
- Parameters:
- x1float or array
Coordinate x1.
- x2float or array
Coordinate x2.
- Returns:
- d11float or array
2nd derivative of the Fermat potential wrt x1 twice.
- d12float or array
2nd derivative of the Fermat potential wrt x1 and x2.
- d22float or array
2nd derivative of the Fermat potential wrt x2 twice.
- dphi_Fermat_dx1(x1, x2, y)
Return only d1 from
dphi_Fermat_vec().
- dphi_Fermat_dx2(x1, x2, y)
Return only d2 from
dphi_Fermat_vec().
- ddphi_Fermat_ddx1(x1, x2)
Return only d11 from
ddphi_Fermat_vec().
- ddphi_Fermat_ddx2(x1, x2)
Return only d22 from
ddphi_Fermat_vec().
- ddphi_Fermat_dx1dx2(x1, x2)
Return only d12 from
ddphi_Fermat_vec().
- dpsi_dx1(x1, x2)
Return only d1 from
dpsi_vec().
- dpsi_dx2(x1, x2)
Return only d2 from
dpsi_vec().
- ddpsi_ddx1(x1, x2)
Return only d11 from
ddpsi_vec().
- ddpsi_ddx2(x1, x2)
Return only d22 from
ddpsi_vec().
- ddpsi_dx1dx2(x1, x2)
Return only d12 from
ddpsi_vec().
- shear(x1, x2)
Magnification matrix.
The Jacobian matrix for the lens mapping is [1]
\[A_{ij} = \frac{\partial y_i}{\partial x_j} = \partial_i\partial_j\phi_F = \delta_{ij} - \partial_i\partial_j\psi\]It can be written as
\[\begin{split}A = \begin{pmatrix}1-\kappa-\gamma_1 & -\gamma_2\\ -\gamma_2 & 1-\kappa+\gamma_1 \end{pmatrix}\end{split}\]The convergence, \(\kappa\), and shear, \(\gamma\), can be expressed in terms of the second derivatives of the lensing potential
\[\begin{split}\begin{align} \kappa &= (\psi_{11} + \psi_{22})/2\\ \gamma_1 &= (\psi_{11} - \psi_{22})/2\\ \gamma_2 &= \psi_{12}\\ \gamma &= \sqrt{\gamma_1^2 + \gamma_2^2} \end{align}\end{split}\]The eigenvalues of \(A\) are
\[\begin{split}\begin{align} \lambda_1 &= 1 - \kappa - \gamma\\ \lambda_2 &= 1 - \kappa + \gamma\\ \text{tr}\,A &= \lambda_1+\lambda_2 = 2(1-\kappa)\\ \det A &= \lambda_1\lambda_2 = (1-\kappa)^2-\gamma^2 \end{align}\end{split}\]Finally, the magnification, \(\mu\), is defined as
\[\mu = \frac{1}{|\det A|}\]- Parameters:
- x1, x2float or array
Coordinates.
- Returns:
- ddict
Dictionary with keys:
gamma1(float or array) – \(\gamma_1\)gamma2(float or array) – \(\gamma_2\)kappa(float or array) – \(\kappa\)gamma(float or array) – \(\gamma\)lambda1(float or array) – \(\lambda_1\)lambda2(float or array) – \(\lambda_2\)detA(float or array) – \(\det A\)trA(float or array) – \(\text{tr}\,A\)mag(float or array) – \(\mu\)
References
[1]P. Schneider, J. Ehlers, and E. E. Falco, Gravitational Lenses, (1992).
- default_params()
(subclass defined) Initialize the default parameters.
- Returns:
- p_physdict
Default physical parameters.
- p_precdict
Default precision parameters.
- check_input()
(subclass defined, optional) Check the input of the lens implementation.
- psi(x1, x2)
(subclass defined) Lensing potential.
- Parameters:
- x1, x2float or array
Coordinates.
- Returns:
- psifloat or array or None, default=None
- dpsi_vec(x1, x2)
(subclass defined) Gradient of the lensing potential.
- Parameters:
- x1, x2float or array
Coordinates.
- Returns:
- d1float or array or None, default=None
Derivative of the lensing potential wrt x1.
- d2float or array or None, default=None
Derivative of the lensing potential wrt x2.
- ddpsi_vec(x1, x2)
(subclass defined) Hessian of the lensing potential.
- Parameters:
- x1, x2float or array
Coordinate x1.
- Returns:
- d11float or array or None, default=None
2nd derivative of the lensing potential wrt x1 twice.
- d12float or array or None, default=None
2nd derivative of the lensing potential wrt x1 and x2.
- d22float or array or None, default=None
2nd derivative of the lensing potential wrt x2 twice.
- class glow.lenses.PsiAxisym(p_phys={}, p_prec={})
Bases:
PsiGeneralBase class for an axisymmetric lens.
- Parameters:
- p_physdict, optional
Physical parameters of the lens.
- p_precdict, optional
Precision parameters of the lens.
- Attributes:
- isAxisymbool, default=True
Allows to easily differentiate this class from
PsiGeneral.
Methods
ddpsi_ddx(x)(subclass defined) Second derivative of the lensing potential.
ddpsi_vec(x1, x2)Wrapper for
ddpsi_ddx().dpsi_dx(x)(subclass defined) First derivative of the lensing potential.
dpsi_vec(x1, x2)Wrapper for
dpsi_dx().psi(x1, x2)Wrapper for
psi_x().psi_x(x)(subclass defined) Lensing potential.
to_file(fname, xmin, xmax, Nx[, extension])Evaluate the lensing potential and its derivatives on a grid and store it.
- psi(x1, x2)
Wrapper for
psi_x().This method allows to use axisymmetric lenses with algorithms designed only for generic lenses. It defines the general lensing potential from its symmetric version as
\[\psi(x_1, x_2) = \psi\left(x=\sqrt{x_1^2+x_2^2}\right)\]- Parameters:
- x1, x2float or array
Coordinates.
- Returns:
- psifloat or array
Lensing potential at (x1, x2).
- dpsi_vec(x1, x2)
Wrapper for
dpsi_dx().- The derivatives are evaluated as
- \[\begin{split}\begin{align} \partial_1\psi &= \psi'\frac{x_1}{x}\\ \partial_2\psi &= \psi'\frac{x_2}{x} \end{align}\end{split}\]
- Parameters:
- x1, x2float or array
Coordinates.
- Returns:
- d1float or array
\(\partial_1\psi\)
- d2float or array
\(\partial_2\psi\)
- ddpsi_vec(x1, x2)
Wrapper for
ddpsi_ddx().- The derivatives are evaluated as
- \[\begin{split}\begin{align} \partial_{11}\psi &= (1-r_1^2)\psi'/x + r_1^2\psi''\\ \partial_{12}\psi &= r_1r_2(\psi'' - \psi'/x)\\ \partial_{22}\psi &= (1-r_2^2)\psi'/x + r_2^2\psi'' \end{align}\end{split}\]
with \(r_{1,2}=x_{1,2}/x\).
- Parameters:
- x1, x2float or array
Coordinates x1.
- Returns:
- d11float or array
\(\partial_{11}\psi\)
- d12float or array
\(\partial_{12}\psi\)
- d22float or array
\(\partial_{22}\psi\)
- to_file(fname, xmin, xmax, Nx, extension='_lens.dat')
Evaluate the lensing potential and its derivatives on a grid and store it.
This method is called when a lens that has not been implemented in C is used in the C part of the code. The lens is then evaluated from
xmintoxmaxin a logarithmic grid withNxpoints, stored and later read and interpolated from C. The files are stored in:fname+'_psi'+extensionfname+'_dpsi'+extensionfname+'_ddpsi'+extension
- Parameters:
- fnamestr
Root of the file name.
- xminfloat
Minimum radius in the grid.
- xmaxfloat
Maximum radius in the grid.
- Nxfloat
Number of grid points.
- extensionstr, optional
Extension of the file.
Notes
This method is intended for internal use, but can be used to save the lens to disk.
- psi_x(x)
(subclass defined) Lensing potential.
- Parameters:
- xfloat or array
Radius.
- Returns:
- psifloat or array or None, default=None
- dpsi_dx(x)
(subclass defined) First derivative of the lensing potential.
- Parameters:
- xfloat or array
Radius.
- Returns:
- dpsifloat or array or None, default=None
Derivative of the lensing potential wrt x.
- ddpsi_ddx(x)
(subclass defined) Second derivative of the lensing potential.
- Parameters:
- xfloat or array
Radius.
- Returns:
- ddpsifloat or array or None, default=None
Second derivative of the lensing potential wrt x.