Esempio n. 1
0
    def readdata(self, start=None, stop=None):

        if start is None:
            start = self.starttime

        if stop is None:
            stop = self.endtime

        if not (self._expand_time and self._unwrap_data):  #slice on records
            tslice = self.timeslice(start, stop, extra=0)
            data = self.data.default[tslice]
            return data

        tslice = self.timeslice(start, stop, extra=1)
        data = self.data.default[tslice]

        try:
            seg = Segment([start, stop])

            if self._field_groups['default'] == ['time']:
                valid = seg.contains(data)
                data = data[valid]
            elif isinstance(data, dict) and 'time' in data.keys():
                valid = seg.contains(data['time'])[0]
                data['time'] = data['time'][valid]

                if 'signal' in data.keys():
                    data['signal'] = data['signal'][valid]
        except:
            raise

        return data
Esempio n. 2
0
 def __init__(self, segs: Segment, events: ndarray):
     """ Segments are assumed sorted. """
     self._isinseg, self._ninseg, self._contains = segs.contains(events)