serpentTools.objects.DepletedMaterial

class serpentTools.objects.DepletedMaterial(name, metadata)

Base class for storing material data from a depleted material file

Many of the instance attributes are shortcuts for accessing data in the underlying dictionary. For example, the following command fetch the same data:

>>> m.data["adens"]
>>> m["adens"]
>>> m.adens

With one exception: the attribute-based accessing is guaranteed to not raise an error if the data has not been loaded into the dictionary. This may be the case if a file was read using filtering settings and adens was not read.

Parameters
  • name (str) – Name of this material

  • metadata (dict) – Dictionary with file metadata

data

Main dictionary of arrays from the output file

Type

dict

zai

Isotopic ZZAAAI identifiers like 922350. Ordered like the rows of the data arrays

Type

list of int

names

Isotope names like "U235". Ordered like the rows of the data arrays

Type

list of str

days

Time in days for each column in the data arrays

Type

numpy.ndarray

burnup

Burnup vector for this specific material

Type

numpy.ndarray or None

volume

Volume of this material over time

Type

numpy.ndarray or None

adens

2D array of atom densities in atoms/b-cm

Type

numpy.ndarray or None

mdens

2D array of mass densites in g/cm3

Type

numpy.ndarray or None

activity

2D array of activities in Bq

Type

numpy.ndarray or None

decayHeat

2D array of decay heats in W

Type

numpy.ndarray or None

spontaneousFissionRate

2D array of spontaneous fission rate in fission per second

Type

numpy.ndarray or None

photonProdRate

2D array of photon emission rate in photons per second

Type

numpy.ndarray or None

ingTox

2D array of ingestion toxicity in sieverts

Type

numpy.ndarray or None

inhTox

2D array of inhalation toxicity in sieverts

Type

numpy.ndarray or None

__getitem__(item)

Retrieve a value from the data dictionary

addData(variable, rawData)

Add data straight from the file onto a variable.

Parameters
  • variable (str) – Name of the variable directly from SERPENT

  • rawData (list) – List of strings corresponding to the raw data from the file

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 other is less than lower percent different that the same quantity on this object, consider this allowable and make no messages. Quantities that are greater than upper percent different will have a error messages printed and the comparison will return False, 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

True if the objects are in agreement with each other according to the parameters specified

Return type

bool

Raises
  • TypeError – If other is not of the same class as this class nor a subclass of this class

  • ValueError – If upper > lower, If sigma, lower, or upper are negative

get(key, default=None)

Retrieve a value from the dictionary, or default if not found

Parameters
  • key (str) – Name of a quantity that may or may not exist in data

  • default (object, optional) – Item to return if key is not found

Returns

numpy.ndarray if key was found, otherwise default

Return type

object

getValues(xUnits, yUnits, timePoints=None, names=None, zai=None)

Return material variable data at specified time points and isotopes

If the quantity yUnits corresponds to a vector in the data dictionary, e.g. burnup or volume, and not something that varies by isotope, then names does not have to be given

Parameters
  • xUnits (str) – name of x value to obtain, e.g. 'days', 'burnup'

  • yUnits (str) – name of y value to return, e.g. 'adens', 'burnup'

  • timePoints (list or None) – If given, select the time points according to those specified here. Otherwise, select all points

  • names (str or list or None) – If given, return y values corresponding to these isotope names. Otherwise, return values for all isotopes.

  • zai (str or list or None) –

    If given, return y values corresponding to isotopes with these ZZAAAI as would be present in self.zai. Otherwise, return values for all isotopes.

    New in version 0.5.1.

Returns

Array of values.

Return type

numpy.array

Raises
  • AttributeError – If the names of the isotopes have not been obtained and specific isotopes have been requested

  • KeyError – If at least one of the days requested is not present

  • TypeError – If both names and zai arguments are passed

  • ValueError – If one isotope cannot be found

plot(xUnits, yUnits=None, timePoints=None, names=None, zai=None, ax=None, legend=None, xlabel=None, ylabel=None, logx=False, logy=False, loglog=False, labelFmt=None, ncol=1, title=None, **kwargs)

Plot some data as a function of time for some or all isotopes.

Note

kwargs will be passed to the plot for all isotopes. If c='r' is passed, to make a plot red, then data for all isotopes plotted will be red and potentially very confusing.

Parameters
  • xUnits (str) – name of x value to obtain, e.g. 'days', 'burnup' If xUnits is given and yUnits is None, then the plotted data will be xUnits against 'days'

  • yUnits (str) – name of y value to return, e.g. 'adens', 'burnup'

  • timePoints (list or None) –

    If given, select the time points according to those specified here. Otherwise, select all points

    Deprecated since version 0.7.0: Will plot against all time points

  • names (str or list or None) – If given, plot values corresponding to these isotope names. Otherwise, plot values for all isotopes.

  • zai (int or list or None) –

    If given, plot values corresponding to these isotope ZZAAAI values. Otherwise, plot for all isotopes

    New in version 0.5.1.

  • ax (matplotlib.axes.Axes, optional) – Ax on which to plot the data. If not provided, create a new plot

  • 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

  • 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 not None but evaluates to False, do not label. Otherwise, use xUnits

  • 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 not None but evaluates to False, do not label. Otherwise, use yUnits

  • logx (bool) – Apply a log scale to x axis.

  • logy (bool) – Apply a log scale to y axis.

  • loglog (bool) – Apply a log scale to both axes.

  • labelFmt (str, optional) –

    Formattable string for labeling the individual plots. If not given, just label as isotope name, e.g. 'U235'. Will make the following substitutions on the labelFmt string, if given:

    Keyword

    Replacement

    'mat'

    name of this material

    'iso'

    specific isotope name

    'zai'

    specific isotope ZZAAAI

  • ncol (int) – Integer number of columns to apply to the legend.

  • title (str) – Title to apply to the figure.

  • kwargs (dict, optional) – Addition keyword arguments to pass to matplotlib.pyplot.plot()

Returns

Ax on which the data was plotted.

Return type

matplotlib.axes.Axes

See also

Raises
  • KeyError – If x axis units are not 'days' nor 'burnup'

  • TypeError – If both names and zai are given

toDataFrame(quantity, names=None, zai=None, time='days', multiIndex=False)

Create a pandas DataFrame for a property of interest

If names and zai are not provided, then the isotope names will be used as the columns.

Parameters
  • quantity (str) – Either a key in data or the string name of an attribute like photonProdRate for photonProdRate

  • names (sequence of str, optional) – Specific isotope names to obtain. Not compatible with zai

  • zai (sequence of int, optional) – Specific isotope zai to obtain. Not compatible with names

  • time ({"days", "burnup", "step"}, optional) – What array to use for the index or rows of the DataFrame. Defaults to using days, but "burnup" can be passed to use burnup, if it is present. The value of "step" will simply create a basic index that starts at 0 and increments by one per row

Returns

2D tabulated representation of the requested array. Columns reflect isotopes, rows represent points in time

Return type

pandas.DataFrame