serpentTools.samplers.SampledDepletedMaterial¶
-
class
serpentTools.samplers.
SampledDepletedMaterial
(N, name, metadata)¶ Class that stores data from a variety of depleted materials
While
adens
,mdens
, andburnup
are accessible directly withmaterial.adens
, all variables read in from the file can be accessed through thedata
dictionary:>>> assert material.adens is material.data['adens'] >>> assert material.adens is material['adens'] # The three methods are equivalent
Note
free()
setsallData
to an empty dictionary If<sampler.freeAll>
is True, thenfree
will be called after all files have been read and processed.- Parameters
-
zai
¶ Isotopic ZZAAA identifiers, e.g. 93325
Changed in version 0.5.1: Now a list of integers, not strings
- Type
-
days
¶ Vector of total, cumulative days of burnup for the run that created this material
- Type
-
burnup
¶ Vector of total, cumulative burnup [MWd/kgU] for this specific material
- Type
-
adens
¶ 2D array of atomic densities where where row
j
corresponds to isotopej
and columni
corresponds to timei
- Type
-
mdens
¶ 2D array of mass densities where where row
j
corresponds to isotopej
and columni
corresponds to timei
- Type
-
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
-
__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 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
-
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
- Returns
numpy.ndarray
ifkey
was found, otherwisedefault
- Return type
-
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 thedata
dictionary, e.g.burnup
orvolume
, and not something that varies by isotope, thennames
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.
If given, return y values corresponding to isotopes with these
ZZAAAI
as would be present inself.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
andzai
arguments are passedValueError – If one isotope cannot be found
-
loadFromContainer
(container)¶ Copy data from a similar container.
- Parameters
container – Incoming container from which to take data.
- Raises
serpentTools.messages.MismatchedContainersError – If the incoming container is not the expected type declared at construction
serpentTools.messages.SamplerError – If more containers have been loaded than specified at construction
-
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. Ifc='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 plotsigma (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 notNone
but 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 notNone
but evaluates toFalse
, 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 thelabelFmt
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
See also
getValues()
-
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 plotxlabel (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.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.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