Intervals

When dealing with time domain data, it is very common to specify ranges of time that have some meaning. These might be spans of good or bad data, or time ranges that enclose some important event or feature. This use case is so common that TIDAS has a built in object for this. An “intervals” object represents a list of time ranges. Each span can also optionally have a range of sample indices, which is useful if the intervals are associated with a particular group.

Python

class tidas.Intrvl(*args, **kwargs)

Overloaded function.

  1. __init__(self: tidas._pytidas.Intrvl) -> None
  2. __init__(self: tidas._pytidas.Intrvl, arg0: float, arg1: float, arg2: int, arg3: int) -> None
class tidas.Intervals(*args, **kwargs)

Overloaded function.

  1. __init__(self: tidas._pytidas.Intervals) -> None
  2. __init__(self: tidas._pytidas.Intervals, arg0: tidas._pytidas.Dictionary, arg1: int) -> None
dictionary(self: tidas._pytidas.Intervals) → tidas._pytidas.Dictionary
info(self: tidas._pytidas.Intervals, arg0: std::ostream, arg1: int) → None
read(self: tidas._pytidas.Intervals) → List[tidas._pytidas.Intrvl]
seek(arg0: List[tidas._pytidas.Intrvl], arg1: float) → tidas._pytidas.Intrvl
seek_ceil(arg0: List[tidas._pytidas.Intrvl], arg1: float) → tidas._pytidas.Intrvl
seek_floor(arg0: List[tidas._pytidas.Intrvl], arg1: float) → tidas._pytidas.Intrvl
size(self: tidas._pytidas.Intervals) → int
total_samples(arg0: List[tidas._pytidas.Intrvl]) → int
total_time(arg0: List[tidas._pytidas.Intrvl]) → float
write(self: tidas._pytidas.Intervals, arg0: List[tidas._pytidas.Intrvl]) → None

C++

class tidas::intrvl

intrvl class.

This represents a single span of time and their sample indices for a particular group.

Public Functions

intrvl()

Default constructor.

intrvl(time_type new_start, time_type new_stop, index_type new_first, index_type new_last)

Constructor specifying the start and stop times and the first and last indices.

Public Members

time_type start

Start time of the interval.

time_type stop

Stop time of the interval.

index_type first

First sample index in the interval.

index_type last

Last sample index in the interval.

class tidas::intervals

An intervals object represents a list of disjoint spans of time.

Although each interval has both a time range and a sample range, those sample indices are only meaningful in the context of a particular group. An intervals object has an optional dictionary associated with it at construction time. Some public methods are only used internally and are not needed for normal use of the object. These are labelled “internal”.

Public Functions

intervals()

Default constructor. The backend is set to be memory based.

intervals(dict const &d, size_t const &size)

Constructor with specified size and dictionary.

~intervals()

Destructor.

intervals &operator=(intervals const &other)

Assignment operator.

intervals(intervals const &other)

Copy constructor.

intervals(backend_path const &loc)

(Internal) Load the intervals from the specified location.

All meta data operations will apply to this location.

intervals(intervals const &other, std::string const &filter, backend_path const &loc)

(Internal) Copy from an existing intervals instance.

Apply an optional filter to elements and relocate to a new location. If a filter is given, a new location must be specified.

void relocate(backend_path const &loc)

(Internal) Change the location of the intervals.

void sync()

(Internal) Reload metadata from the current location, overwriting the current state in memory.

void flush() const

(Internal) Write metadata to the current location, overwriting the information at that location.

void copy(intervals const &other, std::string const &filter, backend_path const &loc)

(Internal) Copy with optional selection and relocation.

(Internal) Create a link at the specified location.

void wipe() const

(Internal) Delete the on-disk data and metadata associated with this object.

In-memory metadata is not modified.

backend_path location() const

(Internal) The current location.

dict const &dictionary() const

A (const) reference to the dictionary specified at construction.

size_t size() const

The number of intervals contained in this object.

void read_data(interval_list &intr) const

Read the list of intervals from the current location.

interval_list read_data() const

Read the list of intervals from the current location.

void write_data(interval_list const &intr)

Write the list of intervals to the current location.

void info(std::ostream &out, size_t indent) const

Print information to a stream.

Public Static Functions

index_type total_samples(interval_list const &intr)

The total number of samples included in all intervals.

time_type total_time(interval_list const &intr)

The total time span included in all intervals.

intrvl seek(interval_list const &intr, time_type time)

Return the single interval that contains a specified time.

If no interval contains the time, an empty interval is returned.

intrvl seek_ceil(interval_list const &intr, time_type time)

Return the first interval whose stop time is after the specified time.

intrvl seek_floor(interval_list const &intr, time_type time)

Return the last interval whose start time is before the specified time.