:py:mod:`kernel2d` ================== .. py:module:: kernel2d Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: kernel2d.Kernel2D kernel2d.FunctionalKernel2D kernel2d.NGonKernel2D Attributes ~~~~~~~~~~ .. autoapisummary:: kernel2d.device .. py:data:: device .. py:class:: Kernel2D(a_min, a_max) .. py:method:: normalization_constant(a) Computes the normalization constant for the kernel at each source-detector distance a. This method should be implemented in the child class. :param a: Source detector distances :type a: torch.Tensor[Ld] :returns: Normalization at each source-detector distance :rtype: torch.Tensor[Ld] .. py:method:: __call__(yv, a) Computes the kernel value at each point in the meshgrid defined by xv and yv for each source-detector distance a. This method should be implemented in the child class. :param xv: Meshgrid x-coordinates :type xv: torch.Tensor[Lx,Ly] :param yv: Meshgrid y-coordinates :type yv: torch.Tensor[Lx,Ly] :param a: Source-detector distances :type a: torch.Tensor[Ld] :returns: Kernel values at each point in the meshgrid for each source-detector distance :rtype: torch.Tensor[Ld,Lx,Ly] .. py:class:: FunctionalKernel2D(kernel_fn, amplitude_fn, sigma_fn, amplitude_params, sigma_params, a_min = -torch.inf, a_max = torch.inf) Bases: :py:obj:`Kernel2D` .. py:method:: _compute_norm_via_integral() Compute the normalization constant by integrating k(x,y) from -infinity to infinity. To do this, a variable transformation is used to convert the integral to a definite integral over the range [-pi/2, pi/2]. The definite integral is computed using the Simpson's rule. .. py:method:: normalization_constant(xv, yv, a) Obtains the normalization constant for the 2D kernel :param xv: Meshgrid x-coordinates :type xv: torch.Tensor[Lx,Ly] :param yv: Meshgrid y-coordinates :type yv: torch.Tensor[Lx,Ly] :param a: Source-detector distances :type a: torch.Tensor[Ld] :returns: Normalization constant at each source-detector distance :rtype: torch.Tensor[Ld] .. py:method:: __call__(xv, yv, a, normalize = False) Computes the kernel at each source detector distance :param xv: Meshgrid x-coordinates :type xv: torch.Tensor[Lx,Ly] :param yv: Meshgrid y-coordinates :type yv: torch.Tensor[Lx,Ly] :param a: Source-detector distances :type a: torch.Tensor[Ld] :param normalize: Whether or not to normalize the output of the kernel. Defaults to False. :type normalize: bool, optional :returns: Kernel at each source-detector distance :rtype: torch.Tensor[Ld,Lx,Ly] .. py:class:: NGonKernel2D(N_sides, Nx, collimator_width, amplitude_fn, sigma_fn, amplitude_params, sigma_params, a_min=-torch.inf, a_max=torch.inf, rot = 0) Bases: :py:obj:`Kernel2D` .. py:method:: _compute_convolved_polygon() Computes the convolved polygon .. py:method:: normalization_constant(xv, yv, a) Computes the normalization constant for the kernel at each source-detector distance a. :param xv: Meshgrid x-coordinates :type xv: torch.Tensor[Lx,Ly] :param yv: Meshgrid y-coordinates :type yv: torch.Tensor[Lx,Ly] :param a: Source-detector distances :type a: torch.Tensor[Ld] :returns: Normalization constant at each source detector distance. :rtype: torch.Tensor[Ld] .. py:method:: __call__(xv, yv, a, normalize = False) Computes the kernel at each source detector distance :param xv: Meshgrid x-coordinates :type xv: torch.Tensor[Lx,Ly] :param yv: Meshgrid y-coordinates :type yv: torch.Tensor[Lx,Ly] :param a: Source-detector distances :type a: torch.Tensor[Ld] :param normalize: Whether or not to normalize the output of the kernel. Defaults to False. :type normalize: bool, optional :returns: Kernel at each source-detector distance :rtype: torch.Tensor[Ld,Lx,Ly]