Skip to content

Commit d4eedd5

Browse files
author
David Turner
committed
Fixed a (hopefully) final hard coded erosita issue in the eSASS region creator function - the signature also had to change so that erosita or erass can be passed.
Signed-off-by: David Turner <djturner@umbc.edu>
1 parent e6e1a7a commit d4eedd5

3 files changed

Lines changed: 23 additions & 41 deletions

File tree

xga/generate/common.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This code is 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) 4/27/26, 4:05 PM. Copyright (c) The Contributors.
2+
# Last modified by David J Turner (djturner@umbc.edu) 5/6/26, 6:32 PM. Copyright (c) The Contributors.
33

44
import os
55
import sys
@@ -11,7 +11,7 @@
1111
from astropy.units import Quantity, UnitBase, deg
1212
from regions import EllipseSkyRegion
1313

14-
from xga.exceptions import XGADeveloperError
14+
from xga.exceptions import XGADeveloperError, InvalidTelescopeError
1515
from ..products import BaseProduct, Image, ExpMap, Spectrum, PSFGrid, EventList
1616
from ..products.lightcurve import LightCurve
1717
from ..sources import BaseSource
@@ -198,7 +198,7 @@ def _interloper_esass_string(reg: EllipseSkyRegion) -> str:
198198
return shape_str
199199

200200

