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 usingnames
,burnup
,days
, andzais
- Parameters
filePath (str) – path to the depletion file
-
days
¶ Vector of points in time
- Type
-
burnup
¶ Nominal burnup in MWd/kgU
- Type
-
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
-
__contains__
(name)¶ Check if a material is stored
-
__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 thanlower
percent different that the same quantity on this object, consider this allowable and make no messages. Quantities that are greater thanupper
percent 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
True
if the objects are in agreement with each other according to the parameters specified- Return type
- Raises
TypeError – If
other
is not of the same class as this class nor a subclass of this classValueError – 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 againstlower (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
- 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 againstlower (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
- 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
- Returns
A
serpentTools.objects.DepletedMaterial
if it is stored underkey
. Otherwise returndefault
- Return type
-
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 andyUnits
isNone
, then the plotted data will bexUnits
against'days'
name of x value to obtain, e.g.'days'
,'burnup'
yUnits (str) – name of y value to return, e.g.
'adens'
,'ingTox'
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.
If given, plot values corresponding to these isotope
ZZAAAI
values. Otherwise, plot for all isotopesNew in version 0.5.1.
materials (None or list) – Selection of materials from
self.materials
to plot. If None, plot all materials, potentially includingtot
ax (
matplotlib.axes.Axes
, optional) – Ax on which to plot the data. If not provided, create a new plotlegend (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 notNone
but evaluates toFalse
, do not label. Otherwise, usexUnits
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 notNone
but evaluates toFalse
, do not label. Otherwise, useyUnits
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 thelabelFmt
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
See also
str.format()
- used for formatting labels
- Raises
KeyError – If x axis units are not
'days'
nor'burnup'
SerpentToolsException – If the materials dictionary does not contain any items
-
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 themixedCase
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 overwrittenformat ({'5', '4'}) – Format of file to write.
'5'
for MATLAB 5 to 7.2,'4'
for MATLAB 4longNames (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
See also
-
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 ifappend==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 overwrittenformat ({'5', '4'}) – Format of file to write.
'5'
for MATLAB 5 to 7.2,'4'
for MATLAB 4longNames (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
See also
-
values
()¶ Values-view into material dictionary