If the function extract_halo is called to get the particles of the last halo in the catalogue, an IndexError is raised because the code tries to use the difference between the offset for this halo and the next halo to count particles, but the next halo does not exist. For instance, on cosma:
from velociraptor import load
from velociraptor.particles import load_groups
data_dir = '/cosma7/data/dp004/dc-chai1/nearly_final_model/L50N752_BH3SOFT_FEB2022_Coolingv2_NoBHPot'
velociraptor_filebase = 'halo_2460'
cat = load(f'{data_dir}/{velociraptor_filebase}.properties')
groups = load_groups(f'{data_dir}/{velociraptor_filebase}.catalog_groups.0', catalogue=cat)
Ngroups = cat.ids.id.size
groups.extract_halo(halo_index=Ngroups - 1)
Produces the output:
Traceback (most recent call last):
File "/cosma/home/durham/dc-oman1/vrbug.py", line 11, in <module>
groups.extract_halo(halo_index=Ngroups-1)
File "/cosma7/ICC-data/dc-oman1/code/velociraptor-python/velociraptor/particles/particles.py", line 138, in extract_halo
number_of_particles = self.offset[halo_index + 1] - self.offset[halo_index]
IndexError: index 474417 is out of bounds for axis 0 with size 474417
The self.offset[halo_index + 1] is expected be out of bounds for the last halo; this is a fundamental design issue.
If the function
extract_halo
is called to get the particles of the last halo in the catalogue, anIndexError
is raised because the code tries to use the difference between the offset for this halo and the next halo to count particles, but the next halo does not exist. For instance, on cosma:Produces the output:
The
self.offset[halo_index + 1]
is expected be out of bounds for the last halo; this is a fundamental design issue.