mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Adding energy axis units to plot xs (#2876)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
02c0a09281
commit
b75ccd598e
2 changed files with 25 additions and 4 deletions
|
|
@ -105,7 +105,7 @@ def _get_title(reactions):
|
|||
def plot_xs(reactions, divisor_types=None, temperature=294., axis=None,
|
||||
sab_name=None, ce_cross_sections=None, mg_cross_sections=None,
|
||||
enrichment=None, plot_CE=True, orders=None, divisor_orders=None,
|
||||
**kwargs):
|
||||
energy_axis_units="eV", **kwargs):
|
||||
"""Creates a figure of continuous-energy cross sections for this item.
|
||||
|
||||
Parameters
|
||||
|
|
@ -148,6 +148,10 @@ def plot_xs(reactions, divisor_types=None, temperature=294., axis=None,
|
|||
**kwargs :
|
||||
All keyword arguments are passed to
|
||||
:func:`matplotlib.pyplot.figure`.
|
||||
energy_axis_units : {'eV', 'keV', 'MeV'}
|
||||
Units used on the plot energy axis
|
||||
|
||||
.. versionadded:: 0.14.1
|
||||
|
||||
Returns
|
||||
-------
|
||||
|
|
@ -161,6 +165,9 @@ def plot_xs(reactions, divisor_types=None, temperature=294., axis=None,
|
|||
import matplotlib.pyplot as plt
|
||||
|
||||
cv.check_type("plot_CE", plot_CE, bool)
|
||||
cv.check_value("energy_axis_units", energy_axis_units, {"eV", "keV", "MeV"})
|
||||
|
||||
axis_scaling_factor = {"eV": 1.0, "keV": 1e-3, "MeV": 1e-6}
|
||||
|
||||
# Generate the plot
|
||||
if axis is None:
|
||||
|
|
@ -217,6 +224,8 @@ def plot_xs(reactions, divisor_types=None, temperature=294., axis=None,
|
|||
if divisor_types[line] != 'unity':
|
||||
types[line] += ' / ' + divisor_types[line]
|
||||
|
||||
E *= axis_scaling_factor[energy_axis_units]
|
||||
|
||||
# Plot the data
|
||||
for i in range(len(data)):
|
||||
data[i, :] = np.nan_to_num(data[i, :])
|
||||
|
|
@ -232,9 +241,12 @@ def plot_xs(reactions, divisor_types=None, temperature=294., axis=None,
|
|||
ax.set_xscale('log')
|
||||
ax.set_yscale('log')
|
||||
|
||||
ax.set_xlabel('Energy [eV]')
|
||||
ax.set_xlabel(f"Energy [{energy_axis_units}]")
|
||||
if plot_CE:
|
||||
ax.set_xlim(_MIN_E, _MAX_E)
|
||||
ax.set_xlim(
|
||||
_MIN_E * axis_scaling_factor[energy_axis_units],
|
||||
_MAX_E * axis_scaling_factor[energy_axis_units],
|
||||
)
|
||||
else:
|
||||
ax.set_xlim(E[-1], E[0])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue