LoadPart.select#
- pyPLUTO.LoadPart.select(self, var: ndarray, cond: str | Callable, sort: bool = False, ascending: bool = True) ndarray[source]#
Selects or sorts the indices that satisfy a given condition for the particles. The condition is given by a string or a callable function.
- 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:
- indx: 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 that satisfy a condition through a callable
>>> import pyPLUTO as pp >>> D = pp.LoadPart(0) >>> indx = pp.select(D.vx1, lambda v: v > 0 sort = True) >>> print(indx)