space_packet_parser.xtce.calibrators ==================================== .. py:module:: space_packet_parser.xtce.calibrators .. autoapi-nested-parse:: Calibrator definitions Classes ------- .. autoapisummary:: space_packet_parser.xtce.calibrators.Calibrator space_packet_parser.xtce.calibrators.SplinePoint space_packet_parser.xtce.calibrators.SplineCalibrator space_packet_parser.xtce.calibrators.PolynomialCoefficient space_packet_parser.xtce.calibrators.PolynomialCalibrator space_packet_parser.xtce.calibrators.MathOperationCalibrator space_packet_parser.xtce.calibrators.ContextCalibrator Module Contents --------------- .. py:class:: Calibrator Bases: :py:obj:`space_packet_parser.common.AttrComparable`, :py:obj:`space_packet_parser.common.XmlObject` Abstract base class for XTCE calibrators .. py:method:: 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 :classmethod: :abstractmethod: Abstract classmethod to create a default_calibrator object from an XML element. :param element: XML element :type element: ElementTree.Element :param tree: Ignored :type tree: Optional[ElementTree.Element] :param parameter_lookup: Ignored :type parameter_lookup: Optional[dict] :param parameter_type_lookup: Ignored :type parameter_type_lookup: Optional[dict] :param container_lookup: Ignored :type container_lookup: Optional[dict[str, SequenceContainer]] :rtype: Calibrator .. py:method:: calibrate(uncalibrated_value: int | float) -> float :abstractmethod: Takes an integer-encoded or float-encoded value and returns a calibrated version. :param uncalibrated_value: The uncalibrated, raw encoded value :type uncalibrated_value: Union[int, float] :returns: Calibrated value :rtype: float .. py:class:: SplinePoint Bases: :py:obj:`tuple` .. py:attribute:: raw .. py:attribute:: calibrated .. py:class:: SplineCalibrator(points: list, order: int = 0, extrapolate: bool = False) Bases: :py:obj:`Calibrator` .. py:attribute:: order :value: 0 .. py:attribute:: points .. py:attribute:: extrapolate :value: False .. py:method:: 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 :classmethod: Create a spline default_calibrator object from an XML element. :param element: The XML element from which to create the object. :type element: ElementTree.Element :param tree: Ignored :type tree: Optional[ElementTree.Element] :param parameter_lookup: Ignored :type parameter_lookup: Optional[dict] :param parameter_type_lookup: Ignored :type parameter_type_lookup: Optional[dict] :param container_lookup: Ignored :type container_lookup: Optional[dict[str, SequenceContainer]] .. py:method:: to_xml(*, elmaker: lxml.builder.ElementMaker) -> lxml.etree.Element Create a SplineCalibrator XML element :param elmaker: Element factory with predefined namespace :type elmaker: ElementMaker :rtype: ElementTree.Element .. py:method:: calibrate(uncalibrated_value: float) -> float Take an integer-encoded value and returns a calibrated version according to the spline points. :param uncalibrated_value: Query point. :type uncalibrated_value: float :returns: Calibrated value :rtype: float .. py:method:: _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. :param query_point: Query point. :type query_point: float :returns: Calibrated value. :rtype: float .. py:method:: _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. :param query_point: Query point. :type query_point: float :returns: Calibrated value. :rtype: float .. py:class:: PolynomialCoefficient Bases: :py:obj:`tuple` .. py:attribute:: coefficient .. py:attribute:: exponent .. py:class:: PolynomialCalibrator(coefficients: list[PolynomialCoefficient]) Bases: :py:obj:`Calibrator` .. py:attribute:: coefficients .. py:method:: 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 :classmethod: Create a polynomial default_calibrator object from an XML element. :param element: XML element :type element: ElementTree.Element :param tree: Ignored :type tree: Optional[ElementTree.Element] :param parameter_lookup: Ignored :type parameter_lookup: Optional[dict] :param parameter_type_lookup: Ignored :type parameter_type_lookup: Optional[dict] :param container_lookup: Ignored :type container_lookup: Optional[dict[str, SequenceContainer]] .. py:method:: to_xml(elmaker: lxml.builder.ElementMaker) -> lxml.etree.Element Create a PolynomialCalibrator XML element :param elmaker: Element factory with predefined namespace :type elmaker: ElementMaker :rtype: ElementTree.Element .. py:method:: calibrate(uncalibrated_value: float) -> float Evaluate the polynomial defined by object coefficients at the specified uncalibrated point. :param uncalibrated_value: Query point. :type uncalibrated_value: float :returns: Calibrated value :rtype: float .. py:class:: MathOperationCalibrator Bases: :py:obj:`Calibrator` .. py:attribute:: err_msg :value: 'The MathOperationCalibrator element is not supported in this package but pull requests are welcome!' .. py:method:: 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 :classmethod: :abstractmethod: Create a math operation default_calibrator from an XML element. :param element: The XML element from which to create the object. :type element: ElementTree.Element :param tree: Ignored :type tree: Optional[ElementTree.Element] :param parameter_lookup: Ignored :type parameter_lookup: Optional[dict] :param parameter_type_lookup: Ignored :type parameter_type_lookup: Optional[dict] :param container_lookup: Ignored :type container_lookup: Optional[dict[str, SequenceContainer]] :rtype: MathOperationCalibrator .. py:method:: to_xml(elmaker: dict) -> lxml.etree.Element :abstractmethod: Create a MathOperationsCalibrator XML element :param elmaker: XML namespace dict :type elmaker: dict :rtype: ElementTree.Element .. py:method:: calibrate(uncalibrated_value: int) :abstractmethod: Stub :param uncalibrated_value: .. py:class:: ContextCalibrator(match_criteria: list, calibrator: Calibrator) Bases: :py:obj:`space_packet_parser.common.AttrComparable`, :py:obj:`space_packet_parser.common.XmlObject` .. py:attribute:: match_criteria .. py:attribute:: calibrator .. py:method:: get_context_match_criteria(element: lxml.etree.Element) -> list[space_packet_parser.xtce.comparisons.MatchCriteria] :staticmethod: Parse contextual requirements from a Comparison, ComparisonList, or BooleanExpression :param element: XML element from which to parse the ContextCalibrator object. :type element: ElementTree.Element :returns: List of Comparisons that can be evaluated to determine whether this calibrator should be used. :rtype: List[MatchCriteria] .. py:method:: 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 :classmethod: Create a ContextCalibrator object from an XML element :param element: XML element from which to parse the ContextCalibrator object. :type element: ElementTree.Element :param tree: Ignored :type tree: Optional[ElementTree.Element] :param parameter_lookup: Ignored :type parameter_lookup: Optional[dict] :param parameter_type_lookup: Ignored :type parameter_type_lookup: Optional[dict] :param container_lookup: Ignored :type container_lookup: Optional[dict[str, SequenceContainer]] :rtype: cls .. py:method:: to_xml(*, elmaker: lxml.builder.ElementMaker) -> lxml.etree.Element Create a MathOperationsCalibrator XML element :param elmaker: Element factory with predefined namespace :type elmaker: ElementMaker :rtype: ElementTree.Element .. py:method:: calibrate(parsed_value: int | float) -> float Wrapper method for the internal `Calibrator.calibrate` :param parsed_value: Uncalibrated value. :type parsed_value: Union[int, float] :returns: Calibrated value :rtype: float