@@ -55,20 +55,16 @@ def generate_spatial_mask(
5555 "Please use a particles instance with an associated halo " "catalogue."
5656 )
5757
58- spatial_mask = [
59- [
60- particles .x / length_factor - particles .r_size / length_factor ,
61- particles .x / length_factor + particles .r_size / length_factor ,
62- ],
63- [
64- particles .y / length_factor - particles .r_size / length_factor ,
65- particles .y / length_factor + particles .r_size / length_factor ,
66- ],
67- [
68- particles .z / length_factor - particles .r_size / length_factor ,
69- particles .z / length_factor + particles .r_size / length_factor ,
70- ],
71- ]
58+ xyz = swiftsimio .cosmo_array (
59+ [particles .x , particles .y , particles .z ],
60+ comoving = True ,
61+ scale_factor = length_factor ,
62+ scale_exponent = 1 ,
63+ )
64+ size = swiftsimio .cosmo_array (
65+ particles .r_size , comoving = True , scale_factor = length_factor , scale_exponent = 1
66+ )
67+ spatial_mask = swiftsimio .cosmo_array ([xyz - size , xyz + size ]).T
7268
7369 swift_mask .constrain_spatial (spatial_mask )
7470
@@ -97,11 +93,27 @@ def generate_bound_mask(
9793
9894 particle_name_masks = {}
9995
96+ try :
97+ if not particles .groups_instance .catalogue .units .comoving :
98+ length_factor = particles .groups_instance .catalogue .units .a
99+ else :
100+ length_factor = 1.0
101+ except AttributeError :
102+ raise RuntimeError (
103+ "Please use a particles instance with an associated halo " "catalogue."
104+ )
105+
100106 for particle_name in data .metadata .present_group_names :
101107 # This will change if we ever take advantage of the
102108 # parttypes available through velociraptor.
103109 particle_name_masks [particle_name ] = np .in1d (
104- getattr (data , particle_name ).particle_ids , particles .particle_ids
110+ getattr (data , particle_name ).particle_ids ,
111+ swiftsimio .cosmo_array (
112+ particles .particle_ids ,
113+ comoving = True ,
114+ scale_factor = length_factor ,
115+ scale_exponent = 0 ,
116+ ),
105117 )
106118
107119 # Finally we generate a named tuple with the correct fields and
0 commit comments