hec.rating.abstract_rating
Exception class for AbstractRating objects
Abstract class for all rating classes;
Specifies required methods for sub-classes, holds information and implements code common one or more sub-classes.
Initializer for AbstractRating objects.
Arguments:
- specification (Any): A RatingSpecification object to initialize from.
This is typed as
Anyto avoid circular import dependencies. - effective_time (Union[datetime, HecTime, str]): The effective date/time of the rating
Raises:
- TypeError: if
specificationis not a RatingSpecification object.
Converts a tuple or list of value from/to the specified units
Arguments:
- values (Sequence[float]): The values to convert
- from_unit (str): The unit to convert from
- to_unit (str): The unit to convert to
Returns:
Sequence[float]: The converted values
The creation date/time of the rating, if any
Operations:
Read/Write
The default data units, if any.
The default data units are used if the rate or reverse_rate
methods are called without any specified units.
Operations:
Read/Write
The default vertical datum for rating Elev parameter values.
If not None, Elev parameter values will be converted to the default vertical datum before (input values) or after (output values) the rating is performed.
If None, the native vertical datum will be used.
When setting, must be None, NGVD-29, NAVD-99, or OTHER.
Operations:
Read/Write
Creates a rating object from an XML instance
Arguments:
- xml_str (str): The XML instance to create the rating from
Raises:
- AbstractRatingException: if no subclass of AbstractRating has a registered from_xml()
- method that is compatible with the specified XML instance
Returns:
AbstractRating: The rating created from the XML instance
Whether the rating has "Elev" as the base parameter for one of the indpendent parameters or the dependent parameter
Operations:
Read-Only
Creates a list of offsets (in rating units) from the specified vertical datum to the rating native vertical datum plus the offset for from the rating native vertical datum to the specified vertical datum.
All offsets except the last one are for independent parameter values in the same position. The last offset is for the dependent parameter value (hence the difference in offset direction).
In any postion, the offset will be None if: * The parameter at that position is not an elevation parameter * The offset is zero
Arguments:
- vertical_datum (str): The specified vertical datum
Returns:
list[Optional[float]]: The list of offsets.
Creates a list of two vertical datum offsets (in rating units). The first is from the specified vertical datum to the rating native vertical datum; the second from the rating native vertical datum to the specified datum.
The first offset will be None if the base parameter of the rating dependent parameter is not "Elev" or the offset is zero. The secons offset will be None if the base parameter of the (single) rating independent parameter is not "Elev" or the offset is zero.
Arguments:
- vertical_datum (str): The specified vertical datum
Returns:
list[Optional[float]]: The list of offsets.
Creates a list of unit conversion functions (each optionally None for the identity function) for converting the dependent parameter values to rating units and the independent parameter value to specified unit
Arguments:
- unit_list (list[str]): The list of [dependent parameter unit, independent parameter unit].
Returns:
list[Optional[Callable[[float], float]]]: The list of unit conversions. The first is for converting from the rating independent parameter unit to the specified unit. The second one is for converting the specified unit to the rating dependent parameter unit.
Creates a function that converts a value from/to specified units
Arguments:
- from_unit (str): The unit to convert from
- to_unit (str): The unit to conver to
Returns:
Optional[Callable[[float],float]]: The conversion function or None for the identity conversion
Creates a list of unit conversion functions (each optionally None for the identity function) for converting independent parameter values to rating units and the dependent parameter value to specified unit
Arguments:
- unit_list (list[str]): The list of independent parameter units plus the dependent parameter unit.
Returns:
list[Optional[Callable[[float], float]]]: The list of unit conversions. All but the last one are for converting the specified unit to the rating unit for the independent parameter at that position. The last one is for converting from the rating dependent parameter unit to the specified unit.
The info common to all ratings as an lxml.etree.Element object
Operations:
Read-Only
Rates independent parameter values and returns dependent parameter values.
Arguments:
- input (Union[list[list[float]], TimeSeries, Sequence[TimeSeries]]): The input parameter values.
- If specified as a list of lists of floats:
- The list must be of the same length as the number of independent parameters of the rating.
- Each list of values must have the same times and be of the same length
- The
timesparameter is used, if specified - The
units, if specified, is the unit of each independent and dependent parameter. - A list of floats is returned
- If specified as a TimeSeries:
- The rating must have a single independent parameter
- The
timesparameter is not used and will cause an exception if specified - The
unitsparameter, if specified, is the unit of the rated time series - A time series is returned
- If specified as a list of TimeSeries:
- The list must be of the same length as the number of independent parameters of the rating.
- The
timesparameter is not used and will cause an exception if specified - The
unitsparameter, if specified, is the unit of the rated time series - A time series is returned
- If specified as a list of lists of floats:
- units (Optional[str], must be passed by name): Defaults to None.
- If
inputis a list of list of floats, this specifies units of the independent parameter values and the rated values. A comma-delimited string of independent value units concatendated with a semicolon and the dependent parameter unit. Defaults to None. If not specified or None, the rating's default data units are used, if specified. If the rating has no default data units, the rating units are used. - If specified as a TimeSeries or list of TimeSeries, this specifies the unit of the rated time series. If not specified or None, rating's default data unit for the dependent parameter, if any, is used. Otherwise, the dependent parameter's default unit will be used.
- If
- vertical_datum (Optional[str], must be passed by name): Defaults to None.
- If
inputis a list of list of floats, this specifies the vertical datum of any input elevation value and the desired vertical datum of any output elevation values. If None, or not specified, the location's native vertical datum is used. - If specified as a TimeSeries or list of TimeSeries, this specifies the desired vertical datum for any output elevation values. Any input elevation values will be in the vertical datum of the input time series.
- If
- round (bool, optional, must be passed by name): Whether to use the rating's specification's dependent rounding specification . Defaults to False.
Returns:
Union[list[float], TimeSeries]: The dependent parameter values as described in
inputabove
The native units of the rating, one for each independent parameter, plus the dependent parameter
Operations:
Read-Only
Rates dependent parameter values and returns independent parameter values.
Arguments:
- input (Union[list[float], TimeSeries]): The input parameter values.
- If specified as a lists of floats:
- The
timesparameter is used, if specified - The
units, if specified, is the unit of each independent and dependent parameter. - A list of floats is returned
- The
- If specified as a TimeSeries:
- The rating must have a single independent parameter
- The
timesparameter is not used and will cause an exception if specified - The
unitsparameter, if specified, is the unit of the rated time series - A time series is returned
- If specified as a lists of floats:
- units (Optional[str], optional, must be passed by name): Defaults to None.
- If
inputis a list of list of floats, this specifies units of the independent parameter values and the rated values. A comma-delimited string of independent value units concatendated with a semicolon and the dependent parameter unit. Defaults to None. If not specified or None, the rating's default data units are used, if specified. If the rating has no default data units, the rating units are used. - If specified as a TimeSeries or list of TimeSeries, this specifies the unit of the rated time series. If not specified or None, rating's default data unit for the dependent parameter, if any, is used. Otherwise, the dependent parameter's default unit will be used.
- If
- round (bool, optional, must be passed by name): Whether to use the rating's specification's dependent rounding specification . Defaults to False.
Returns:
Union[list[float], TimeSeries]: The dependent parameter values as described in
inputabove
A copy of the rating's specification
Operations:
Read-Only
Returns a formatted xml representation of the rating.
For unformatted xml use etree.tostring(<template_obj>.xml_element)
Arguments:
- indent (str, optional): The string to use for each level of indentation. Defaults to " ".
- prepend (Optional[str], optional): A string to prepend to each line. Defaults to None.
Returns:
str: The formatted xml
The date/time of beginning of transition from the previous rating, if any
Operations:
Read/Write
The vertical datum info of the rating's specification's location, if any
Operations:
Read-Only
The vertical datum info of the rating's specification's location, if any, as a JSON object
Operations:
Read-Only