openmc.arithmetic.CrossFilter¶
- class openmc.arithmetic.CrossFilter(left_filter, right_filter, binary_op)[source]¶
A special-purpose filter used to encapsulate all combinations of two tally’s filter bins as an outer product for tally arithmetic.
- Parameters
left_filter (openmc.Filter or CrossFilter) – The left filter in the outer product
right_filter (openmc.Filter or CrossFilter) – The right filter in the outer product
binary_op (str) – The tally arithmetic binary operator (e.g., ‘+’, ‘-’, etc.) used to combine two tally’s filter bins with this CrossFilter
- Variables
type (str) – The type of the crossfilter (e.g., ‘energy / energy’)
left_filter (openmc.Filter or CrossFilter) – The left filter in the outer product
right_filter (openmc.Filter or CrossFilter) – The right filter in the outer product
binary_op (str) – The tally arithmetic binary operator (e.g., ‘+’, ‘-’, etc.) used to combine two tally’s filter bins with this CrossFilter
bins (dict of Iterable) – A dictionary of the bins from each filter keyed by the types of the left / right filters
num_bins (Integral) – The number of filter bins (always 1 if aggregate_filter is defined)
- get_bin_index(filter_bin)[source]¶
Returns the index in the CrossFilter for some bin.
- Parameters
filter_bin (2-tuple) – A 2-tuple where each value corresponds to the bin of interest in the left and right filter, respectively. A bin is the integer ID for ‘material’, ‘surface’, ‘cell’, ‘cellborn’, and ‘universe’ Filters. The bin is an integer for the cell instance ID for ‘distribcell’ Filters. The bin is a 2-tuple of floats for ‘energy’ and ‘energyout’ filters corresponding to the energy boundaries of the bin of interest. The bin is a (x,y,z) 3-tuple for ‘mesh’ filters corresponding to the mesh cell of interest.
- Returns
filter_index – The index in the Tally data array for this filter bin.
- Return type
Integral
- get_pandas_dataframe(data_size, summary=None)[source]¶
Builds a Pandas DataFrame for the CrossFilter’s bins.
This method constructs a Pandas DataFrame object for the CrossFilter with columns annotated by filter bin information. This is a helper method for the Tally.get_pandas_dataframe(…) method. This method recursively builds and concatenates Pandas DataFrames for the left and right filters and crossfilters.
This capability has been tested for Pandas >=0.13.1. However, it is recommended to use v0.16 or newer versions of Pandas since this method uses Pandas’ Multi-index functionality.
- Parameters
data_size (Integral) – The total number of bins in the tally corresponding to this filter
summary (None or Summary) – An optional Summary object to be used to construct columns for distribcell tally filters (default is None). The geometric information in the Summary object is embedded into a Multi-index column with a geometric “path” to each distribcell instance.
- Returns
A Pandas DataFrame with columns of strings that characterize the crossfilter’s bins. Each entry in the DataFrame will include one or more binary operations used to construct the crossfilter’s bins. The number of rows in the DataFrame is the same as the total number of bins in the corresponding tally, with the filter bins appropriately tiled to map to the corresponding tally bins.
- Return type
See also
Tally.get_pandas_dataframe
,Filter.get_pandas_dataframe