def deflections_2d_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Following Eq. (15) and (16), but the parameters are slightly different. Parameters ---------- grid : aa.Grid2D The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ factor = (2.0 * self.mass_to_light_ratio * self.intensity / (1 + self.axis_ratio) * self.axis_ratio / np.sqrt(1.0 - self.axis_ratio**2.0)) core_radius_0 = np.sqrt( (4.0 * self.core_radius_0**2.0) / (1.0 + self.axis_ratio)**2) core_radius_1 = np.sqrt( (4.0 * self.core_radius_1**2.0) / (1.0 + self.axis_ratio)**2) psi0 = psi_from(grid=grid, axis_ratio=self.axis_ratio, core_radius=core_radius_0) psi1 = psi_from(grid=grid, axis_ratio=self.axis_ratio, core_radius=core_radius_1) deflection_y0 = np.arctanh( np.divide( np.multiply(np.sqrt(1.0 - self.axis_ratio**2.0), grid[:, 0]), np.add(psi0, self.axis_ratio**2.0 * core_radius_0), )) deflection_x0 = np.arctan( np.divide( np.multiply(np.sqrt(1.0 - self.axis_ratio**2.0), grid[:, 1]), np.add(psi0, core_radius_0), )) deflection_y1 = np.arctanh( np.divide( np.multiply(np.sqrt(1.0 - self.axis_ratio**2.0), grid[:, 0]), np.add(psi1, self.axis_ratio**2.0 * core_radius_1), )) deflection_x1 = np.arctan( np.divide( np.multiply(np.sqrt(1.0 - self.axis_ratio**2.0), grid[:, 1]), np.add(psi1, core_radius_1), )) deflection_y = np.subtract(deflection_y0, deflection_y1) deflection_x = np.subtract(deflection_x0, deflection_x1) return self.rotate_grid_from_reference_frame( np.multiply(factor, np.vstack((deflection_y, deflection_x)).T))
def deflections_2d_from_grid(self, grid): """ Calculate the deflection angles on a grid of (y,x) arc-second coordinates. For coordinates (0.0, 0.0) the analytic calculation of the deflection angle gives a NaN. Therefore, \ coordinates at (0.0, 0.0) are shifted slightly to (1.0e-8, 1.0e-8). Parameters ---------- grid : aa.Grid2D The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ factor = (2.0 * self.einstein_radius_rescaled * self.axis_ratio / np.sqrt(1 - self.axis_ratio**2)) psi = psi_from(grid=grid, axis_ratio=self.axis_ratio, core_radius=0.0) deflection_y = np.arctanh( np.divide(np.multiply(np.sqrt(1 - self.axis_ratio**2), grid[:, 0]), psi)) deflection_x = np.arctan( np.divide(np.multiply(np.sqrt(1 - self.axis_ratio**2), grid[:, 1]), psi)) return self.rotate_grid_from_reference_frame( grid=np.multiply(factor, np.vstack((deflection_y, deflection_x)).T))