201-
def get_annular_esass_region(source: BaseSource, inner_radius: Quantity, outer_radius: Quantity, obs_id: str,
201+
def get_annular_esass_region(source: BaseSource, inner_radius: Quantity, outer_radius: Quantity, obs_id: str, telescope: str,
202202
output_unit: Union[UnitBase, str] = deg, rot_angle: Quantity = Quantity(0, 'deg'),
203203
interloper_regions: np.ndarray = None, central_coord: Quantity = None,
204204
bkg_reg: bool = False, rand_ident: int = None, out_root_path: str = None) -> str:
@@ -215,6 +215,7 @@ def get_annular_esass_region(source: BaseSource, inner_radius: Quantity, outer_r
215215
quantity has multiple elements then an elliptical region will be generated, with the first element
216216
being the outer radius on the semi-major axis, and the second on the semi-minor axis.
217217
:param str obs_id: The ObsID of the observation you wish to generate the eSASS region for.
218+
:param str telescope: The particular eROSITA mission skew to create a region for; 'erosita' or 'erass'.
218219
:param UnitBase/str output_unit: The desired units for the region string/file to be written in.
219220
:param Quantity rot_angle: The rotation angle of the source region, default is zero degrees.
220221
:param np.ndarray interloper_regions: The interloper regions to remove from the source region,
@@ -233,6 +234,9 @@ def get_annular_esass_region(source: BaseSource, inner_radius: Quantity, outer_r
233234
contaminating regions.
234235
:rtype: str
235236
"""
237+
if telescope not in ['erosita', 'erass']:
238+
raise InvalidTelescopeError("Pass either 'erosita' or 'erass' to this function's telescope argument.")
239+
236240
if central_coord is None:
237241
central_coord = source.default_coord
238242

@@ -260,9 +264,9 @@ def get_annular_esass_region(source: BaseSource, inner_radius: Quantity, outer_r
260264
# so that within_radii can just be called once externally for a set of ObsID-instrument combinations,
261265
# like in evselect_spectrum for instance.
262266
if interloper_regions is None and inner_radius.isscalar:
263-
interloper_regions = source.regions_within_radii(inner_radius, outer_radius, "erosita", central_coord)
267+
interloper_regions = source.regions_within_radii(inner_radius, outer_radius, telescope, central_coord)
264268
elif interloper_regions is None and not inner_radius.isscalar:
265-
interloper_regions = source.regions_within_radii(min(inner_radius), max(outer_radius), "erosita", central_coord)
269+
interloper_regions = source.regions_within_radii(min(inner_radius), max(outer_radius), telescope, central_coord)
266270

267271
# So now we convert our interloper regions into their eSASS equivalents
268272
esass_interloper = [_interloper_esass_string(i) for i in interloper_regions]

xga/generate/esass/lightcurve.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This code is 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) 5/6/26, 9:04 AM. Copyright (c) The Contributors.
2+
# Last modified by David J Turner (djturner@umbc.edu) 5/6/26, 6:28 PM. Copyright (c) The Contributors.
33

44
import os
55
from copy import deepcopy
@@ -166,23 +166,12 @@ def _make_lc_cmd_info(cur_evt_list):
166166
os.symlink(cur_evt_list.path, os.path.join(dest_dir, evt_symlink_name))
167167

168168
# This constructs the eSASS strings/region files
169-
reg = get_annular_esass_region(source,
170-
src_inn_rad,
171-
src_out_rad,
172-
cur_evt_list.obs_id,
173-
interloper_regions=interloper_regions,
174-
central_coord=source.default_coord,
175-
rand_ident=rand_ident,
176-
out_root_path=final_dest_dir)
177-
b_reg = get_annular_esass_region(source,
178-
bck_inn_rad,
179-
bck_out_rad,
180-
cur_evt_list.obs_id,
181-
interloper_regions=back_inter_reg,
182-
central_coord=source.default_coord,
183-
bkg_reg=True,
184-
rand_ident=rand_ident,
185-
out_root_path=final_dest_dir)
169+
reg = get_annular_esass_region(source, src_inn_rad, src_out_rad, cur_evt_list.obs_id, er_miss,
170+
interloper_regions=interloper_regions, central_coord=source.default_coord,
171+
rand_ident=rand_ident, out_root_path=final_dest_dir)
172+
b_reg = get_annular_esass_region(source, bck_inn_rad, bck_out_rad, cur_evt_list.obs_id, er_miss,
173+
interloper_regions=back_inter_reg, central_coord=source.default_coord,
174+
bkg_reg=True, rand_ident=rand_ident, out_root_path=final_dest_dir)
186175

187176
# Set up a string describing the central coordinate in addition to the regions
188177
coord_str = "icrs;{ra},{dec}".format(ra=source.default_coord[0].value,

xga/generate/esass/spec.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This code is 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) 5/4/26, 6:40 PM. Copyright (c) The Contributors.
2+
# Last modified by David J Turner (djturner@umbc.edu) 5/6/26, 6:28 PM. Copyright (c) The Contributors.
33

44
import os
55
from copy import deepcopy, copy
@@ -175,23 +175,12 @@ def _make_spec_cmd_info(cur_evt_list: EventList):
175175
os.symlink(cur_evt_list.path, os.path.join(dest_dir, evt_symlink_name))
176176

177177
# This constructs the eSASS strings/region files
178-
reg = get_annular_esass_region(source,
179-
src_inn_rad,
180-
src_out_rad,
181-
cur_evt_list.obs_id,
182-
interloper_regions=interloper_regions,
183-
central_coord=source.default_coord,
184-
rand_ident=rand_ident,
185-
out_root_path=final_dest_dir)
186-
b_reg = get_annular_esass_region(source,
187-
bck_inn_rad,
188-
bck_out_rad,
189-
cur_evt_list.obs_id,
190-
interloper_regions=back_inter_reg,
191-
central_coord=source.default_coord,
192-
bkg_reg=True,
193-
rand_ident=rand_ident,
194-
out_root_path=final_dest_dir)
178+
reg = get_annular_esass_region(source, src_inn_rad, src_out_rad, cur_evt_list.obs_id, er_miss,
179+
interloper_regions=interloper_regions, central_coord=source.default_coord,
180+
rand_ident=rand_ident, out_root_path=final_dest_dir)
181+
b_reg = get_annular_esass_region(source, bck_inn_rad, bck_out_rad, cur_evt_list.obs_id, er_miss,
182+
interloper_regions=back_inter_reg, central_coord=source.default_coord,
183+
bkg_reg=True, rand_ident=rand_ident, out_root_path=final_dest_dir)
195184

196185
# Set up a string describing the central coordinate in addition to the regions
197186
coord_str = "icrs;{ra},{dec}".format(ra=source.default_coord[0].value,

0 commit comments

Comments
 (0)