openmc.CellInstanceFilter

class openmc.CellInstanceFilter(bins, filter_id=None)[source]

Bins tally events based on which cell instance a particle is in.

This filter is similar to DistribcellFilter but allows one to select particular instances to be tallied (instead of obtaining all instances by default) and allows instances from different cells to be specified in a single filter.

New in version 0.12.

Parameters
  • bins (iterable of 2-tuples or numpy.ndarray) – The cell instances to tally, given as 2-tuples. For the first value in the tuple, either openmc.Cell objects or their integral ID numbers can be used. The second value indicates the cell instance.

  • filter_id (int) – Unique identifier for the filter

Variables
  • bins (numpy.ndarray) – 2D numpy array of cell IDs and instances

  • id (int) – Unique identifier for the filter

  • num_bins (Integral) – The number of filter bins

classmethod from_xml_element(elem, **kwargs)[source]

Generate a filter from an XML element

Parameters
  • elem (lxml.etree._Element) – XML element

  • **kwargs – Keyword arguments (e.g., mesh information)

Returns

Filter object

Return type

openmc.Filter

get_pandas_dataframe(data_size, stride, **kwargs)[source]

Builds a Pandas DataFrame for the Filter’s bins.

This method constructs a Pandas DataFrame object for the filter with columns annotated by filter bin information. This is a helper method for Tally.get_pandas_dataframe().

Parameters
  • data_size (int) – The total number of bins in the tally corresponding to this filter

  • stride (int) – Stride in memory for the filter

Returns

A Pandas DataFrame with a multi-index column for the cell instance. The number of rows in the DataFrame is the same as the total number of bins in the corresponding tally, with the filter bin appropriately tiled to map to the corresponding tally bins.

Return type

pandas.DataFrame

See also

Tally.get_pandas_dataframe, CrossFilter.get_pandas_dataframe

to_xml_element()[source]

Return XML Element representing the Filter.

Returns

element – XML element containing filter data

Return type

lxml.etree._Element