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 a True value indicates the corresponding element of data 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. If axis is None, the result is a scalar value. If axis is input, the result is an array of dimension data.ndim - 1.

maxscalar or ndarray

The maximum value of data. If axis is None, the result is a scalar value. If axis is input, the result is an array of dimension data.ndim - 1.

Notes

This function is decorated with support_nddata and thus supports NDData 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]))