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:
start (Any) –
end (Any) –
definition (EpochDefinition | None) –
- 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 beTrue
if both thestart
andend
of theother
epoch is within thestart
andend
of this epoch. If only a datetime object is provided, the result isTrue
if the time is betweenstart
andend
including the boundaries.- Return type:
- property duration: Timedelta#
Get the duration of the epoch.
- Returns:
The duration of the epoch.
- Return type:
- 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:
- property id: DefinitionId#
Get the ID from the definition of the epoch.
- Returns:
The id of the
Epoch.definition
.- Return type:
- 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:
- 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 beTrue
if either thestart
orend
of theother
epoch is within thestart
orend
of this epoch. If only a datetime object is provided, the result isTrue
if the time is betweenstart
andend
including the boundaries.- Return type:
- 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:
id_ (str | DefinitionId) –
name (str | None) –
description (str | None) –
- property id: DefinitionId#
Get the ID of the definition.
- Returns:
The ID of the epoch definition.
- Return type: