dispel.data.epochs module#

A data model to describe epochs in time.

When processing signals, one of the fundamental concepts is to describe specific aspects of a signal in a defined period. Epoch provides the basic mechanics.

class dispel.data.epochs.Epoch[source]#

Bases: FlagMixIn

An epoch marking a specific time point or period.

Parameters:
  • start – The beginning of the epoch.

  • end – An optional end of the epoch. If no end is provided, the epoch end will be considered in the future and the Epoch.is_incomplete property will be True.

  • definition – An optional definition of the epoch.

__init__(start, end, definition=None)[source]#
Parameters:
contains(other)[source]#

Test if other is contained within this epoch.

Parameters:

other (Epoch | datetime | Timestamp) – The other epoch or datetime-like object to be tested.

Returns:

If an epoch is provided contains will be True if both the start and end of the other epoch is within the start and end of this epoch. If only a datetime object is provided, the result is True if the time is between start and end including the boundaries.

Return type:

bool

property duration: Timedelta#

Get the duration of the epoch.

Returns:

The duration of the epoch.

Return type:

pandas.Timedelta

Raises:

ValueError – If the epoch has no end.

property end: Timestamp | None#

Get the end of the epoch.

Returns:

The end of the epoch. None, if the epoch end has not been observed (i.e., was not set).

Return type:

pandas.Timestamp

property id: DefinitionId#

Get the ID from the definition of the epoch.

Returns:

The id of the Epoch.definition.

Return type:

DefinitionId

Raises:

AttributeError – Will be risen if no definition was set for the epoch.

property is_incomplete: bool#

Check if the epoch has an end date.

An epoch is considered incomplete if it does not have an end date time.

Returns:

True if the end date time is unknown. Otherwise, False.

Return type:

bool

overlaps(other)[source]#

Test if other overlaps with this epoch.

Parameters:

other (Epoch | datetime | Timestamp) – The other epoch or datetime-like object to be tested.

Returns:

If an epoch is provided overlap will be True if either the start or end of the other epoch is within the start or end of this epoch. If only a datetime object is provided, the result is True if the time is between start and end including the boundaries.

Return type:

bool

property start: Timestamp#

Get the beginning of the epoch.

Returns:

The beginning of the epoch.

Return type:

pandas.Timestamp

class dispel.data.epochs.EpochDefinition[source]#

Bases: object

The definition of an epoch.

Parameters:
  • id – The identifier of the epoch. This identifier does not have to be unique across multiple epochs and can serve as a type of epoch.

  • name – An optional plain-text name of the epoch definition.

  • description – A detailed description of the epoch providing additional resolution beyond the name property.

name#

An optional plain-text name of the epoch definition.

description#

A detailed description of the epoch providing additional resolution beyond the name property.

__init__(id_, name=None, description=None)[source]#
Parameters:
property id: DefinitionId#

Get the ID of the definition.

Returns:

The ID of the epoch definition.

Return type:

DefinitionId