I am loading an existing halo catalog to create a DataSet object:

    import yt
    ds = yt.load("test_halo_catalog.h5")

I then wish to use the all_data() method:

    ad = ds.all_data()

But if the halo catalog contains zero halos, I get this error message:


yt : [INFO     ] 2024-04-26 14:06:04,162 Allocating for 0.000e+00 particles
Traceback (most recent call last):
  File "~/hc_analysis.py", line 130, in <module>
    ad = ds.all_data()
  File 
"/home/hannah/anaconda3/envs/yt-rockstar/lib/python3.10/site-packages/yt/data_objects/static_output.py",
 line 1122, in all_data
    self.index
  File 
"/home/hannah/anaconda3/envs/yt-rockstar/lib/python3.10/site-packages/yt/data_objects/static_output.py",
 line 559, in index
    self._instantiated_index = self._index_class(
  File 
"/home/hannah/anaconda3/envs/yt-rockstar/lib/python3.10/site-packages/yt/geometry/particle_geometry_handler.py",
 line 27, in __init__
    self._initialize_index()
  File 
"/home/hannah/anaconda3/envs/yt-rockstar/lib/python3.10/site-packages/yt/geometry/particle_geometry_handler.py",
 line 164, in _initialize_index
    self.regions = ParticleBitmap(
  File "yt/geometry/particle_oct_container.pyx", line 476, in 
yt.geometry.particle_oct_container.ParticleBitmap.__init__
TypeError: an integer is required


It seems that all_data() only works if the halo catalog contains a nonzero 
integer number of halos.
Is there a method for a DataSet object to determine the total number of halos 
found?
I wish to implement something like this:

if ds.total_halos != 0:
    ad = ds.all_data()

else:
    print("No halos found in this halo catalog")

Any help would be much appreciated, thank you!
Kind regards,
Hannah O'Brennan
_______________________________________________
yt-users mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/yt-users.python.org/
Member address: [email protected]

Reply via email to