f4enix.output.mctal.Mctal#
- class f4enix.output.mctal.Mctal(filepath: PathLike | str)#
Bases:
objectObject responsible for the parsing of MCNP mctal files.
- Parameters:
filepath (os.PathLike | str) – path to the mctal file to be parsed
- Variables:
tallydata (dict[int, pd.DataFrame]) – dictionary that at each tally id associate a pandas dataframe containing the results. It supports multi-binning tallies.
header (Header) – it is the parsed data of the mctal file. See the Header doc to understand how to access the data.
Examples
Parse the mctal file and access the data >>> # Import the mctal module … from f4enix.output.mctal import Mctal … # Parse the Mctal file … file = ‘mctal’ … mctal = Mctal(file) … # get a summary of the min and max errors across tallies … mctal.get_error_summary().sort_values(by=’tally num’)
tally num min rel error max rel error
0 4 NaN 1.0000 22 6 0.0007 0.0272 19 14 NaN 1.0000 1 16 0.0008 0.0381
Methods
__init__(filepath)Object responsible for the parsing of MCNP mctal files.
get_error_summary([include_abs_err])Return a dataframe containing a summary of the min and max errror registered in each tally.
remove_totals(tally_number)Remove all rows containing 'total' in any column from the tally DataFrame for the specified tally number in self.tallydata.
set_d1s_relative_contribution(tally_number)For the given tally number, set the User column to int, rename it to user_label (Parent/Daughter/Cell), and for each unique bin defined by the other columns, add a 'Normalized Value' column representing the relative contribution of each user (Parent/Daughter/Cell) in that bin.
- get_error_summary(include_abs_err: bool = False) DataFrame#
Return a dataframe containing a summary of the min and max errror registered in each tally. If both value and error are equal to zero, the errors will be set to NaN, since it means that nothing has been scored in the tally.
- Parameters:
include_abs_err (bool, optional) – if True includes the absolute error in addition to the total one, by default is False
- Returns:
error summary
- Return type:
pd.DataFrame
- remove_totals(tally_number: int) None#
Remove all rows containing ‘total’ in any column from the tally DataFrame for the specified tally number in self.tallydata.
- Parameters:
tally_number (int) – The tally number whose DataFrame should be cleaned.
- set_d1s_relative_contribution(tally_number: int, user_label: str = 'Daughter') None#
For the given tally number, set the User column to int, rename it to user_label (Parent/Daughter/Cell), and for each unique bin defined by the other columns, add a ‘Normalized Value’ column representing the relative contribution of each user (Parent/Daughter/Cell) in that bin.
- Parameters:
tally_number (int) – The tally number whose DataFrame should be processed.
user_label (str) – The new name for the User column (e.g., ‘Parent’, ‘Daughter’, ‘Cell’).