Skip to content

Commit 5d086f0

Browse files
author
David Turner
committed
Fixed errors in HydrostaticMass, SpecificEntropy, and ThermalPressure profiles so that they can take string names of models without failing.
Signed-off-by: David Turner <djturner@umbc.edu>
1 parent db863fa commit 5d086f0

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

xga/products/profile.py

Lines changed: 13 additions & 13 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/14/26, 4:26 PM. Copyright (c) The Contributors.
2+
# Last modified by David J Turner (djturner@umbc.edu) 5/20/26, 7:48 PM. Copyright (c) The Contributors.
33

44
from copy import copy
55
from typing import Tuple, Union, List
@@ -1503,11 +1503,11 @@ class HydrostaticMass(BaseProfile1D):
15031503
15041504
:param GasTemperature3D/ProjectedGasTemperature1D temperature_profile: The XGA 3D or projected
15051505
temperature profile to take temperature information from.
1506+
:param GasDensity3D density_profile: The XGA 3D density profile to take density information from.
15061507
:param str/BaseModel1D temperature_model: The model to fit to the temperature profile (if smooth models are to
15071508
be used to calculate the hydrostatic mass profile), either a name or an instance of an XGA temperature
15081509
model class. Default is None, in which case this class will use profile data points to calculate
15091510
hydrostatic mass.
1510-
:param GasDensity3D density_profile: The XGA 3D density profile to take density information from.
15111511
:param str/BaseModel1D density_model: The model to fit to the density profile (if smooth models are to
15121512
be used to calculate the hydrostatic mass profile), either a name or an instance of an XGA density model class.
15131513
Default is None, in which case this class will use profile data points to calculate hydrostatic mass.
@@ -1576,11 +1576,11 @@ def __init__(self, temperature_profile: Union[GasTemperature3D, ProjectedGasTemp
15761576
15771577
:param GasTemperature3D/ProjectedGasTemperature1D temperature_profile: The XGA 3D or projected
15781578
temperature profile to take temperature information from.
1579+
:param GasDensity3D density_profile: The XGA 3D density profile to take density information from.
15791580
:param str/BaseModel1D temperature_model: The model to fit to the temperature profile (if smooth models are to
15801581
be used to calculate the hydrostatic mass profile), either a name or an instance of an XGA temperature
15811582
model class. Default is None, in which case this class will use profile data points to calculate
15821583
hydrostatic mass.
1583-
:param GasDensity3D density_profile: The XGA 3D density profile to take density information from.
15841584
:param str/BaseModel1D density_model: The model to fit to the density profile (if smooth models are to
15851585
be used to calculate the hydrostatic mass profile), either a name or an instance of an XGA density
15861586
model class. Default is None, in which case this class will use profile data points to calculate
@@ -1752,7 +1752,7 @@ def __init__(self, temperature_profile: Union[GasTemperature3D, ProjectedGasTemp
17521752
elif not in_mod_names:
17531753
temperature_model = temperature_profile.fit(temperature_model, fit_method, num_samples, temp_steps,
17541754
num_walkers, progress, show_warn, force_refit=False)
1755-
key_temp_mod_part = "tm{t}".format(t=temperature_model.name)
1755+
key_temp_mod_part = "tm{t}".format(t=t_mn)
17561756
# Have to check whether the fits were actually successful, as the fit method will return a model instance
17571757
# either way
17581758
if not temperature_model.success:
@@ -1776,7 +1776,7 @@ def __init__(self, temperature_profile: Union[GasTemperature3D, ProjectedGasTemp
17761776
density_model = density_profile.fit(density_model, fit_method, num_samples, dens_steps,
17771777
num_walkers, progress, show_warn, force_refit=False)
17781778

1779-
key_dens_mod_part = "dm{d}".format(d=density_model.name)
1779+
key_dens_mod_part = "dm{d}".format(d=d_mn)
17801780
# Have to check whether the fits were actually successful, as the fit method will return a model instance
17811781
# either way
17821782
if not density_model.success:
@@ -2713,10 +2713,10 @@ class SpecificEntropy(BaseProfile1D):
27132713
27142714
:param GasTemperature3D / ProjectedGasTemperature1D temperature_profile: The XGA 3D or projected
27152715
temperature profile to take temperature information from.
2716+
:param GasDensity3D density_profile: The XGA 3D density profile to take density information from.
27162717
:param str/BaseModel1D temperature_model: The model to fit to the temperature profile (if smooth models are to
27172718
be used to calculate the entropy profile), either a name or an instance of an XGA temperature model class.
27182719
Default is None, in which case this class will use profile data points to calculate entropy.
2719-
:param GasDensity3D density_profile: The XGA 3D density profile to take density information from.
27202720
:param str/BaseModel1D density_model: The model to fit to the density profile (if smooth models are to
27212721
be used to calculate the entropy profile), either a name or an instance of an XGA density model class.
27222722
Default is None, in which case this class will use profile data points to calculate entropy.
@@ -2784,10 +2784,10 @@ def __init__(self, temperature_profile: Union[GasTemperature3D, ProjectedGasTemp
27842784
27852785
:param GasTemperature3D/ProjectedGasTemperature1D temperature_profile: The XGA 3D or projected
27862786
temperature profile to take temperature information from.
2787+
:param GasDensity3D density_profile: The XGA 3D density profile to take density information from.
27872788
:param str/BaseModel1D temperature_model: The model to fit to the temperature profile (if smooth models are to
27882789
be used to calculate the entropy profile), either a name or an instance of an XGA temperature model class.
27892790
Default is None, in which case this class will use profile data points to calculate entropy.
2790-
:param GasDensity3D density_profile: The XGA 3D density profile to take density information from.
27912791
:param str/BaseModel1D density_model: The model to fit to the density profile (if smooth models are to
27922792
be used to calculate the entropy profile), either a name or an instance of an XGA density model class.
27932793
Default is None, in which case this class will use profile data points to calculate entropy.
@@ -2958,7 +2958,7 @@ def __init__(self, temperature_profile: Union[GasTemperature3D, ProjectedGasTemp
29582958
elif not in_mod_names:
29592959
temperature_model = temperature_profile.fit(temperature_model, fit_method, num_samples, temp_steps,
29602960
num_walkers, progress, show_warn, force_refit=False)
2961-
key_temp_mod_part = "tm{t}".format(t=temperature_model.name)
2961+
key_temp_mod_part = "tm{t}".format(t=t_mn)
29622962
# Have to check whether the fits were actually successful, as the fit method will return a model instance
29632963
# either way
29642964
if not temperature_model.success:
@@ -2980,7 +2980,7 @@ def __init__(self, temperature_profile: Union[GasTemperature3D, ProjectedGasTemp
29802980
elif not in_mod_names:
29812981
density_model = density_profile.fit(density_model, fit_method, num_samples, dens_steps,
29822982
num_walkers, progress, show_warn, force_refit=False)
2983-
key_dens_mod_part = "dm{d}".format(d=density_model.name)
2983+
key_dens_mod_part = "dm{d}".format(d=d_mn)
29842984
# Have to check whether the fits were actually successful, as the fit method will return a model instance
29852985
# either way
29862986
if not density_model.success:
@@ -3312,10 +3312,10 @@ class ThermalPressure(BaseProfile1D):
33123312
33133313
:param GasTemperature3D / ProjectedGasTemperature1D temperature_profile: The XGA 3D or projected
33143314
temperature profile to take temperature information from.
3315+
:param GasDensity3D density_profile: The XGA 3D density profile to take density information from.
33153316
:param str/BaseModel1D temperature_model: The model to fit to the temperature profile (if smooth models are to
33163317
be used to calculate the thermal pressure profile), either a name or an instance of an XGA temperature model
33173318
class. Default is None, in which case this class will use profile data points to calculate thermal pressure.
3318-
:param GasDensity3D density_profile: The XGA 3D density profile to take density information from.
33193319
:param str/BaseModel1D density_model: The model to fit to the density profile (if smooth models are to
33203320
be used to calculate the thermal pressure profile), either a name or an instance of an XGA density model class.
33213321
Default is None, in which case this class will use profile data points to calculate thermal pressure.
@@ -3382,11 +3382,11 @@ def __init__(self, temperature_profile: Union[GasTemperature3D, ProjectedGasTemp
33823382
33833383
:param GasTemperature3D / ProjectedGasTemperature1D temperature_profile: The XGA 3D or projected
33843384
temperature profile to take temperature information from.
3385+
:param GasDensity3D density_profile: The XGA 3D density profile to take density information from.
33853386
:param str/BaseModel1D temperature_model: The model to fit to the temperature profile (if smooth models are to
33863387
be used to calculate the thermal pressure profile), either a name or an instance of an XGA temperature
33873388
model class. Default is None, in which case this class will use profile data points to calculate
33883389
thermal pressure.
3389-
:param GasDensity3D density_profile: The XGA 3D density profile to take density information from.
33903390
:param str/BaseModel1D density_model: The model to fit to the density profile (if smooth models are to
33913391
be used to calculate the thermal pressure profile), either a name or an instance of an XGA density
33923392
model class. Default is None, in which case this class will use profile data points to calculate thermal
@@ -3559,7 +3559,7 @@ def __init__(self, temperature_profile: Union[GasTemperature3D, ProjectedGasTemp
35593559
elif not in_mod_names:
35603560
temperature_model = temperature_profile.fit(temperature_model, fit_method, num_samples, temp_steps,
35613561
num_walkers, progress, show_warn, force_refit=False)
3562-
key_temp_mod_part = "tm{t}".format(t=temperature_model.name)
3562+
key_temp_mod_part = "tm{t}".format(t=t_mn)
35633563
# Have to check whether the fits were actually successful, as the fit method will return a model instance
35643564
# either way
35653565
if not temperature_model.success:
@@ -3582,7 +3582,7 @@ def __init__(self, temperature_profile: Union[GasTemperature3D, ProjectedGasTemp
35823582
elif not in_mod_names:
35833583
density_model = density_profile.fit(density_model, fit_method, num_samples, dens_steps,
35843584
num_walkers, progress, show_warn, force_refit=False)
3585-
key_dens_mod_part = "dm{d}".format(d=density_model.name)
3585+
key_dens_mod_part = "dm{d}".format(d=d_mn)
35863586
# Have to check whether the fits were actually successful, as the fit method will return a model instance
35873587
# either way
35883588
if not density_model.success:

xga/sourcetools/misc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# 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) 16/01/2024, 14:56. Copyright (c) The Contributors
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/20/26, 7:42 PM. Copyright (c) The Contributors.
33

44
from __future__ import annotations
55

@@ -11,7 +11,7 @@
1111
from astropy.coordinates import SkyCoord
1212
from astropy.cosmology import Cosmology
1313
from astropy.units import Quantity
14-
from numpy import array, ndarray, pi
14+
from numpy import array, pi
1515

1616
from .. import DEFAULT_COSMO
1717
from ..exceptions import HeasoftError
@@ -170,7 +170,7 @@ def model_check(sources: Union[BaseSource, BaseSample, List[BaseSource]],
170170
-> Union[List[BaseModel1D], List[str]]:
171171
"""
172172
Very simple function that checks if a passed set of models is appropriately structured for the number of sources
173-
that have been passed. I can't imagine why a user would need this directly, its only here as these checks
173+
that have been passed. There is no reason a user would need this directly, it's only here as these checks
174174
have to be performed in multiple places in sourcetools.
175175
176176
:param BaseSource/BaseSample/List[BaseSource] sources: The source(s) for which we are checking models.

0 commit comments

Comments
 (0)