Skip to content

Commit 3e511d3

Browse files
author
David Turner
committed
Made sure the blacklist and census constants used in _separation_search are indexed with the relevant telescope name.
1 parent f44cf97 commit 3e511d3

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

xga/sourcetools/match.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This code is a part of X-ray: Generate and Analyse (XGA), a module designed for the XMM Cluster Survey (XCS).
2-
# Last modified by David J Turner (djturner@umbc.edu) 04/06/2026, 12:54. Copyright (c) The Contributors
2+
# Last modified by David J Turner (djturner@umbc.edu) 11/06/2026, 09:08. Copyright (c) The Contributors
33
from __future__ import annotations
44

55
import gc
@@ -61,29 +61,24 @@ def _separation_search(ra: float, dec: float, telescope: str, search_rad: float)
6161
were relevant but have ALL instruments blacklisted).
6262
:rtype: Tuple[float, float, DataFrame, DataFrame]
6363
"""
64-
# Making a copy of the census because I add a distance-from-coords column - don't want to do that for the
65-
# original census especially when this is being multi-threaded
66-
local_census = CENSUS[telescope].copy()
67-
local_blacklist = BLACKLIST[telescope].copy()
6864
# TODO would rather use the _dist_from_source but one of the inputs is a region, which doesn't work here - maybe
6965
# I'll generalise that function further at some point
70-
hav_sep = 2 * np.arcsin(np.sqrt((np.sin(((local_census["DEC_PNT"]*(np.pi / 180))-(dec*(np.pi / 180))) / 2) ** 2)
71-
+ np.cos((dec * (np.pi / 180))) * np.cos(local_census["DEC_PNT"] * (np.pi / 180))
72-
* np.sin(((local_census["RA_PNT"]*(np.pi / 180)) - (ra*(np.pi / 180))) / 2) ** 2))
66+
hav_sep = 2 * np.arcsin(np.sqrt((np.sin(((CENSUS[telescope]["DEC_PNT"]*(np.pi / 180))-(dec*(np.pi / 180))) / 2) ** 2)
67+
+ np.cos((dec * (np.pi / 180))) * np.cos(CENSUS[telescope]["DEC_PNT"] * (np.pi / 180))
68+
* np.sin(((CENSUS[telescope]["RA_PNT"]*(np.pi / 180)) - (ra*(np.pi / 180))) / 2) ** 2))
7369
# Converting back to degrees from radians
7470
hav_sep /= (np.pi / 180)
75-
# Storing the separations in the local copy of the census
76-
local_census["dist"] = hav_sep
7771

7872
# Select any ObsIDs within (or at) the search radius input to the function
7973
try:
80-
matches = local_census[local_census["dist"] <= search_rad]
74+
matches = CENSUS[telescope][hav_sep <= search_rad]
8175
except ValueError:
8276
# Temp handling for samples
83-
matches = local_census[local_census["dist"] <= search_rad[0]]
77+
matches = CENSUS[telescope][hav_sep <= search_rad[0]]
78+
8479
# Locate any ObsIDs that are in the blacklist, then test to see whether ALL the instruments are to be excluded
85-
in_bl = local_blacklist[
86-
local_blacklist['ObsID'].isin(matches[matches["ObsID"].isin(local_blacklist["ObsID"])]['ObsID'])]
80+
in_bl = BLACKLIST[telescope][
81+
BLACKLIST[telescope]['ObsID'].isin(matches[matches["ObsID"].isin(BLACKLIST[telescope]["ObsID"])]['ObsID'])]
8782
# This will find relevant blacklist entries that have specifically ALL instruments excluded. In that case
8883
# the ObsID shouldn't be returned - firstly we locate the 'exclude_{INST NAME}' columns for this telescope's
8984
# blacklist
@@ -94,8 +89,6 @@ def _separation_search(ra: float, dec: float, telescope: str, search_rad: float)
9489
# least some usable data.
9590
matches = matches[~matches["ObsID"].isin(all_excl["ObsID"])]
9691

97-
del local_census
98-
del local_blacklist
9992
return ra, dec, matches, all_excl
10093

10194

0 commit comments

Comments
 (0)