def _read_particle_coords(self, chunks, ptf):
# This will read chunks and yield the results.
chunks = list(chunks)
data_files = set([])
for chunk in chunks:
for obj in chunk.objs:
data_files.update(obj.data_files)
for data_file in sorted(data_files):
with h5py.File(data_file.filename, "r") as f:
for ptype, field_list in sorted(ptf.items()):
pcount = data_file.total_particles[ptype]
coords = f[ptype]["%sPos" % ptype].value.astype("float64")
coords = np.resize(coords, (pcount, 3))
x = coords[:, 0]
y = coords[:, 1]
z = coords[:, 2]
yield ptype, (x, y, z)
评论列表
文章目录