LoadPart.select#
- PartToolsManager.select(var: ndarray, cond: str | Callable, sort: bool = False, ascending: bool = True) ndarray[source]
Select or sort particle indices matching a condition.
- Parameters:
- - ascending: bool, default True
If True, the indices are sorted in ascending order.
- - cond (not optional): str | Callable
The condition to be satisfied.
- - sort: bool, default False
If True, the indices are sorted in descending (or ascending) order.
- - var (not optional): np.ndarray
The chosen variable for the selection.
- Returns:
- np.ndarray
Examples
Example #1: Select the indices that satisfy a condition
>>> import pyPLUTO as pp >>> D = pp.LoadPart(0) >>> indx = pp.select(D.vx1, "vx1 > 0.0") >>> print(indx)
Example #2: Sort the indices through a callable
>>> import pyPLUTO as pp >>> D = pp.LoadPart(0) >>> indx = pp.select(D.vx1, lambda v: v > 0, sort=True) >>> print(indx)