sandy.mcnp.meshtal module
This module contains all classes and functions to provide a API for a MCNP meshtal file.
- class sandy.mcnp.meshtal.MshtTally(data, *args, **kwargs)
Bases:
object
Container for a Meshtal tally.
- Attributes:
- datapandas.DataFrame
tabulated mesthal tally with column names according to mesthal output file.
Methods
filter_by
(query)Filter meshtally data according to given query.
from_file
([file, encoding, errors])Parse a meshtal output file and return tallies.
get_mesh
([x, y, values, aggfunc])Pivot meshtally data according to two axes (e.g.
pivot_table
([x, y, values, aggfunc])Pivot meshtally data according to two axes (e.g.
plot
(ax[, x, y, values, aggfunc, query])Plot meshtally data using matplotlib.
- filter_by(query)
Filter meshtally data according to given query.
- Parameters:
- querystr
The query string used to filter data columns. Examples are ‘X > -10 & X < 10’ or ‘Z == 0’.
- Returns:
- MshTally
filtered meshtally object
- classmethod from_file(file='meshtal', encoding='utf8', errors='ignore')
Parse a meshtal output file and return tallies.
- Parameters:
- filenamestr, optional, default is ‘meshtal’
name of the meshtal file
- encodingstr, optional, default is ‘utf8’
option passed to python built-in function open
- errorsstr, optional, default is ‘ignore’
option passed to python built-in function open
- Returns:
- dict
dictionary of (tally numbers, MshtTally objects)
- get_mesh(x='X', y='Y', values='Result', aggfunc='sum')
Pivot meshtally data according to two axes (e.g. ‘X’ and ‘Y’) and return the coordinates and values on a meshgrid.
- Parameters:
- xstr, optional, default is ‘X’
data on the plot x-axis. Other options are ‘X’, ‘Y’, ‘Z’, ‘Energy’.
- ystr, optional, default is ‘Y’
data on the plot y-axis. Other options are ‘X’, ‘Y’, ‘Z’, ‘Energy’.
- valuesstr, optional, default is Result
data to plot. Other options are:
‘RelError’ : relative error (fraction)
- ‘RsltVol’‘Result’ mutliplied by ‘’Volume’, only
if out=cf was used in fmesh
- aggfuncfunction, optional, default is ‘sum’
function to aggregate values (as in pandas.pivot_table). Other options are ‘mean’, ‘min’, ‘max’, ‘std’.
- Returns:
- Three NxM arrays
2D arrays for x, y and values that can be used for a meshplot
- pivot_table(x='X', y='Y', values='Result', aggfunc='sum')
Pivot meshtally data according to two axes (e.g. ‘X’ and ‘Y’)
- Parameters:
- xstr, optional, default is ‘X’
data on the plot x-axis. Other options are ‘X’, ‘Y’, ‘Z’, ‘Energy’.
- ystr, optional, default is ‘Y’
data on the plot y-axis. Other options are ‘X’, ‘Y’, ‘Z’, ‘Energy’.
- valuesstr, optional, default is Result
data to plot. Other options are:
‘RelError’ : relative error (fraction)
- ‘RsltVol’‘Result’ mutliplied by ‘’Volume’, only
if out=cf was used in fmesh
- aggfuncfunction, optional, default is ‘sum’
function to aggregate values (as in pandas.pivot_table). Other options are ‘mean’, ‘min’, ‘max’, ‘std’.
- Returns:
- pandas.DataFrame
An Excel-style pivot table
- plot(ax, x='X', y='Y', values='Result', aggfunc='sum', query=None, **kwargs)
Plot meshtally data using matplotlib.
- Parameters:
- axmatplotlib.axes.Axes
Axes instance used for plotting
- xstr, optional, default is ‘X’
data on the plot x-axis. Other options are ‘X’, ‘Y’, ‘Z’, ‘Energy’.
- ystr, optional, default is ‘Y’
data on the plot y-axis. Other options are ‘X’, ‘Y’, ‘Z’, ‘Energy’.
- valuesstr, optional, default is Result
data to plot. Other options are:
‘RelError’ : relative error (fraction)
- ‘RsltVol’‘Result’ mutliplied by ‘’Volume’, only
if out=cf was used in fmesh
- aggfuncfunction, optional, default is ‘sum’
function to aggregate values (as in pandas.pivot_table). Other options are ‘mean’, ‘min’, ‘max’, ‘std’.
- querystr, optional, default is None
The query string used to filter data columns. Examples are ‘X > -10 & X < 10’ or ‘Z == 0’.
- **kwargskeyword arguments
Additionally, the following arguments are allowed. They are passed along to the matplotlib.axes.Axes.pcolormesh constructor.
- Returns:
- matplotlib.collections.QuadMesh
matplotlib.axes.Axes.pcolormesh output
Notes
Input parameter ax is affected by this method.