space_packet_parser.xtce.calibrators
Calibrator definitions
Classes
Abstract base class for XTCE calibrators |
|
<xtce:SplineCalibrator> |
|
<xtce:PolynomialCalibrator> |
|
<xtce:MathOperationCalibrator> |
|
<xtce:ContextCalibrator> |
Module Contents
- class space_packet_parser.xtce.calibrators.Calibrator
Bases:
space_packet_parser.common.AttrComparable,space_packet_parser.common.XmlObjectAbstract base class for XTCE calibrators
- classmethod from_xml(element: lxml.etree.Element, *, tree: lxml.etree.Element | None = None, parameter_lookup: dict[str, any] | None = None, parameter_type_lookup: dict[str, any] | None = None, container_lookup: dict[str, any] | None = None) Calibrator
- Abstractmethod:
Abstract classmethod to create a default_calibrator object from an XML element.
- Parameters:
element (ElementTree.Element) – XML element
tree (Optional[ElementTree.Element]) – Ignored
parameter_lookup (Optional[dict]) – Ignored
parameter_type_lookup (Optional[dict]) – Ignored
container_lookup (Optional[dict[str, SequenceContainer]]) – Ignored
- Return type:
- abstract calibrate(uncalibrated_value: int | float) float
Takes an integer-encoded or float-encoded value and returns a calibrated version.
- Parameters:
uncalibrated_value (Union[int, float]) – The uncalibrated, raw encoded value
- Returns:
Calibrated value
- Return type:
float
- class space_packet_parser.xtce.calibrators.SplineCalibrator(points: list, order: int = 0, extrapolate: bool = False)
Bases:
Calibrator<xtce:SplineCalibrator>
- order = 0
- points
- extrapolate = False
- classmethod from_xml(element: lxml.etree.Element, *, tree: lxml.etree.Element | None = None, parameter_lookup: dict[str, any] | None = None, parameter_type_lookup: dict[str, any] | None = None, container_lookup: dict[str, any] | None = None) SplineCalibrator
Create a spline default_calibrator object from an <xtce:SplineCalibrator> XML element.
- Parameters:
element (ElementTree.Element) – The XML element from which to create the object.
tree (Optional[ElementTree.Element]) – Ignored
parameter_lookup (Optional[dict]) – Ignored
parameter_type_lookup (Optional[dict]) – Ignored
container_lookup (Optional[dict[str, SequenceContainer]]) – Ignored
- to_xml(*, elmaker: lxml.builder.ElementMaker) lxml.etree.Element
Create a SplineCalibrator XML element
- Parameters:
elmaker (ElementMaker) – Element factory with predefined namespace
- Return type:
ElementTree.Element
- calibrate(uncalibrated_value: float) float
Take an integer-encoded value and returns a calibrated version according to the spline points.
- Parameters:
uncalibrated_value (float) – Query point.
- Returns:
Calibrated value
- Return type:
float
- _zero_order_spline_interp(query_point: float) float
Abstraction for zero order spline interpolation. If extrapolation is set to a truthy value, we use the nearest point to extrapolate outside the range of the given spline points. Within the range of spline points, we use nearest lower point interpolation.
- Parameters:
query_point (float) – Query point.
- Returns:
Calibrated value.
- Return type:
float
- _first_order_spline_interp(query_point: float) float
Abstraction for first order spline interpolation. If extrapolation is set to a truthy value, we use the end points to make a linear function and use it to extrapolate.
- Parameters:
query_point (float) – Query point.
- Returns:
Calibrated value.
- Return type:
float
- class space_packet_parser.xtce.calibrators.PolynomialCoefficient
Bases:
tuple- coefficient
- exponent
- class space_packet_parser.xtce.calibrators.PolynomialCalibrator(coefficients: list[PolynomialCoefficient])
Bases:
Calibrator<xtce:PolynomialCalibrator>
- coefficients
- classmethod from_xml(element: lxml.etree.Element, *, tree: lxml.etree.Element | None = None, parameter_lookup: dict[str, any] | None = None, parameter_type_lookup: dict[str, any] | None = None, container_lookup: dict[str, any] | None = None) PolynomialCalibrator
Create a polynomial default_calibrator object from an <xtce:PolynomialCalibrator> XML element.
- Parameters:
element (ElementTree.Element) – <xtce:PolynomialCalibrator> XML element
tree (Optional[ElementTree.Element]) – Ignored
parameter_lookup (Optional[dict]) – Ignored
parameter_type_lookup (Optional[dict]) – Ignored
container_lookup (Optional[dict[str, SequenceContainer]]) – Ignored
- to_xml(elmaker: lxml.builder.ElementMaker) lxml.etree.Element
Create a PolynomialCalibrator XML element
- Parameters:
elmaker (ElementMaker) – Element factory with predefined namespace
- Return type:
ElementTree.Element
- calibrate(uncalibrated_value: float) float
Evaluate the polynomial defined by object coefficients at the specified uncalibrated point.
- Parameters:
uncalibrated_value (float) – Query point.
- Returns:
Calibrated value
- Return type:
float
- class space_packet_parser.xtce.calibrators.MathOperationCalibrator
Bases:
Calibrator<xtce:MathOperationCalibrator>
- err_msg = 'The MathOperationCalibrator element is not supported in this package but pull requests are welcome!'
- classmethod from_xml(element: lxml.etree.Element, *, tree: lxml.etree.Element | None = None, parameter_lookup: dict[str, any] | None = None, parameter_type_lookup: dict[str, any] | None = None, container_lookup: dict[str, any] | None = None) MathOperationCalibrator
- Abstractmethod:
Create a math operation default_calibrator from an <xtce:MathOperationCalibrator> XML element.
- Parameters:
element (ElementTree.Element) – The XML element from which to create the object.
tree (Optional[ElementTree.Element]) – Ignored
parameter_lookup (Optional[dict]) – Ignored
parameter_type_lookup (Optional[dict]) – Ignored
container_lookup (Optional[dict[str, SequenceContainer]]) – Ignored
- Return type:
- abstract to_xml(elmaker: dict) lxml.etree.Element
Create a MathOperationsCalibrator XML element
- Parameters:
elmaker (dict) – XML namespace dict
- Return type:
ElementTree.Element
- abstract calibrate(uncalibrated_value: int)
Stub
- Parameters:
uncalibrated_value
- class space_packet_parser.xtce.calibrators.ContextCalibrator(match_criteria: list, calibrator: Calibrator)
Bases:
space_packet_parser.common.AttrComparable,space_packet_parser.common.XmlObject<xtce:ContextCalibrator>
- match_criteria
- calibrator
- static get_context_match_criteria(element: lxml.etree.Element) list[space_packet_parser.xtce.comparisons.MatchCriteria]
Parse contextual requirements from a Comparison, ComparisonList, or BooleanExpression
- Parameters:
element (ElementTree.Element) – <xtce:ContextCalibrator> XML element from which to parse the ContextCalibrator object.
- Returns:
List of Comparisons that can be evaluated to determine whether this calibrator should be used.
- Return type:
List[MatchCriteria]
- classmethod from_xml(element: lxml.etree.Element, *, tree: lxml.etree.Element | None = None, parameter_lookup: dict[str, any] | None = None, parameter_type_lookup: dict[str, any] | None = None, container_lookup: dict[str, any] | None = None) ContextCalibrator
Create a ContextCalibrator object from an <xtce:ContextCalibrator> XML element
- Parameters:
element (ElementTree.Element) – <xtce:ContextCalibrator> XML element from which to parse the ContextCalibrator object.
tree (Optional[ElementTree.Element]) – Ignored
parameter_lookup (Optional[dict]) – Ignored
parameter_type_lookup (Optional[dict]) – Ignored
container_lookup (Optional[dict[str, SequenceContainer]]) – Ignored
- Return type:
cls
- to_xml(*, elmaker: lxml.builder.ElementMaker) lxml.etree.Element
Create a MathOperationsCalibrator XML element
- Parameters:
elmaker (ElementMaker) – Element factory with predefined namespace
- Return type:
ElementTree.Element
- calibrate(parsed_value: int | float) float
Wrapper method for the internal Calibrator.calibrate
- Parameters:
parsed_value (Union[int, float]) – Uncalibrated value.
- Returns:
Calibrated value
- Return type:
float