Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 对数据集执行快速傅里叶变换后输出阵列_Python_Numpy_Fft - Fatal编程技术网

Python 对数据集执行快速傅里叶变换后输出阵列

Python 对数据集执行快速傅里叶变换后输出阵列,python,numpy,fft,Python,Numpy,Fft,我试图对我拥有的数据集进行傅里叶变换,然后分别写出它的实部和虚部 这是我的代码: import sys,string import numpy as np from math import * import fileinput from scipy.fftpack import fft, ifft temparray = [] for i in range(200000): line = sys.stdin.readline() ## reads data from a text f

我试图对我拥有的数据集进行傅里叶变换,然后分别写出它的实部和虚部

这是我的代码:

import sys,string
import numpy as np
from math import *
import fileinput
from scipy.fftpack import fft, ifft

temparray = []

for i in range(200000):
    line = sys.stdin.readline() ## reads data from a text file
    fields = map(float,line.split())
    temparray.append(fields)
acf = sum(temparray,[]) ## I need to do this as the appended array from above is nested
y = np.fft.fft(acf)
z = (y.real,y.imag)
print z
我得到的结果如下:

(array([ 2600.36368107, 2439.50426935, 1617.52631545, ..., 1575.78483016, 1617.52631545, 2439.50426935]), array([ 0. , -767.19967198, -743.75183367, ..., 726.45052092, 743.75183367, 767.19967198]))
它似乎只打印前几个和最后几个值,完全跳过了中间的所有内容。谁能告诉我为什么会这样


谢谢

正如其他人所指出的,包括

>>> np.set_printoptions(edgeitems=5,linewidth=80,precision=2,suppress=True,threshold=10) 
>>> a = np.arange(0,100.)
>>> 
>>> a
array([  0.,   1.,   2.,   3.,   4., ...,  95.,  96.,  97.,  98.,  99.])
>>> np.set_printoptions(edgeitems=5,linewidth=80,precision=2,suppress=True,threshold=100) 
>>> a
array([  0.,   1.,   2.,   3.,   4.,   5.,   6.,   7.,   8.,   9.,  10.,  11.,
        12.,  13.,  14.,  15.,  16.,  17.,  18.,  19.,  20.,  21.,  22.,  23.,
        24.,  25.,  26.,  27.,  28.,  29.,  30.,  31.,  32.,  33.,  34.,  35.,
        36.,  37.,  38.,  39.,  40.,  41.,  42.,  43.,  44.,  45.,  46.,  47.,
        48.,  49.,  50.,  51.,  52.,  53.,  54.,  55.,  56.,  57.,  58.,  59.,
        60.,  61.,  62.,  63.,  64.,  65.,  66.,  67.,  68.,  69.,  70.,  71.,
        72.,  73.,  74.,  75.,  76.,  77.,  78.,  79.,  80.,  81.,  82.,  83.,
        84.,  85.,  86.,  87.,  88.,  89.,  90.,  91.,  92.,  93.,  94.,  95.,
        96.,  97.,  98.,  99.])

np.set_printoptions(edgeitems=3,linewidth=80,precision=2,suppress=True,threshold=5)
也许将阈值设置为某个非常大的数字

附录

如果我没有声明上述问题的最简单解决方案是简单使用,那我就是失职了

>>> list(a)

您是否应该关心数组是否以可视方式返回。

您是否只是指在打印时numpy不会显示全部内容?这样做是为了使大型阵列不会完全填充输出。您可以更改一个设置,请参见此处: