Ñò
"pXJc           @   s¼   d  d k  l Z l Z l Z l Z l Z l Z l Z l Z l	 Z	 l
 Z
 l Z l Z l Z l Z l Z l Z d d „ Z d d „ Z d d d d d	 d	 d
 „ Z d	 d d d d	 d d „ Z d S(   iÿÿÿÿ(   t   asarrayt   zerost   placet   nant   modt   pit   extractt   logt   sqrtt   expt   cost   sint   sizet   polyvalt   polyintt   log10i   c         C   sg  t  |  ƒ t  | ƒ }  } t  | |  |  ƒ } t  |  | | ƒ }  |  i i d j o |  i i } n d } t |  i | ƒ } | d j | d j  B} t | | t ƒ t |  d t ƒ } d | | | d t j  @} t	 | | ƒ } t	 | | ƒ }	 t | | | t |	 d ƒ d | d | @}
 t	 |
 | ƒ } t	 |
 | ƒ }	 t | |
 t |	 d | t d |	 ƒ | S(   sÝ   Returns a periodic sawtooth waveform with period 2*pi
    which rises from -1 to 1 on the interval 0 to width*2*pi
    and drops from 1 to -1 on the interval width*2*pi to 2*pi
    width must be in the interval [0,1]
    t   fFdDt   di   i    i   (   R   (
   R    t   dtypet   charR   t   shapeR   R   R   R   R   (   t   tt   widtht   wt   ytypet   yt   mask1t   tmodt   mask2t   tsubt   wsubt   mask3(    (    sF   C:\graphics\Tools\Python26\Lib\site-packages\scipy\signal\waveforms.pyt   sawtooth   s&    (g      à?c         C   sC  t  |  ƒ t  | ƒ }  } t  | |  |  ƒ } t  |  | | ƒ }  |  i i d j o |  i i } n d } t |  i | ƒ } | d j | d j  B} t | | t ƒ t |  d t ƒ } d | | | d t j  @} t	 | | ƒ } t	 | | ƒ }	 t | | d ƒ d | d | @}
 t	 |
 | ƒ } t	 |
 | ƒ }	 t | |
 d ƒ | S(   s¦   Returns a periodic square-wave waveform with period 2*pi
    which is +1 from 0 to 2*pi*duty and -1 from 2*pi*duty to 2*pi
    duty must be in the interval [0,1]
    R   R   i   i    i   iÿÿÿÿ(   s   fFdD(
   R    R   R   R   R   R   R   R   R   R   (   R   t   dutyR   R   R   R   R   R   R   R   R   (    (    sF   C:\graphics\Tools\Python26\Lib\site-packages\scipy\signal\waveforms.pyt   square.   s&    iè  iúÿÿÿiÄÿÿÿi    c         C   s”  | d j  o t  d | ‚ n | d j o t  d | ‚ n | d j o t  d | ‚ n t d | d ƒ } t | | d d t | ƒ } |  d	 j oC | d j o t  d
 ‚ n t d | d ƒ }	 t t |	 ƒ | ƒ St | |  |  ƒ }
 |
 t d t | |  ƒ } |
 t d t | |  ƒ } | o | o | S| o | o | |
 f S| o | o | | f S| o | o | | |
 f Sd S(   s@  Return a gaussian modulated sinusoid:  exp(-a t^2) exp(1j*2*pi*fc)

    If retquad is non-zero, then return the real and imaginary parts
       (inphase and quadrature)
    If retenv is non-zero, then return the envelope (unmodulated signal).
    Otherwise, return the real part of the modulated sinusoid.

    Inputs:

       t   --  Input array.
       fc  --  Center frequency (Hz).
       bw  --  Fractional bandwidth in frequency domain of pulse (Hz).
       bwr --  Reference level at which fractional bandwidth is calculated (dB).
       tpr --  If t is 'cutoff', then the function returns the cutoff time for when the
                  pulse amplitude falls below tpr (in dB).
       retquad -- Return the quadrature (imaginary) as well as the real part of the signal
       retenv  -- Return the envelope of th signal.
    i    s'   Center frequency (fc=%.2f) must be >=0.s+   Fractional bandwidth (bw=%.2f) must be > 0.s7   Reference level for bandwidth (bwr=%.2f) must be < 0 dBi
   i   i   i   t   cutoffs.   Reference level for time cutoff must be < 0 dBN(   t
   ValueErrort   powR   R   R   R	   R
   R   (   R   t   fct   bwt   bwrt   tprt   retquadt   retenvt   reft   at   treft   yenvt   yIt   yQ(    (    sF   C:\graphics\Tools\Python26\Lib\site-packages\scipy\signal\waveforms.pyt
   gausspulseS   s2    !id   t   linearc         C   sø  | t  d 9} t | ƒ d j o& t d t  t t | ƒ |  ƒ | ƒ S| d j o4 | | | } d t  | |  d | |  |  } nc| d j oÄ | d j o/ t | | ƒ }	 t | | ƒ }
 |	 |
 } } nM | d j o/ t | | ƒ }	 t | | ƒ }
 |
 |	 } } n t d | ƒ ‚ | | | | } d t  | |  | |  |  |  d } n’ | d j ot | | j o t d | | f ƒ ‚ n t | | ƒ | } d t  | |  t	 d | |  ƒ d | t
 d ƒ } n t d | ƒ ‚ t | | ƒ S(   sê  Frequency-swept cosine generator.

    Parameters
    ----------
    t : ndarray
        Times at which to evaluate the waveform.
    f0 : float or ndarray, optional
        Frequency (in Hz) of the waveform at time 0.  If `f0` is an
        ndarray, it specifies the frequency change as a polynomial in
        `t` (see Notes below).
    t1 : float, optional
        Time at which `f1` is specified.
    f1 : float, optional
        Frequency (in Hz) of the waveform at time `t1`.
    method : {'linear', 'quadratic', 'logarithmic'}, optional
        Kind of frequency sweep.
    phi : float
        Phase offset, in degrees.
    qshape : {'convex', 'concave'}
        If method is 'quadratic', `qshape` specifies its shape.

    Notes
    -----
    If `f0` is an array, it forms the coefficients of a polynomial in
    `t` (see `numpy.polval`). The polynomial determines the waveform
    frequency change in time.  In this case, the values of `f1`, `t1`,
    `method`, and `qshape` are ignored.

    i´   i   i   R3   t   lint   lig      à?t	   quadratict   quadt   qt   concavet   convexsH   qshape must be either 'concave' or 'convex' but a value of %r was given.i   t   logarithmicR   t   los9   For a logarithmic sweep, f1=%f must be larger than f0=%f.i
   sS   method must be 'linear', 'quadratic', or 'logarithmic' but a value of %r was given.(   R3   R4   R5   (   R6   R7   R8   (   R;   s   logs   lo(   R   R   R
   R   R   t   maxt   minR$   R   R%   R   (   R   t   f0t   t1t   f1t   methodt   phit   qshapet   betat   phase_anglet   mxft   mnf(    (    sF   C:\graphics\Tools\Python26\Lib\site-packages\scipy\signal\waveforms.pyt   chirpŠ   s:    &&
*9
N(   t   numpyR    R   R   R   R   R   R   R   R   R	   R
   R   R   R   R   R   R    R"   R2   t   NoneRI   (    (    (    sF   C:\graphics\Tools\Python26\Lib\site-packages\scipy\signal\waveforms.pyt   <module>   s   j'%7