Filters¶
Filters take a system as input and generate a new system according to some user-defined criteria. There are filters that remove particles of a given type (or types), filters that remove the centre-of-mass-position from the particles, filters that include or exclude particles according to a user-defined function and more.
Once a filter has been created, it can be applied to single systems like this::
new_system = my_filter.filter(old_system)
In addition, filters can be applied to whole trajectories by using the BaseTrajectory’s add_filter() method before these are parsed.
Filter that uses a user-provided callable to choose which particles will be included in the new system. |
|
-
class
baggianalysis.core.BaseFilter(self: baggianalysis.core.BaseFilter) → None¶ Bases:
pybind11_builtins.pybind11_object-
filter(self: baggianalysis.core.BaseFilter, system: baggianalysis.core.System) → baggianalysis.core.System¶ Returns a copy of the given system, filtered according to some criterion. This method should be overridden by child classes.
-
-
class
baggianalysis.core.FilterByFunction(self: baggianalysis.core.FilterByFunction, arg0: Callable[[baggianalysis.core.Particle], bool]) → None¶ Bases:
baggianalysis.core.BaseFilterFilter that uses a user-provided callable to choose which particles will be included in the new system.
As an example, the following snippet creates a filter that will include in the new system only those particles whose type is different from “2” and whose position along the x coordinate is larger than 5:
my_filter = ba.FilterByFunction(lambda p: p.type != "2" and p.position[0] > 5)
The same effect can be achieved without using a lambda function:
def filter_func(p): return p.type != "2" and p.position[0] > 5 my_filter = ba.FilterByFunction(filter_func)
The constructor takes as a parameter a callable that will be used to decided which particles will be included in the new system.
- Parameters
function (callable) – A callable that takes a particle and returns True if the particle should be included in the new system, False otherwise.
-
class
baggianalysis.core.FilterByReducingToCOM(self: baggianalysis.core.FilterByReducingToCOM) → None¶
-
class
baggianalysis.core.FilterByType(self: baggianalysis.core.FilterByType, arg0: List[str]) → None¶
-
class
baggianalysis.core.FixParticlePath(self: baggianalysis.core.FixParticlePath) → None¶
-
class
baggianalysis.core.SubtractCOM(self: baggianalysis.core.SubtractCOM) → None¶