Server : Apache System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64 User : dh_edsupp ( 6597262) PHP Version : 8.2.26 Disable Function : NONE Directory : /lib/python3/dist-packages/numpy/fft/__pycache__/ |
Upload File : |
o 6��a � @ s� d Z ddlmZmZmZmZmZ ddlmZm Z g d�Z eefZddd�Z ee dd �dd d��Zee dd �ddd ��Ze d�ddd��Ze d�ddd��ZdS )z* Discrete Fourier Transforms - helper.py � )�integer�empty�arange�asarray�roll)�array_function_dispatch� set_module)�fftshift� ifftshift�fftfreq�rfftfreqNc C s | fS �N� )�x�axesr r �2/usr/lib/python3/dist-packages/numpy/fft/helper.py�_fftshift_dispatcher s r z numpy.fft)�modulec sh t � �� |du rtt� j��}dd� � jD �}nt|t�r%� j| d }n � fdd�|D �}t� ||�S )ad Shift the zero-frequency component to the center of the spectrum. This function swaps half-spaces for all axes listed (defaults to all). Note that ``y[0]`` is the Nyquist component only if ``len(x)`` is even. Parameters ---------- x : array_like Input array. axes : int or shape tuple, optional Axes over which to shift. Default is None, which shifts all axes. Returns ------- y : ndarray The shifted array. See Also -------- ifftshift : The inverse of `fftshift`. Examples -------- >>> freqs = np.fft.fftfreq(10, 0.1) >>> freqs array([ 0., 1., 2., ..., -3., -2., -1.]) >>> np.fft.fftshift(freqs) array([-5., -4., -3., -2., -1., 0., 1., 2., 3., 4.]) Shift the zero-frequency component only along the second axis: >>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3) >>> freqs array([[ 0., 1., 2.], [ 3., 4., -4.], [-3., -2., -1.]]) >>> np.fft.fftshift(freqs, axes=(1,)) array([[ 2., 0., 1.], [-4., 3., 4.], [-1., -3., -2.]]) Nc S s g | ]}|d �qS �� r ��.0�dimr r r � <listcomp>C s zfftshift.<locals>.<listcomp>r c s g | ] }� j | d �qS r ��shape�r �ax�r r r r G s �r �tuple�range�ndimr � isinstance� integer_typesr �r r �shiftr r r r s - r c sj t � �� |du rtt� j��}dd� � jD �}nt|t�r&� j| d }n � fdd�|D �}t� ||�S )a/ The inverse of `fftshift`. Although identical for even-length `x`, the functions differ by one sample for odd-length `x`. Parameters ---------- x : array_like Input array. axes : int or shape tuple, optional Axes over which to calculate. Defaults to None, which shifts all axes. Returns ------- y : ndarray The shifted array. See Also -------- fftshift : Shift zero-frequency component to the center of the spectrum. Examples -------- >>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3) >>> freqs array([[ 0., 1., 2.], [ 3., 4., -4.], [-3., -2., -1.]]) >>> np.fft.ifftshift(np.fft.fftshift(freqs)) array([[ 0., 1., 2.], [ 3., 4., -4.], [-3., -2., -1.]]) Nc S s g | ]}|d �qS r r r r r r r r s zifftshift.<locals>.<listcomp>r c s g | ] }� j | d �qS r r r r r r r v s r r% r r r r L s # r � �?c C sz t | t�s td��d| | }t| t�}| d d d }td|td�}||d|�<