Skip to content

Commit

Permalink
Merge pull request #195 from SWIFTSIM/load_fof_catalogues_refactor
Browse files Browse the repository at this point in the history
Load fof catalogues refactor
  • Loading branch information
JBorrow authored Sep 19, 2024
2 parents 64b8d94 + e6b4a62 commit d8ccdae
Show file tree
Hide file tree
Showing 7 changed files with 1,341 additions and 1,143 deletions.
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,27 @@ packages = [
"swiftsimio.metadata.particle",
"swiftsimio.metadata.unit",
"swiftsimio.metadata.writer",
"swiftsimio.metadata.soap",
"swiftsimio.visualisation",
"swiftsimio.visualisation.projection_backends",
"swiftsimio.visualisation.slice_backends",
"swiftsimio.visualisation.tools",
"swiftsimio.visualisation.smoothing_length",
"swiftsimio.metadata.soap"
]

[project]
name = "swiftsimio"
version="8.0.1"
version="9.0.0"
authors = [
{ name="Josh Borrow", email="[email protected]" },
]
description="SWIFTsim (swift.dur.ac.uk) i/o routines for python."
description="SWIFTsim (swiftsim.com) i/o routines for python."
readme = "README.md"
requires-python = ">3.8.0"
requires-python = ">3.10.0"
classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
"Operating System :: OS Independent",
]
Expand Down
2 changes: 1 addition & 1 deletion swiftsimio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def mask(filename, spatial_only=True) -> SWIFTMask:
"""

units = SWIFTUnits(filename)
metadata = SWIFTMetadata(filename, units)
metadata = metadata_discriminator(filename, units)

return SWIFTMask(metadata=metadata, spatial_only=spatial_only)

Expand Down
15 changes: 8 additions & 7 deletions swiftsimio/masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ def __init__(self, metadata: SWIFTMetadata, spatial_only=True):
self.units = metadata.units
self.spatial_only = spatial_only

if self.metadata.filetype == "FOF":
# No virtual snapshots or cells metadata for fof currently
raise NotImplementedError("Masking not supported for FOF filetype")
if not self.metadata.masking_valid:
raise NotImplementedError(
f"Masking not supported for {self.metadata.output_type} filetype"
)

if self.metadata.partial_snapshot:
raise InvalidSnapshot(
Expand Down Expand Up @@ -111,12 +112,12 @@ def _unpack_cell_metadata(self):
for group, group_name in zip(
self.metadata.present_groups, self.metadata.present_group_names
):
if self.metadata.filetype == "SOAP":
counts = count_handle["Subhalos"][:]
offsets = offset_handle["Subhalos"][:]
elif self.metadata.filetype == "snapshot":
if self.metadata.shared_cell_counts is None:
counts = count_handle[group][:]
offsets = offset_handle[group][:]
else:
counts = count_handle[self.metadata.shared_cell_counts][:]
offsets = offset_handle[self.metadata.shared_cell_counts][:]

# When using MPI, we cannot assume that these are sorted.
if sort is None:
Expand Down
2 changes: 2 additions & 0 deletions swiftsimio/metadata/metadata/metadata_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
header_unpack_arrays = {
"BoxSize": "boxsize",
"NumPart_ThisFile": "num_part",
"NumGroup_ThisFile": "num_group",
"NumSubhalos_ThisFile": "num_subhalo",
"CanHaveTypes": "has_type",
"NumFilesPerSnapshot": "num_files_per_snapshot",
"OutputType": "output_type",
Expand Down
Loading

0 comments on commit d8ccdae

Please sign in to comment.