From 2d3715e02a9750243ce259389e74f4f9dd912cef Mon Sep 17 00:00:00 2001 From: robjmcgibbon Date: Mon, 28 Sep 2026 14:23:03 +0100 Subject: [PATCH 1/2] Squash bug when matching FoF catalogues --- misc/match_group_membership.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/misc/match_group_membership.py b/misc/match_group_membership.py index 081078b1..f8c2aede 100644 --- a/misc/match_group_membership.py +++ b/misc/match_group_membership.py @@ -81,6 +81,9 @@ def load_particle_data(snap_basename, membership_basename, ptypes, match_fof, co # Remove any particles which are not bound to a subhalo mask = halo_catalogue_idx != -1 + if match_fof: + # SWIFT sets FOFGroupIDs to this value for particles not in a group + mask &= halo_catalogue_idx != 2147483647 particle_ids = particle_ids[mask] halo_catalogue_idx = halo_catalogue_idx[mask] rank_bound = rank_bound[mask] From 8e1ca9878caf7e13bb090a5a0ffa29ae1230bb05 Mon Sep 17 00:00:00 2001 From: robjmcgibbon Date: Mon, 28 Sep 2026 15:49:04 +0100 Subject: [PATCH 2/2] Don't modify array in-place --- misc/match_group_membership.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/misc/match_group_membership.py b/misc/match_group_membership.py index f8c2aede..0e6be1ed 100644 --- a/misc/match_group_membership.py +++ b/misc/match_group_membership.py @@ -161,6 +161,8 @@ def match_sim( host_halo_catalogue_idx = psort.fetch_elements( catalogue_to_match["halo_catalogue_idx"], host_halo_idx, comm=comm ) + # Copy so we don't modify the caller's array + particle_halo_ids_to_match = particle_halo_ids_to_match.copy() particle_halo_ids_to_match[is_sat] = host_halo_catalogue_idx # Sort particles @@ -270,7 +272,7 @@ def match_sim( match_count = np.zeros_like(catalogue["halo_catalogue_idx"]) # Retrieve the values we require, skipping halos which don't have a match - idx = psort.parallel_match(catalogue["halo_catalogue_idx"], halo_ids) + idx = psort.parallel_match(catalogue["halo_catalogue_idx"], halo_ids, comm=comm) match_index[idx != -1] = psort.fetch_elements( matched_catalogue_idx, idx[idx != -1], comm=comm )