[Scipy-svn] r6242 - trunk/scipy/signal

scipy-svn@scip... scipy-svn@scip...
Fri Feb 19 05:02:13 CST 2010


Author: stefan
Date: 2010-02-19 05:02:12 -0600 (Fri, 19 Feb 2010)
New Revision: 6242

Modified:
   trunk/scipy/signal/waveforms.py
Log:
DOC: Waveforms: format math in monospace.

Modified: trunk/scipy/signal/waveforms.py
===================================================================
--- trunk/scipy/signal/waveforms.py	2010-02-19 11:01:31 UTC (rev 6241)
+++ trunk/scipy/signal/waveforms.py	2010-02-19 11:02:12 UTC (rev 6242)
@@ -13,6 +13,7 @@
     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,w = asarray(t), asarray(width)
     w = asarray(w + (t-t))
@@ -51,6 +52,7 @@
     """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]
+
     """
     t,w = asarray(t), asarray(duty)
     w = asarray(w + (t-t))
@@ -102,6 +104,7 @@
                   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.
+
     """
     if fc < 0:
         raise ValueError, "Center frequency (fc=%.2f) must be >=0." % fc
@@ -152,7 +155,7 @@
     t : ndarray
         Times at which to evaluate the waveform.
     f0 : float
-        Frequency (in Hz) at time t=0. 
+        Frequency (in Hz) at time t=0.
     t1 : float
         Time at which `f1` is specified.
     f1 : float
@@ -171,50 +174,55 @@
     -------
     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.
+        ``cos(phase + (pi/180)*phi)``
+    where `phase` is the integral (from 0 to t) of ``2*pi*f(t)``.
+    ``f(t)`` is defined below.
 
     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
-        
+        ``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
+        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.waveforms.sweep_poly`.
 
     logarithmic, log, lo:
 
-        f(t) = f0 * (f1/f0)**(t/t1)
-        
+        ``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)
-        
+        ``f(t) = f0*f1*t1 / ((f0 - f1)*t + f1*t1)``
+
         f1 must be positive, and f0 must be greater than f1.
 
     See Also
     --------
     scipy.signal.waveforms.sweep_poly
+
     """
     # 'phase' is computed in _chirp_phase, to make testing easier.
     phase = _chirp_phase(t, f0, t1, f1, method, vertex_zero)
@@ -222,11 +230,12 @@
     phi *= pi / 180
     return cos(phase + phi)
 
-    
+
 def _chirp_phase(t, f0, t1, f1, method='linear', vertex_zero=True):
     """
     Calculate the phase used by chirp_phase to generate its output.  See
     chirp_phase for a description of the arguments.
+
     """
     if method in ['linear', 'lin', 'li']:
         beta = (f1 - f0) / t1
@@ -237,7 +246,7 @@
         if vertex_zero:
             phase = 2*pi * (f0*t + beta * t**3/3)
         else:
-            phase = 2*pi * (f1*t + beta * ((t1 - t)**3 - t1**3)/3)               
+            phase = 2*pi * (f1*t + beta * ((t1 - t)**3 - t1**3)/3)
 
     elif method in ['logarithmic', 'log', 'lo']:
         if f0*f1 <= 0.0:
@@ -266,7 +275,7 @@
 def sweep_poly(t, poly, phi=0):
     """Frequency-swept cosine generator, with a time-dependent frequency specified
     as a polynomial.
-    
+
     This function generates a sinusoidal function whose instantaneous frequency
     varies with time.  The frequency at time `t` is given by the polynomial `poly`.
 
@@ -275,12 +284,14 @@
     t : ndarray
         Times at which to evaluate the waveform.
     poly : 1D ndarray (or 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)
+        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 is 0.
 
@@ -288,12 +299,14 @@
     -------
     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. 
-    
+        ``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
     --------
     scipy.signal.waveforms.chirp
+
     """
     # 'phase' is computed in _sweep_poly_phase, to make testing easier.
     phase = _sweep_poly_phase(t, poly)
@@ -305,6 +318,7 @@
     """
     Calculate the phase used by sweep_poly to generate its output.  See
     sweep_poly for a description of the arguments.
+
     """
     # polyint handles lists, ndarrays and instances of poly1d automatically.
     intpoly = polyint(poly)



More information about the Scipy-svn mailing list