[SciPy-User] frequency components of a signal buried in a noisy time domain signal

Ivo Maljevic ivo.maljevic at gmail.com
Sat Feb 27 13:58:23 EST 2010


I am sorry guys, but the solution I've proposed, and the one that was
proposed by the scipy camp would cause confusion for those who switch from
Matlab, and I just checked that.
If you are going to use the same name as the Matlab one, than this function
should return the m such that 2**m >= abs(n), and should not return 2^m.

Whatever approach you guys want to use (and I believe that especially given
what the function should return), do not return 2**m, but just m instead.
For example:

>>> def nextpow2(n):
...   return np.ceil(np.log2(n))
...
>>> m=nextpow2(1000)
>>> m
10.0
>>> 2**m
1024.0


On 27 February 2010 13:45, Robert Kern <robert.kern at gmail.com> wrote:

> On Sat, Feb 27, 2010 at 12:41,  <josef.pktd at gmail.com> wrote:
> > On Sat, Feb 27, 2010 at 1:31 PM, Charles R Harris
> > <charlesr.harris at gmail.com> wrote:
> >>
> >> On Sat, Feb 27, 2010 at 11:02 AM, Robert Kern <robert.kern at gmail.com>
> wrote:
> >>>
> >>> On Sat, Feb 27, 2010 at 04:02, Ivo Maljevic <ivo.maljevic at gmail.com>
> >>> wrote:
> >>> > David,
> >>> > Nice way of avoiding log2, but how do you determine the length of
> your
> >>> > tab
> >>> > array?
> >>>
> >>> The input arrays can only be so large. Even on 64-bit machines, the
> >>> table need not have more than 64 entries.
> >>>
> >>>  tab = 2 ** np.arange(np.iinfo(np.intp).bits)
> >>>
> >>
> >> Or
> >>
> >> tab = 1 << arange(iinfo(intp).bits - 1)
> >
> > I think I prefer a readable solution to this for calls that are not in
> > an inner loop.
> >
> > scipy.signal.fftconvolve uses the same as Ivo's solution
> >
> > <<  means it's much larger than 1 ?
>
> It's a bitshift operator. Basically "x << y" means "x * (2 ** y)" for
> integer arguments.
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
>  -- Umberto Eco
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20100227/02d97bbc/attachment.html>


More information about the SciPy-User mailing list