Skip to content

Commit f463f5f

Browse files
authored
Merge pull request #1403 from DavidT3/refine/prodRetrievalRadiiPrecision
Refine/prod retrieval radii precision
2 parents ab61736 + 25fd657 commit f463f5f

File tree

11 files changed

+245
-210
lines changed

11 files changed

+245
-210
lines changed

xga/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
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) 04/11/2024, 10:36. Copyright (c) The Contributors
2+
# Last modified by David J Turner (turne540@msu.edu) 16/07/2025, 12:25. Copyright (c) The Contributors
33
from . import _version
44
__version__ = _version.get_versions()['version']
55

6-
from .utils import xga_conf, CENSUS, OUTPUT, NUM_CORES, XGA_EXTRACT, BASE_XSPEC_SCRIPT, MODEL_PARS, \
7-
MODEL_UNITS, ABUND_TABLES, XSPEC_FIT_METHOD, COUNTRATE_CONV_SCRIPT, NHC, BLACKLIST, HY_MASS, MEAN_MOL_WEIGHT, \
8-
SAS_VERSION, XSPEC_VERSION, SAS_AVAIL, DEFAULT_COSMO, TELESCOPES, USABLE, DEFAULT_TELE_SEARCH_DIST, COMBINED_INSTS, \
9-
eSASS_AVAIL, SRC_REGION_COLOURS, check_telescope_choices, PRETTY_TELESCOPE_NAMES, ESASS_VERSION
6+
from .utils import (xga_conf, CENSUS, OUTPUT, NUM_CORES, XGA_EXTRACT, BASE_XSPEC_SCRIPT, MODEL_PARS, MODEL_UNITS,
7+
ABUND_TABLES, XSPEC_FIT_METHOD, COUNTRATE_CONV_SCRIPT, NHC, BLACKLIST, HY_MASS, MEAN_MOL_WEIGHT,
8+
SAS_VERSION, XSPEC_VERSION, SAS_AVAIL, DEFAULT_COSMO, TELESCOPES, USABLE, DEFAULT_TELE_SEARCH_DIST,
9+
COMBINED_INSTS, eSASS_AVAIL, SRC_REGION_COLOURS, check_telescope_choices, PRETTY_TELESCOPE_NAMES,
10+
ESASS_VERSION, RAD_MATCH_PRECISION)

xga/models/density.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) 08/06/2023, 22:40. Copyright (c) The Contributors
2+
# Last modified by David J Turner (turne540@msu.edu) 18/07/2025, 10:21. Copyright (c) The Contributors
33

44
from typing import Union, List
55

@@ -356,7 +356,7 @@ def model(x: Quantity, beta: Quantity, r_core: Quantity, alpha: Quantity, r_s: Q
356356
second_term = 1 / ((1 + rs_rat**3)**(epsilon / 3))
357357
result = norm * np.sqrt(first_term * second_term)
358358
except ZeroDivisionError:
359-
result = np.NaN
359+
result = np.nan
360360

361361
return result
362362

@@ -517,7 +517,7 @@ def model(x: Quantity, beta_one: Quantity, r_core_one: Quantity, alpha: Quantity
517517
second_term = 1 / ((1 + rs_rat**gamma)**(epsilon / gamma))
518518
additive_term = 1 / ((1 + rc2_rat**2)**(3 * beta_two))
519519
except ZeroDivisionError:
520-
return np.NaN
520+
return np.nan
521521

522522
return np.sqrt((np.power(norm_one, 2) * first_term * second_term) + (np.power(norm_two, 2) * additive_term))
523523

xga/models/fitting.py

Lines changed: 2 additions & 2 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) 20/02/2023, 14:04. Copyright (c) The Contributors
2+
# Last modified by David J Turner (turne540@msu.edu) 18/07/2025, 10:21. Copyright (c) The Contributors
33

44
from typing import List
55

@@ -26,7 +26,7 @@ def log_likelihood(theta: np.ndarray, r: np.ndarray, y: np.ndarray, y_err: np.nd
2626
try:
2727
lik = -np.sum(np.log(y_err*np.sqrt(2*np.pi)) + (((y - m_func(r, *theta))**2) / (2*y_err**2)))
2828
except ZeroDivisionError:
29-
lik = np.NaN
29+
lik = np.nan
3030
return lik
3131

3232

xga/models/temperature.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) 29/07/2024, 16:04. Copyright (c) The Contributors
2+
# Last modified by David J Turner (turne540@msu.edu) 18/07/2025, 10:21. Copyright (c) The Contributors
33

44
from typing import Union, List
55

@@ -117,7 +117,7 @@ def model(x: Quantity, r_cool: Quantity, a_cool: Quantity, t_min: Quantity, t_ze
117117
out_expr = 1 / ((1 + (x / r_tran)**2)**(c_power / 2))
118118
result = t_zero * cool_expr * out_expr
119119
except ZeroDivisionError:
120-
result = np.NaN
120+
result = np.nan
121121

122122
return result
123123

@@ -269,7 +269,7 @@ def model(x: Quantity, r_cool: Quantity, a_cool: Quantity, t_min: Quantity, t_ze
269269
result = t_zero * t_cool * t_outer
270270

271271
except ZeroDivisionError:
272-
result = np.NaN
272+
result = np.nan
273273

274274
return result
275275

xga/products/lightcurve.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) 07/02/2024, 09:05. Copyright (c) The Contributors
2+
# Last modified by David J Turner (turne540@msu.edu) 18/07/2025, 10:21. Copyright (c) The Contributors
33
import re
44
from datetime import datetime
55
from typing import Union, List, Tuple
@@ -552,9 +552,9 @@ def _read_on_demand(self):
552552

553553
else:
554554
self._bck_cnt_rate = Quantity(np.full(len(all_lc['RATE'].read_column('TIME')),
555-
np.NaN), 'ct/s')[good_ent]
555+
np.nan), 'ct/s')[good_ent]
556556
self._bck_cnt_rate_err = Quantity(np.full(len(all_lc['RATE'].read_column('TIME')),
557-
np.NaN), 'ct/s')[good_ent]
557+
np.nan), 'ct/s')[good_ent]
558558

