[SciPy-user] Matlab function detrend

Pearu Peterson pearu at cens.ioc.ee
Wed Aug 14 07:23:59 EDT 2002


On Wed, 14 Aug 2002, Nils Wagner wrote:

> There seems to be a problem with detrend
> 
> dgelss:lwork=134
> Traceback (most recent call last):
>   File "io.py", line 36, in ?
>     detrend_intyou = signal.detrend(intyou,-1,'linear')
>   File
> "/usr/local/lib/python2.1/site-packages/scipy/signal/signaltools.py",
> line 1107, in detrend
>     coef,resids,rank,s = linalg.lstsq(A,newdata[sl])
>   File "/usr/local/lib/python2.1/site-packages/scipy/linalg/basic.py",
> line 277, in lstsq
>     overwrite_b = overwrite_b)
> flapack.error: (lwork>=3*minmn+MAX(2*minmn,MAX(maxmn,nrhs))) failed for
> 2nd keyword lwork
> 
> Any idea or suggestion ?

What is intyou? An array of what type and shape? Also, what lapack are you
using? Is scipy.linalg.test(1) succesful?

detrend works here:

>>> scipy.signal.detrend(array([1,2,3,4,6,7],'d'),-1,'linear')
array([ 0.23809524,  0.00952381, -0.21904762, -0.44761905,  0.32380952,
0.0952381 ])



Travis, is there any reasons to keep the line #1105 as
            A = ones((Npts,2),'d')
and not
            A = ones((Npts,2),data.typecode())
? Or may be data should be set to 'd' from the beginning? Is detrend
supposed to work with complex input as well?

These questions arised when I used a list of integers as an input to
detrend:
>>> scipy.signal.detrend([1,2,3,4,6,7],-1,'linear')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File
"/home/peterson/opt/lib/python2.2/site-packages/scipy/signal/signaltools.py",
line 1108, in detrend
    newdata[sl] = newdata[sl] - dot(A,coef)
TypeError: Array can not be safely cast to required type

Regards,
	Pearu




More information about the SciPy-User mailing list