Timespan¶
- 
class lsst.daf.butler.Timespan(begin: Union[astropy.time.core.Time, lsst.daf.butler.core.timespan._SpecialTimespanBound, None], end: Union[astropy.time.core.Time, lsst.daf.butler.core.timespan._SpecialTimespanBound, None], padInstantaneous: bool = True, _nsec: Optional[Tuple[int, int]] = None)¶
- Bases: - object- A half-open time interval with nanosecond precision. - Parameters: - begin : astropy.time.Time,Timespan.EMPTY, orNone
- Minimum timestamp in the interval (inclusive). - Noneindicates that the timespan has no lower bound.- Timespan.EMPTYindicates that the timespan contains no times; if this is used as either bound, the other bound is ignored.
- end : astropy.time.Time,SpecialTimespanBound, orNone
- Maximum timestamp in the interval (exclusive). - Noneindicates that the timespan has no upper bound. As with- begin,- Timespan.EMPTYcreates an empty timespan.
- padInstantaneous : bool, optional
- If - True(default) and- begin == endafter discretization to integer nanoseconds, extend- endby one nanosecond to yield a finite-duration timespan. If- False,- begin == endevaluates to the empty timespan.
- _nsec : tupleofint, optional
- Integer nanosecond representation, for internal use by - Timespanand- TimespanDatabaseRepresentationimplementation only. If provided, all other arguments are are ignored.
 - Raises: - TypeError
- Raised if - beginor- endhas a type other than- astropy.time.Time, and is not- Noneor- Timespan.EMPTY.
- ValueError
- Raised if - beginor- endexceeds the minimum or maximum times supported by this class.
 - Notes - Timespans are half-open intervals, i.e. - [begin, end).- Any timespan with - begin > endafter nanosecond discretization (- begin >= endif- padInstantaneousis- False), or with either bound set to- Timespan.EMPTY, is transformed into the empty timespan, with both bounds set to- Timespan.EMPTY. The empty timespan is equal to itself, and contained by all other timespans (including itself). It is also disjoint with all timespans (including itself), and hence does not overlap any timespan - this is the only case where- containsdoes not imply- overlaps.- Finite timespan bounds are represented internally as integer nanoseconds, and hence construction from - astropy.time.Time(which has picosecond accuracy) can involve a loss of precision. This is of course deterministic, so any- astropy.time.Timevalue is always mapped to the exact same timespan bound, but if- padInstantaneousis- True, timespans that are empty at full precision (- begin > end,- begin - end < 1ns) may be finite after discretization. In all other cases, the relationships between full-precision timespans should be preserved even if the values are not.- The - astropy.time.Timebounds that can be obtained after construction from- Timespan.beginand- Timespan.endare also guaranteed to round-trip exactly when used to construct other- Timespaninstances.- Attributes Summary - EMPTY- begin- Minimum timestamp in the interval, inclusive. - end- Maximum timestamp in the interval, exclusive. - Methods Summary - contains(other, …)- Test whether the intersection of this timespan with another timespan or point is equal to the other one. - difference(other)- Return the one or two timespans that cover the interval(s) that are in - selfbut not- other.- fromInstant(time)- Construct a timespan that approximates an instant in time by a minimum-possible (1 ns) duration timespan. - intersection(*args)- Return a new - Timespanthat is contained by all of the given ones.- isEmpty()- Test whether - selfis the empty timespan (- bool).- makeEmpty()- Construct an empty timespan. - overlaps(other)- Test whether the intersection of this Timespan with another is empty. - Attributes Documentation - 
EMPTY= 1¶
 - 
begin¶
- Minimum timestamp in the interval, inclusive. - If this bound is finite, this is an - astropy.time.Timeinstance. If the timespan is unbounded from below, this is- None. If the timespan is empty, this is the special value- Timespan.EMPTY.
 - 
end¶
- Maximum timestamp in the interval, exclusive. - If this bound is finite, this is an - astropy.time.Timeinstance. If the timespan is unbounded from above, this is- None. If the timespan is empty, this is the special value- Timespan.EMPTY.
 - Methods Documentation - 
contains(other: Union[astropy.time.core.Time, lsst.daf.butler.core.timespan.Timespan]) → bool¶
- Test whether the intersection of this timespan with another timespan or point is equal to the other one. - Parameters: - other : Timespanorastropy.time.Time.
- Timespan or instant in time to relate to - self.
 - Returns: - overlaps : bool
- The result of the contains test. 
 - Notes - If - otheris empty,- Trueis always returned. In all other cases,- self.contains(other)being- Trueimplies that- self.overlaps(other)is also- True.- Testing whether an instantaneous - astropy.time.Timevalue is contained in a timespan is not equivalent to testing a timespan constructed via- Timespan.fromInstant, because Timespan cannot exactly represent zero-duration intervals. In particular,- [a, b)contains the time- b, but not the timespan- [b, b + 1ns)that would be returned by- Timespan.fromInstant(b)`.
- other : 
 - 
difference(other: lsst.daf.butler.core.timespan.Timespan) → Generator[lsst.daf.butler.core.timespan.Timespan, None, None]¶
- Return the one or two timespans that cover the interval(s) that are in - selfbut not- other.- This is implemented as a generator because the result may be zero, one, or two - Timespanobjects, depending on the relationship between the operands.- Parameters: - other : Timespan
- Timespan to subtract. 
 - Yields: 
- other : 
 - 
classmethod fromInstant(time: astropy.time.core.Time) → lsst.daf.butler.core.timespan.Timespan¶
- Construct a timespan that approximates an instant in time by a minimum-possible (1 ns) duration timespan. - This is equivalent to - Timespan(time, time, padInstantaneous=True), but may be slightly more efficient.- Parameters: - time : astropy.time.Time
- Time to use for the lower bound. 
 - Returns: - instant : Timespan
- A - [time, time + 1ns)timespan.
 
- time : 
 - 
intersection(*args) → lsst.daf.butler.core.timespan.Timespan¶
- Return a new - Timespanthat is contained by all of the given ones.- Parameters: - *args
- All positional arguments are - Timespaninstances.
 - Returns: - intersection : Timespan
- The intersection timespan. 
 
 - 
classmethod makeEmpty() → lsst.daf.butler.core.timespan.Timespan¶
- Construct an empty timespan. - Returns: - empty : Timespan
- A timespan that is contained by all timespans (including itself) and overlaps no other timespans (including itself). 
 
- empty : 
 - 
overlaps(other: lsst.daf.butler.core.timespan.Timespan) → bool¶
- Test whether the intersection of this Timespan with another is empty. - Parameters: - other : Timespan
- Timespan to relate to - self.
 - Returns: - overlaps : bool
- The result of the overlap test. 
 - Notes - If either - selfor- otheris empty, the result is always- False. In all other cases,- self.contains(other)being- Trueimplies that- self.overlaps(other)is also- True.
- other : 
 
- begin :