Selector Module¶
sensingpy.selector provides tools for selecting and compositing array subsets
based on value intervals and aggregation methods.
interval_choice¶
interval_choice
¶
Generates a random sample from the given array based on the provided intervals.
Args: array (np.ndarray): array to be sampled size (int): size for each interval intervals (Iterable): intervals to be sampled from
e.g. [(0, 1), (1, 2), (2, 3)]
replace (bool, optional): np.choice sample argument. Defaults to True.
Returns: np.ndarray: Random sample from the given array based on the provided intervals.
Source code in sensingpy/selector.py
sample_indices_by_interval¶
sample_indices_by_interval
¶
sample_indices_by_interval(array: ndarray, size: int, intervals: Iterable, replace=True) -> np.ndarray
Get indices of a random sample from the array based on value intervals.
Args: array (np.ndarray): array to be sampled size (int): number of samples per interval intervals (Iterable): value intervals to sample from
e.g. [(0, 1), (1, 2), (2, 3)]
replace (bool, optional): whether to sample with replacement. Defaults to True.
Returns: np.ndarray: Indices of the random sample from the given array.
Examples: >>> # Sample 10 indices from each depth interval >>> depths = np.array([0.5, 1.5, 2.5, 3.5, 4.5]) >>> indices = sample_indices_by_interval(depths, 10, [0, 2, 4, 6])
Source code in sensingpy/selector.py
arginterval_choice¶
arginterval_choice
¶
Generates the indexes of a random sample from the given array based on the provided intervals.
.. deprecated:: 2.1.0
Use :func:sample_indices_by_interval instead. This function will be removed in version 3.0.0.
Args: array (np.ndarray): array to be sampled size (int): size for each interval intervals (Iterable): intervals to be sampled from
e.g. [(0, 1), (1, 2), (2, 3)]
replace (bool, optional): np.choice sample argument. Defaults to True.
Returns: np.ndarray: The indexes of a random sample from the given array based on the provided intervals.
Source code in sensingpy/selector.py
composite¶
composite
¶
Generates a synthetic array based on the provided method.
Args: arrays (np.ndarray): a list of arrays to be composed method (Callable | np.ndarray, optional): numpy funcion or list of indexes to compose the final array. Defaults to np.nanmax.
Returns: np.ndarray: a synthetic array based on the provided method.
Source code in sensingpy/selector.py
composite_indices¶
composite_indices
¶
Get indices of optimal values across multiple arrays for compositing.
Finds which array contains the optimal value (e.g., maximum, minimum) at each position, returning an index array that can be used with the composite() function.
Args: arrays (np.ndarray): stack of arrays with shape (n_arrays, height, width) method (Callable, optional): numpy argmax/argmin function to determine optimal values. Defaults to np.argmax.
Returns: np.ndarray: 2D array of indices indicating which input array has the optimal value at each position.
Examples: >>> # Create max NDVI composite >>> ndvi_stack = np.array([img1_ndvi, img2_ndvi, img3_ndvi]) >>> best_indices = composite_indices(ndvi_stack, np.argmax) >>> max_ndvi_composite = composite(image_stack, best_indices)
Source code in sensingpy/selector.py
argcomposite¶
argcomposite
¶
Generates the indexes of a synthetic array based on the provided method.
.. deprecated:: 2.1.0
Use :func:composite_indices instead. This function will be removed in version 3.0.0.
Args: arrays (np.ndarray): the array to be composed method (Callable, optional): a numpy method such as argmax. Defaults to np.argmax.
Returns: np.ndarray: The indexes of a synthetic array