Skip to content

Commit

Permalink
Made the get_view method the aggregate scaling relation use the nanma…
Browse files Browse the repository at this point in the history
…xarg and nanminarg functions
  • Loading branch information
DavidT3 committed Jan 28, 2025
1 parent 97594e6 commit 69a2376
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 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:00. Copyright (c) The Contributors
# Last modified by David J Turner ([email protected]) 28/01/2025, 13:06. Copyright (c) The Contributors

import inspect
import pickle
Expand Down Expand Up @@ -1794,7 +1794,6 @@ def get_view(self, ax: Axes, x_lims: Quantity = None, log_scale: bool = True, pl
:param bool one_to_one: If True, a one-to-one line will be plotted on the scaling relation view. Default is
False.
"""

# Very large chunks of this are almost direct copies of the view method of ScalingRelation, but this
# was the easiest way of setting this up, so I think the duplication is justified.

Expand Down Expand Up @@ -1849,8 +1848,8 @@ def get_view(self, ax: Axes, x_lims: Quantity = None, log_scale: bool = True, pl
elif comb_x_lims is not None:
x_lims = np.array([comb_x_lims.value.min(), comb_x_lims.value.max()])
elif x_lims is None and len(comb_x_data) != 0:
max_x_ind = np.argmax(comb_x_data[:, 0])
min_x_ind = np.argmin(comb_x_data[:, 0])
max_x_ind = np.nanargmax(comb_x_data[:, 0])
min_x_ind = np.nanargmin(comb_x_data[:, 0])
x_lims = [0.9 * (comb_x_data[min_x_ind, 0].value - comb_x_data[min_x_ind, 1].value),
1.1 * (comb_x_data[max_x_ind, 0].value + comb_x_data[max_x_ind, 1].value)]
elif x_lims is None and len(comb_x_data) == 0:
Expand All @@ -1861,11 +1860,6 @@ def get_view(self, ax: Axes, x_lims: Quantity = None, log_scale: bool = True, pl
# Setting the axis limits
ax.set_xlim(x_lims)

# Making the scale log if requested
if log_scale:
ax.set_xscale("log")
ax.set_yscale("log")

# Setup the aesthetics of the axis
ax.minorticks_on()
ax.tick_params(axis='both', direction='in', which='both', top=True, right=True)
Expand Down Expand Up @@ -1931,6 +1925,11 @@ def get_view(self, ax: Axes, x_lims: Quantity = None, log_scale: bool = True, pl
# Setting the axis limits
ax.set_ylim(y_lims.value)

# Making the scale log if requested
if log_scale:
ax.set_xscale("log")
ax.set_yscale("log")

# I can dynamically grab the units in LaTeX formatting from the Quantity objects (thank you astropy)
# However I've noticed specific instances where the units can be made prettier
# Parsing the astropy units so that if they are double height then the square brackets will adjust size
Expand Down

0 comments on commit 69a2376

Please sign in to comment.