MeasurementEditing#
- class MeasurementEditing(datasets)#
Bases:
objectInteractive and automated editing of measurement residuals for orbit determination.
Provides three editing modes:
Lasso Selector — graphically select points to flag as outliers on a plot.
Chi-Squared — automatically flag points whose residuals exceed a chi-squared threshold.
Date Range — manually specify time windows to flag or unflag observations.
- Parameters:
datasets (
listofMeasurementDataSet) – The datasets to edit. Nested lists are flattened one level.
Notes
Edits are non-destructive: original
outlier_flagarrays are copied internally and not written back untilapply_flags()orget_datasets()is called.See also
scarabaeus.FilterDataManagerCombines datasets and applies editing before indexing.
scarabaeus.FilterODBase 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:
datasetsThe list of managed datasets.
outlier_flagsDict of {dataset_name: bool array} of current outlier flags.
Methods
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].
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 (
strorNone) – 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 (
floatorstr) – Start of the window. Either a numeric epoch (seconds) or ISO 8601 string (e.g. “2024-01-01T00:00:00”).t_end (
floatorstr) – End of the window (same format as t_start).dataset_name (
strorNone) – 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:
- 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()withaction='flag'to all target datasets for the entered epoch range.Unflag — apply
date_range_filter()withaction='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.
- 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.
- 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()orget_datasets()has been called).- Return type: