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: object

Specification of one or more measurement datasets for filtering.

This class can represent either a single measurement specification (leaf mode) or a container of multiple MeasurementSpec objects (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

dataset_name#

Human-readable name of the dataset (used for labeling and plotting).

Type:

str

file_label#

Optional label associated with the measurement file on disk.

Type:

str, optional

_items#

Internal container holding multiple MeasurementSpec objects. If set, this instance acts as a container and yields each contained spec when iterated.

Type:

tuple of MeasurementSpec, optional

Notes

A MeasurementSpec operates 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 (dict or list or tuple) – 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:

MeasurementSpec

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 (iterable of dict) – Each dict must satisfy the same requirements as the argument to from_dict().

Returns:

A container spec equivalent to MeasurementSpec.many(*specs).

Return type:

MeasurementSpec

classmethod many(*specs: MeasurementSpec) MeasurementSpec#

Create a container spec holding multiple MeasurementSpec objects.

Parameters:

*specs (MeasurementSpec) – One or more individual MeasurementSpec instances to group.

Returns:

A container instance whose iteration yields one dict per spec.

Return type:

MeasurementSpec

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:

dict

Raises:
  • TypeError – If _items is not None (container mode cannot be converted to a single dict).

  • ValueError – If both observed_meas and epochs are None, or if both are set.

to_list() list#

Convert the MeasurementSpec object to a list of measurement dictionaries.

Returns:

A list of dictionaries, one per contained spec.

Return type:

list