Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a7badd5
Moved the check for a minimum number of noticed channels in the gener…
Dec 8, 2025
31715a1
Added some comments to my XSPEC fitting script changes. For issue #1345
Dec 8, 2025
94a473f
Added simple log writing to the execute_cmd function, so that the sta…
Dec 9, 2025
248d7f3
Added errors to spec and light curve generation that mean people cann…
Dec 9, 2025
12c6380
Made sure the data product generation logs contain the command that w…
Dec 9, 2025
1c6bf57
Added a _common.py file to the generate.esass submodule - at the mome…
Dec 9, 2025
fd7d647
Made SO many changes to the _spec_cmds function of generate.esass. Lo…
Dec 9, 2025
8f12146
Modified telescope checks in esass_spectrum_set. For issue #1485
Dec 9, 2025
314cd0d
Neatened some things up, removed old commented out code, etc.
Dec 9, 2025
0518383
Debugggg
Dec 9, 2025
6cb1bee
Debugggg
Dec 9, 2025
574f9c3
Moved a check for erosita/erass presence for a source in the _spec_cm…
Dec 9, 2025
a2be45a
_spec_cmds should now handle when either eROSITA or eRASS isn't assoc…
Dec 9, 2025
7b17ba4
Made sure that if eSASS4DR1 is being used, the writeinsts parameter o…
Dec 9, 2025
7219422
Added symlink clean up commands to the eROSITA spectral generation co…
Dec 9, 2025
10d61db
Re-added eSASS version determination
Dec 9, 2025
96bc5f3
Removed a print statement
Dec 9, 2025
b959aa4
Cleaned up some of the XSPEC execute_cmd function, and made sure that…
Dec 9, 2025
0279912
Added tiny comment
Dec 9, 2025
b146ee9
Added a check for the 'range' of noticed channels being null in the X…
Dec 10, 2025
1ef2641
Changed a comment in the XSPEC template script. For issue #1345
Dec 10, 2025
ae09340
Changed copyright comment in the general_xspec_fit.xcm file. Closes i…
Dec 10, 2025
cba4a8e
Diagnosing a problem with combined eROSITA spectrum generation.
Dec 10, 2025
368f34f
Trying to diagnose why all merged spectra are being removed/not being…
Dec 10, 2025
16c9288
Really smashing up the _make_spec_cmd_info and _spec_cmds functions t…
Dec 10, 2025
df9730f
Restored some commented out parts of the _make_spec_cmd_info internal…
Dec 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions xga/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# This code is a part of X-ray: Generate and Analyse (XGA), a module designed for the XMM Cluster Survey (XCS).
# Last modified by David J Turner (turne540@msu.edu) 16/07/2025, 12:25. Copyright (c) The Contributors
# Last modified by David J Turner (turne540@msu.edu) 09/12/2025, 15:20. Copyright (c) The Contributors
from . import _version
__version__ = _version.get_versions()['version']

from .utils import (xga_conf, CENSUS, OUTPUT, NUM_CORES, XGA_EXTRACT, BASE_XSPEC_SCRIPT, MODEL_PARS,
MODEL_UNITS, ABUND_TABLES, XSPEC_FIT_METHOD, COUNTRATE_CONV_SCRIPT, NHC, BLACKLIST, HY_MASS, MEAN_MOL_WEIGHT,
SAS_VERSION, XSPEC_VERSION, SAS_AVAIL, DEFAULT_COSMO, TELESCOPES, USABLE, DEFAULT_TELE_SEARCH_DIST, COMBINED_INSTS,
eSASS_AVAIL, SRC_REGION_COLOURS, check_telescope_choices, PRETTY_TELESCOPE_NAMES, CIAO_AVAIL, CIAO_VERSION, CALDB_AVAIL,
CALDB_VERSION, ESASS_VERSION, RAD_MATCH_PRECISION)
MODEL_UNITS, ABUND_TABLES, XSPEC_FIT_METHOD, COUNTRATE_CONV_SCRIPT, NHC, BLACKLIST, HY_MASS, MEAN_MOL_WEIGHT,
SAS_VERSION, XSPEC_VERSION, SAS_AVAIL, DEFAULT_COSMO, TELESCOPES, USABLE, DEFAULT_TELE_SEARCH_DIST, COMBINED_INSTS,
ESASS_AVAIL, SRC_REGION_COLOURS, check_telescope_choices, PRETTY_TELESCOPE_NAMES, CIAO_AVAIL, CIAO_VERSION, CALDB_AVAIL,
CALDB_VERSION, ESASS_VERSION, RAD_MATCH_PRECISION)
11 changes: 10 additions & 1 deletion xga/generate/ciao/spec.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This code is a part of X-ray: Generate and Analyse (XGA), a module designed for the XMM Cluster Survey (XCS).
# Last modified by David J Turner (turne540@msu.edu) 26/03/2025, 10:57. Copyright (c) The Contributors
# Last modified by David J Turner (turne540@msu.edu) 09/12/2025, 10:36. Copyright (c) The Contributors

