L i,dddlZddlmZddlmZddlmZgdZdZdZ d d Z d d Z d d Z d d Z y)N)normalize_axis_index) _ni_support) _nd_image)fourier_gaussianfourier_uniformfourier_ellipsoid fourier_shiftc||jjtjtjtj fvr-tj |j|j}|Stj |jtj}|St|turn|tjtjtj tjfvr tdtj |j|}|S|j|jk7r td|SNdtypezoutput type not supportedzoutput shape not correct) rtypenp complex64 complex128float32zerosshapefloat64 RuntimeErroroutputinputs \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/scipy/ndimage/_fourier.py_get_output_fourierr(s ~ ;;   bmmRZZH HXXekk=F MXXekk>> from scipy import ndimage, datasets >>> import numpy.fft >>> import matplotlib.pyplot as plt >>> fig, (ax1, ax2) = plt.subplots(1, 2) >>> plt.gray() # show the filtered result in grayscale >>> ascent = datasets.ascent() >>> input_ = numpy.fft.fft2(ascent) >>> result = ndimage.fourier_gaussian(input_, sigma=4) >>> result = numpy.fft.ifft2(result) >>> ax1.imshow(ascent) >>> ax2.imshow(result.real) # the imaginary part is an artifact >>> plt.show() r r rasarrayrrndimr_normalize_sequencerflags contiguouscopyrfourier_filter)rsigmanaxisrsigmass rrrGs\ JJu E  /F ejj 1D  , ,UEJJ ?F ZZbjj 1F << " " UFAtVQ? Mrc~tj|}t||}t||j}t j ||j}tj|tj}|jjs|j}tj|||||d|S)a Multidimensional uniform fourier filter. The array is multiplied with the Fourier transform of a box of given size. Parameters ---------- input : array_like The input array. size : float or sequence The size of the box used for filtering. If a float, `size` is the same for all axes. If a sequence, `size` has to contain one value for each axis. n : int, optional If `n` is negative (default), then the input is assumed to be the result of a complex fft. If `n` is larger than or equal to zero, the input is assumed to be the result of a real fft, and `n` gives the length of the array before transformation along the real transform direction. axis : int, optional The axis of the real transform. output : ndarray, optional If given, the result of filtering the input is placed in this array. Returns ------- fourier_uniform : ndarray The filtered input. Examples -------- >>> from scipy import ndimage, datasets >>> import numpy.fft >>> import matplotlib.pyplot as plt >>> fig, (ax1, ax2) = plt.subplots(1, 2) >>> plt.gray() # show the filtered result in grayscale >>> ascent = datasets.ascent() >>> input_ = numpy.fft.fft2(ascent) >>> result = ndimage.fourier_uniform(input_, size=20) >>> result = numpy.fft.ifft2(result) >>> ax1.imshow(ascent) >>> ax2.imshow(result.real) # the imaginary part is an artifact >>> plt.show() r rr!rsizer*r+rsizess rrrs\ JJu E  /F ejj 1D  + +D%** =E JJuBJJ /E ;; ! !  UE1dFA> Mrctj|}|jdkDr tdt ||}|j dk(r|St ||j}tj||j}tj|tj}|jjs|j}tj|||||d|S)ah Multidimensional ellipsoid Fourier filter. The array is multiplied with the fourier transform of an ellipsoid of given sizes. Parameters ---------- input : array_like The input array. size : float or sequence The size of the box used for filtering. If a float, `size` is the same for all axes. If a sequence, `size` has to contain one value for each axis. n : int, optional If `n` is negative (default), then the input is assumed to be the result of a complex fft. If `n` is larger than or equal to zero, the input is assumed to be the result of a real fft, and `n` gives the length of the array before transformation along the real transform direction. axis : int, optional The axis of the real transform. output : ndarray, optional If given, the result of filtering the input is placed in this array. Returns ------- fourier_ellipsoid : ndarray The filtered input. Notes ----- This function is implemented for arrays of rank 1, 2, or 3. Examples -------- >>> from scipy import ndimage, datasets >>> import numpy.fft >>> import matplotlib.pyplot as plt >>> fig, (ax1, ax2) = plt.subplots(1, 2) >>> plt.gray() # show the filtered result in grayscale >>> ascent = datasets.ascent() >>> input_ = numpy.fft.fft2(ascent) >>> result = ndimage.fourier_ellipsoid(input_, size=20) >>> result = numpy.fft.ifft2(result) >>> ax1.imshow(ascent) >>> ax2.imshow(result.real) # the imaginary part is an artifact >>> plt.show() z'Only 1d, 2d and 3d inputs are supportedrr )rr"r#NotImplementedErrorrr/rrr$rr%r&r'rr(r.s rr r sd JJu E zzA~!"KLL  /F {{a ejj 1D  + +D%** =E JJuBJJ /E ;; ! !  UE1dFA> Mrc|tj|}t||}t||j}t j ||j}tj|tj}|jjs|j}tj||||||S)a Multidimensional Fourier shift filter. The array is multiplied with the Fourier transform of a shift operation. Parameters ---------- input : array_like The input array. shift : float or sequence The size of the box used for filtering. If a float, `shift` is the same for all axes. If a sequence, `shift` has to contain one value for each axis. n : int, optional If `n` is negative (default), then the input is assumed to be the result of a complex fft. If `n` is larger than or equal to zero, the input is assumed to be the result of a real fft, and `n` gives the length of the array before transformation along the real transform direction. axis : int, optional The axis of the real transform. output : ndarray, optional If given, the result of shifting the input is placed in this array. Returns ------- fourier_shift : ndarray The shifted input. Examples -------- >>> from scipy import ndimage, datasets >>> import matplotlib.pyplot as plt >>> import numpy.fft >>> fig, (ax1, ax2) = plt.subplots(1, 2) >>> plt.gray() # show the filtered result in grayscale >>> ascent = datasets.ascent() >>> input_ = numpy.fft.fft2(ascent) >>> result = ndimage.fourier_shift(input_, shift=200) >>> result = numpy.fft.ifft2(result) >>> ax1.imshow(ascent) >>> ax2.imshow(result.real) # the imaginary part is an artifact >>> plt.show() r ) rr"rrr#rr$rr%r&r'rr )rshiftr*r+rshiftss rr r sZ JJu E ( 7F ejj 1D  , ,UEJJ ?F ZZbjj 1F << " " E61dF; Mr)r8N)numpyrscipy._lib._utilrrr__all__rrrrr r rrr>s<>1   7t6r@F5r