hec.duration
Provides standard time durations
Exception specific to Duration operations
Class to hold information about the durations represented by time series values.
Durations are a restriction of the TimeSpan base class that also hold extra information.
- Restriction: At most one of
years,months,days,hours, andminutescan be non-zero, andsecondsmust be zero. - Extension:
- Each duration has a name
- Each duration is a Beginning of Period (BOP) or End of Period (EOP) duration. Normally values represent the state at the end of duration (e.g, the elevation or flow at the end of an hour or day). EOP Duration objects are returned unless otherwise specified.
Durations should not need to be created by the user, as durations for all CWMS intervals are created during module initialization.
@staticmethod
def
for_interval( interval: Union[hec.Interval, str, int], bop: bool = False) -> Duration:
Returns a Duration object for a specified interval
Arguments:
- interval (Union[Interval, str, int]): A standard CWMS Interval object, or the name or (actual or characteristic) minutes of a standard CWMS interval
- bop (bool, optional): Specifies whether to return a Beginning of Period Duration object. Defaults to False.
Raises:
- TypeError: If the first argument is not an Interval, string, or integer
- DurationException: If the first argument a non-standard name or minutes or no such Duration object exists
Returns:
Duration: The Duration object matching the specified interval and bop setting.