Glitch Removal

The deglitch command detects and corrects local artifacts (glitches) in reciprocal-domain data. It is composed of two parts:

  1. a finder subcommand, used to flag glitch points
  2. a remover subcommand, used to apply the correction

Basic Usage

deglitch [range] <finder ...> <remover ...>

where:

  • [range] is an optional range of two numbers
  • <finder ...> chooses how glitches are detected
  • <remover ...> chooses how flagged points are handled

If [range] is omitted, the command operates on the full available axis range.

Command Options

Option Description
[range] Optional two-value range where detection is performed. See range for syntax details.
--kweight <value>
-k <value>
Non-negative k-weight parameter (default: 0.0).

Finder Subcommands

The finder decides which points are marked as glitches.

Finder Description
force Selects the whole given region as glitch.
polynomial Fits a polynomial in the selected region, then flags points whose residual is above a threshold from --pvalue.
point <position> Flags a single point within the selected region (closest sample to position).
even Estimates noise from even/odd differences and flags points above the noise threshold.

Finder-specific options

polynomial

deglitch [range] polynomial [options] <remover ...>
Option Description
--degree <n>
-d <n>
Polynomial degree (required).
--constant
-C
Degree 0.
--linear
-l
Degree 1.
--quadratic
-q
Degree 2.
--cubic
-c
Degree 3.
--pvalue <value>
-p <value>
Statistical threshold for glitch detection (default: 0.0002).
--axis <axis> Axis used for fitting (auto-inferred if omitted).
--column <col>
--col <col>
Data column used for fitting (default: I0).

point

deglitch [range] point <position> <remover ...>

<position> accepts eV or k units and flags the closest sample point.

This finder can be used to remove a known bad point. The range can be omitted, as the position is sufficient to identify the target point.

deglitch point 8333eV remove

even

deglitch [range] even [options] <remover ...>
Option Description
--column <col>
--col <col>
Data column used to estimate noise (default: I0).
--pvalue <value>
-p <value>
Statistical threshold for glitch detection (default: 0.0002).
--median-window <n> Median window size control (default: 1).

Remover Subcommands

The remover applies the correction to points flagged by the finder.

Remover Description
remove Removes all flagged points from the dataset.
interpolate Replaces flagged points by interpolation over neighboring non-glitch points.

Examples

# Force-remove all points in a narrow region
deglitch 8.2k 8.4k force remove

# Polynomial finder with interpolation
deglitch -50eV 250eV polynomial --linear --pvalue 0.001 interpolate

# Remove a single known bad point
deglitch point 8333eV remove

# Even/odd noise-based detection with interpolation
deglitch even --pvalue 0.0005 --median-window 2 interpolate

Notes

  • remove is irreversible because flagged rows are deleted.
  • interpolate preserves row count and updates data columns with interpolated values.
  • If a finder flags too many points, revise the range and threshold before applying removal.

See also: