Skip to content

Commit 2a5a6ea

Browse files
authored
Merge pull request #1146 from DavidT3/bug/catchNoneNoAttributeErrorsOnRedeclare
Hopefully will catch incomplete annular spectra being read in - with …
2 parents 47d178e + 169715a commit 2a5a6ea

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

xga/sources/base.py

Lines changed: 13 additions & 7 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) 02/05/2024, 10:40. Copyright (c) The Contributors
2+
# Last modified by David J Turner (turne540@msu.edu) 27/05/2024, 10:48. Copyright (c) The Contributors
33

44
import os
55
import pickle
@@ -1004,12 +1004,18 @@ def parse_lightcurve(inven_entry: pd.Series) -> LightCurve:
10041004
# those objects and add them to the storage structure
10051005
if len(ann_spec_constituents) != 0:
10061006
for set_id in ann_spec_constituents:
1007-
if ann_spec_usable[set_id]:
1008-
ann_spec_obj = AnnularSpectra(ann_spec_constituents[set_id])
1009-
if self._redshift is not None:
1010-
# If we know the redshift we will add the radii to the annular spectra in proper distance units
1011-
ann_spec_obj.proper_radii = self.convert_radius(ann_spec_obj.radii, 'kpc')
1012-
self.update_products(ann_spec_obj, update_inv=False)
1007+
try:
1008+
if ann_spec_usable[set_id]:
1009+
ann_spec_obj = AnnularSpectra(ann_spec_constituents[set_id])
1010+
if self._redshift is not None:
1011+
# If we know the redshift we will add the radii to the annular spectra in proper
1012+
# distance units
1013+
ann_spec_obj.proper_radii = self.convert_radius(ann_spec_obj.radii, 'kpc')
1014+
self.update_products(ann_spec_obj, update_inv=False)
1015+
except AttributeError:
1016+
# This should hopefully act to catch the NoneType has no attribute problems that have plagued this
1017+
# class - while I find a better general solution that should solve this properly
1018+
pass
10131019

10141020
# Here we load in any combined images and exposure maps that may have been generated
10151021
os.chdir(OUTPUT + 'combined')

0 commit comments

Comments
 (0)