def deflections_from_grid(self, grid, tabulate_bins=1000):
        """
        Calculate the deflection angles at a given set of arc-second gridded coordinates.

        Parameters
        ----------
        grid : grids.RegularGrid
            The grid of (y,x) arc-second coordinates the deflection angles are computed on.
        tabulate_bins : int
            The number of bins to tabulate the inner integral of this profile.
        """

        @jit_integrand
        def surface_density_integrand(x, kappa_radius, scale_radius, inner_slope):
            return (3 - inner_slope) * (x + kappa_radius / scale_radius) ** (inner_slope - 4) * (1 - np.sqrt(1 - x * x))

        def calculate_deflection_component(npow, index):
            deflection_grid = 2.0 * self.kappa_s * self.axis_ratio * grid[:, index]
            deflection_grid *= quad_grid(self.deflection_func, 0.0, 1.0,
                                         grid, args=(npow, self.axis_ratio, minimum_log_eta, maximum_log_eta,
                                                     tabulate_bins, surface_density_integral),
                                         epsrel=EllipticalGeneralizedNFW.epsrel)[0]

            return deflection_grid

        eta_min, eta_max, minimum_log_eta, maximum_log_eta, bin_size = self.tabulate_integral(grid, tabulate_bins)

        surface_density_integral = np.zeros((tabulate_bins,))

        for i in range(tabulate_bins):
            eta = 10. ** (minimum_log_eta + (i - 1) * bin_size)

            integral = quad(surface_density_integrand, a=0.0, b=1.0, args=(eta, self.scale_radius,
                                                                           self.inner_slope),
                            epsrel=EllipticalGeneralizedNFW.epsrel)[0]

            surface_density_integral[i] = ((eta / self.scale_radius) ** (1 - self.inner_slope)) * \
                                          (((1 + eta / self.scale_radius) ** (self.inner_slope - 3)) + integral)

        deflection_y = calculate_deflection_component(1.0, 0)
        deflection_x = calculate_deflection_component(0.0, 1)

        return self.rotate_grid_from_profile(np.multiply(1.0, np.vstack((deflection_y, deflection_x)).T))
def deflections_from_grid(self, grid, tabulate_bins=1000):
        """
        Calculate the deflection angles at a given set of arc-second gridded coordinates.

        Parameters
        ----------
        grid : grids.RegularGrid
            The grid of (y,x) arc-second coordinates the deflection angles are computed on.
        tabulate_bins : int
            The number of bins to tabulate the inner integral of this profile.
        """

        @jit_integrand
        def surface_density_integrand(x, kappa_radius, scale_radius, inner_slope):
            return (3 - inner_slope) * (x + kappa_radius / scale_radius) ** (inner_slope - 4) * (1 - np.sqrt(1 - x * x))

        def calculate_deflection_component(npow, index):
            deflection_grid = 2.0 * self.kappa_s * self.axis_ratio * grid[:, index]
            deflection_grid *= quad_grid(self.deflection_func, 0.0, 1.0,
                                         grid, args=(npow, self.axis_ratio, minimum_log_eta, maximum_log_eta,
                                                     tabulate_bins, surface_density_integral),
                                         epsrel=EllipticalGeneralizedNFW.epsrel)[0]

            return deflection_grid

        eta_min, eta_max, minimum_log_eta, maximum_log_eta, bin_size = self.tabulate_integral(grid, tabulate_bins)

        surface_density_integral = np.zeros((tabulate_bins,))

        for i in range(tabulate_bins):
            eta = 10. ** (minimum_log_eta + (i - 1) * bin_size)

            integral = quad(surface_density_integrand, a=0.0, b=1.0, args=(eta, self.scale_radius,
                                                                           self.inner_slope),
                            epsrel=EllipticalGeneralizedNFW.epsrel)[0]

            surface_density_integral[i] = ((eta / self.scale_radius) ** (1 - self.inner_slope)) * \
                                          (((1 + eta / self.scale_radius) ** (self.inner_slope - 3)) + integral)

        deflection_y = calculate_deflection_component(1.0, 0)
        deflection_x = calculate_deflection_component(0.0, 1)

        return self.rotate_grid_from_profile(np.multiply(1.0, np.vstack((deflection_y, deflection_x)).T))
def deflections_from_grid ( self , grid , tabulate_bins = 1000 ) : @ jit_integrand def surface_density_integrand ( x , kappa_radius , scale_radius , inner_slope ) : return ( 3 - inner_slope ) * ( x + kappa_radius / scale_radius ) ** ( inner_slope - 4 ) * ( 1 - np . sqrt ( 1 - x * x ) ) def calculate_deflection_component ( npow , index ) : deflection_grid = 2.0 * self . kappa_s * self . axis_ratio * grid [ : , index ] deflection_grid *= quad_grid ( self . deflection_func , 0.0 , 1.0 , grid , args = ( npow , self . axis_ratio , minimum_log_eta , maximum_log_eta , tabulate_bins , surface_density_integral ) , epsrel = EllipticalGeneralizedNFW . epsrel ) [ 0 ] return deflection_grid eta_min , eta_max , minimum_log_eta , maximum_log_eta , bin_size = self . tabulate_integral ( grid , tabulate_bins ) surface_density_integral = np . zeros ( ( tabulate_bins , ) ) for i in range ( tabulate_bins ) : eta = 10. ** ( minimum_log_eta + ( i - 1 ) * bin_size ) integral = quad ( surface_density_integrand , a = 0.0 , b = 1.0 , args = ( eta , self . scale_radius , self . inner_slope ) , epsrel = EllipticalGeneralizedNFW . epsrel ) [ 0 ] surface_density_integral [ i ] = ( ( eta / self . scale_radius ) ** ( 1 - self . inner_slope ) ) * ( ( ( 1 + eta / self . scale_radius ) ** ( self . inner_slope - 3 ) ) + integral ) deflection_y = calculate_deflection_component ( 1.0 , 0 ) deflection_x = calculate_deflection_component ( 0.0 , 1 ) return self . rotate_grid_from_profile ( np . multiply ( 1.0 , np . vstack ( ( deflection_y , deflection_x ) ) . T ) )
Calculate the deflection angles at a given set of arc-second gridded coordinates.

        Parameters
        ----------
        grid : grids.RegularGrid
            The grid of (y,x) arc-second coordinates the deflection angles are computed on.
        tabulate_bins : int
            The number of bins to tabulate the inner integral of this profile.
Calculate the deflection angles at a given set of arc - second gridded coordinates .