§
    ¢éUg+P  ã                   óœ   — d dl Zd dl mZmZmZmZmZmZmZm	Z	m
Z
mZmZmZmZmZ g d¢Zdd„Zdd„Z	 	 dd„Zdd„Zdd„Zdd„Zd„ Zdefd„ZdS )é    N)ÚasarrayÚzerosÚplaceÚnanÚmodÚpiÚextractÚlogÚsqrtÚexpÚcosÚsinÚpolyvalÚpolyint)ÚsawtoothÚsquareÚ
gausspulseÚchirpÚ
sweep_polyÚunit_impulseé   c                 óÌ  — t          | ¦  «        t          |¦  «        }} t          || | z
  z   ¦  «        }t          | ||z
  z   ¦  «        } | j        j        dv r| j        j        }nd}t          | j        |¦  «        }|dk    |dk     z  }t          ||t          ¦  «         t          | dt          z  ¦  «        }d|z
  ||dz  t          z  k     z  }t          ||¦  «        }t          ||¦  «        }	t          |||t          |	z  z  dz
  ¦  «         d|z
  d|z
  z  }
t          |
|¦  «        }t          |
|¦  «        }	t          ||
t          |	dz   z  |z
  t          d|	z
  z  z  ¦  «         |S )a´  
    Return a periodic sawtooth or triangle waveform.

    The sawtooth waveform has a period ``2*pi``, rises from -1 to 1 on the
    interval 0 to ``width*2*pi``, then drops from 1 to -1 on the interval
    ``width*2*pi`` to ``2*pi``. `width` must be in the interval [0, 1].

    Note that this is not band-limited.  It produces an infinite number
    of harmonics, which are aliased back and forth across the frequency
    spectrum.

    Parameters
    ----------
    t : array_like
        Time.
    width : array_like, optional
        Width of the rising ramp as a proportion of the total cycle.
        Default is 1, producing a rising ramp, while 0 produces a falling
        ramp.  `width` = 0.5 produces a triangle wave.
        If an array, causes wave shape to change over time, and must be the
        same length as t.

    Returns
    -------
    y : ndarray
        Output array containing the sawtooth waveform.

    Examples
    --------
    A 5 Hz waveform sampled at 500 Hz for 1 second:

    >>> import numpy as np
    >>> from scipy import signal
    >>> import matplotlib.pyplot as plt
    >>> t = np.linspace(0, 1, 500)
    >>> plt.plot(t, signal.sawtooth(2 * np.pi * 5 * t))

    ©ÚfFdDÚdr   r   é   )
