cf.Data.argmax¶

Data.
argmax
(axis=None, unravel=False)[source]¶ Return the indices of the maximum values along an axis.
If no axis is specified then the returned index locates the maximum of the whole data.
In case of multiple occurrences of the maximum values, the indices corresponding to the first occurrence are returned.
Performance
If the data index is returned as a
tuple
(see the unravel parameter) then all delayed operations are computed.New in version 3.0.0.
See also
 Parameters
 axis:
int
, optional The specified axis over which to locate the maximum values. By default the maximum over the flattened data is located.
 unravel:
bool
, optional If True then when locating the maximum over the whole data, return the location as an integer index for each axis as a
tuple
. By default an index to the flattened array is returned in this case. Ignored if locating the maxima over a subset of the axes.
 axis:
 Returns
Examples
>>> d = cf.Data(np.arange(6).reshape(2, 3)) >>> print(d.array) [[0 1 2] [3 4 5]] >>> a = d.argmax() >>> a <CF Data(): 5> >>> print(a.array) 5
>>> index = d.argmax(unravel=True) >>> index (1, 2) >>> d[index] <CF Data(1, 1): [[5]]>
>>> d.argmax(axis=0) <CF Data(3): [1, 1, 1]> >>> d.argmax(axis=1) <CF Data(2): [2, 2]>
Only the location of the first occurrence is returned:
>>> d = cf.Data([0, 4, 2, 3, 4]) >>> d.argmax() <CF Data(): 1>
>>> d = cf.Data(np.arange(6).reshape(2, 3)) >>> d[1, 1] = 5 >>> print(d.array) [[0 1 2] [3 5 5]] >>> d.argmax(axis=1) <CF Data(2): [2, 1]>