TimeFrame

time.TimeFrame(self, start_date, duration_days)

Describes a time frame as a contiguous set of calendar dates, primarily used to define the time frame of a simulation.

TimeFrame is a frozen dataclass. TimeFrame is iterable, and produces the sequence of dates in the time frame.

Examples

from datetime import date

from epymorph.time import TimeFrame

# For your convenience, there are a number of ways to construct TimeFrames:

# 1. Start January 1st, 2020 and go for 150 days
TimeFrame(date(2020, 1, 1), 150)

# 2. Equivalent, but accept dates as ISO-8601 strings
TimeFrame.of("2020-01-01", 150)

# 3. January through March 2020
TimeFrame.range("2020-01-01", "2020-03-31")

# 4. Equivalent, but using an exclusive endpoint
TimeFrame.rangex("2020-01-01", "2020-04-01")

# 5. The whole of 2020
TimeFrame.year(2020)

Attributes

start_date: date

The first date in the time frame.

duration_days: int

The number of days for included in the time frame.

days: int

Alias for duration_days

end_date: date

The last date included in the time frame.

select: TimeSelector

Create a time-axis strategy from this time frame.

In most cases, this will be used to process a simulation result and so you should use a selection on the time frame used in the RUME that produced the result.

Methods

Name Description
of Alternate constructor: start date and a given duration in days.
range Alternate constructor: start and end date (inclusive).
rangex Alternate constructor: start and end date (exclusive).
year Alternate constructor: an entire calendar year.
is_subset Is the given TimeFrame a subset of this one?