Exemple #1
0
def alpha(x, y, b, q, t):
    """
    Converts the parameters from lenstronomy definitions (as defined in PEMD) to the definitions of Tessore+(2015)

    :param x: x-coordinate (angle)
    :param y: y-coordinate (angle)
    :param theta_E: Einstein radius (angle), pay attention to specific definition!
    :param e1: eccentricity component
    :param e2: eccentricity component
    :param gamma: logarithmic slope of the power-law profile. gamma=2 corresponds to isothermal
    :param center_x: x-position of lens center
    :param center_y: y-position of lens center
    :return: complex derotated coordinate, rescaled Einstein radius, powerlaw index, elliptical axis ratio and angle
    """
    zz = x * q + 1j * y
    R = np.abs(zz)
    phi = np.angle(zz)
    Omega = omega(phi, t, q)
    alph = (2 * b) / (1 + q) * nan_to_num((b / R)**t * R / b) * Omega
    return alph
Exemple #2
0
def alpha(x, y, b, q, t, Omega=None):
    """
    Calculates the complex deflection

    :param x: x-coordinate (angle)
    :param y: y-coordinate (angle)
    :param b: Einstein radius (angle), pay attention to specific definition!
    :param q: axis ratio
    :param t: logarithmic power-law slope. Is t=gamma-1
    :param Omega: If given, use this Omega (to avoid recalculations)
    :return: complex deflection angle
    """
    zz = x * q + 1j * y
    R = np.abs(zz)
    phi = np.angle(zz)
    if Omega is None:
        Omega = omega(phi, t, q)
    # Omega = omega(phi, t, q)
    alph = (2 * b) / (1 + q) * nan_to_num((b / R)**t * R / b) * Omega
    return alph
Exemple #3
0
    def hessian(x, y, theta_E, gamma, e1, e2, center_x=0., center_y=0.):
        """

        :param x: x-coordinate (angle)
        :param y: y-coordinate (angle)
        :param theta_E: Einstein radius (angle), pay attention to specific definition!
        :param gamma: logarithmic slope of the power-law profile. gamma=2 corresponds to isothermal
        :param e1: eccentricity component
        :param e2: eccentricity component
        :param center_x: x-position of lens center
        :param center_y: y-position of lens center
        :return: Hessian components f_xx, f_yy, f_xy
        """
        z, b, t, q, ang_ell = param_transform(x, y, theta_E, gamma, e1, e2,
                                              center_x, center_y)
        ang = np.angle(z)
        r = np.abs(z)
        zz_ell = z.real * q + 1j * z.imag
        R = np.abs(zz_ell)
        phi = np.angle(zz_ell)

        u = nan_to_num(
            (b / R)**t
        )  # I remove all factors of (b/R)**t to only have to remove nans once
        kappa = (2 - t) / 2
        Roverr = np.sqrt(np.cos(ang)**2 * q**2 + np.sin(ang)**2)

        Omega = omega(phi, t, q)
        alph = (2 * b) / (1 + q) / b * Omega
        gamma_shear = -np.exp(2j * (ang + ang_ell)) * kappa + (1 - t) * np.exp(
            1j * (ang + 2 * ang_ell)) * alph * Roverr

        f_xx = (kappa + gamma_shear.real) * u
        f_yy = (kappa - gamma_shear.real) * u
        f_xy = gamma_shear.imag * u
        # Fix the nans if x=y=0 is filled in

        return f_xx, f_xy, f_xy, f_yy