scipp.lookup#

scipp.lookup(func, dim)#

Create a “lookup table” from a histogram (data array with bin-edge coord).

The lookup table can be used to map, e.g., time-stamps to corresponding values given by a time-series log.

Parameters
  • func (DataArray) – Histogram defining the lookup table.

  • dim (str) – Dimension along which the lookup occurs.

Examples

>>> x = sc.linspace(dim='x', start=0.0, stop=1.0, num=4)
>>> vals = sc.array(dims=['x'], values=[3, 2, 1])
>>> hist = sc.DataArray(data=vals, coords={'x': x})
>>> sc.lookup(hist, 'x')[sc.array(dims=['event'], values=[0.1,0.4,0.1,0.6,0.9])]
<scipp.Variable> (event: 5)      int64  [dimensionless]  [3, 2, ..., 2, 1]