@@ -97,10 +97,10 @@ def __load_attributes(self):
9797
9898 return
9999
100- def extract_halo (self , halo_id : int , filenames : Union [Dict [str , str ], None ] = None ):
100+ def extract_halo (self , halo_index : int , filenames : Union [Dict [str , str ], None ] = None ):
101101 """
102- Get a halo particles object for a given ID. Filenames is
103- either a dictionary with the following structure:
102+ Get a halo particles object for a given index into the catalogue (NOT the halo unique
103+ id). Filenames is either a dictionary with the following structure:
104104
105105 {
106106 "particles_filename": "...",
@@ -132,36 +132,36 @@ def extract_halo(self, halo_id: int, filenames: Union[Dict[str, str], None] = No
132132 unbound_particles_filename = filenames ["unbound_particles_filename" ]
133133 unbound_parttypes_filename = filenames ["unbound_parttypes_filename" ]
134134
135- number_of_particles = self .offset [halo_id + 1 ] - self .offset [halo_id ]
135+ number_of_particles = self .offset [halo_index + 1 ] - self .offset [halo_index ]
136136 number_of_unbound_particles = (
137- self .offset_unbound [halo_id + 1 ] - self .offset_unbound [halo_id ]
137+ self .offset_unbound [halo_index + 1 ] - self .offset_unbound [halo_index ]
138138 )
139139 assert (
140140 number_of_particles + number_of_unbound_particles
141- == self .group_size [halo_id ]
141+ == self .group_size [halo_index ]
142142 ), "Something is incorrect in the calculation of group sizes for halo {}. Group_Size: {}, Bound: {}, Unbound: {}" .format (
143- halo_id , number_of_particles , number_of_unbound_particles
143+ halo_index , number_of_particles , number_of_unbound_particles
144144 )
145145
146146 particles = VelociraptorParticles (
147147 particles_filename = particles_filename ,
148148 parttypes_filename = parttypes_filename ,
149- offset = self .offset [halo_id ],
149+ offset = self .offset [halo_index ],
150150 group_size = number_of_particles ,
151151 groups_instance = self ,
152152 )
153153
154154 unbound_particles = VelociraptorParticles (
155155 particles_filename = unbound_particles_filename ,
156156 parttypes_filename = unbound_parttypes_filename ,
157- offset = self .offset_unbound [halo_id ],
157+ offset = self .offset_unbound [halo_index ],
158158 group_size = number_of_unbound_particles ,
159159 groups_instance = self ,
160160 )
161161
162162 if self .catalogue is not None :
163- particles .register_halo_attributes (self .catalogue , halo_id )
164- unbound_particles .register_halo_attributes (self .catalogue , halo_id )
163+ particles .register_halo_attributes (self .catalogue , halo_index )
164+ unbound_particles .register_halo_attributes (self .catalogue , halo_index )
165165
166166 return particles , unbound_particles
167167
@@ -249,52 +249,51 @@ def __load_parttypes(self):
249249
250250 return
251251
252- def register_halo_attributes (self , catalogue : VelociraptorCatalogue , halo_id : int ):
252+ def register_halo_attributes (self , catalogue : VelociraptorCatalogue , halo_index : int ):
253253 """
254254 Registers useful halo attributes to this object (such as the mass and radii of the halo).
255255 """
256256
257- self .halo_id = halo_id
257+ self .halo_index = halo_index
258258
259- self .mass_200crit = catalogue .masses .mass_200crit [halo_id ]
260- self .mass_200mean = catalogue .masses .mass_200mean [halo_id ]
261- self .mass_bn98 = catalogue .masses .mass_bn98 [halo_id ]
262- self .mass_fof = catalogue .masses .mass_fof [halo_id ]
263- self .mvir = catalogue .masses .mvir [halo_id ]
259+ self .mass_200crit = catalogue .masses .mass_200crit [halo_index ]
260+ self .mass_200mean = catalogue .masses .mass_200mean [halo_index ]
261+ self .mass_bn98 = catalogue .masses .mass_bn98 [halo_index ]
262+ self .mass_fof = catalogue .masses .mass_fof [halo_index ]
263+ self .mvir = catalogue .masses .mvir [halo_index ]
264264
265- self .r_200crit = catalogue .radii .r_200crit [halo_id ]
266- self .r_200mean = catalogue .radii .r_200mean [halo_id ]
267- self .r_bn98 = catalogue .radii .r_bn98 [halo_id ]
268- self .r_size = catalogue .radii .r_size [halo_id ]
269- self .rmax = catalogue .radii .rmax [halo_id ]
270- self .rvir = catalogue .radii .rvir [halo_id ]
265+ self .r_200crit = catalogue .radii .r_200crit [halo_index ]
266+ self .r_200mean = catalogue .radii .r_200mean [halo_index ]
267+ self .r_bn98 = catalogue .radii .r_bn98 [halo_index ]
268+ self .r_size = catalogue .radii .r_size [halo_index ]
269+ self .rmax = catalogue .radii .rmax [halo_index ]
270+ self .rvir = catalogue .radii .rvir [halo_index ]
271271
272- self .x = catalogue .positions .xc [halo_id ]
273- self .y = catalogue .positions .yc [halo_id ]
274- self .z = catalogue .positions .zc [halo_id ]
272+ self .x = catalogue .positions .xc [halo_index ]
273+ self .y = catalogue .positions .yc [halo_index ]
274+ self .z = catalogue .positions .zc [halo_index ]
275275
276276 # x_gas and x_star are measured relative to xc for some reason.
277277 # The following may not be available in the catalogues.
278278 try :
279- self .x_gas = catalogue .positions .xc_gas [halo_id ] + self .x
280- self .y_gas = catalogue .positions .yc_gas [halo_id ] + self .y
281- self .z_gas = catalogue .positions .zc_gas [halo_id ] + self .z
279+ self .x_gas = catalogue .positions .xc_gas [halo_index ] + self .x
280+ self .y_gas = catalogue .positions .yc_gas [halo_index ] + self .y
281+ self .z_gas = catalogue .positions .zc_gas [halo_index ] + self .z
282282 except AttributeError :
283283 pass
284284
285285 try :
286- self .x_star = catalogue .positions .xc_star [halo_id ] + self .x
287- self .y_star = catalogue .positions .yc_star [halo_id ] + self .y
288- self .z_star = catalogue .positions .zc_star [halo_id ] + self .z
286+ self .x_star = catalogue .positions .xc_star [halo_index ] + self .x
287+ self .y_star = catalogue .positions .yc_star [halo_index ] + self .y
288+ self .z_star = catalogue .positions .zc_star [halo_index ] + self .z
289289 except AttributeError :
290290 pass
291291
292292 try :
293- self .x_mbp = catalogue .positions .xcmbp [halo_id ]
294- self .y_mbp = catalogue .positions .ycmbp [halo_id ]
295- self .z_mbp = catalogue .positions .zcmbp [halo_id ]
293+ self .x_mbp = catalogue .positions .xcmbp [halo_index ]
294+ self .y_mbp = catalogue .positions .ycmbp [halo_index ]
295+ self .z_mbp = catalogue .positions .zcmbp [halo_index ]
296296 except AttributeError :
297297 pass
298298
299299 return
300-
0 commit comments