|
1 | 1 | # 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 (turne540@msu.edu) 26/07/2024, 10:56. Copyright (c) The Contributors |
| 2 | +# Last modified by David J Turner (turne540@msu.edu) 14/02/2025, 09:46. Copyright (c) The Contributors |
3 | 3 | import gc
|
4 | 4 | import os
|
5 | 5 | from copy import deepcopy
|
@@ -265,7 +265,7 @@ def _in_region(ra: Union[float, List[float], np.ndarray], dec: Union[float, List
|
265 | 265 | # "search.".format(obs_id))
|
266 | 266 |
|
267 | 267 | # Reading in the region file using the Regions module
|
268 |
| - og_ds9_regs = Regions.read(reg_path, format='ds9').regions |
| 268 | + og_ds9_regs = np.array(Regions.read(reg_path, format='ds9').regions) |
269 | 269 |
|
270 | 270 | # Bodged declaration, the instrument and energy bounds don't matter - all I need this for is the
|
271 | 271 | # nice way it extracts the WCS information that I need
|
@@ -601,6 +601,18 @@ def xmm_region_match(src_ra: Union[float, np.ndarray], src_dec: Union[float, np.
|
601 | 601 | raise XGAConfigError("This function requires at least one set of images (PN, MOS1, or MOS2) be referenced in "
|
602 | 602 | "the XGA configuration file.")
|
603 | 603 |
|
| 604 | + # We ensure that the RA and Decs are in arrays, even if there is only one coordinate - also in the case of a |
| 605 | + # single coordinate we set the number of cores to one |
| 606 | + if type(src_ra) != type(src_dec): |
| 607 | + raise TypeError("'src_ra' and 'src_dec' arguments must be the same type; either floats or arrays.") |
| 608 | + elif isinstance(src_ra, float): |
| 609 | + src_ra = np.array([src_ra]) |
| 610 | + src_dec = np.array([src_dec]) |
| 611 | + num_cores = 1 |
| 612 | + elif isinstance(src_ra, list): |
| 613 | + src_ra = np.array(src_ra) |
| 614 | + src_dec = np.array(src_dec) |
| 615 | + |
604 | 616 | # This runs the simple xmm match and gathers the results.
|
605 | 617 | s_match, s_match_bl = simple_xmm_match(src_ra, src_dec, num_cores=num_cores)
|
606 | 618 | # The initial results are then processed into some more useful formats.
|
@@ -666,7 +678,8 @@ def error_callback(err):
|
666 | 678 |
|
667 | 679 | # If any errors occurred during the matching process, they are all raised here as a grouped exception
|
668 | 680 | if len(search_errors) != 0:
|
669 |
| - ExceptionGroup("The following exceptions were raised in the multi-threaded region finder", search_errors) |
| 681 | + raise ExceptionGroup("The following exceptions were raised in the multi-threaded " |
| 682 | + "region finder", search_errors) |
670 | 683 |
|
671 | 684 | # This formats the match and no-match information so that the output is the same length and order as the input
|
672 | 685 | # source lists
|
|
0 commit comments