Skip to content

Commit 34be756

Browse files
author
David Turner
committed
Altered Sample inits to store the text of caught NoValidObservation errors in the failed reason property of the sample
1 parent e0a6257 commit 34be756

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

xga/samples/base.py

Lines changed: 4 additions & 4 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 (turne540@msu.edu) 14/07/2025, 08:55. Copyright (c) The Contributors
2+
# Last modified by David J Turner (djturner@umbc.edu) 11/12/2025, 17:14. Copyright (c) The Contributors
33

44
from typing import Union, List, Dict
55
from warnings import warn
@@ -13,7 +13,7 @@
1313

1414
from .. import DEFAULT_COSMO
1515
from ..exceptions import (NoMatchFoundError, ModelNotAssociatedError, ParameterNotAssociatedError, \
16-
NotAssociatedError, TelescopeNotAssociatedError, NoValidObservationsError)
16+
NotAssociatedError, TelescopeNotAssociatedError, NoValidObservationsError)
1717
from ..sources.base import BaseSource
1818
from ..sourcetools.misc import coord_to_name
1919
from ..utils import check_telescope_choices, PRETTY_TELESCOPE_NAMES
@@ -135,7 +135,7 @@ def __init__(self, ra: ndarray, dec: ndarray, redshift: ndarray = None, name: nd
135135
self._sources[n] = temp
136136
self._names.append(n)
137137
self._accepted_inds.append(ind)
138-
except (NoMatchFoundError, NoValidObservationsError):
138+
except (NoMatchFoundError, NoValidObservationsError) as err:
139139
if n is not None:
140140
# We don't be liking spaces in source names
141141
# n = n.replace(" ", "")
@@ -145,7 +145,7 @@ def __init__(self, ra: ndarray, dec: ndarray, redshift: ndarray = None, name: nd
145145
n = coord_to_name(ra_dec)
146146

147147
# We record that a particular source name was not successfully declared
148-
self._failed_sources[n] = "NoMatch"
148+
self._failed_sources[n] = str(err)
149149
dec_base.update(1)
150150

151151
# It is possible (especially if someone is using the Sample classes as a way to check whether things have

xga/samples/general.py

Lines changed: 9 additions & 9 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 (turne540@msu.edu) 14/07/2025, 08:55. Copyright (c) The Contributors
2+
# Last modified by David J Turner (djturner@umbc.edu) 11/12/2025, 17:14. Copyright (c) The Contributors
33

44
from typing import Union, List
55
from warnings import warn
@@ -184,11 +184,11 @@ def __init__(self, ra: np.ndarray, dec: np.ndarray, redshift: np.ndarray = None,
184184
load_fits, peak_find_method, True, telescope, search_distance,
185185
clean_obs, clean_obs_reg, clean_obs_threshold)
186186
final_names.append(n)
187-
except NoValidObservationsError:
188-
self._failed_sources[n] = "Failed ObsClean"
187+
except NoValidObservationsError as err:
188+
self._failed_sources[n] = str(err)
189189

190-
except NoValidObservationsError:
191-
self._failed_sources[n] = "CleanedNoMatch"
190+
except NoValidObservationsError as err:
191+
self._failed_sources[n] = str(err)
192192

193193
dec_lb.update(1)
194194
self._names = final_names
@@ -423,11 +423,11 @@ def __init__(self, ra: np.ndarray, dec: np.ndarray, redshift: np.ndarray = None,
423423
search_distance=search_distance,
424424
clean_obs=clean_obs, clean_obs_threshold=clean_obs_threshold)
425425
final_names.append(n)
426-
except NoValidObservationsError:
427-
self._failed_sources[n] = "FailedObsClean"
426+
except NoValidObservationsError as err:
427+
self._failed_sources[n] = str(err)
428428

429-
except NoValidObservationsError:
430-
self._failed_sources[n] = "CleanedNoMatch"
429+
except NoValidObservationsError as err:
430+
self._failed_sources[n] = str(err)
431431

432432
dec_lb.update(1)
433433
self._names = final_names

xga/samples/point.py

Lines changed: 3 additions & 3 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 (turne540@msu.edu) 14/07/2025, 08:55. Copyright (c) The Contributors
2+
# Last modified by David J Turner (djturner@umbc.edu) 11/12/2025, 17:14. Copyright (c) The Contributors
33

44
from typing import Union, List
55
from warnings import warn
@@ -204,8 +204,8 @@ def __init__(self, ra: np.ndarray, dec: np.ndarray, distance: np.ndarray = None,
204204
# been set yet when all radii should be forced to be the same unit
205205
self._pr_unit = pr.unit
206206
final_names.append(n)
207-
except NoValidObservationsError:
208-
self._failed_sources[n] = "CleanedNoMatch"
207+
except NoValidObservationsError as err:
208+
self._failed_sources[n] = str(err)
209209

210210
dec_lb.update(1)
211211
self._names = final_names

0 commit comments

Comments
 (0)