space_packet_parser.calibrators

Calibrator definitions

Attributes

SplinePoint

PolynomialCoefficient

Classes

Calibrator

Abstract base class for XTCE calibrators

SplineCalibrator

<xtce:SplineCalibrator>

PolynomialCalibrator

<xtce:PolynomialCalibrator>

MathOperationCalibrator

<xtce:MathOperationCalibrator>

ContextCalibrator

<xtce:ContextCalibrator>

Module Contents

class space_packet_parser.calibrators.Calibrator

Bases: space_packet_parser.comparisons.AttrComparable

Abstract base class for XTCE calibrators

classmethod from_calibrator_xml_element(element: lxml.etree.Element, ns: dict) Calibrator
Abstractmethod:

Abstract classmethod to create a default_calibrator object from an XML element.

Parameters:
  • element (ElementTree.Element) – XML element

  • ns (dict) – XML namespace dict

Return type:

cls

abstract calibrate(uncalibrated_value: int | float) int | 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:

Union[int, float]

space_packet_parser.calibrators.SplinePoint
class space_packet_parser.calibrators.SplineCalibrator(points: list, order: int = 0, extrapolate: bool = False)

Bases: Calibrator

<xtce:SplineCalibrator>

_order_mapping
order
points
extrapolate
classmethod from_calibrator_xml_element(element: lxml.etree.Element, ns: dict) SplineCalibrator

Create a spline default_calibrator object from an <xtce:SplineCalibrator> XML 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

space_packet_parser.calibrators.PolynomialCoefficient
class space_packet_parser.calibrators.PolynomialCalibrator(coefficients: list)

Bases: Calibrator

<xtce:PolynomialCalibrator>

coefficients
classmethod from_calibrator_xml_element(element: lxml.etree.Element, ns: dict) PolynomialCalibrator

Create a polynomial default_calibrator object from an <xtce:PolynomialCalibrator> XML element.

Parameters:
  • element (ElementTree.Element) – <xtce:PolynomialCalibrator> XML element

  • ns (dict) – Namespace dict

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.calibrators.MathOperationCalibrator

Bases: Calibrator

<xtce:MathOperationCalibrator>

err_msg = 'The MathOperationCalibrator element is not supported in this package but pull requests are welcome!'
classmethod from_calibrator_xml_element(element: lxml.etree.Element, ns: dict) MathOperationCalibrator
Abstractmethod:

Create a math operation default_calibrator from an <xtce:MathOperationCalibrator> XML element.

abstract calibrate(uncalibrated_value: int)

Stub

Parameters:

uncalibrated_value

class space_packet_parser.calibrators.ContextCalibrator(match_criteria: list, calibrator: Calibrator)

Bases: space_packet_parser.comparisons.AttrComparable

<xtce:ContextCalibrator>

match_criteria
calibrator
static get_context_match_criteria(element: lxml.etree.Element, ns: dict) List[space_packet_parser.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.

  • ns (dict) – Namespace dict for XML parsing

Returns:

List of Comparisons that can be evaluated to determine whether this calibrator should be used.

Return type:

List[MatchCriteria]

classmethod from_context_calibrator_xml_element(element: lxml.etree.Element, ns: dict) 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.

  • ns (dict) – Namespace dict for XML parsing

Return type:

cls

calibrate(parsed_value: int | float) int | float

Wrapper method for the internal Calibrator.calibrate

Parameters:

parsed_value (Union[int, float]) – Uncalibrated value.

Returns:

Calibrated value

Return type:

Union[int, float]