|
1 | 1 | # 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/5/26, 12:43 PM. Copyright (c) The Contributors. |
| 2 | +# Last modified by David J Turner (djturner@umbc.edu) 5/5/26, 2:16 PM. Copyright (c) The Contributors. |
3 | 3 |
|
| 4 | +import importlib |
4 | 5 | import json |
5 | 6 | import os |
6 | 7 | import re |
|
14 | 15 |
|
15 | 16 | import numpy as np |
16 | 17 | import pandas as pd |
17 | | -import pkg_resources |
18 | 18 | from astropy.constants import m_p, m_e |
19 | 19 | from astropy.cosmology import LambdaCDM |
20 | 20 | from astropy.io import fits |
@@ -245,7 +245,7 @@ def _get_xspec_info() -> Tuple[Union[Version, None], List[str], List[str]]: |
245 | 245 | else: |
246 | 246 | try: |
247 | 247 | # null_script.xcm does absolutely nothing, it's just a way to get the version out |
248 | | - null_path = pkg_resources.resource_filename(__name__, "xspec_scripts/null_script.xcm") |
| 248 | + null_path = importlib.resources.files(__name__) / "xspec_scripts/null_script.xcm" |
249 | 249 | xspec_out, xspec_err = Popen("xspec - {}".format(null_path), stdout=PIPE, stderr=PIPE, |
250 | 250 | shell=True).communicate() |
251 | 251 | # Got to parse the stdout to get the XSPEC version |
@@ -876,21 +876,24 @@ def check_telescope_choices(telescope: Union[str, List[str]]) -> List[str]: |
876 | 876 | # reading the information in on demand would be overkill for this |
877 | 877 |
|
878 | 878 | # Here we read in files that list the errors and warnings in SAS |
879 | | -errors = pd.read_csv(pkg_resources.resource_filename(__name__, "files/sas_errors.csv"), header="infer") |
880 | | -warnings = pd.read_csv(pkg_resources.resource_filename(__name__, "files/sas_warnings.csv"), header="infer") |
| 879 | +errors = pd.read_csv(importlib.resources.files(__name__) / "files/sas_errors.csv", header="infer") |
| 880 | +warnings = pd.read_csv(importlib.resources.files(__name__) / "files/sas_warnings.csv", header="infer") |
881 | 881 | # Just the names of the errors in two handy constants |
882 | 882 | SASERROR_LIST = errors["ErrName"].values |
883 | 883 | SASWARNING_LIST = warnings["WarnName"].values |
884 | 884 |
|
885 | 885 | # XSPEC file extraction (and base fit) scripts |
886 | | -XGA_EXTRACT = pkg_resources.resource_filename(__name__, "xspec_scripts/xga_extract.tcl") |
887 | | -BASE_XSPEC_SCRIPT = pkg_resources.resource_filename(__name__, "xspec_scripts/general_xspec_fit.xcm") |
888 | | -COUNTRATE_CONV_SCRIPT = pkg_resources.resource_filename(__name__, "xspec_scripts/cr_conv_calc.xcm") |
| 886 | +XGA_EXTRACT = importlib.resources.files(__name__) / "xspec_scripts/xga_extract.tcl" |
| 887 | +BASE_XSPEC_SCRIPT = importlib.resources.files(__name__) / "xspec_scripts/general_xspec_fit.xcm" |
| 888 | +COUNTRATE_CONV_SCRIPT = importlib.resources.files(__name__) / "xspec_scripts/cr_conv_calc.xcm" |
| 889 | + |
889 | 890 | # Useful jsons of all XSPEC models, their required parameters, and those parameter's units |
890 | | -with open(pkg_resources.resource_filename(__name__, "files/xspec_model_pars.json5"), 'r') as filey: |
| 891 | +with open(importlib.resources.files(__name__) / "files/xspec_model_pars.json5", 'r') as filey: |
891 | 892 | MODEL_PARS = json.load(filey) |
892 | | -with open(pkg_resources.resource_filename(__name__, "files/xspec_model_units.json5"), 'r') as filey: |
| 893 | + |
| 894 | +with open(importlib.resources.files(__name__) / "files/xspec_model_units.json5", 'r') as filey: |
893 | 895 | MODEL_UNITS = json.load(filey) |
| 896 | + |
894 | 897 | # -------------------------------------------------------------------------- |
895 | 898 |
|
896 | 899 |
|
|
0 commit comments