有人知道如何修改下面的代码,这样我就可以在Python中读取3D-hdf数据的特定z分量片段吗?正如您从所附图像中看到的,z值从0到160,我只想绘制“80”。尺寸为400x160x160。这是我的密码。在
import h5handler as h5h
h5h.manager.setPath('E:\data\Data5', False)
for i in np.arange(0,1,5000):
cycleFile = h5h.CycleFile(h5h.manager.cycleFiles['cycle_'+str(i)+'.hdf'], 'r')
fig = plt.figure()
fig.suptitle('Cycle_'+str(i)+' at t=14.4s', fontsize=20)
ax1 = plt.subplot(311)
ax2 = plt.subplot(312)
ax3 = plt.subplot(313)
Bx = np.reshape(cycleFile.get('/fields/Bx').value.T, (160,400))*6.872130320978866e-06*(1e9)
我可以从名称猜测h5handler是一个用于处理HDF5(.h5)文件的工具,而您所使用的文件似乎是HDF4或HDF-EOS(.HDF)文件。用于处理HDF4文件的两个库是pyhdf(http://pysclint.sourceforge.net/pyhdf/documentation.html)和pyNIO(https://www.pyngl.ucar.edu/Nio.shtml)。在
如果选择使用pyhdf,可以按如下方式读取数据片段:
如果选择使用pyNIO,则可以按如下方式读取数据片段:
^{pr2}$希望有帮助!在
相关问题 更多 >
编程相关推荐