Skip to content

Commit

Permalink
move ptf halo validation to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishavlin committed Jul 25, 2023
1 parent 7a67fe3 commit c3784b0
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions yt/frontends/ahf/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ def _read_particle_coords(self, chunks, ptf):
# This needs to *yield* a series of tuples of (ptype, (x, y, z), hsml).
# chunks is a list of chunks, and ptf is a dict where the keys are
# ptypes and the values are lists of fields.
self._validate_particle_ptf(ptf)

# Only support halo reading for now.
assert len(ptf) == 1
assert list(ptf.keys())[0] == "halos"
for data_file in self._sorted_chunk_iterator(chunks):
pos = data_file._get_particle_positions("halos")
x, y, z = (pos[:, i] for i in range(3))
Expand All @@ -35,7 +38,9 @@ def _read_particle_fields(self, chunks, ptf, selector):
# reading ptype, field and applying the selector to the data read in.
# Selector objects have a .select_points(x,y,z) that returns a mask, so
# you need to do your masking here.
self._validate_particle_ptf(ptf)
# Only support halo reading for now.
assert len(ptf) == 1
assert list(ptf.keys())[0] == "halos"
for data_file in self._sorted_chunk_iterator(chunks):
si, ei = data_file.start, data_file.end
cols = []
Expand Down Expand Up @@ -67,14 +72,6 @@ def _identify_fields(self, data_file):
fields = [("halos", f) for f in data_file.col_names]
return fields, {}

# Helper methods

@staticmethod
def _validate_particle_ptf(ptf):
# Only support halo reading for now.
assert len(ptf) == 1
assert list(ptf.keys())[0] == "halos"

def _sorted_chunk_iterator(self, chunks):
# yield from sorted list of data_files
data_files = self._get_data_files(chunks)
Expand Down

0 comments on commit c3784b0

Please sign in to comment.