hec.parameter
Provides parameter info and operations
Comprises the classes:
Base Parameter Definitions
The tab separated variable file resources/base_parameters.tsv in this module's installation provides the following information about base parameters.
| Field No. | Content | Type | Notes |
|---|---|---|---|
| 1 | Base Parameter Identifier | String | Required |
| 2 | Long Name | String | Required |
| 3 | Description | String | Required |
| 4 | Default English Unit | String | Required |
| 5 | Default SI Unit | String | Required |
| 6 | Parameter is Accumuatable Over Time | Boolean | Required |
| 7 | Integrated Base Parameter | String | Optional. Base Parameter of integrating the base parameter in Field 1 over time |
| 8 | Differentiated Base Parameter | String | Optional. Base Parameter of differentiating the base parameter in Field 1 with respect to time |
| 9 | English Differentiation Conversion Factor | Numeric | Required if Field 8 is present. Factor to convert:
|
| 10 | SI Differentiation Conversion Factor | Numeric | Required if Field 8 is present. Factor to convert:
|
Returns a list of base parameter names that are compatible with the specified unit
Arguments:
- unit Union[str, Unit]): The unit to get the compatible parameters for
Returns:
list[str]: The list of compatible base parameter names
Exception specific to Parameter operations
Holds info (name and unit) for a parameter.
See base_parameter_definitions for information on base parameters and their conversions.
Initializer
Arguments:
- name (str): The full parmeter name
- unit_or_system (Optional[str]):
- If
ENorNone, the default English unit for the base parameter will be assigned - if
SI, the default Système International unit for the base parameter will be assigned - Otherwise the specified unit will be assigned
- If
Raises:
- ParameterException: If the parameter name does not contain a valid base parameter name, or if the specified unit is not valid for the parameter
- KeyError: If the specified unit is not a valid unit name, alias or Pint unit definition
Returns a list of base parameter names that can be accumulated over time for the specified context
See base_parameter_definitions for information on base parameters and their conversions.
Arguments:
- context (str): The context for the base parameter names. Currently only "CWMS" is supported. Defaults to "CWMS"
Raises:
- ParameterException: If an invalid context is specified
Returns:
List[str]: A sorted list of names of base parameter that can be integrated over time for the context
The actual base parameter used. Will be same as basename unless the
parameter was created using a parameter alias
Operations:
Read Only
Returns a list of valid base parameter names for the specified context
See base_parameter_definitions for information on base parameters and their conversions.
Arguments:
- context (str): The context for the base parameter names. Currently only "CWMS" is supported. Defaults to "CWMS"
Raises:
- ParameterException: If an invalid context is specified
Returns:
List[str]: A sorted list of valid base parameter names for the context
The name of the parameter as specified up to any initial '-' character
Operations:
Read Only
Returns a list of base parameter names that can be differentiated with respect to time for the specified context
See base_parameter_definitions for information on base parameters and their conversions.
Arguments:
- context (str): The context for the base parameter names. Currently only "CWMS" is supported. Defaults to "CWMS"
Raises:
- ParameterException: If an invalid context is specified
Returns:
List[str]: A sorted list of names of base parameter that can be differentiated with respect to time for the context
Returns differentiation information for a base parameter name
See base_parameter_definitions for information on base parameters and their conversions.
Arguments:
- base_parameter (str): The base parameter to get the information for.
- context (str): The context for the base parameter names. Currently only "CWMS" is supported. Defaults to "CWMS"
Returns:
dict: A dictionary with the following content: { "base_parameter":
, "EN" : , "SI" : , }
Returns the list of unit names compatible with this parameter's unit
Returns:
list[str]: The list of compatible unit names
Returns a list of base parameter names that can be integrated over time for the specified context
See base_parameter_definitions for information on base parameters and their conversions.
Arguments:
- context (str): The context for the base parameter names. Currently only "CWMS" is supported. Defaults to "CWMS"
Raises:
- ParameterException: If an invalid context is specified
Returns:
List[str]: A sorted list of names of base parameter that can be integrated over time for the context
Assigns a unit to this parameter.
Identical to calling .to(unit_or_system, in_place=True)
Arguments:
- unit_or_system (str):
- If
EN, the default English unit for the base parameter will be assigned - if
SI, the default Système International unit for the base parameter will be assigned - Otherwise the specified unit will be assigned
- If
Raises:
- ParameterException: If the specified unit is not valid for the parameter
Returns:
Parameter: The converted object
The name of the parameter as specified after any initial '-' character
Operations:
Read Only
Assigns a unit to this parameter or a copy of this parameter
Arguments:
- unit_or_system (str):
- If
EN, the default English unit for the base parameter will be assigned - if
SI, the default Système International unit for the base parameter will be assigned - Otherwise the specified unit will be assigned
- If
- in_place (bool, optional): Specifies whether to modify and return this object (True) or a copy of this object (False). Defaults to False.
Raises:
- ParameterException: If the specified unit is not valid for the parameter
Returns:
Parameter: The converted object (self if in_place == True, otherwise a converted copy)
Holds info (name and vertical datum information) for an elevation parameter
Initializes the ElevParameter object
Arguments:
- name (str): The full parameter name
- vertical_datum_info (Union[str, dict[str, Any]]): The vertical datum info as an xml string or dictionary
Raises:
- ElevParameter.VerticalDatumException: If
vertical datuminfo is invalid - ParameterException: If the base parameter is not 'Elev'
The elevation of this object in the current datum and unit
Operations:
Read Only
Returns the offset from the current vertical datum to the specified target datum in the current unit.
Arguments:
- target_datum (str): The target datum
Raises:
- ElevParameter.VerticalDatumException: If the target datum is invalid or the object does not specify an offset to the target datum
Returns:
Optional[UnitQuantity]: The offset from the current datum to the target datum or
Noneif the current and target datums are the same.
Converts this object to the specified unit or vertical datum and returns it.
Identical to calling .to(unit_or_system_or_datum, in_place=True
Arguments:
- unit_or_system_or_datum (Union[str, Unit]): The unit, unit_system, or vertical datum to convert to. If unit system ("EN" or "SI"), the default Elev unit for that system is used.
Returns:
ElevParameter: The converted object, whether this object of a copy of it
The offset from the native datum of this object to NGVD-29, in the current unit, or None if
* the native vertical datum is NGVD-29
* the native vertical datum is not NGVD-29, but the object does not have such an offset
Operations:
Read Only
Whether the offset from the native vertical datum to NGVD-29 is an estimate (e.g, VERTCON)
or None if the native vertical datum is NGVD-29 or the object does not have such and offset
Operations:
Read Only
Converts either this object or a copy of it to the specified unit or vertical datum and returns it
Arguments:
- unit_or_system_or_datum (Union[str, Unit]): The unit, unit_system, or vertical datum to convert to. If unit system ("EN" or "SI"), the default Elev unit for that system is used.
- in_place (bool, optional): If
True, this object is converted and returned, otherwise a copy is converted and returned. Defaults to False.
Returns:
ElevParameter: The converted object, whether this object of a copy of it
The VerticalDatumInfo object of this parameter
Operations:
Read Only
The VerticalDatumInfo object of this parameter as a dictionary
Operations:
Read Only
Exception specific to vertical datum operations
Exception specific to ParameterType operations
Holds info about parameter types.
Parameter types have 3 separate contexts, RAW, CWMS, and DSS. There's not much use for the RAW context except for providing a bridge between the CWMS and DSS contexts. Users would normally work in either the CWMS or DSS context.
The contexts of already-instantiated objects can also be set.
Parameter type names in the different contexts are:
| RAW | CWMS | DSS |
|---|---|---|
| Total | Total | PER-CUM |
| Maximum | Max | PER-MAX |
| Minimum | Min | PER-MIN |
| Constant | Const | CONST |
| Average | Ave | PER-AVER |
| Instantaneous | Inst | INST-CUM (for Precip or Count) |
| INST-VAL (for others) |
Initializes a ParameterType object
Arguments:
- param_type (str): The name of the parameter type
Raises:
- ParameterTypeException: If
param_typeis not one of the values listed in the table above (context-insensitive)
Returns the name of the parameter time for the CWMS context
Returns:
str: The CWMS context name
Returns the name of the parameter time for the DSS context
Arguments:
- is_precip (bool, optional): Whether the parameter type is for a precipitation parameter.
This matters only for the
Instantaneousparameter type (CWMS=Inst). Defaults to False.False:INST-CUMTrue:INST-VAL
Returns:
str: The DSS context name
Returns the name of the parameter time for the RAW context
Returns:
str: The RAW context name
Returns a list of valid parameter type names for the context.
Arguments:
- context (str): The context for the parameter type names. Currently only "RAW", "CWMS", "DSS", and "ALL" are supported.
- If "RAW", the parameter types for all contexts are returned
Raises:
- ParameterTypeException: If an invlid context is specified
Returns:
List[str]: A sorted list of valid parameter type names for the context