mò
rß@c           @   sQ  d  Z  d Z d Z y e Wn d \ Z Z n Xy( d k Z d k Z d k Z d k Z Wn@ e	 j
 o4 y e i
 i d e ƒ Wn e GHn Xe	 ‚ n Xe i d i e i ƒ d Z e i ƒ  d Z e a d „  Z d	 „  Z d
 k Td k Z d k Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d j o e ƒ  n d S(   so   package of variants on fourier transform, including power spectrum

   see descriptions of individual functionss%  
    power - variants on fourier transform
    Copyright (C) 2004  John Comeau <jc@jcomeau.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    s5   Not all needed libraries found, upgrade or check pathi   i    Ns   %s
iÿÿÿÿc          G   s)   t  o t i i d t |  ƒ ƒ n d  S(   Ns   %s
(   t	   debuggingt   syst   stderrt   writet   reprt   whatever(   R   (    (    t   /home/jcomeau/src/power.pyt
   DebugPrint0   s     c          G   s   d GHt  |  ƒ d S(   s6   check if lowercase functions actually work as programss=   this is a test. it is only a test. passed arguments follow...N(   R   t   args(   R   (    (    R   t   test5   s     (   t   *s:   this string has to be here, see template.py for reason whyc         C   sË   t  |  ƒ } x‘ t |  d ƒ t i j p1 t |  d ƒ t i j p t |  d ƒ t j oE t  |  d ƒ } t  |  ƒ d j o t |  d ƒ } n |  d }  q Wt	 |  ƒ } t t | ƒ } t | ƒ | f S(   s  return a numeric array and size...

    whether it was passed AS an array, or another sequence type,
    or even as a list of strings like .12, .22, .65, etc.
    if the first element is an array, then the second element will
    be taken as the size parameter to be passed to fft()i    i   N(   t   lenR   t   sizet   typet   typest   ListTypet	   TupleTypet	   ArrayTypet   intt   listt   datat   mapt   floatt   array(   R   R   R   (    (    R   t   getarrayA   s      Kc          G   s
   t  |  ƒ S(   s   for command-line testingN(   t   fftR   (   R   (    (    R   t   FftV   s     c          G   s"   t  |  ƒ \ } } t i | | ƒ S(   s2   pydoc FFT.fft, this is just an interface into thatN(   R   R   R   R   t   FFTR   (   R   R   R   (    (    R   R   Z   s     c          G   s
   t  |  ƒ S(   s   for command-line testingN(   t   powerspectrumR   (   R   (    (    R   t   PowerSpectruma   s     c          G   sI   t  |  ƒ \ } } t | | ƒ } t | t | ƒ ƒ t | ƒ d } | S(   sr   Power spectrum code from University of Cape Town website

 http://www.phy.uct.ac.za/courses/phy400w/cp/pyfrags.htmi   N(
   R   R   R   R   R   t	   transformt   abst	   conjugateR   t   spectrum(   R   R   R!   R   R   (    (    R   R   e   s
     $c          C   s  t  i d i t i ƒ d } | i d ƒ d }  y­ t d |  ƒ t i	 j o‚ t
 i d ƒ i |  ƒ d j o t d |  ƒ qÜ y t t d |  ƒ ƒ GHWqÜ t  i i d |  t t  i d ƒ f ƒ ‚  qÜ Xn t d	 |  ‚ Wn¬ t j
 o  } y | i d } Wn d
 } n X| d	 |  j o t | ‚ n t t  i ƒ d j o t  i i d ƒ t ƒ  qŒt  i i d t t i d ƒ d f ƒ n Xd S(   sÀ  main routine, only used for command-line testing

    let's say this program is called 'template.py'
    don't, by the way, name the program with the name
     of an included function if you're using this system...
    now if the program is invoked as './template.py', it will simply
     output a usage message.
    if invoked as './template.py MyFunction 1 2 3'
     we will attempt to call MyFunction(1, 2, 3) and
     show whatever is found
    if invoked as './template.py myfunction 1 2 3'
     we attempt to call myfunction(1, 2, 3) as a program and
     let it output whatever it decides
    likewise if you symlink like so: 'ln -s template.py myfunction'
     then invoke as './myfunction 1 2 3'i    iÿÿÿÿt   .s   type(%s)s   ^[a-z0-9]+$s   %s(sys.argv[1:])s&   Error occurred testing routine %s(%s)
i   s   %s not a functions   unknown NameErrors_   Usage: %s [OPTIONS] INPUT[...]
    or for more detailed help, read source or:
    pydoc %s
    N(   R   t   argvt   splitt   ost   sept   programt   functiont   evalR   t   FunctionTypet   ret   compilet   matcht   NoneR   R   R   t	   NameErrort   instanceR   t   messageR   t   popt   maint   self(   R(   R0   R'   R1   (    (    R   R3   n   s0     '
t   __main__(   i   i    (   t   __doc__t	   Copyrightt   errormessaget   Truet   FalseR   R%   R   R+   t	   exceptionR   R   R#   R$   R&   R4   t   originalselfR    R   R	   t   NumericR   t   powerR   R   R   R   R   R3   t   __name__(   R8   R7   R   R   R   R   R4   R+   R	   R3   R9   R>   R<   R   R   R   R:   R   R   R%   (    (    R   t   ?   s<   (										2