r   ÚdtypeÚcharr   Úshaper   r   r   r   r	   )ÚtÚwidthÚwÚytypeÚyÚmask1ÚtmodÚmask2ÚtsubÚwsubÚmask3s              úV/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/scipy/signal/_waveforms.pyr   r      sk  € õN �1‰:Œ:•w˜u‘~”~€q€AÝ��Q˜‘U‘ÑÔ€AÝ��Q˜‘U‘ÑÔ€AØ„w„|�xÐÐØ””ˆˆàˆÝˆaŒg�uÑÔ€Að �ŠU�q˜1’uÑ€EÝ	ˆ!ˆU•CÑÔÐõ ˆq�!•b‘&‰>Œ>€Dð �‰Y˜4 ! a¡%­"¡*Ò,Ñ-€EÝ�5˜$ÑÔ€DÝ�5˜!ÑÔ€DÝ	ˆ!ˆU�D�B ™IÑ&¨Ñ*Ñ+Ô+Ð+ð
 �‰Y˜1˜u™9Ñ%€EÝ�5˜$ÑÔ€DÝ�5˜!ÑÔ€DÝ	ˆ!ˆU•R˜4 !™8‘_ tÑ+µ°a¸$±h±Ñ@ÑAÔAÐAØ€Hó    ç      à?c                 óø  — t          | ¦  «        t          |¦  «        }} t          || | z
  z   ¦  «        }t          | ||z
  z   ¦  «        } | j        j        dv r| j        j        }nd}t          | j        |¦  «        }|dk    |dk     z  }t          ||t          ¦  «         t          | dt          z  ¦  «        }d|z
  ||dz  t          z  k     z  }t          ||d¦  «         d|z
  d|z
  z  }t          ||d¦  «         |S )aB  
    Return a periodic square-wave waveform.

    The square wave has a period ``2*pi``, has value +1 from 0 to
    ``2*pi*duty`` and -1 from ``2*pi*duty`` to ``2*pi``. `duty` must be in
    the interval [0,1].

    Note that this is not band-limited.  It produces an infinite number
    of harmonics, which are aliased back and forth across the frequency
    spectrum.

    Parameters
    ----------
    t : array_like
        The input time array.
    duty : array_like, optional
        Duty cycle.  Default is 0.5 (50% duty cycle).
        If an array, causes wave shape to change over time, and must be the
        same length as t.

    Returns
    -------
    y : ndarray
        Output array containing the square waveform.

    Examples
    --------
    A 5 Hz waveform sampled at 500 Hz for 1 second:

    >>> import numpy as np
    >>> from scipy import signal
    >>> import matplotlib.pyplot as plt
    >>> t = np.linspace(0, 1, 500, endpoint=False)
    >>> plt.plot(t, signal.square(2 * np.pi * 5 * t))
    >>> plt.ylim(-2, 2)

    A pulse-width modulated sine wave:

    >>> plt.figure()
    >>> sig = np.sin(2 * np.pi * t)
    >>> pwm = signal.square(2 * np.pi * 30 * t, duty=(sig + 1)/2)
    >>> plt.subplot(2, 1, 1)
    >>> plt.plot(t, sig)
    >>> plt.subplot(2, 1, 2)
    >>> plt.plot(t, pwm)
    >>> plt.ylim(-1.5, 1.5)

    r   r   r   r   r   éÿÿÿÿ)	r   r   r   r   r   r   r   r   r   )	r    Údutyr"   r#   r$   r%   r&   r'   r*   s	            r+   r   r   X   s  € õb �1‰:Œ:•w˜t‘}”}€q€AÝ��Q˜‘U‘ÑÔ€AÝ��Q˜‘U‘ÑÔ€AØ„w„|�xÐÐØ””ˆˆàˆåˆaŒg�uÑÔ€Að �ŠU�q˜1’uÑ€EÝ	ˆ!ˆU•CÑÔÐõ ˆq�!•b‘&‰>Œ>€DØ�‰Y˜4 ! a¡%­"¡*Ò,Ñ-€EÝ	ˆ!ˆU�AÑÔÐð �‰Y˜1˜u™9Ñ%€EÝ	ˆ!ˆU�BÑÔÐØ€Hr,   éè  éúÿÿÿéÄÿÿÿFc                 óÖ  — |dk     rt          d|z  ¦  «        ‚|dk    rt          d|z  ¦  «        ‚|dk    rt          d|z  ¦  «        ‚t          d|dz  ¦  «        }t          |z  |z  dz   dt          |¦  «        z  z  }t	          | t
          ¦  «        r]| d	k    rH|dk    rt          d
