MeasurementEditing#

class MeasurementEditing(datasets)#

Bases: object

Interactive and automated editing of measurement residuals for orbit determination.

Provides three editing modes:

  1. Lasso Selector — graphically select points to flag as outliers on a plot.

  2. Chi-Squared — automatically flag points whose residuals exceed a chi-squared threshold.

  3. Date Range — manually specify time windows to flag or unflag observations.

Parameters:

datasets (list of MeasurementDataSet) – The datasets to edit. Nested lists are flattened one level.

Notes

Edits are non-destructive: original outlier_flag arrays are copied internally and not written back until apply_flags() or get_datasets() is called.

See also

scarabaeus.FilterDataManager

Combines datasets and applies editing before indexing.

scarabaeus.FilterOD

Base filter that consumes the edited datasets.

Examples

editor = MeasurementEditing(datasets)
editor.lasso_editor(dataset_name="DSN_Range")
editor.chi_squared_filter(sigma_scale=3.0)
editor.date_range_filter("2024-01-01T00:00:00", "2024-01-05T12:00:00")
edited_datasets = editor.get_datasets()
Attributes:
datasets

The list of managed datasets.

outlier_flags

Dict of {dataset_name: bool array} of current outlier flags.

Methods

apply_flags()

Write the edited outlier_flag arrays back into each dataset's data dict.

chi_squared_filter([dataset_name, ...])

Automatically flag measurements whose normalised residuals exceed a chi-squared threshold.

date_range_filter(t_start, t_end[, ...])

Flag or unflag all measurements whose time falls within [t_start, t_end].

get_datasets()

Apply flags and return the list of edited datasets.

interactive_date_range([dataset_name])

Open an interactive GUI for manual date-range flagging and unflagging.

lasso_editor(dataset_name[, x_field, ...])

Open an interactive matplotlib figure for lasso-based outlier selection.

reset([dataset_name])

Clear all outlier flags.

summary()

Print a per-dataset summary of flagged vs. total measurements.

apply_flags()#

Write the edited outlier_flag arrays back into each dataset’s data dict. Call this when satisfied with edits, before passing datasets to the filter.

chi_squared_filter(dataset_name: str = None, sigma_scale: float = 3.0, dof: int = 1, preview: bool = True)#

Automatically flag measurements whose normalised residuals exceed a chi-squared threshold.

Criterion: (residual / sigma)^2 > chi2.ppf(1 - alpha, dof) where alpha = 1 - CDF(sigma_scale^2, dof=1) → equivalent to N-sigma.

Parameters:
  • dataset_name (str or None) – Name of the dataset to filter. If None, applies to all datasets.

  • sigma_scale (float) – Equivalent Gaussian sigma multiplier (e.g. 3.0 → 3-sigma rejection).

  • dof (int) – Degrees of freedom for chi-squared distribution (default 1).

  • preview (bool) – If True, show a summary plot before applying flags.

date_range_filter(t_start, t_end, dataset_name: str = None, action: str = 'flag', time_field: str = 't2')#

Flag or unflag all measurements whose time falls within [t_start, t_end].

Parameters:
  • t_start (float or str) – Start of the window. Either a numeric epoch (seconds) or ISO 8601 string (e.g. “2024-01-01T00:00:00”).

  • t_end (float or str) – End of the window (same format as t_start).

  • dataset_name (str or None) – Dataset to apply to. None → all datasets.

  • action (str) – “flag” → mark measurements in window as outliers. “unflag” → remove outlier flag from measurements in window.

  • time_field (str) – Time field to use for comparison (default: ‘t2’).

get_datasets()#

Apply flags and return the list of edited datasets.

Return type:

list of MeasurementDataSet

interactive_date_range(dataset_name: str = None)#

Open an interactive GUI for manual date-range flagging and unflagging.

Displays a residuals scatter plot for the first targeted dataset and provides two text boxes (t_start, t_end) and three buttons:

  • Flag — apply date_range_filter() with action='flag' to all target datasets for the entered epoch range.

  • Unflag — apply date_range_filter() with action='unflag'.

  • Done — close the figure and return.

Both text boxes accept numeric epoch strings (seconds, e.g. "705427200.0") or ISO 8601 date strings (e.g. "2024-01-01T00:00:00").

The plot updates immediately after each Flag/Unflag action to reflect the current outlier state of the first dataset.

Parameters:

dataset_name (str or None) – Dataset to target. If None, all managed datasets are targeted (the plot preview always shows the first one).

lasso_editor(dataset_name: str, x_field: str = 't2', y_field: str = 'residuals', title: str = None)#

Open an interactive matplotlib figure for lasso-based outlier selection.

Left-click drag → draw lasso; enclosed points are toggled as outliers. Button [Confirm] → apply and close. Button [Reset] → clear all flags for this dataset.

Parameters:
  • dataset_name (str) – Name of the dataset to edit (must match MeasurementDataSet.set_name).

  • x_field (str) – Field to use for x-axis (default: ‘t2’).

  • y_field (str) – Field to use for y-axis (default: ‘residuals’).

  • title (str, optional) – Plot title override.

reset(dataset_name: str = None)#

Clear all outlier flags.

Parameters:

dataset_name (str or None) – If None, resets all datasets.

summary()#

Print a per-dataset summary of flagged vs. total measurements.

property datasets: list#

The list of managed datasets.

Returns:

Datasets as stored internally (flags not yet written back unless apply_flags() or get_datasets() has been called).

Return type:

list of MeasurementDataSet

property outlier_flags: dict#

bool array} of current outlier flags.

Type:

Dict of {dataset_name