#NEWLINE# def gausspulse( t , fc = 1000 , bw = 0.5 , bwr = ( - 6 ) , tpr = ( - 60 ) , retquad = False , retenv = False ) : #NEWLINE# #INDENT# "\n    Return a Gaussian modulated sinusoid:\n\n        ``exp(-a t^2) exp(1j*2*pi*fc*t).``\n\n    If `retquad` is True, then return the real and imaginary parts\n    (in-phase and quadrature).\n    If `retenv` is True, then return the envelope (unmodulated signal).\n    Otherwise, return the real part of the modulated sinusoid.\n\n    Parameters\n    ----------\n    t : ndarray or the string 'cutoff'\n        Input array.\n    fc : int, optional\n        Center frequency (e.g. Hz).  Default is 1000.\n    bw : float, optional\n        Fractional bandwidth in frequency domain of pulse (e.g. Hz).\n        Default is 0.5.\n    bwr : float, optional\n        Reference level at which fractional bandwidth is calculated (dB).\n        Default is -6.\n    tpr : float, optional\n        If `t` is 'cutoff', then the function returns the cutoff\n        time for when the pulse amplitude falls below `tpr` (in dB).\n        Default is -60.\n    retquad : bool, optional\n        If True, return the quadrature (imaginary) as well as the real part\n        of the signal.  Default is False.\n    retenv : bool, optional\n        If True, return the envelope of the signal.  Default is False.\n\n    Returns\n    -------\n    yI : ndarray\n        Real part of signal.  Always returned.\n    yQ : ndarray\n        Imaginary part of signal.  Only returned if `retquad` is True.\n    yenv : ndarray\n        Envelope of signal.  Only returned if `retenv` is True.\n\n    See Also\n    --------\n    scipy.signal.morlet\n\n    Examples\n    --------\n    Plot real component, imaginary component, and envelope for a 5 Hz pulse,\n    sampled at 100 Hz for 2 seconds:\n\n    >>> from scipy import signal\n    >>> import matplotlib.pyplot as plt\n    >>> t = np.linspace(-1, 1, 2 * 100, endpoint=False)\n    >>> i, q, e = signal.gausspulse(t, fc=5, retquad=True, retenv=True)\n    >>> plt.plot(t, i, t, q, t, e, '--')\n\n    " #NEWLINE# if ( fc < 0 ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Center frequency (fc=%.2f) must be >=0.' % fc ) ) #NEWLINE# #UNINDENT# if ( bw <= 0 ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Fractional bandwidth (bw=%.2f) must be > 0.' % bw ) ) #NEWLINE# #UNINDENT# if ( bwr >= 0 ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Reference level for bandwidth (bwr=%.2f) must be < 0 dB' % bwr ) ) #NEWLINE# #UNINDENT# ref = pow ( 10.0 , ( bwr / 20.0 ) ) #NEWLINE# a = ( ( - ( ( ( pi * fc ) * bw ) ** 2 ) ) / ( 4.0 * log ( ref ) ) ) #NEWLINE# if ( t == 'cutoff' ) : #NEWLINE# #INDENT# if ( yenv >= 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'Reference level for time cutoff must be < 0 dB' ) #NEWLINE# #UNINDENT# tref = pow ( 10.0 , ( tpr / 20.0 ) ) #NEWLINE# return sqrt ( ( ( - log ( tref ) ) / a ) ) #NEWLINE# #UNINDENT# yenv = exp ( ( ( ( - a ) * t ) * t ) ) #NEWLINE# yI = ( yenv * cos ( ( ( ( 2 * pi ) * fc ) * t ) ) ) #NEWLINE# yQ = ( yenv * sin ( ( ( ( 2 * pi ) * fc ) * t ) ) ) #NEWLINE# if ( ( not retquad ) and ( not retenv ) ) : #NEWLINE# #INDENT# return yI #NEWLINE# #UNINDENT# if ( ( not retquad ) and retenv ) : #NEWLINE# #INDENT# return ( yI , yenv ) #NEWLINE# #UNINDENT# if ( retquad and ( not retenv ) ) : #NEWLINE# #INDENT# return ( yI , yQ ) #NEWLINE# #UNINDENT# if ( retquad and retenv ) : #NEWLINE# #INDENT# return ( yI , yQ , yenv )