satkit.time.timeinterval

Time interval module.

TimeInterval class stores time intervals and TimeIntervalList class stores lists of TimeInterval objects.

Classes

TimeInterval(start_time, end_time[, ...])

Represent and manipulate a single time interval.

TimeIntervalList(intervals[, valid_interval])

Represent and manipulate time intervals.

class TimeInterval(start_time, end_time, start_inclusive=True, end_inclusive=True)[source]

Represent and manipulate a single time interval.

This is a thin wrapper around the Interval class from portion package (for the Atomic intervals), using AbsoluteDateExt classes under the hood.

Parameters
  • start_time (type[org.orekit.time.AbsoluteDate]) –

  • end_time (type[org.orekit.time.AbsoluteDate]) –

contains(interval)[source]

Checks whether the requested interval is contained within this (self) interval.

Parameters

interval (TimeInterval) – Time interval to be checked

Returns

True if check interval is contained within this interval, False otherwise

Return type

bool

property duration: Quantity

Computes the duration of the interval.

Returns

Duration of the interval (always positive)

Return type

Quantity

property end: AbsoluteDateExt

Returns the end time of the interval.

expand(start_delta=0, end_delta=0, start_inclusive=True, end_inclusive=True)[source]

Expands (or shrinks) the interval.

Generates a new, expanded (or shrunk) TimeInterval, where:

  • new interval start: interval_start - start_delta

  • new interval end: interval_end + end_delta

Negative start and/or end times are possible (to shrink the interval), though values ending in a negative interval will throw a ValueError. This method can be used to modify the ends of the interval (open or closed) as well.

Parameters
  • start_delta (Quantity or float) – The delta time to expand the start of the interval (or to shrink, with negative values) [seconds]

  • end_delta (Quantity or float) – The delta time to expand the end of the interval (or to shrink, with negative values) [seconds]

  • start_inclusive (bool) – True if the start of the new interval is inclusive (closed), False if exclusive (open)

  • end_inclusive (bool) – True if the start of the new interval is inclusive (closed), False if exclusive (open)

Returns

A new TimeInterval that is the result of the requested change

Return type

TimeInterval

Raises

ValueError – Raised if the requested expansion results in a negative duration interval

from_duration(duration, start_inclusive=True, end_inclusive=True)[source]

Generates a TimeInterval object from a start time and a duration.

Return type

TimeInterval

Parameters
  • start_time (Type[AbsoluteDate]) – Start time

  • duration (Quantity of float) – duration [seconds]

  • start_inclusive (bool) – True if the start of the interval is inclusive (closed), False if exclusive (open)

  • end_inclusive (bool) – True if the start of the interval is inclusive (closed), False if exclusive (open)

Returns

The new TimeInterval object

Return type

TimeInterval

static from_interval(interval)[source]

Generates a deep copy of the TimeInterval object.

Return type

TimeInterval

Parameters

interval (TimeInterval) – TimeInterval to be copied

Returns

The new, deep copied TimeInterval object

Return type

TimeInterval

intersect(interval)[source]

Intersection operator for a time interval and this time interval.

Returns a new interval that is the Intersection of two intervals, or None if there is no intersection.

Parameters

interval (TimeInterval) – Time interval to be checked

Returns

A new interval that is the Intersection of two intervals, or None if there is no intersection

Return type

TimeInterval

property is_end_inclusive: bool

Returns whether the end time of the interval is inclusive.

is_equal(interval, tolerance=<Quantity(10, 'nanosecond')>)[source]

Checks whether two intervals are (almost) equal in value.

If the two start or end values are as close as tolerance, then they are assumed to be equal in value. The default tolerance is given in _EPS_TIME and is on the order of nanoseconds.

Parameters

interval (TimeInterval) – Time interval to be checked

tolerancefloat or Quantity

the separation, in seconds, under which the two bounds of the interval will be considered close to each other

Returns

True if interval start and end are (almost) equal, False otherwise

Return type

bool

is_in_interval(time)[source]

Checks whether the requested time is within the time interval.

Parameters

time (Time) – Time to be checked

Returns

True if time is within the reference interval, False otherwise

Return type

bool

is_intersecting(interval)[source]

