Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ytdata: check for all_data in particle selection #4579

Merged
merged 2 commits into from
Jul 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions yt/frontends/ytdata/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,14 @@ def _read_particle_coords(self, chunks, ptf):
)
yield ptype, (x, y, z), 0.0

def _read_particle_fields(self, chunks, ptf, selector):
# Now we have all the sizes, and we can allocate
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, key=lambda x: (x.filename, x.start)):
with h5py.File(data_file.filename, mode="r") as f:
for ptype, field_list in sorted(ptf.items()):
def _read_particle_data_file(self, data_file, ptf, selector):
data_return = {}

with h5py.File(data_file.filename, mode="r") as f:
for ptype, field_list in sorted(ptf.items()):
if selector is None or getattr(selector, "is_all_data", False):
mask = slice(None, None, None)
else:
units = _get_position_array_units(ptype, f, "x")
x, y, z = (
self.ds.arr(_get_position_array(ptype, f, ax), units)
Expand All @@ -228,9 +226,12 @@ def _read_particle_fields(self, chunks, ptf, selector):
del x, y, z
if mask is None:
continue
for field in field_list:
data = f[ptype][field][mask].astype("float64")
yield (ptype, field), data

for field in field_list:
data = f[ptype][field][mask].astype("float64")
chrishavlin marked this conversation as resolved.
Show resolved Hide resolved
data_return[(ptype, field)] = data

return data_return

def _count_particles(self, data_file):
si, ei = data_file.start, data_file.end
Expand Down