¦  «        ‚t          d|dz  ¦  «        }	t          t          |	¦  «         |z  ¦  «        S t          d¦  «        ‚t          | | z  | z  ¦  «        }
|
t          dt          z  |z  | z  ¦  «        z  }|
t          dt          z  |z  | z  ¦  «        z  }|s|s|S |s|r||
fS |r|s||fS |r|r|||
fS dS dS )aa  
    Return a Gaussian modulated sinusoid:

        ``exp(-a t^2) exp(1j*2*pi*fc*t).``

    If `retquad` is True, then return the real and imaginary parts
    (in-phase and quadrature).
    If `retenv` is True, then return the envelope (unmodulated signal).
    Otherwise, return the real part of the modulated sinusoid.

    Parameters
    ----------
    t : ndarray or the string 'cutoff'
        Input array.
    fc : float, optional
        Center frequency (e.g. Hz).  Default is 1000.
    bw : float, optional
        Fractional bandwidth in frequency domain of pulse (e.g. Hz).
        Default is 0.5.
    bwr : float, optional
        Reference level at which fractional bandwidth is calculated (dB).
        Default is -6.
    tpr : float, optional
        If `t` is 'cutoff', then the function returns the cutoff
        time for when the pulse amplitude falls below `tpr` (in dB).
        Default is -60.
    retquad : bool, optional
        If True, return the quadrature (imaginary) as well as the real part
        of the signal.  Default is False.
    retenv : bool, optional
        If True, return the envelope of the signal.  Default is False.

    Returns
    -------
    yI : ndarray
        Real part of signal.  Always returned.
    yQ : ndarray
        Imaginary part of signal.  Only returned if `retquad` is True.
    yenv : ndarray
        Envelope of signal.  Only returned if `retenv` is True.

    See Also
    --------
    scipy.signal.morlet

    Examples
    --------
    Plot real component, imaginary component, and envelope for a 5 Hz pulse,
    sampled at 100 Hz for 2 seconds:

    >>> import numpy as np
    >>> from scipy import signal
    >>> import matplotlib.pyplot as plt
    >>> t = np.linspace(-1, 1, 2 * 100, endpoint=False)
    >>> i, q, e = signal.gausspulse(t, fc=5, retquad=True, retenv=True)
    >>> plt.plot(t, i, t, q, t, e, '--')

    r   z'Center frequency (fc=%.2f) must be >=0.z+Fractional bandwidth (bw=%.2f) must be > 0.z7Reference level for bandwidth (bwr=%.2f) must be < 0 dBg      $@g      4@r   g      @Úcutoffz.Reference level for time cutoff must be < 0 dBz'If `t` is a string, it must be 'cutoff'N)
Ú
ValueErrorÚpowr   r
   Ú
isinstanceÚstrr   r   r   r   )r    ÚfcÚbwÚbwrÚtprÚretquadÚretenvÚrefÚaÚtrefÚyenvÚyIÚyQs                r+   r   r   £   sà  € ðx 
ˆA‚v€vÝÐBÀRÑGÑHÔHÐHØ	ˆQ‚w€wÝÐFÈÑKÑLÔLÐLØ
ˆa‚x€xÝð %Ø'*ñ+ñ ,ô ,ð 	,õ
 ˆd�C˜$‘JÑ
