【发布时间】:2014-08-07 11:57:09
【问题描述】:
我从未使用过 Python,我从手册中看到了一段代码,我很想知道它是什么意思。
这是手册中的代码:
import h5py
h5file = h5py.File('Output/ScottCreek250b/simulation.results.DY.hdf5')
channel_flows = h5file['Channel/Qc_out'][...]
plt.plot(channel_flows[:, 0])
plt.ylim((-0.01,0.01))
plt.title('Streamflow at outlet', fontweight='bold')
plt.ylabel('Flow ($\mathbf{m^3/s}$)')
plt.xlabel('Model time-steps (24 hours)')
我想知道这两行是什么意思,尤其是[...] 和[:, 0] 和[:, :10] 代表什么。
channel_flows = h5file['Channel/Qc_out'][...]
plt.plot(channel_flows[:, 0])
soil_stores = h5file['Soil/V_s'][...]
plt.plot(soil_stores[:, :10])
【问题讨论】:
-
那是
numpy索引 - 请参阅 docs.scipy.org/doc/numpy/reference/arrays.indexing.html -
我可以假设数据结构类似于 R 中的列表目标或 3D 数组吗? [...] 表示 x、y、z 值。
-
我不知道 R - 请阅读我链接到的文档,其中解释了它是如何工作的。
标签: python python-2.7 matplotlib plot h5py