idxmax

function of dascore.proc.aggregate source

idxmax(
    patch: Patch ,
    dim: str ,
    dim_reduce: str | collections.abc.Callable[str, Callable] = empty,
)-> ‘PatchType’

Return the coordinate value where the data are largest along a dimension.

Parameters

Parameter Description
patch The input Patch.
dim The name of the single dimension to reduce. None or a sequence,
which the other aggregations accept, raises here.
dim_reduce How to reduce the dimensional coordinate associated with the
aggregated axis. Can be the name of any valid aggregator, a callable,
“empty” (the default) which returns a length 1 partial coord, or
“squeeze” which drops the coordinate. For dimensions with datetime
or timedelta datatypes, if the operation fails it will automatically
be applied to the coordinates converted to floats then the output
converted back to the appropriate time type.
Note
  • The data become coordinate values rather than the values found there, so they take the coordinate’s dtype. Use Patch.max or Patch.min for the values themselves.

  • NaN and NaT samples are skipped. A slice with none left has no coordinate to point at, so it yields a null; an integer coordinate is widened to float64 to hold one, which loses exactness above 2**53, and a coordinate which can hold no null, such as a string one, raises.

  • Ties go to the first occurrence, as in NumPy.

Examples

import dascore as dc

patch = dc.get_example_patch()

# The time of each channel's largest sample.
peak_time = patch.idxmax("time")

# Drop the reduced dimension, as xarray's idxmax does.
squeezed = patch.idxmax("time", dim_reduce="squeeze")

See Also