FeatureGenerator#

class ctapipe.core.FeatureGenerator(*args: t.Any, **kwargs: t.Any)[source]#

Bases: Component

Generate features for astropy.table.Table.

Raises Exceptions in two cases: 1. If a feature already exists in the table 2. If a feature cannot be built with the given expression

Attributes Summary

features

List of 2-Tuples of Strings: ('new_feature_name', 'expression to generate feature').

Methods Summary

__call__(table, **kwargs)

Apply feature generation to the input table.

Attributes Documentation

features#

List of 2-Tuples of Strings: (‘new_feature_name’, ‘expression to generate feature’). You can use numpy as np and astropy.units as u. Several math functions are usable without the np-prefix. Use feature.quantity.to_value(unit) to create features without units.

Methods Documentation

__call__(table: Table | QTable, **kwargs) Table[source]#

Apply feature generation to the input table.

This method returns a shallow copy of the input table with the new features added. Existing columns will share the underlying data, however the new columns won’t be visible in the input table.

Parameters:
table: QTable | Table

Input table. Internally a Table will be converted to a QTable so that unit propagation works, so expressions should only rely on properties of QTables.

**kwargs:

Other objects that should be available in expressions. For example, if a you pass subarray=subarray, expressions can use that object. This can also be special functions like f=my_function, which would allow an expression like "f(col1)".

Returns:
QTable|Table:

A new table with the same columns as the input, but with new columns for each feature. The returned class depends on what was passed in.