Check out the Hyperspy Workshop May 13-17, 2024 Online

value2index#

UniformDataAxis.value2index(value, rounding=<built-in function round>)#

Return the closest index/indices to the given value(s) if between the axis limits.

Parameters:
  • value (float, str, numpy.ndarray) – If string, should either be a calibrated unit like “20nm” or a relative slicing like “rel0.2”.

  • rounding (callable) – Handling of values intermediate between two axis points: If rounding=round, use python’s standard round-half-to-even strategy to find closest value. If rounding=math.floor, round to the next lower value. If rounding=math.ceil, round to the next higher value.

Return type:

int or numpy.ndarray

Raises:

ValueError – If value is out of bounds or contains out of bounds values (array). If value is NaN or contains NaN values (array). If value is incorrectly formatted str or contains incorrectly formatted str (array).