python中vstack作用_我应该如何使用Numpy的vstack方法?

首先,这里是代码的相关部分:stokes_list = np.zeros(shape=(numrows,1024)) # 'numrows' defined earlier

for i in range(numrows):

epoch_name = y['filename'][i] # 'y' is an array from earlier

os.system('pdv -t {0} > temp.txt '.format(epoch_name)) # 'pdv' is a command from another piece of software - here I copy the output into a temporary file

stokes_line = np.genfromtxt('temp.txt', usecols=3, dtype=[('stokesI','float')], skip_header=1)

stokes_list = np.vstack((stokes_line,stokes_line))

所以,基本上,每次代码循环时,stokes_line从文件temp.txt中提取一列(第四列),我希望它每次都向stokes_list添加一行。

例如,如果第一个stokes_line是1.1 2.2 3.3

第二个是4.4 5.5 6.6

那么stokes_list将1.1 2.2 3.3

4.4 5.5 6.6

会继续成长。。。

现在不行,因为我觉得这句话:stokes_list = np.vstack((stokes_line,stokes_line))

不正确。它只堆叠了两个列表-这很有意义,因为我只有两个参数。我基本上想知道我是怎么一次又一次地叠东西的。

任何帮助都将不胜感激!

如果需要,以下是temp.txt文件格式的示例:File: t091110_065921.SFTC Src: J1903+0925 Nsub: 1 Nch: 1 Npol: 4 Nbin: 1024 RMS: 0.00118753

0 0 0 0.00148099 -0.00143755 0.000931365 -0.00296775

0 0 1 0.000647476 -0.000896698 0.000171287 0.00218597

0 0 2 0.000704697 -0.00052846 -0.000603842 -0.000868739

0 0 3 0.000773361 -0.00234724 -0.0004112 0.00358033

0 0 4 0.00101559 -0.000691062 0.000196023 -0.000163109

0 0 5 -0.000220367 -0.000944024 0.000181002 -0.00268215

0 0 6 0.000311783 0.00191545 -0.00143816 -0.00213856

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值