hec.duration

Provides standard time durations

class DurationException(hec.timespan.TimeSpanException):

Exception specific to Duration operations

class Duration(hec.timespan.TimeSpan):

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, and minutes can be non-zero, and seconds must 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.

Duration(interval: Union[hec.Interval, str], bop: bool = False)

Initializer used by module

is_bop: bool

Whether this object is a Beginning of Period Duration

Operations:

Read-only

is_eop: bool

Whether this object is an End of Period Duration

Operations:

Read-only

@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.

minutes: int

The minutes (actual or characteristic) of this object

Operations:

Read-only

name: str

The name of this object

Operations:

Read-only