import os
from copy import copy
Expand Down Expand Up @@ -46,6 +46,15 @@ def _chandra_spec_cmds(sources: Union[BaseSource, BaseSample], outer_radius: Uni
:param bool force_gen: This boolean flag will force the regeneration of spectra, even if they already exist.
"""

# Early XGA could generate spectra within the detection regions of the source, but
# that has been deprecated for quite a while, as it was a bad idea. The generation
# of spectra within user-specified regions will be possible, but it will be
# implemented differently. The original way was bad because the detection region
# could/almost certainly would be different for each observation
if outer_radius == 'region':
raise ValueError("The string 'region' is no longer a valid option for "
"the 'outer_radius' argument.")

stack = False # This tells the ciao_call routine that this command won't be part of a stack.
execute = True # This should be executed immediately.
# This function supports passing both individual sources and samples - but if it is a source we like to be able
Expand Down
19 changes: 18 additions & 1 deletion xga/generate/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This code is a part of X-ray: Generate and Analyse (XGA), a module designed for the XMM Cluster Survey (XCS).
# Last modified by David J Turner (turne540@msu.edu) 08/07/2025, 17:26. Copyright (c) The Contributors
# Last modified by David J Turner (turne540@msu.edu) 09/12/2025, 10:39. Copyright (c) The Contributors

import os
import sys
Expand Down Expand Up @@ -45,10 +45,27 @@ def execute_cmd(cmd: str, p_type: Union[str, List[str]], p_path: list, extra_inf
if "DYLD_LIBRARY_PATH" in sys_env:
cmd = f"export DYLD_LIBRARY_PATH={sys_env['DYLD_LIBRARY_PATH']} && {cmd}"

# This runs the passed command - it captures the stdout and stderr as well
out, err = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE).communicate()
# Captured out/err are byte type, will decode that into str for easier use
out = out.decode("UTF-8", errors='ignore')
err = err.decode("UTF-8", errors='ignore')

# We will assume that the first entry in the product path argument is the
# primary output file, and will name the log files after it
log_stem = p_path[0][:p_path[0].rfind('.')]
# One file for out and one for error
std_out_file = log_stem + "_stdout.log"
std_err_file = log_stem + "_stderr.log"

# Write the standard out to a log file
with open(std_out_file, "w") as std_outo:
std_outo.write(cmd + "\n\n" + out)
# If there are standard error entries, write them to a file as well
if len(err) > 0:
with open(std_err_file, "w") as std_erro:
std_erro.write(cmd + "\n\n" + err)

# Trying to make sure that any passed arrays get smoothed out into the list type we want
if type(p_path) == np.ndarray:
p_path = list(p_path)
Expand Down
7 changes: 7 additions & 0 deletions xga/generate/esass/_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This code is a part of X-ray: Generate and Analyse (XGA), a module designed for the XMM Cluster Survey (XCS).
# Last modified by David J Turner (turne540@msu.edu) 09/12/2025, 11:57. Copyright (c) The Contributors

from astropy.units import Quantity

EROSITA_EXTMAP_LO_EN = Quantity(0.2, 'keV')
EROSITA_EXTMAP_HI_EN = Quantity(10.0, 'keV')
11 changes: 10 additions & 1 deletion xga/generate/esass/lightcurve.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This code is a part of X-ray: Generate and Analyse (XGA), a module designed for the XMM Cluster Survey (XCS).
# Last modified by David J Turner (turne540@msu.edu) 03/07/2025, 10:55. Copyright (c) The Contributors
# Last modified by David J Turner (turne540@msu.edu) 09/12/2025, 10:36. Copyright (c) The Contributors

import os
from copy import deepcopy
Expand Down Expand Up @@ -191,6 +191,15 @@ def _append_lc_info(evt_list):
"hi_en": hi_en,
"telescope": 'erosita'})

# Early XGA could generate spectra within the detection regions of the source, but
# that has been deprecated for quite a while, as it was a bad idea. The generation
# of spectra within user-specified regions will be possible, but it will be
# implemented differently. The original way was bad because the detection region
# could/almost certainly would be different for each observation
if outer_radius == 'region':
raise ValueError("The string 'region' is no longer a valid option for "
"the 'outer_radius' argument.")

# We check to see whether there is an eROSITA entry in the 'telescopes' property. If sources is a Source
# object, then that property contains the telescopes associated with that source, and if it is a Sample object
# then 'telescopes' contains the list of unique telescopes that are associated with at least one member source.
Expand Down
6 changes: 3 additions & 3 deletions xga/generate/esass/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This code is a part of X-ray: Generate and Analyse (XGA), a module designed for the XMM Cluster Survey (XCS).
# Last modified by David J Turner (turne540@msu.edu) 08/07/2025, 10:05. Copyright (c) The Contributors
# Last modified by David J Turner (turne540@msu.edu) 09/12/2025, 15:20. Copyright (c) The Contributors

from functools import wraps
from multiprocessing.dummy import Pool
Expand All @@ -9,7 +9,7 @@
from tqdm import tqdm

from ..common import execute_cmd
from ... import eSASS_AVAIL
from ... import ESASS_AVAIL
from ...exceptions import eSASSNotFoundError, ProductGenerationError
from ...products import BaseProduct, AnnularSpectra
from ...samples.base import BaseSample
Expand All @@ -27,7 +27,7 @@ def esass_call(esass_func):
@wraps(esass_func)
def wrapper(*args, **kwargs):
# Checking eSASS is installed and available on the system
if not eSASS_AVAIL:
if not ESASS_AVAIL:
raise eSASSNotFoundError("No eSASS installation has been found on this machine.")

# The first argument of all of these eSASS functions will be the source object (or a list of),
Expand Down
Loading