minmax¶
- astroimtools.stats.minmax(data, mask=None, axis=None)[source]¶
Return the minimum and maximum values of an array (or along an array axis).
- Parameters:
- dataarray-like
The input data.
- maskarray_like (bool), optional
A boolean mask, with the same shape as
data
, where aTrue
value indicates the corresponding element ofdata
is masked.- axisint, optional
The axis along which to operate. By default, flattened input is used.
- Returns:
- minscalar or
ndarray
The minimum value of
data
. Ifaxis
isNone
, the result is a scalar value. Ifaxis
is input, the result is an array of dimensiondata.ndim - 1
.- maxscalar or
ndarray
The maximum value of
data
. Ifaxis
isNone
, the result is a scalar value. Ifaxis
is input, the result is an array of dimensiondata.ndim - 1
.
- minscalar or
Notes
This function is decorated with
support_nddata
and thus supportsNDData
objects as input.Examples
>>> import numpy as np >>> from astroimtools import minmax >>> np.random.seed(12345) >>> data = np.random.random((3, 3)) >>> minmax(data) (0.18391881167709445, 0.9645145197356216)
>>> mask = (data < 0.3) >>> minmax(data, mask=mask) (0.3163755545817859, 0.9645145197356216)
>>> minmax(data, axis=1) (array([0.18391881, 0.20456028, 0.6531771 ]), array([0.92961609, 0.5955447 , 0.96451452]))