你可以玩 python 和 numpy:
from __future__ import print_function, division
import numpy as np
file = "L1.T.rev01.p3d.hex.r8.ugrid"
n=8
dt = np.dtype([('field0','>f8'), ('field1', '>f8'), ('field2', '>f8')])
ndt = len(dt)
data = np.fromfile(file, dt, count=n) #omit count= to read all records
for row in data:
print(row)
#print(row['field0'])
将以下内容打印到屏幕上:
(5.9416208318e-313, 2.0743e-319, 0.0)
(3.15696e-318, 5.94342273776e-313, 260.16056)
(0.0, 118.46084, 272.1421)
(0.0, 115.94573, 284.80264)
(0.0, 113.49254, 298.1431)
(0.0, 111.13511, 312.15776)
(0.0, 108.90879, 326.83354)
(0.0, 106.84945, 342.14944)
我不确定如何处理标头,但有效的方法来创建-numpy-arrays-from-binary-files可能会有所帮助。对于 numpy 中的大端、小端和其他数据类型,请参阅数据类型对象