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

Changes for when swiftsimio merges SOAP support #110

Merged
merged 7 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = ["velociraptor"]
packages = ["velociraptor", "velociraptor.catalogue", "velociraptor.fitting_formulae", "velociraptor.observations", "velociraptor.autoplotter", "velociraptor.particles", "velociraptor.swift", "velociraptor.tools"]

[project]
name = "velociraptor-python"
Expand Down
27 changes: 0 additions & 27 deletions setup.py

This file was deleted.

27 changes: 24 additions & 3 deletions velociraptor/catalogue/velociraptor_catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,30 @@ def getter(self):
with h5py.File(filename, "r") as handle:
try:
mask = getattr(self, "mask")
setattr(
self, f"_{name}", unyt.unyt_array(handle[field][mask], unit)
)
if (
np.ndim(mask) != 0
and np.issubdtype(np.array(mask).dtype, np.integer)
and not np.all(mask[:-1] < mask[1:])
):
# We have a mask picking out items by index, and it's
# not sorted. hdf5 demands that it be sorted.
# We sort, read and then reverse the sort.
sort_mask = np.argsort(mask)
unsort_mask = np.argsort(sort_mask)
setattr(
self,
f"_{name}",
unyt.unyt_array(
handle[field][mask[sort_mask]][unsort_mask],
unit,
),
)
else:
setattr(
self,
f"_{name}",
unyt.unyt_array(handle[field][mask], unit),
)
getattr(self, f"_{name}").name = full_name
getattr(self, f"_{name}").file = filename
except KeyError:
Expand Down
5 changes: 2 additions & 3 deletions velociraptor/swift/swift.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
datasets in a computationally efficient way.
"""


import swiftsimio
import numpy as np

Expand Down Expand Up @@ -98,7 +97,7 @@ def generate_bound_mask(

particle_name_masks = {}

for particle_name in data.metadata.present_particle_names:
for particle_name in data.metadata.present_group_names:
# This will change if we ever take advantage of the
# parttypes available through velociraptor.
particle_name_masks[particle_name] = np.in1d(
Expand All @@ -107,7 +106,7 @@ def generate_bound_mask(

# Finally we generate a named tuple with the correct fields and
# fill it with the contents of our dictionary
MaskTuple = namedtuple("MaskCollection", data.metadata.present_particle_names)
MaskTuple = namedtuple("MaskCollection", data.metadata.present_group_names)
mask = MaskTuple(**particle_name_masks)

return mask
Expand Down
Loading