Skip to content

Commit

Permalink
Altered the ScalingRelation class so that the name of a relation can …
Browse files Browse the repository at this point in the history
…be none, and that is what would trigger the view method making its own label
  • Loading branch information
DavidT3 committed Jan 31, 2025
1 parent c645b07 commit a56c6bf
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions xga/products/relation.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 ([email protected]) 28/01/2025, 13:14. Copyright (c) The Contributors
# Last modified by David J Turner ([email protected]) 30/01/2025, 22:03. Copyright (c) The Contributors

import inspect
import pickle
Expand Down Expand Up @@ -217,11 +217,9 @@ def __init__(self, fit_pars: np.ndarray, fit_par_errs: np.ndarray, model_func, x
else:
self._chains = chains

# If the user hasn't passed the name of the relation then I'll generate one from what I know so far
if relation_name is None:
self._name = self._y_name + '-' + self._x_name + ' ' + self.fit_method
else:
self._name = relation_name
# If the user hasn't passed the name of the relation then the view method will generate one for itself, which
# is the main place that it is used
self._name = relation_name

# For relations from literature especially I need to give credit the author, and the original paper
self._author = relation_author
Expand Down Expand Up @@ -1586,10 +1584,11 @@ def get_view(self, ax: Axes, x_lims: Quantity = None, log_scale: bool = True, pl
for m_name in MODEL_PUBLICATION_NAMES:
mod_name = mod_name.replace(m_name, MODEL_PUBLICATION_NAMES[m_name])

if rel.author != 'XGA':
if rel.name is None:
relation_label = " ".join([rel.author, rel.year])
else:
relation_label = rel.name + ' Scaling Relation'

plt.plot(model_x * rel.x_norm.value, model_median, color=m_colour, label=relation_label)

plt.plot(model_x * rel.x_norm.value, model_upper, color=m_colour, linestyle="--")
Expand Down

0 comments on commit a56c6bf

Please sign in to comment.