hec.rating.table_rating

class TableRatingException(hec.rating.simple_rating.SimpleRatingException):

Exception class for TableRating objects

Implements lookup-based ratings

TableRating( specification: hec.rating.RatingSpecification, effective_time: Union[datetime.datetime, hec.HecTime, str])

Initializer for AbstractRating objects.

Arguments:
  • specification (Any): A RatingSpecification object to initialize from. This is typed as Any to avoid circular import dependencies.
  • effective_time (Union[datetime, HecTime, str]): The effective date/time of the rating
Raises:
@staticmethod
def from_element( root: lxml.etree._Element, specification: Optional[hec.rating.RatingSpecification]) -> hec.rating.SimpleRating:

Creates a TableRating from a XML element and rating spec

Arguments:
  • root (etree._Element): The element
  • specification (Optional[RatingSpecification]): The rating specification.
    • If specified: If specification vertical datum info is None, it will be created from any vertical datum info in the XML
    • If not specified: The rating spec for the rating will be constructed from the XML
Raises:
  • AbstractRatingException: If there is any invalid XML in the portion common to all ratings
  • TableRatingException: If there is any invalid XML in the elements
Returns:

SimpleRating: The created rating

has_rating_points: bool

Whether the table rating has rating points

Concrete (non-reference) rating sets (see LocalRatingSet) may be initailized in a manner in which the included TableRating objects are initialized with or without data points.

This is controlled by specifying 'EAGER' or 'LAZY' as the loading method. A TableRating object in LocalRatingSet loaded with LAZY loading keeps a reference to the datastore from which it was loaded in order to retrieve rating points on the first use of the rating.

Operations:

Read/Write

@staticmethod
def interpolate_or_select( x: float, x0: float, x1: float, y0: float, y1: float, lookup: str) -> float:

Performs dependent value interpolation, extrapolation, or selection based on specified behavior

Arguments:
  • x (float): The independent value
  • x0 (float): The nearest independent value <= x in a sorted list
  • x1 (float): The nearest independent value >= x in a sorted list
  • y0 (float): The dependent value corresponding to x0
  • y1 (float): The dependent value corresponding to x1
  • lookup (str): The computation or selection behavior to use. See LookupMethod
Returns:

float: The interpolated, extrapolated, or selected dependent value

def populate_rating_points(self) -> None:
def rate_value( self, ind_value: list[float], lo_key: list[float] = [], hi_key: list[float] = []) -> float:

Rates a single independent parameter value set

The value set is expected to be in the native units and vertical datum of the rating. To specify units, vertical datum or rounding use rate_values, nesting ind_value in a list and extracting the result from the returned list.

Arguments:
  • ind_value (list[float]): The list of values (one for each independent parameter) that comprises the input value set
  • lo_key (list[float], optional): Do not set; only used internally on recursion. Defaults to [].
  • hi_key (list[float], optional): Do not set; only used internally on recursion. Defaults to [].
Returns:

float: The rated (dependent parameter) value

def reverse_rate_value(self, dep_value: float) -> float:

Reverse rates a single dependent parameter value

The dependent parameter value is expected to be in the native unit and vertical datum of the rating. To specify units, vertical datum or rounding use reverse_rate_values, putting dep_value in a list and extracting the result from the returned list.

Arguments:
  • dep_value (float): The dependent parameter value to reverse rate
Returns:

float: The rated (independent parameter) value

xml_element: lxml.etree._Element

The rating as an lxml.etree.Element object

Operations:

Read-Only

def xml_tag_name(self) -> str:

The XML tag name for this rating type

Oprations:

Read-Only