CutFlow¶
-
class
ctapipe.utils.
CutFlow
(name='CutFlow')[source]¶ Bases:
object
a class that keeps track of e.g. events/images that passed cuts or other events that could reject them
Methods Summary
__call__
(*args, **kwargs)creates an astropy table of the cut names, counted events and selection efficiencies prints the instance name and the astropy table
add_cut
(cut, function)sets a function that selects on whatever you want to count sets the counter corresponding to the selection criterion to 0 that means: it overwrites whatever you counted before under this name
add_cuts
(cut_dict[, clear])sets functions that select on whatever you want to count sets the counter corresponding to the selection criterion to 0 that means: it overwrites whatever you counted before under this name
count
(cut[, weight])counts an event/image at a given stage of the analysis
cut
(cut, *args[, weight])selects the function associated with
cut
and hands it all additional arguments provided.get_table
([base_cut, sort_column, …])creates an astropy table of the cut names, counted events and selection efficiencies
keep
(cut, *args[, weight])selects the function associated with
cut
and hands it all additional arguments provided.set_cut
(cut, function)sets a function that selects on whatever you want to count sets the counter corresponding to the selection criterion to 0 that means: it overwrites whatever you counted before under this name
set_cuts
(cut_dict[, clear])sets functions that select on whatever you want to count sets the counter corresponding to the selection criterion to 0 that means: it overwrites whatever you counted before under this name
Methods Documentation
-
__call__
(*args, **kwargs)[source]¶ creates an astropy table of the cut names, counted events and selection efficiencies prints the instance name and the astropy table
- Parameters
- kwargskeyword arguments
arguments to be passed to the
get_table
function; see there
- Returns
- t
astropy.table.Table
the table containing the cut names, counted events and efficiencies – sorted in the order the cuts were added if not specified otherwise
- t
-
add_cut
(cut, function)¶ sets a function that selects on whatever you want to count sets the counter corresponding to the selection criterion to 0 that means: it overwrites whatever you counted before under this name
- Parameters
- cutstring
name of the cut/stage where you want to count
- functionfunction
a function that is your selection criterion
Notes
add_cut and set_cut are aliases
-
add_cuts
(cut_dict, clear=False)¶ sets functions that select on whatever you want to count sets the counter corresponding to the selection criterion to 0 that means: it overwrites whatever you counted before under this name
- Parameters
- cut_dict{string: functor} dictionary
dictionary of {name: function} of cuts to add as your selection criteria
- clearbool, optional (default: False)
if set to
True
, clear the cut-dictionary before adding the new cuts
Notes
add_cuts and set_cuts are aliases
-
count
(cut, weight=1)[source]¶ counts an event/image at a given stage of the analysis
- Parameters
- cutstring
name of the cut/stage where you want to count
- weightint or float, optional (default: 1)
weight of the current element
Notes
If
cut
is not yet being tracked, it will simply be added Will be an alias to __getitem__
-
cut
(cut, *args, weight=1, **kwargs)[source]¶ selects the function associated with
cut
and hands it all additional arguments provided. if the function returnsFalse
, the event counter is incremented.- Parameters
- cutstring
name of the selection criterion
- args, kwargs: additional arguments
anything you want to hand to the associated function
- weightint or float, optional (default: 1)
weight of the current element
- Returns
- True if the function evaluats to True
- False otherwise
- Raises
-
get_table
(base_cut=None, sort_column=None, sort_reverse=False, value_format='5.3f')[source]¶ creates an astropy table of the cut names, counted events and selection efficiencies
- Parameters
- base_cutstring, optional (default: None)
name of the selection criterion that should be taken as 100 % in efficiency calculation if not given, the criterion with the highest count is used
- sort_columninteger, optional (default: None)
the index of the column that should be used for sorting the entries by default the table is sorted in the order the cuts were added (index 0: cut name, index 1: number of passed events, index 2: efficiency)
- sort_reversebool, optional (default: False)
if true, revert the order of the entries
- value_formatstring, optional (default: ‘5.3f’)
formatting string for the efficiency column
- Returns
- t
astropy.table.Table
the table containing the cut names, counted events and efficiencies – sorted in the order the cuts were added if not specified otherwise
- t
-
keep
(cut, *args, weight=1, **kwargs)[source]¶ selects the function associated with
cut
and hands it all additional arguments provided. if the function returns True, the event counter is incremented.- Parameters
- cutstring
name of the selection criterion
- args, kwargs: additional arguments
anything you want to hand to the associated function
- weightint or float, optional (default: 1)
weight of the current element
- Returns
- True if the function evaluats to True
- False otherwise
- Raises
- UndefinedCut if
cut
is not known - PureCountingCut if
cut
has no associated function - (i.e. manual counting mode)
- UndefinedCut if
-
set_cut
(cut, function)[source]¶ sets a function that selects on whatever you want to count sets the counter corresponding to the selection criterion to 0 that means: it overwrites whatever you counted before under this name
- Parameters
- cutstring
name of the cut/stage where you want to count
- functionfunction
a function that is your selection criterion
Notes
add_cut and set_cut are aliases
-
set_cuts
(cut_dict, clear=False)[source]¶ sets functions that select on whatever you want to count sets the counter corresponding to the selection criterion to 0 that means: it overwrites whatever you counted before under this name
- Parameters
- cut_dict{string: functor} dictionary
dictionary of {name: function} of cuts to add as your selection criteria
- clearbool, optional (default: False)
if set to
True
, clear the cut-dictionary before adding the new cuts
Notes
add_cuts and set_cuts are aliases
-