559559
# Grab the start, stop, and time assign values from the overall header of the light curve
560560
hdr = all_lc['RATE'].read_header()

xga/samples/extended.py

Lines changed: 22 additions & 22 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 (turne540@msu.edu) 18/07/2025, 10:21. Copyright (c) The Contributors
33

44
from typing import List
55

@@ -524,7 +524,7 @@ def _get_overdens_rad_checks(self, rad_name: str) -> Quantity:
524524
rad = gcs.get_radius(rad_name, 'kpc')
525525
# Result could be None, if the radius wasn't set for that clusters, have to account for that
526526
if rad is None:
527-
rads.append(np.NaN)
527+
rads.append(np.nan)
528528
else:
529529
rads.append(rad)
530530

@@ -688,24 +688,24 @@ def Tx(self, telescope: str, outer_radius: Union[str, Quantity] = 'r500', model:
688688
# If the measured temperature is 64keV I know that's a failure condition of the XSPEC fit,
689689
# so its set to NaN
690690
if quality_checks and gcs_temp[0] > 25:
691-
gcs_temp = np.array([np.NaN, np.NaN, np.NaN])
691+
gcs_temp = np.array([np.nan, np.nan, np.nan])
692692
warn("A temperature of {m}keV was measured for {s}, anything over 30keV considered a failed "
693693
"fit by XGA".format(s=gcs.name, m=gcs_temp), stacklevel=2)
694694
elif quality_checks and gcs_temp.min() < 0:
695-
gcs_temp = np.array([np.NaN, np.NaN, np.NaN])
695+
gcs_temp = np.array([np.nan, np.nan, np.nan])
696696
warn("A negative value was detected in the temperature array for {s}, this is considered a failed "
697697
"measurement".format(s=gcs.name), stacklevel=2)
698698
elif quality_checks and ((gcs_temp[0] - gcs_temp[1]) <= 0):
699-
gcs_temp = np.array([np.NaN, np.NaN, np.NaN])
699+
gcs_temp = np.array([np.nan, np.nan, np.nan])
700700
warn("The temperature value - the lower error goes below zero for {s}, this makes the temperature"
701701
" hard to use for scaling relations as values are often logged.".format(s=gcs.name),
702702
stacklevel=2)
703703
elif quality_checks and ((gcs_temp[1] / gcs_temp[2]) > 3 or (gcs_temp[1] / gcs_temp[2]) < 0.33):
704-
gcs_temp = np.array([np.NaN, np.NaN, np.NaN])
704+
gcs_temp = np.array([np.nan, np.nan, np.nan])
705705
warn("One of the temperature uncertainty values for {s} is more than three times larger than "
706706
"the other, this means the fit quality is suspect.".format(s=gcs.name), stacklevel=2)
707707
elif quality_checks and ((gcs_temp[0] - gcs_temp[1:].mean()) < 0):
708-
gcs_temp = np.array([np.NaN, np.NaN, np.NaN])
708+
gcs_temp = np.array([np.nan, np.nan, np.nan])
709709
warn("The temperature value - the average error goes below zero for {s}, this makes the "
710710
"temperature hard to use for scaling relations as values are often logged".format(s=gcs.name),
711711
stacklevel=2)
@@ -716,7 +716,7 @@ def Tx(self, telescope: str, outer_radius: Union[str, Quantity] = 'r500', model:
716716
# If any of the possible errors are thrown, we print the error as a warning and replace
717717
# that entry with a NaN
718718
warn(str(err), stacklevel=2)
719-
temps.append(np.array([np.NaN, np.NaN, np.NaN]))
719+
temps.append(np.array([np.nan, np.nan, np.nan]))
720720

721721
# Turn the list of 3 element arrays into an Nx3 array which is then turned into an astropy Quantity
722722
temps = Quantity(np.array(temps), 'keV')
@@ -820,29 +820,29 @@ def gas_mass(self, rad_name: str, telescope: str, dens_model: str, method: str,
820820
try:
821821
cur_gmass = dens_profs.gas_mass(dens_model, gas_mass_rad)[0]
822822
if quality_checks and (cur_gmass[1] > cur_gmass[0] or cur_gmass[2] > cur_gmass[0]):
823-
gms.append([np.NaN, np.NaN, np.NaN])
823+
gms.append([np.nan, np.nan, np.nan])
824824
elif quality_checks and cur_gmass[0] < Quantity(1e+9, 'Msun'):
825-
gms.append([np.NaN, np.NaN, np.NaN])
825+
gms.append([np.nan, np.nan, np.nan])
826826
warn("{s}'s gas mass is less than 1e+12 solar masses", stacklevel=2)
827827
elif quality_checks and cur_gmass[0] > Quantity(1e+16, 'Msun'):
828-
gms.append([np.NaN, np.NaN, np.NaN])
828+
gms.append([np.nan, np.nan, np.nan])
829829
warn("{s}'s gas mass is greater than 1e+16 solar masses", stacklevel=2)
830830
else:
831831
gms.append(cur_gmass.value)
832832
except ModelNotAssociatedError:
833-
gms.append([np.NaN, np.NaN, np.NaN])
833+
gms.append([np.nan, np.nan, np.nan])
834834
except ValueError:
835-
gms.append([np.NaN, np.NaN, np.NaN])
835+
gms.append([np.nan, np.nan, np.nan])
836836
warn("{s}'s gas mass is negative", stacklevel=2)
837837

838838
else:
839839
warn("Somehow there multiple matches for {s}'s density profile, this is the developer's "
840840
"fault.".format(s=gcs.name), stacklevel=2)
841-
gms.append([np.NaN, np.NaN, np.NaN])
841+
gms.append([np.nan, np.nan, np.nan])
842842

843843
except NoProductAvailableError:
844844
# If no dens_prof has been run or something goes wrong then NaNs are added
845-
gms.append([np.NaN, np.NaN, np.NaN])
845+
gms.append([np.nan, np.nan, np.nan])
846846
warn("{s} doesn't have a density profile associated, please look at "
847847
"sourcetools.density.".format(s=gcs.name), stacklevel=2)
848848

@@ -902,23 +902,23 @@ def hydrostatic_mass(self, rad_name: str, telescope: str, temp_model_name: str =
902902
try:
903903
cur_mass = mass_profs.mass(actual_rad)[0]
904904
if quality_checks and (cur_mass[1] > cur_mass[0] or cur_mass[2] > cur_mass[0]):
905-
ms.append([np.NaN, np.NaN, np.NaN])
905+
ms.append([np.nan, np.nan, np.nan])
906906
warn("{s}'s mass uncertainties are larger than the mass value.", stacklevel=2)
907907
elif quality_checks and cur_mass[0] < Quantity(1e+12, 'Msun'):
908-
ms.append([np.NaN, np.NaN, np.NaN])
908+
ms.append([np.nan, np.nan, np.nan])
909909
warn("{s}'s mass is less than 1e+12 solar masses", stacklevel=2)
910910
elif quality_checks and cur_mass[0] > Quantity(1e+16, 'Msun'):
911-
ms.append([np.NaN, np.NaN, np.NaN])
911+
ms.append([np.nan, np.nan, np.nan])
912912
warn("{s}'s mass is greater than 1e+16 solar masses", stacklevel=2)
913913
else:
914914
ms.append(cur_mass.value)
915915
except ValueError:
916916
warn("{s}'s mass is negative", stacklevel=2)
917-
ms.append([np.NaN, np.NaN, np.NaN])
917+
ms.append([np.nan, np.nan, np.nan])
918918

919919
except NoProductAvailableError:
920920
# If no dens_prof has been run or something goes wrong then NaNs are added
921-
ms.append([np.NaN, np.NaN, np.NaN])
921+
ms.append([np.nan, np.nan, np.nan])
922922
warn("{s} doesn't have a matching hydrostatic mass profile associated".format(s=gcs.name),
923923
stacklevel=2)
924924

@@ -989,11 +989,11 @@ def calc_overdensity_radii(self, delta: int, telescope: str, temp_model_name: st
989989
"didn't bracket the requested overdensity radius. See the docs of overdensity_radius "
990990
"method of HydrostaticMass for more info.".format(s=gcs.name), stacklevel=2)
991991

992-
rs.append(np.NaN)
992+
rs.append(np.nan)
993993

994994
except NoProductAvailableError:
995995
# If no dens_prof has been run or something goes wrong then NaNs are added
996-
rs.append(np.NaN)
996+
rs.append(np.nan)
997997
warn("{s} doesn't have a matching hydrostatic mass profile associated".format(s=gcs.name),
998998
stacklevel=2)
999999

0 commit comments

Comments
 (0)