Skip to content

Commit

Permalink
Implement an option to mask a SOAP catalogue down to a single row.
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleaoman committed Aug 27, 2024
1 parent 43fe3b3 commit 3292d56
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions swiftsimio/masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
snapshots.
"""

import warnings

import unyt
import h5py

Expand Down Expand Up @@ -409,6 +411,25 @@ def convert_masks_to_ranges(self):

return

def constrain_index(self, index: int):
"""
Constrain the mask to a single row.
Intended for use with SOAP catalogues, mask to read only a single row.
Parameters
----------
index : int
The index of the row to select.
"""
if not self.metadata.filetype == "SOAP":
warnings.warn("Not masking a SOAP catalogue, nothing constrained.")
return
for group_name in self.metadata.present_group_names:
setattr(self, group_name, np.array([[index, index + 1]]))
setattr(self, f"{group_name}_size", 1)
return

def get_masked_counts_offsets(self) -> (Dict[str, np.array], Dict[str, np.array]):
"""
Returns the particle counts and offsets in cells selected by the mask
Expand Down

0 comments on commit 3292d56

Please sign in to comment.