serpentTools.objects.XSData¶
-
class
serpentTools.objects.XSData(name, metadata, isIso=False)¶ Base class for storing cross section data an xsplot file
- Parameters
-
energies¶ Energy grid [MeV]
- Type
-
metadata¶ File-wide metadata from the reader. Alias for accessing
energies. Will be removed in the future- Type
-
__getitem__(mt)¶ Return data corresponding to a given mt
- Parameters
mt (int) – Integer MT reaction number
- Returns
Cross section data for this mt
- Return type
- Raises
AttributeError – If
xsdatais empty
-
__len__()¶ Number of reactions stored
-
compare(other, lower=0, upper=10, sigma=2, verbosity=None)¶ Compare the results of this reader to another.
For values without uncertainties, the upper and lower arguments control what passes and what messages get raised. If a quantity in
otheris less thanlowerpercent different that the same quantity on this object, consider this allowable and make no messages. Quantities that are greater thanupperpercent different will have a error messages printed and the comparison will returnFalse, but continue. Quantities with difference between these ranges will have warning messages printed.- Parameters
other – Other reader instance against which to compare. Must be a similar class as this one.
lower (float or int) – Lower limit for relative tolerances in percent Differences below this will be considered allowable
upper (float or int) – Upper limit for relative tolerances in percent. Differences above this will be considered failure and errors messages will be raised
sigma (int) – Size of confidence interval to apply to quantities with uncertainties. Quantities that do not have overlapping confidence intervals will fail
verbosity (None or str) – If given, update the verbosity just for this comparison.
- Returns
Trueif the objects are in agreement with each other according to the parameters specified- Return type
- Raises
TypeError – If
otheris not of the same class as this class nor a subclass of this classValueError – If upper > lower, If sigma, lower, or upper are negative
-
describe(mt)¶ Return the description for any reaction MT
-
get(mt, default=None)¶ Return data corresponding to a given mt or a default
- Parameters
- Returns
numpy.ndarrayifmtis found. Otherwisedefault- Return type
- Raises
AttributeError – If
xsdatais empty
-
hasExpectedData()¶ Check that the expected data (MT numbers, an energy grid, etc) were collected.
-
static
negativeMTDescription(mt)¶ Descriptions for Serpent negative MT numbers
These correspond to macroscopic properties, like fission energy production, and for neutrons only. From Serpent Wiki
-
plot(mts='all', ax=None, loglog=False, xlabel=None, ylabel=None, logx=True, logy=False, title=None, legend=None, ncol=1, labels=None, **kwargs)¶ Plot XS corresponding to their MTs.
- Parameters
mts (int, string, or list of ints) – If it’s a string, it should be ‘all’. A single int indicates one MT reaction number. A list should be a list of MT numbers to plot.
ax (
matplotlib.axes.Axes, optional) – Ax on which to plot the data. If not provided, create a new plotloglog (bool) – Apply a log scale to both axes.
logx (bool) – Apply a log scale to x axis.
logy (bool) – Apply a log scale to y axis.
xlabel (str or bool, optional) – Label to apply to the x-axis. If given as
None, a label will be determined from other arguments. If notNonebut evaluates toFalse, do not label.ylabel (str or bool, optional) – Label to apply to the y-axis. If given as
None, a label will be determined from other arguments. If notNonebut evaluates toFalse, do not label.title (str) – Title to apply to the figure.
legend (bool or str or None) – Automatically label the plot. No legend will be made if a single item is plotted. Pass one of the following values to place the legend outside the plot: above, right
ncol (int) – Integer number of columns to apply to the legend.
labels (str or list of str or dict {int: str}) – Labels to apply to the plot. Defaults to labeling by MT description. If a string, then
mtsmust be a single integer. If a list of strings, each label will be applied to each entry inmts. If a dictionary, keys must be mts and their labels as values. The number of keys do not have to align with the number of MTskwargs (dict, optional) – Addition keyword arguments to pass to
matplotlib.pyplot.plot()
- Returns
Ax on which the data was plotted.
- Return type
- Raises
TypeError – If MT numbers that don’t make sense come up
-
setData(chunk)¶ Parse data from chunk to np array.
-
setMTs(chunk)¶ Parse chunk to MT numbers and descriptions
-
setNuData(chunk)¶ Add fission neutrons per fission data
-
showMT(retstring=False)¶ Create a pretty-print style string of the MT values avaialable
- Parameters
retstring (bool) – Return a string if true. Otherwise, print it
-
tabulate(mts='all', colnames=None)¶ Returns a pandas table, for pretty tabulation in Jupyter notebooks.
- Parameters
mts (int, string, or list of ints) – If it’s a string, it should be ‘all’, which is default. A single int indicates one MT reaction number. A list should be a list of MT numbers to plot.
colnames (any type with string representation) – Column names for each MT number, if you’d like to change them.
- Returns
Tabulated representation of the cross section data
- Return type
- Raises
ImportError – If
pandasis not installedTypeError – if MT numbers that don’t make sense come up