ostk.physics.time.Interval

class Interval(
self: ostk.physics.time.Interval,
start_instant: ostk::physics::time::Instant,
end_instant: ostk::physics::time::Instant,
type: ostk.mathematics.object.RealInterval.Type,
)

Bases: pybind11_object

Time interval.

Constructor.

Parameters:

Methods

centered

Create a centered interval.

clip

Creates a clipped list of intervals.

closed

Create a closed interval.

contains_instant

Check if the interval contains an instant.

contains_interval

Check if the interval contains another interval.

generate_grid

Generate a grid of instants with a given time step.

get_center

Get the center instant.

get_duration

Get the duration.

get_end

Get the end instant.

get_gaps

Creates a list of intervals gaps.

get_intersection_with

Get the intersection with another interval.

get_lower_bound

Get the lower bound.

get_start

Get the start instant.

get_union_with

Get the union with another interval.

get_upper_bound

Get the upper bound.

half_open_left

Create a half-open left interval.

half_open_right

Create a half-open right interval.

intersects

Check if the interval intersects another interval.

is_defined

Check if the interval is defined.

is_degenerate

Check if interval is degenerate, i.e. its lower and upper bounds are the equal.

logical_and

Creates a list of intervals by a logical-and conjunction.

logical_or

Creates a list of intervals by a logical-or conjunction.

merge

Creates a merged list of intervals.

open

Create a open interval.

parse

Parse an interval from a string representation.

sort

Creates a sorted list of intervals.

to_datetime_span

Get the datetime span.

to_string

Convert the interval to a string.

undefined

Create an undefined interval.

class Type(self: ostk.physics.time.Interval.Type, value: int)

Bases: pybind11_object

Members:

Undefined :

Undefined interval type.

Closed :

Closed interval type.

Open :

Open interval type.

HalfOpenLeft :

Half-open left interval type.

HalfOpenRight :

Half-open right interval type.

property name
static centered(
instant: ostk::physics::time::Instant,
duration: ostk.physics.time.Duration,
type: ostk.mathematics.object.RealInterval.Type,
) ostk.physics.time.Interval

Create a centered interval.

Parameters:
Returns:

Centered interval.

Return type:

Interval

static clip(
intervals: list[ostk.physics.time.Interval],
interval: ostk.physics.time.Interval,
) list[ostk.physics.time.Interval]

Creates a clipped list of intervals.

` intervals = [[1, 3], [5, 7], [9, 11]] interval = [4, 10] output = [[5, 7], [9, 10]] `

Parameters:
Returns:

Clipped intervals.

Return type:

Interval

static closed(
start_instant: ostk::physics::time::Instant,
end_instant: ostk::physics::time::Instant,
) ostk.physics.time.Interval

Create a closed interval.

Parameters:
  • start_instant (Instant) -- Start instant.

  • end_instant (Instant) -- End instant.

Returns:

Closed interval.

Return type:

Interval

contains_instant(
self: ostk.physics.time.Interval,
instant: ostk::physics::time::Instant,
) bool

Check if the interval contains an instant.

Parameters:

instant (Instant) -- An instant.

Returns:

True if the interval contains the instant.

Return type:

bool

contains_interval(
self: ostk.physics.time.Interval,
interval: ostk.physics.time.Interval,
) bool

Check if the interval contains another interval.

Parameters:

interval (Interval) -- Another interval.

Returns:

True if the interval contains the other interval.

Return type:

bool

generate_grid(
self: ostk.physics.time.Interval,
arg0: ostk.physics.time.Duration,
) list[ostk::physics::time::Instant]

Generate a grid of instants with a given time step.

Parameters:

aTimeStep (Duration) -- Time step.

Returns:

Grid of instants.

Return type:

List[Instant]

get_center(self: ostk.physics.time.Interval) ostk::physics::time::Instant

Get the center instant.

Returns:

Center instant.

Return type:

Instant

get_duration(self: ostk.physics.time.Interval) ostk.physics.time.Duration

Get the duration.

Returns:

Duration.

Return type:

Duration

get_end(self: ostk.physics.time.Interval) ostk::physics::time::Instant

Get the end instant.

Returns:

End instant.

Return type:

Instant

static get_gaps(intervals: list[ostk.physics.time.Interval], interval: ostk.physics.time.Interval = Interval::Undefined()) list[ostk.physics.time.Interval]

Creates a list of intervals gaps.

` intervals = [[1, 3], [5, 7], [9, 11]] interval = [0, 12] output = [[0, 1], [3, 5], [7, 9], [11, 12]] `

Parameters:
  • intervals (list[Interval]) -- A list of intervals.

  • interval (Interval) -- The analysis interval. Used to compute gaps for the first and last interval. Defaults to Undefined.

Returns:

Intervals gaps.

Return type:

Interval

get_intersection_with(
self: ostk.physics.time.Interval,
arg0: ostk.physics.time.Interval,
) ostk.physics.time.Interval

Get the intersection with another interval.

Parameters:

interval (Interval) -- Another interval.

Returns:

Intersection interval (Undefined if there is no intersection).

Return type:

Interval

get_lower_bound(
self: ostk.physics.time.Interval,
) ostk::physics::time::Instant