Ô
€Cõ ˆr‰'�B‰,˜1Ñ	Ð ¥c¨#¡h¤h¡Ñ/€Aå�!•SÑÔð 
HØ�Š=ˆ=ð �aŠxˆxÝ ð "-ñ .ô .ð .å�t˜S 4™ZÑ(Ô(ˆDÝ�˜T™œ˜
 Q™Ñ'Ô'Ð'åÐFÑGÔGÐGå�ˆr�A‰v˜‰z‰?Œ?€DØ	•�A�‘F˜R‘K !‘OÑ$Ô$Ñ	$€BØ	•�A�‘F˜R‘K !‘OÑ$Ô$Ñ	$€BØð ˜6ð Øˆ	Øð �vð Ø�4ˆxˆØð �vð Ø�2ˆvˆØð �6ð Ø�2�tˆ|Ððð ð ð r,   ÚlinearTc                 óh   — t          | |||||¦  «        }|t          dz  z  }t          ||z   ¦  «        S )aR  Frequency-swept cosine generator.

    In the following, 'Hz' should be interpreted as 'cycles per unit';
    there is no requirement here that the unit is one second.  The
    important distinction is that the units of rotation are cycles, not
    radians. Likewise, `t` could be a measurement of space instead of time.

    Parameters
    ----------
    t : array_like
        Times at which to evaluate the waveform.
    f0 : float
        Frequency (e.g. Hz) at time t=0.
    t1 : float
        Time at which `f1` is specified.
    f1 : float
        Frequency (e.g. Hz) of the waveform at time `t1`.
    method : {'linear', 'quadratic', 'logarithmic', 'hyperbolic'}, optional
        Kind of frequency sweep.  If not given, `linear` is assumed.  See
        Notes below for more details.
    phi : float, optional
        Phase offset, in degrees. Default is 0.
    vertex_zero : bool, optional
        This parameter is only used when `method` is 'quadratic'.
        It determines whether the vertex of the parabola that is the graph
        of the frequency is at t=0 or t=t1.

    Returns
    -------
    y : ndarray
        A numpy array containing the signal evaluated at `t` with the
        requested time-varying frequency.  More precisely, the function
        returns ``cos(phase + (pi/180)*phi)`` where `phase` is the integral
        (from 0 to `t`) of ``2*pi*f(t)``. ``f(t)`` is defined below.

    See Also
    --------
    sweep_poly

    Notes
    -----
    There are four options for the `method`.  The following formulas give
    the instantaneous frequency (in Hz) of the signal generated by
    `chirp()`.  For convenience, the shorter names shown below may also be
    used.

    linear, lin, li:

        ``f(t) = f0 + (f1 - f0) * t / t1``

    quadratic, quad, q:

        The graph of the frequency f(t) is a parabola through (0, f0) and
        (t1, f1).  By default, the vertex of the parabola is at (0, f0).
        If `vertex_zero` is False, then the vertex is at (t1, f1).  The
        formula is:

        if vertex_zero is True:

            ``f(t) = f0 + (f1 - f0) * t**2 / t1**2``

        else:

            ``f(t) = f1 - (f1 - f0) * (t1 - t)**2 / t1**2``

        To use a more general quadratic function, or an arbitrary
        polynomial, use the function `scipy.signal.sweep_poly`.

    logarithmic, log, lo:

        ``f(t) = f0 * (f1/f0)**(t/t1)``

        f0 and f1 must be nonzero and have the same sign.

        This signal is also known as a geometric or exponential chirp.

    hyperbolic, hyp:

        ``f(t) = f0*f1*t1 / ((f0 - f1)*t + f1*t1)``

        f0 and f1 must be nonzero.

    Examples
    --------
    The following will be used in the examples:

    >>> import numpy as np
    >>> from scipy.signal import chirp, spectrogram
    >>> import matplotlib.pyplot as plt

    For the first example, we'll plot the waveform for a linear chirp
    from 6 Hz to 1 Hz over 10 seconds:

    >>> t = np.linspace(0, 10, 1500)
    >>> w = chirp(t, f0=6, f1=1, t1=10, method='linear')
    >>> plt.plot(t, w)
    >>> plt.title("Linear Chirp, f(0)=6, f(10)=1")
    >>> plt.xlabel('t (sec)')
    >>> plt.show()

    For the remaining examples, we'll use higher frequency ranges,
    and demonstrate the result using `scipy.signal.spectrogram`.
    We'll use a 4 second interval sampled at 7200 Hz.

    >>> fs = 7200
    >>> T = 4
    >>> t = np.arange(0, int(T*fs)) / fs

    We'll use this function to plot the spectrogram in each example.

    >>> def plot_spectrogram(title, w, fs):
    ...     ff, tt, Sxx = spectrogram(w, fs=fs, nperseg=256, nfft=576)
    ...     fig, ax = plt.subplots()
    ...     ax.pcolormesh(tt, ff[:145], Sxx[:145], cmap='gray_r',
    ...                   shading='gouraud')
    ...     ax.set_title(title)
    ...     ax.set_xlabel('t (sec)')
    ...     ax.set_ylabel('Frequency (Hz)')
    ...     ax.grid(True)
    ...

    Quadratic chirp from 1500 Hz to 250 Hz
    (vertex of the parabolic curve of the frequency is at t=0):

    >>> w = chirp(t, f0=1500, f1=250, t1=T, method='quadratic')
    >>> plot_spectrogram(f'Quadratic Chirp, f(0)=1500, f({T})=250', w, fs)
    >>> plt.show()

    Quadratic chirp from 1500 Hz to 250 Hz
    (vertex of the parabolic curve of the frequency is at t=T):

    >>> w = chirp(t, f0=1500, f1=250, t1=T, method='quadratic',
    ...           vertex_zero=False)
    >>> plot_spectrogram(f'Quadratic Chirp, f(0)=1500, f({T})=250\n' +
    ...                  '(vertex_zero=False)', w, fs)
    >>> plt.show()

    Logarithmic chirp from 1500 Hz to 250 Hz:

    >>> w = chirp(t, f0=1500, f1=250, t1=T, method='logarithmic')
    >>> plot_spectrogram(f'Logarithmic Chirp, f(0)=1500, f({T})=250', w, fs)
    >>> plt.show()

    Hyperbolic chirp from 1500 Hz to 250 Hz:

    >>> w = chirp(t, f0=1500, f1=250, t1=T, method='hyperbolic')
    >>> plot_spectrogram(f'Hyperbolic Chirp, f(0)=1500, f({T})=250', w, fs)
    >>> plt.show()

    é´   )Ú_chirp_phaser   r   )r    Úf0Út1Úf1ÚmethodÚphiÚvertex_zeroÚphases           r+   r   r     s;   € õp ˜˜B  B¨°Ñ<Ô<€Eà�2�‰8�O€CÝˆu�s‰{ÑÔÐr,   c                 ó€  — t          | ¦  «        } t          |¦  «        }t          |¦  «        }t          |¦  «        }|dv r&||z
  |z  }dt          z  || z  d|z  | z  | z  z   z  }�nW|dv rR||z
  |dz  z  }|rdt          z  || z  || dz  z  dz  z   z  }�n(dt          z  || z  ||| z
  dz  |dz  z
  z  dz  z   z  }�n|dv ro||z  dk    rt          d¦  «        ‚||k    rdt          z  |z  | z  }nÎ|t	          ||z  ¦  «        z  }dt          z  |z  |z  t          ||z  | |z  ¦  «        d	z
  z  }nŽ|d
