serpentTools.DepletionReader

class serpentTools.DepletionReader(filePath)

Parser responsible for reading and working with depletion files.

Note

metadata is now a deprecated property, generated at each call. Additional keys added will not be retained. Prefer using names, burnup, days, and zais

Parameters

filePath (str) – path to the depletion file

days

Vector of points in time

Type

numpy.ndarray or None

burnup

Nominal burnup in MWd/kgU

Type

numpy.ndarray or None

names

Names of isotopes corresponding to each row in the 2D arrays

Type

list of str or None

zais

ZZAAAI identifiers for isotopes

Type

list of int or None

metadata

Dictionary with zai and names

Deprecated since version 0.9.3.

Type

dict of str to list

materials

Materials from the file. Keys will be the names as they appear in the file

Type

dict of str to serpentTools.objects.Material

settings

names and values of the settings used to control operations of this reader

Type

dict

__contains__(name)

Check if a material is stored

__getitem__(name)

Retrieve a material from materials.

__iter__()

Iterate over material names

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

compareMaterials(other, lower=0, upper=10, sigma=2)

Return the result of comparing all materials on two readers

Parameters
  • other (DepletionReader) – Reader to compare against

  • 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

Returns

True if all materials agree to the given tolerances

Return type

bool

Raises

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

compareMetadata(other, lower=0, upper=10, sigma=2)

Return the result of comparing metadata on two readers

Parameters
  • other (DepletionReader) – Object to compare against

  • 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

  • header (bool) – Print/log an info message about this comparison.

Returns

True if the metadata agree within the given tolerances

Return type

bool

Raises

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

get(key, default=None)

Retrieve a material from the dictionary if it exists

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

  • default (optional) – Item to return if key isn’t found

Returns

A serpentTools.objects.DepletedMaterial if it is stored under key. Otherwise return default

Return type

object

items()

Iterate over name, material pairs

keys()

Key-view into material dictionary

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

Plot properties for all materials in this file together.

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

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

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

  • materials (None or list) – Selection of materials from self.materials to plot. If None, plot all materials, potentially including tot

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

  • 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
read()

The main method for reading that not only parses data, but also runs pre and post checks.

saveAsMatlab(fileP, reconvert=True, metadata=None, append=True, format='5', longNames=True, compress=True, oned='row')

Write a binary MATLAB file from the contents of this reader

Deprecated since version 0.7.0: Use toMatlab()

Parameters
  • fileP (str or file-like object) – Name of the file to write

  • reconvert (bool) – If this evaluates to true, convert values back into their original form as they appear in the output file, e.g. MAT_TOTAL_ING_TOX. Otherwise, maintain the mixedCase style, total_ingTox.

  • metadata (bool or str or list of strings) – If this evaluates to true, then write all metadata to the file as well.

  • append (bool) – If true and a file exists under output, append to that file. Otherwise the file will be overwritten

  • format ({'5', '4'}) – Format of file to write. '5' for MATLAB 5 to 7.2, '4' for MATLAB 4

  • longNames (bool) – If true, allow variable names to reach 63 characters, which works with MATLAB 7.6+. Otherwise, maximum length is 31 characters

  • compress (bool) – If true, compress matrices on write

  • oned ({'row', 'col'}:) – Write one-dimensional arrays as row vectors if oned=='row' (default), or column vectors

Raises

ImportError – If scipy is not installed

toMatlab(fileP, reconvert=True, append=True, format='5', longNames=True, compress=True, oned='row')

Write a binary MATLAB file from the contents of this object

Parameters
  • fileP (str or file-like object) – Name of the file to write. .mat extension is not needed if append==True

  • reconvert (bool) – If this evaluates to true, convert values back into their original form as they appear in the output file.

  • append (bool) – If true and a file exists under output, append to that file. Otherwise the file will be overwritten

  • format ({'5', '4'}) – Format of file to write. '5' for MATLAB 5 to 7.2, '4' for MATLAB 4

  • longNames (bool) – If true, allow variable names to reach 63 characters, which works with MATLAB 7.6+. Otherwise, maximum length is 31 characters

  • compress (bool) – If true, compress matrices on write

  • oned ({'row', 'col'}) – Write one-dimensional arrays as row vectors if oned=='row' (default), or column vectors

Raises

ImportError – If scipy is not installed

values()

Values-view into material dictionary