Get the lower bound.

Returns:

Lower bound.

Return type:

Instant

get_start(self: ostk.physics.time.Interval) ostk::physics::time::Instant

Get the start instant.

Returns:

Start instant.

Return type:

Instant

get_union_with(
self: ostk.physics.time.Interval,
arg0: ostk.physics.time.Interval,
) ostk.physics.time.Interval

Get the union with another interval.

Parameters:

interval (Interval) -- Another interval.

Returns:

Union interval (Undefined if there is no single-interval union).

Return type:

Interval

get_upper_bound(
self: ostk.physics.time.Interval,
) ostk::physics::time::Instant

Get the upper bound.

Returns:

Upper bound.

Return type:

Instant

static half_open_left(
start_instant: ostk::physics::time::Instant,
end_instant: ostk::physics::time::Instant,
) ostk.physics.time.Interval

Create a half-open left interval.

Parameters:
  • start_instant (Instant) -- Start instant.

  • end_instant (Instant) -- End instant.

Returns:

Half-open left interval.

Return type:

Interval

static half_open_right(
start_instant: ostk::physics::time::Instant,
end_instant: ostk::physics::time::Instant,
) ostk.physics.time.Interval

Create a half-open right interval.

Parameters:
  • start_instant (Instant) -- Start instant.

  • end_instant (Instant) -- End instant.

Returns:

Half-open right interval.

Return type:

Interval

intersects(
self: ostk.physics.time.Interval,
interval: ostk.physics.time.Interval,
) bool

Check if the interval intersects another interval.

Parameters:

interval (Interval) -- Another interval.

Returns:

True if the interval intersects another interval.

Return type:

bool

is_defined(self: ostk.physics.time.Interval) bool

Check if the interval is defined.

Returns:

True if defined.

Return type:

bool

is_degenerate(self: ostk.physics.time.Interval) bool

Check if interval is degenerate, i.e. its lower and upper bounds are the equal.

Returns:

True if degenerate.

Return type:

bool

static logical_and(
intervals_1: list[ostk.physics.time.Interval],
intervals_2: list[ostk.physics.time.Interval],
) list[ostk.physics.time.Interval]

Creates a list of intervals by a logical-and conjunction.

` intervals_1 = [[-1, 1], [2, 4]] intervals_2 = [[0.5, 1.5], [3, 5], [7, 8]] output = [[0.5, 1], [3, 4]] `

Parameters:
Returns:

Logical-and intervals.

Return type:

Interval

static logical_or(
intervals_1: list[ostk.physics.time.Interval],
intervals_2: list[ostk.physics.time.Interval],
) list[ostk.physics.time.Interval]

Creates a list of intervals by a logical-or conjunction.

` intervals_1 = [[-1, 1], [2, 4]] intervals_2 = [[0.5, 1.5], [3, 5], [7, 8]] output = [[-1, 1.5], [2, 5], [7, 8]] `

Parameters:
Returns:

Logical-or intervals.

Return type:

Interval

static merge(
intervals: list[ostk.physics.time.Interval],
) list[ostk.physics.time.Interval]

Creates a merged list of intervals.

` intervals = [[1, 3], [2, 4], [5, 7]] output = [[1, 4], [5, 7]] `

Parameters:

intervals (list[Interval]) -- A list of intervals.

Returns:

Merged intervals.

Return type:

Interval

static open(
start_instant: ostk::physics::time::Instant,
end_instant: ostk::physics::time::Instant,
) ostk.physics.time.Interval

Create a open interval.

Parameters:
  • start_instant (Instant) -- Start instant.

  • end_instant (Instant) -- End instant.

Returns:

Open interval.

Return type:

Interval

static parse(arg0: ostk.core.type.String) ostk.physics.time.Interval

Parse an interval from a string representation.

Parameters:

aString (str) -- String representation.

Returns:

Interval.

Return type:

Interval

static sort(
intervals: list[ostk.physics.time.Interval],
by_lower_bound: bool = True,
ascending: bool = True,
) list[ostk.physics.time.Interval]

Creates a sorted list of intervals.

Parameters:
  • intervals (list[Interval]) -- A list of intervals.

  • by_lower_bound (bool) -- Use lower bound for sorting. Defaults to True.

  • ascending (bool) -- Sort in ascending order. Defaults to True.

Returns:

Sorted intervals.

Return type:

Interval

to_datetime_span(
self: ostk.physics.time.Interval,
scale: ostk.physics.time.Scale = <Scale.UTC: 1>,
) tuple[ostk.physics.time.DateTime, ostk.physics.time.DateTime]

Get the datetime span.

Parameters:

scale (Scale) -- Time scale. Defaults to UTC.

Returns:

Datetime span.

Return type:

Tuple[datetime, datetime]

to_string(
self: ostk.physics.time.Interval,
time_scale: ostk.physics.time.Scale = <Scale.UTC: 1>,
) ostk.core.type.String

Convert the interval to a string.

Parameters:

time_scale (Scale) -- Time scale.

Returns:

String representation of the interval.

Return type:

str

static undefined() ostk.physics.time.Interval

Create an undefined interval.

Returns:

Undefined interval.

Return type:

Interval