Skip to content

Commit f9a4090

Browse files
authored
Merge pull request #110 from kyleaoman/load_fof_catalogues
Changes for when swiftsimio merges SOAP support
2 parents 23a99a6 + a12c933 commit f9a4090

File tree

4 files changed

+27
-34
lines changed

4 files changed

+27
-34
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"]
33
build-backend = "setuptools.build_meta"
44

55
[tool.setuptools]
6-
packages = ["velociraptor"]
6+
packages = ["velociraptor", "velociraptor.catalogue", "velociraptor.fitting_formulae", "velociraptor.observations", "velociraptor.autoplotter", "velociraptor.particles", "velociraptor.swift", "velociraptor.tools"]
77

88
[project]
99
name = "velociraptor-python"

setup.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

velociraptor/catalogue/velociraptor_catalogue.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,30 @@ def getter(self):
117117
with h5py.File(filename, "r") as handle:
118118
try:
119119
mask = getattr(self, "mask")
120-
setattr(
121-
self, f"_{name}", unyt.unyt_array(handle[field][mask], unit)
122-
)
120+
if (
121+
np.ndim(mask) != 0
122+
and np.issubdtype(np.array(mask).dtype, np.integer)
123+
and not np.all(mask[:-1] < mask[1:])
124+
):
125+
# We have a mask picking out items by index, and it's
126+
# not sorted. hdf5 demands that it be sorted.
127+
# We sort, read and then reverse the sort.
128+
sort_mask = np.argsort(mask)
129+
unsort_mask = np.argsort(sort_mask)
130+
setattr(
131+
self,
132+
f"_{name}",
133+
unyt.unyt_array(
134+
handle[field][mask[sort_mask]][unsort_mask],
135+
unit,
136+
),
137+
)
138+
else:
139+
setattr(
140+
self,
141+
f"_{name}",
142+
unyt.unyt_array(handle[field][mask], unit),
143+
)
123144
getattr(self, f"_{name}").name = full_name
124145
getattr(self, f"_{name}").file = filename
125146
except KeyError:

velociraptor/swift/swift.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
datasets in a computationally efficient way.
66
"""
77

8-
98
import swiftsimio
109
import numpy as np
1110

@@ -98,7 +97,7 @@ def generate_bound_mask(
9897

9998
particle_name_masks = {}
10099

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

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

113112
return mask

0 commit comments

Comments
 (0)