serpentTools.samplers.SampledDepletedMaterial

class serpentTools.samplers.SampledDepletedMaterial(N, name, metadata)

Class that stores data from a variety of depleted materials

While adens, mdens, and burnup are accessible directly with material.adens, all variables read in from the file can be accessed through the data dictionary:

>>> assert material.adens is material.data['adens']
>>> assert material.adens is material['adens']
# The three methods are equivalent

Note

free() sets allData to an empty dictionary If <sampler.freeAll> is True, then free will be called after all files have been read and processed.

Parameters
  • N (int) – Number of containers to expect

  • name (str) – Name of this material

  • metadata (dict) – File-wide metadata for this run. Should contain ZAI and names for all isotopes, days, and burnup schedule

data

dictionary that stores all variable data

Type

dict

zai

Isotopic ZZAAA identifiers, e.g. 93325

Changed in version 0.5.1: Now a list of integers, not strings

Type

list

names

Names of isotopes, e.g. U235

Type

list

days

Vector of total, cumulative days of burnup for the run that created this material

Type

numpy.ndarray

burnup

Vector of total, cumulative burnup [MWd/kgU] for this specific material

Type

numpy.ndarray

adens

2D array of atomic densities where where row j corresponds to isotope j and column i corresponds to time i

Type

numpy.ndarray

mdens

2D array of mass densities where where row j corresponds to isotope j and column i corresponds to time i

Type

numpy.ndarray

uncertainties

Absolute uncertainties for all variables stored in data

Type

dict

allData

Dictionary where key, value pairs correspond to names of variables stored on this object and arrays of data from all files. The dimensionality will be increased by one, as the first index corresponds to the order in which files were loaded

Type

dict

__getitem__(item)

Retrieve a value from the data dictionary

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

finalize()

Produce final uncertainties from all aggregated runs

free()

Clear up data from all sampled parsers

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

loadFromContainer(container)

Copy data from a similar container.

Parameters

container – Incoming container from which to take data.

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

Plot the average of some data vs. time for some or all isotopes.

Note

kwargs will be passed to the errorbar 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'

  • 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 (list or None) – If given, return y values corresponding to these isotope names. Otherwise, return values for all isotopes.

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

  • sigma (int) – Confidence interval to apply to errors. If not given or 0, no errors will be drawn.

  • 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.

  • 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.

  • 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.

  • 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.

  • 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

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

Returns

Ax on which the data was plotted.

Return type

matplotlib.axes.Axes

See also

spreadPlot(xUnits, yUnits, isotope=None, zai=None, sampleKwargs=None, meanKwargs=None, timePoints=None, ax=None, xlabel=None, ylabel=None, logx=False, logy=False, loglog=False, legend=True)

Plot the mean quantity and data from all sampled files.

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'

  • isotope (str, optional) – Plot data for this isotope

  • zai (int, optional) – Plot data for this isotope. Not allowed if isotope given.

  • sampleKwargs (dict, optional) – Additional matplotlib-acceptable arguments to be passed into the plot when plotting data from unique runs, e.g. {"c": k, "alpha": 0.5}.

  • meanKwargs (dict, optional) – Additional matplotlib-acceptable argumentst to be used when plotting the mean value, e.g. {"c": "b", "marker": "o"}

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

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

  • 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.

  • 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.

  • 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.

  • 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

Returns

Ax on which the data was plotted.

Return type

matplotlib.axes.Axes