diff --git a/pyproject.toml b/pyproject.toml index 149b108..a3864ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/setup.py b/setup.py deleted file mode 100644 index 8c28f45..0000000 --- a/setup.py +++ /dev/null @@ -1,27 +0,0 @@ -import setuptools -from velociraptor import __version__ - -with open("README.md", "r") as fh: - long_description = fh.read() - -setuptools.setup( - name="velociraptor", - version=__version__, - description="Velociraptor catalogue reading routines.", - url="https://github.com/swiftsim/velociraptor-python", - author="Josh Borrow", - author_email="joshua.borrow@durham.ac.uk", - packages=setuptools.find_packages(), - scripts=["velociraptor-plot"], - long_description=long_description, - long_description_content_type="text/markdown", - zip_safe=False, - classifiers=[ - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", - "Operating System :: OS Independent", - ], - install_requires=["numpy", "unyt>=2.6.0", "h5py", "astropy"], -) diff --git a/velociraptor/catalogue/velociraptor_catalogue.py b/velociraptor/catalogue/velociraptor_catalogue.py index d4c4f2d..60200b8 100644 --- a/velociraptor/catalogue/velociraptor_catalogue.py +++ b/velociraptor/catalogue/velociraptor_catalogue.py @@ -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: diff --git a/velociraptor/swift/swift.py b/velociraptor/swift/swift.py index 126b69a..1bb0ac1 100644 --- a/velociraptor/swift/swift.py +++ b/velociraptor/swift/swift.py @@ -5,7 +5,6 @@ datasets in a computationally efficient way. """ - import swiftsimio import numpy as np @@ -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( @@ -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