v rx|dk    s|dk    rt          d¦  «        ‚||k    rdt          z  |z  | z  }nX| |z  ||z
  z  }dt          z  | |z  z  t	          t          j        d| |z  z
  ¦  «        ¦  «        z  }nt          d|z  ¦  «        ‚|S )z{
    Calculate the phase used by `chirp` to generate its output.

    See `chirp` for a description of the arguments.

    )rF   ÚlinÚlir   r-   )Ú	quadraticÚquadÚqé   )Úlogarithmicr
   Úlog        zJFor a logarithmic chirp, f0 and f1 must be nonzero and have the same sign.g      ð?)Ú
hyperbolicÚhypr   z2For a hyperbolic chirp, f0 and f1 must be nonzero.r   zbmethod must be 'linear', 'quadratic', 'logarithmic', or 'hyperbolic', but a value of %r was given.)r   Úfloatr   r6   r
   r7   ÚnpÚabs)	r    rJ   rK   rL   rM   rO   ÚbetarP   Úsings	            r+   rI   rI   ¦  sG  € õ 	�‰
Œ
€AÝ	ˆr‰Œ€BÝ	ˆr‰Œ€BÝ	ˆr‰Œ€BØÐ(Ð(Ð(Ø�R‘˜2‰~ˆØ•B‘˜"˜q™& 3¨¡:°¡>°AÑ#5Ñ5Ñ6ˆ‰à	Ð-Ð	-Ð	-Ø�R‘˜B !™GÑ$ˆØð 	MØ�‘F˜b 1™f t¨a°1©f¡}°qÑ'8Ñ8Ñ9ˆE‰Eà�‘F˜b 1™f t°°Q±¸1©}¸rÀQ¹wÑ/FÑ'GÈ!Ñ'KÑKÑLˆE‰Eà	Ð/Ð	/Ð	/Ø�‰7�cŠ>ˆ>Ýð ?ñ @ô @ð @à�Š8ˆ8Ø�‘F˜R‘K !‘OˆEˆEà�˜B ™G™œÑ$ˆDØ�‘F˜T‘M BÑ&­#¨b°2©g°q¸2±vÑ*>Ô*>ÀÑ*DÑEˆEˆEà	Ð(Ð	(Ð	(Ø�Š7ˆ7�b˜A’g�gÝð (ñ )ô )ð )à�Š8ˆ8à�‘F˜R‘K !‘OˆEˆEð �3˜‘8˜r B™wÑ'ˆDØ�‘F˜t˜e b™jÑ)­Cµ´°q¸1¸T¹6±zÑ0BÔ0BÑ,CÔ,CÑCˆEˆEõ ð Jà!ñ"ñ #ô #ð 	#ð €Lr,   c                 ó`   — t          | |¦  «        }|t          dz  z  }t          ||z   ¦  «        S )a&
  
    Frequency-swept cosine generator, with a time-dependent frequency.

    This function generates a sinusoidal function whose instantaneous
    frequency varies with time.  The frequency at time `t` is given by
    the polynomial `poly`.

    Parameters
    ----------
    t : ndarray
        Times at which to evaluate the waveform.
    poly : 1-D array_like or instance of numpy.poly1d
        The desired frequency expressed as a polynomial.  If `poly` is
        a list or ndarray of length n, then the elements of `poly` are
        the coefficients of the polynomial, and the instantaneous
        frequency is

          ``f(t) = poly[0]*t**(n-1) + poly[1]*t**(n-2) + ... + poly[n-1]``

        If `poly` is an instance of numpy.poly1d, then the
        instantaneous frequency is

          ``f(t) = poly(t)``

    phi : float, optional
        Phase offset, in degrees, Default: 0.

    Returns
    -------
    sweep_poly : ndarray
        A numpy array containing the signal evaluated at `t` with the
        requested time-varying frequency.  More precisely, the function
        returns ``cos(phase + (pi/180)*phi)``, where `phase` is the integral
        (from 0 to t) of ``2 * pi * f(t)``; ``f(t)`` is defined above.

    See Also
    --------
    chirp

    Notes
    -----
    .. versionadded:: 0.8.0

    If `poly` is a list or ndarray of length `n`, then the elements of
    `poly` are the coefficients of the polynomial, and the instantaneous
    frequency is:

        ``f(t) = poly[0]*t**(n-1) + poly[1]*t**(n-2) + ... + poly[n-1]``

    If `poly` is an instance of `numpy.poly1d`, then the instantaneous
    frequency is:

          ``f(t) = poly(t)``

    Finally, the output `s` is:

        ``cos(phase + (pi/180)*phi)``

    where `phase` is the integral from 0 to `t` of ``2 * pi * f(t)``,
    ``f(t)`` as defined above.

    Examples
    --------
    Compute the waveform with instantaneous frequency::

        f(t) = 0.025*t**3 - 0.36*t**2 + 1.25*t + 2

    over the interval 0 <= t <= 10.

    >>> import numpy as np
    >>> from scipy.signal import sweep_poly
    >>> p = np.poly1d([0.025, -0.36, 1.25, 2.0])
    >>> t = np.linspace(0, 10, 5001)
    >>> w = sweep_poly(t, p)

    Plot it:

    >>> import matplotlib.pyplot as plt
    >>> plt.subplot(2, 1, 1)
    >>> plt.plot(t, w)
    >>> plt.title("Sweep Poly\nwith frequency " +
    ...           "$f(t) = 0.025t^3 - 0.36t^2 + 1.25t + 2$")
    >>> plt.subplot(2, 1, 2)
    >>> plt.plot(t, p(t), 'r', label='f(t)')
    >>> plt.legend()
    >>> plt.xlabel('t')
    >>> plt.tight_layout()
    >>> plt.show()

    rH   )Ú_sweep_poly_phaser   r   )r    ÚpolyrN   rP   s       r+   r   r   Û  s3   € õx ˜a Ñ&Ô&€Eà�2�‰8�O€CÝˆu�s‰{ÑÔÐr,   c                 óZ   — t          |¦  «        }dt          z  t          || ¦  «        z  }|S )zƒ
    Calculate the phase used by sweep_poly to generate its output.

    See `sweep_poly` for a description of the arguments.

    r   )r   r   r   )r    rc   ÚintpolyrP   s       r+   rb   rb   =  s,   € õ �d‰mŒm€GØ•‰F•W˜W aÑ(Ô(Ñ(€EØ€Lr,   c                 óú   — t          | |¦  «        }t          j        | ¦  «        } |€dt          | ¦  «        z  }n<|dk    rt	          | dz  ¦  «        }n#t          |d¦  «        s|ft          | ¦  «        z  }d||<   |S )aB  
    Unit impulse signal (discrete delta function) or unit basis vector.

    Parameters
    ----------
    shape : int or tuple of int
        Number of samples in the output (1-D), or a tuple that represents the
        shape of the output (N-D).
    idx : None or int or tuple of int or 'mid', optional
        Index at which the value is 1.  If None, defaults to the 0th element.
        If ``idx='mid'``, the impulse will be centered at ``shape // 2`` in
        all dimensions.  If an int, the impulse will be at `idx` in all
        dimensions.
    dtype : data-type, optional
        The desired data-type for the array, e.g., ``numpy.int8``.  Default is
        ``numpy.float64``.

    Returns
    -------
    y : ndarray
        Output array containing an impulse signal.

    Notes
    -----
    The 1D case is also known as the Kronecker delta.

    .. versionadded:: 0.19.0

    Examples
    --------
    An impulse at the 0th element (:math:`\delta[n]`):

    >>> from scipy import signal
    >>> signal.unit_impulse(8)
    array([ 1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.])

    Impulse offset by 2 samples (:math:`\delta[n-2]`):

    >>> signal.unit_impulse(7, 2)
    array([ 0.,  0.,  1.,  0.,  0.,  0.,  0.])

    2-dimensional impulse, centered:

    >>> signal.unit_impulse((3, 3), 'mid')
    array([[ 0.,  0.,  0.],
           [ 0.,  1.,  0.],
           [ 0.,  0.,  0.]])

    Impulse at (2, 2), using broadcasting:

    >>> signal.unit_impulse((4, 4), 2)
    array([[ 0.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  0.],
           [ 0.,  0.,  1.,  0.],
           [ 0.,  0.,  0.,  0.]])

    Plot the impulse response of a 4th-order Butterworth lowpass filter:

    >>> imp = signal.unit_impulse(100, 'mid')
    >>> b, a = signal.butter(4, 0.2)
    >>> response = signal.lfilter(b, a, imp)

    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> plt.plot(np.arange(-50, 50), imp)
    >>> plt.plot(np.arange(-50, 50), response)
    >>> plt.margins(0.1, 0.1)
    >>> plt.xlabel('Time [samples]')
    >>> plt.ylabel('Amplitude')
    >>> plt.grid(True)
    >>> plt.show()

    N©r   Úmidr   Ú__iter__r   )r   r]   Ú
atleast_1dÚlenÚtupleÚhasattr)r   Úidxr   Úouts       r+   r   r   J  sˆ   € õT ��uÑ
Ô
€CåŒM˜%Ñ Ô €Eà
€{Ø•S˜‘Z”ZÑˆˆØ	�ŠˆÝ�E˜Q‘JÑÔˆˆÝ�S˜*Ñ%Ô%ð "Øˆf•s˜5‘z”zÑ!ˆà€Cˆ�HØ€Jr,   )r   )r-   )r1   r-   r2   r3   FF)rF   r   T)rF   Trg   )Únumpyr]   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   Ú__all__r   r   r   r   rI   r   rb   r\   r   © r,   r+   ú<module>rs      s™  ðð Ð Ð Ð ð$ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ðð ð €ðEð Eð Eð EðPHð Hð Hð HðV =BØðbð bð bð bðJ[ð [ð [ð [ð|2ð 2ð 2ð 2ðj_ð _ð _ð _ðD
ð 
ð 
ð !¨ð Vð Vð Vð Vð Vð Vr,   