get_slice

function of dascore.io.tdms.utils source

get_slice(
    array ,
    cond ,
)-> <class ’slice

Return a slice object which meets conditions in cond on array.

This is useful for determining how a particular dimension should be trimmed based on a coordinate (array) and an interval (cond).

Parameters

Parameter Description
array Any array with sorted values, but the array can have zeros at the end up to the sorted segment. Eg [1,2,3, 0, 0] works.
cond An interval for which the array is to be indexed. End points are inclusive.

Examples

import numpy as np
from dascore.utils.misc import get_slice
ar = np.arange(100)
array_slice = get_slice(ar, cond=(1, 10))