SciPy的,fftpack和float64 [英] scipy, fftpack and float64
问题描述
我想用DCT功能从scipy.fftpack与numpy的float64的数组。然而,现在看来,这只是实施了np.float32。有没有快速的解决办法,我可以做的就是这个工作?我赶紧看了进去,但我不知道所有的依赖。所以,一切都搞乱之前,我想我会问这里的技巧!
我已经发现迄今这个唯一的一点是此链接: http://mail.scipy.org/pipermail/scipy-svn/2010-September/004197.html
在此先感谢。
下面是它提出了一个ValueError错误:
-------------------------------------- -------------------------------------
ValueError错误回溯(最新最后调用)
< IPython中输入-12-f09567c28e37>与<模块>()
----> 1 scipy.fftpack.dct(C [100])
/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/scipy/fftpack/realtransforms.pyc的DCT(X,类型,N,轴,规范,overwrite_x)
118升NotImplementedError(
119正交化尚不支持DCT-I)
- > 120回_dct(X,类型,N,轴,规范=常态,overwrite_x = overwrite_x)
121
122高清IDCT(X,类型= 2,N =无,轴= -1,规范=无,overwrite_x = 0):
/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/scipy/fftpack/realtransforms.pyc在_dct(X,类型,N,轴,overwrite_x,标准化)
215升ValueError错误(类型%D不理解%型)
216其他:
- > 217升ValueError错误(DTYPE%S不支持%tmp.dtype)
218
219,如果规范化:
ValueError错误:DTYPE>不支持F8
现在的问题是不是双precision。双precision当然是支持的。问题是,你有一点点端计算机和(也许从文件加载一个文件?)有大端数据,请注意>
在 DTYPE>不支持F8
。看来你只需将它转换为本地翻一番自己。如果你知道它的双precision,你可能只是想everytiong一旦转换成你的本地命令:
C = c.astype(浮点)
虽然我猜你也可以检查 c.dtype.byteorder
,我想应该是 ='
,如果,开关...沿东西:
如果c.dtype.byteorder ='='!
C = c.astype(c.dtype.newbyteorder('='))
这应该也是,如果你碰巧有一个precision或整数...
I would like to use the dct functionality from the scipy.fftpack with an array of numpy float64. However, it seems it is only implemented for np.float32. Is there any quick workaround I could do to get this done? I looked into it quickly but I am not sure of all the dependencies. So, before messing everything up, I thought I'd ask for tips here!
The only thing I have found so far about this is this link : http://mail.scipy.org/pipermail/scipy-svn/2010-September/004197.html
Thanks in advance.
Here is the ValueError it raises:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-12-f09567c28e37> in <module>()
----> 1 scipy.fftpack.dct(c[100])
/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/scipy/fftpack/realtransforms.pyc in dct(x, type, n, axis, norm, overwrite_x)
118 raise NotImplementedError(
119 "Orthonormalization not yet supported for DCT-I")
--> 120 return _dct(x, type, n, axis, normalize=norm, overwrite_x=overwrite_x)
121
122 def idct(x, type=2, n=None, axis=-1, norm=None, overwrite_x=0):
/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/scipy/fftpack/realtransforms.pyc in _dct(x, type, n, axis, overwrite_x, normalize)
215 raise ValueError("Type %d not understood" % type)
216 else:
--> 217 raise ValueError("dtype %s not supported" % tmp.dtype)
218
219 if normalize:
ValueError: dtype >f8 not supported
The problem is not the double precision. Double precision is of course supported. The problem is that you have a little endian computer and (maybe loading a file from a file?) have big endian data, note the >
in dtype >f8 not supported
. It seems you will simply have to cast it to native double yourself. If you know its double precision, you probably just want to convert everytiong to your native order once:
c = c.astype(float)
Though I guess you could also check c.dtype.byteorder
which I think should be '='
, and if, switch... something along:
if c.dtype.byteorder != '=':
c = c.astype(c.dtype.newbyteorder('='))
Which should work also if you happen to have single precision or integers...
这篇关于SciPy的,fftpack和float64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!