Skip to content

Commit

Permalink
Update crossmatching to use finder_id rather than finder_offset (cons…
Browse files Browse the repository at this point in the history
…istent with pynbody v2)
  • Loading branch information
apontzen committed Mar 9, 2024
1 parent 432c1e1 commit bc63ba4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tangos/tools/crosslink.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ def need_crosslink_ts(self, ts1, ts2, object_typecode=0):
return False
return True

def create_db_objects_from_catalog(self, cat, finder_offset_to_halos_1, finder_offset_to_halos_2, same_d_id):
def create_db_objects_from_catalog(self, cat, finder_id_to_halos_1, finder_id_to_halos_2, same_d_id):
items = []
missing_db_object = 0
for i, possibilities in enumerate(cat):
h1 = finder_offset_to_halos_1.get(i, None)
h1 = finder_id_to_halos_1.get(i, None)
for cat_i, weight in possibilities:
h2 = finder_offset_to_halos_2.get(cat_i, None)
h2 = finder_id_to_halos_2.get(cat_i, None)

if h1 is not None and h2 is not None:
items.append(core.halo_data.HaloLink(h1, h2, same_d_id, weight))
Expand All @@ -102,9 +102,9 @@ def create_db_objects_from_catalog(self, cat, finder_offset_to_halos_1, finder_o
missing_db_object)
return items

def make_finder_offset_to_halo_map(self, ts, object_typecode):
def make_finder_id_to_halo_map(self, ts, object_typecode):
halos = ts.objects.filter_by(object_typecode=object_typecode).all()
halos_map = {h.finder_offset: h for h in halos}
halos_map = {h.finder_id: h for h in halos}
return halos_map

def crosslink_ts(self, ts1, ts2, halo_min=0, halo_max=None, dmonly=False, threshold=config.default_linking_threshold, object_typecode=0):
Expand All @@ -113,8 +113,8 @@ def crosslink_ts(self, ts1, ts2, halo_min=0, halo_max=None, dmonly=False, thresh
:type ts1 tangos.core.TimeStep
:type ts2 tangos.core.TimeStep"""
logger.info("Gathering halo information for %r and %r", ts1, ts2)
halos1 = self.make_finder_offset_to_halo_map(ts1, object_typecode)
halos2 = self.make_finder_offset_to_halo_map(ts2, object_typecode)
halos1 = self.make_finder_id_to_halo_map(ts1, object_typecode)
halos2 = self.make_finder_id_to_halo_map(ts2, object_typecode)

same_d_id = self._get_linkname_dictionaryitem()

Expand Down

0 comments on commit bc63ba4

Please sign in to comment.