File tree Expand file tree Collapse file tree
autoarray/structures/arrays Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -487,6 +487,37 @@ def convolved_array_from(self, array: Array2D) -> Array2D:
487487
488488 return Array2D (values = convolved_array_1d , mask = array_2d .mask )
489489
490+ def convolved_array_with_mask_from (self , array : Array2D , mask ) -> Array2D :
491+ """
492+ Convolve an array with this Kernel2D
493+
494+ Parameters
495+ ----------
496+ image
497+ An array representing the image the Kernel2D is convolved with.
498+
499+ Returns
500+ -------
501+ convolved_image
502+ An array representing the image after convolution.
503+
504+ Raises
505+ ------
506+ KernelException if either Kernel2D psf dimension is odd
507+ """
508+
509+ if self .mask .shape [0 ] % 2 == 0 or self .mask .shape [1 ] % 2 == 0 :
510+ raise exc .KernelException ("Kernel2D Kernel2D must be odd" )
511+
512+ convolved_array_2d = scipy .signal .convolve2d (array .array , self .native .array , mode = "same" )
513+
514+ convolved_array_1d = array_2d_util .array_2d_slim_from (
515+ mask_2d = np .array (mask ),
516+ array_2d_native = np .array (convolved_array_2d ),
517+ )
518+
519+ return Array2D (values = convolved_array_1d , mask = mask )
520+
490521 def convolve_image (self , image , blurring_image , jax_method = "direct" ):
491522 """
492523 For a given 1D array and blurring array, convolve the two using this psf.
You can’t perform that action at this time.
0 commit comments