MeasurementSpec#
- class MeasurementSpec(model: Any = None, observed_meas: Any = None, epochs: Any = None, dataset_name: str | None = None, file_label: str | None = None, _items: tuple | None = None)#
Bases:
objectSpecification of one or more measurement datasets for filtering.
This class can represent either a single measurement specification (leaf mode) or a container of multiple
MeasurementSpecobjects (container mode). In both cases, the object is iterable and yields dictionaries compatible with the Scarabaeus filtering API.- model#
Measurement model instance (e.g., RangeIdeal, RangeRateIdeal, AngularIdeal).
- Type:
Any
- observed_meas#
Observed measurement quantities as returned by the measurement model.
- Type:
Any
- epochs#
Epochs corresponding to the observed measurements (used in covariance analysis where actual observations are not required).
- Type:
Any
- _items#
Internal container holding multiple
MeasurementSpecobjects. If set, this instance acts as a container and yields each contained spec when iterated.- Type:
tupleofMeasurementSpec, optional
Notes
A
MeasurementSpecoperates in two modes:Leaf mode — represents one dataset; iteration yields a single dictionary
{"model": ..., "observed_meas": ..., "dataset_name": ...}.Container mode — wraps multiple leaf specs; iteration yields one dictionary per contained spec.
Both modes are accepted wherever the filtering pipeline expects a list of measurement dictionaries, providing backward compatibility with the legacy
list[dict]interface.Examples
Single measurement dataset:
spec = MeasurementSpec( model=RangeIdeal(...), observed_meas=y_range, dataset_name="DSN Range", )
Multiple datasets (container mode):
spec = MeasurementSpec.many( MeasurementSpec(model=range_model, ...), MeasurementSpec(model=rangerate_model, ...), )
Legacy dict interface:
spec = MeasurementSpec.from_dict(meas_dict) spec = MeasurementSpec.from_dicts(list_of_dicts)
- Attributes:
- dataset_name
- epochs
- file_label
- model
- observed_meas
Methods
from_dict(d)Create a MeasurementSpec from a dictionary or list of dictionaries.
from_dicts(dicts)Construct a container spec from an iterable of measurement dictionaries.
many(*specs)Create a container spec holding multiple MeasurementSpec objects.
to_dict()Convert the MeasurementSpec instance to a dictionary representation.
to_list()Convert the MeasurementSpec object to a list of measurement dictionaries.
- classmethod from_dict(d)#
Create a MeasurementSpec from a dictionary or list of dictionaries.
- Parameters:
d (
dictorlistortuple) – A dictionary with measurement specification data, or a list/tuple of such dictionaries to create a container spec.- Returns:
A single spec if d is a dict; a container spec if d is a list or tuple.
- Return type:
- Raises:
KeyError – If required keys
"model"or"dataset_name"are missing.
Examples
>>> spec = MeasurementSpec.from_dict({ ... "model": range_model, ... "observed_meas": y_range, ... "dataset_name": "DSN Range", ... "file_label": "dsn_range.json", ... })
- classmethod from_dicts(dicts: Iterable[Dict[str, Any]]) MeasurementSpec#
Construct a container spec from an iterable of measurement dictionaries.
- Parameters:
dicts (
iterableofdict) – Each dict must satisfy the same requirements as the argument tofrom_dict().- Returns:
A container spec equivalent to
MeasurementSpec.many(*specs).- Return type:
- classmethod many(*specs: MeasurementSpec) MeasurementSpec#
Create a container spec holding multiple MeasurementSpec objects.
- Parameters:
*specs (
MeasurementSpec) – One or more individualMeasurementSpecinstances to group.- Returns:
A container instance whose iteration yields one dict per spec.
- Return type:
- to_dict() Dict[str, Any]#
Convert the MeasurementSpec instance to a dictionary representation.
Returns a dictionary containing the model, dataset_name, and either observed_meas or epochs (but not both). Optionally includes file_label if it is set.
- Returns:
A dictionary with keys
"model","dataset_name", either"observed_meas"or"epochs", and optionally"file_label".- Return type:
- Raises:
TypeError – If
_itemsis notNone(container mode cannot be converted to a single dict).ValueError – If both
observed_measandepochsareNone, or if both are set.