Checks whether the requested interval intersects (or is contained within) the reference interval.

Parameters

interval (TimeInterval) – Time interval to be checked

Returns

True if check interval intersects with the reference interval, False otherwise

Return type

bool

property is_start_inclusive: bool

Returns whether the start time of the interval is inclusive.

property p_interval

Returns the underlying Interval object.

Warning

Most users will not need to access this object. Intended for developer use only.

property start: AbsoluteDateExt

Returns the start time of the interval.

union(interval)[source]

Union operator for a time interval and this time interval.

Returns a new interval that is the Union of two intervals, or None if there is no intersection.

Parameters

interval (TimeInterval) – Time interval to be checked

Returns

A new interval that is the Union of two intervals, or None if there is no intersection

Return type

TimeInterval

class TimeIntervalList(intervals, valid_interval=None)[source]

Represent and manipulate time intervals.

This is a thin wrapper around the portion.interval.Interval class, using AbsoluteDateExt classes under the hood.

start_valid and end_valid values are used to mark the start and end of this list of time intervals. If they are not specified, the beginning and end points of the list of TimeInterval instances are used.

If a valid_interval is not specified (None), the beginning and end points of the TimeInterval are used.

Parameters
  • intervals (list[TimeInterval] or None) – List of intervals

  • valid_interval (TimeInterval) – Time interval within which this TimeInterval is valid

get_interval(index)[source]

Gets the time interval for the given index.

Parameters

index (int) – requested index

Returns

TimeInterval corresponding to the index

Return type

TimeInterval

Raises

IndexError – Requested index is out of bounds

intersect(interval)[source]

Intersection operator for a time interval and this time interval list.

Returns a new interval that is the Intersection of the interval and the time interval list, or None if there is no intersection.

Parameters

interval (TimeInterval) – Time interval to be checked

Returns

A new interval that is the Intersection of the interval and the time interval list, or None if there is no intersection.

Return type

TimeInterval

intersect_list(interval_list)[source]

Intersection operator for a time interval list and this time interval list.

Returns a new interval list that is the Intersection of interval_list and this time interval list, or None if there is no intersection even in the validity intervals.

Parameters

interval_list (TimeIntervalList) – Time interval list to be checked

Returns

A new interval list that is the Intersection of interval_list and this time interval list, or None if there is no intersection even in the validity intervals.

Return type

TimeIntervalList

property intervals

Gets the time intervals within this TimeIntervalList.

invert()[source]

Creates an inverted (or complement) copy of this time interval list, while keeping the same validity range.

For example, for a single interval of [t0, t1] in a validity interval [T0,T1], the inverted interval list would be [T0,t0] and [t1,T1]. If there are no intervals, the inverse becomes the entire validity interval.

Returns

A new TimeIntervalList that has the same validity range but the individual intervals are inverted.

Return type

TimeIntervalList

is_in_interval(time)[source]

Checks whether the requested time is within the time interval list.

Parameters

time (TimeStamped) – Time to be checked

Returns

True if time is within the interval list, False otherwise. Also returns False if requested time is outside validity interval.

Return type

bool

is_intersecting(interval)[source]

Checks whether the requested interval intersects (or is contained within) the interval list.

Parameters

interval (TimeInterval) – Time interval to be checked

Returns

True if check interval intersects with the interval list, False otherwise

Return type

bool

union(interval)[source]

Union operator for a time interval and this time interval list.

Returns a new interval that is the Union of the interval and the time interval list, or None if there is no intersection.

Parameters

interval (TimeInterval) – Time interval to be checked

Returns

A new interval that is the Union of the interval and the time interval list, or None if there is no intersection.

Return type

TimeInterval

union_list(interval_list)[source]

Union operator for a time interval list and this time interval list.

Returns a new interval list that is the Union of interval_list and this time interval list, or None if there is no intersection even in the validity intervals.

Parameters

interval_list (TimeIntervalList) – Time interval list to be checked

Returns

A new interval list that is the Union of interval_list and this time interval list, or None if there is no intersection.

Return type

TimeIntervalList

property valid_interval: TimeInterval

Gets the time interval of validity for the TimeIntervalList.