Interpolate
The interpolate command resamples data onto a new uniform grid using cubic spline interpolation. This is a destructive operation — the original axis and data values are replaced.
(Note that the original data file remains unchanged; only the in-memory dataset is modified.)
Basic Usage
interpolate <range> <--interval <step> | --number <n>> [options]
where:
<range>defines the new axis limits- Either
--intervalor--numberspecifies grid spacing (exactly one required)
Command Options
| Option | Description |
|---|---|
<range> | Range for the new interpolated axis (required). See range specification for details. |
--interval <step> | Fixed step size for the new axis (mutually exclusive with --number). Must include units. |
--number <n> | Number of evenly-spaced points in the new axis (mutually exclusive with --interval). |
--axis <axis> | Axis column for interpolation (auto-inferred from range units if omitted). |
--domain <domain> | Domain in which to interpolate (auto-inferred if omitted). Options: reciprocal, fourier. |
Interpolation Method
EstraPy uses cubic spline interpolation (degree 3) via scipy.interpolate.make_interp_spline. This provides:
- Smooth, continuous curves through existing data points
- C² continuity (smooth first and second derivatives)
- Minimal oscillation between points
Examples
# Interpolate to 0.5 eV steps over 8000-9000 eV
interpolate 8000eV 9000eV --interval 0.5eV
# Interpolate to exactly 500 points in k-space
interpolate 3k 15k --number 500
# Fine r-space grid with 0.01 Å spacing
interpolate 0A 6A --interval 0.01A --domain fourier
# Explicit axis specification
interpolate 0 1000 --number 2000 --axis E --domain reciprocal
Behavior
The command:
- Creates a new uniform axis within
[range[0], range[1]]with specified spacing or count - Interpolates all data columns onto this new axis using cubic splines
- Replaces the domain’s data with interpolated values
Destructive operation: Original axis values and data are replaced with interpolated results. The original data file remains unchanged; only the in-memory dataset is modified. Interpolation cannot add information — it only resamples existing data, and may introduce noise or artifacts if the original data is sparse or noisy.
Use Cases
- Uniform grids: Convert irregularly-spaced data to fixed intervals
- Alignment: Resample multiple scans to identical grids before averaging
- Upsampling: Increase point density for smoother plots (cosmetic only)
- Downsampling: Reduce point count while preserving overall shape
Tips and Best Practices
- Avoid excessive upsampling: Interpolation does not improve resolution or add real information
- Preserve Nyquist limits: When downsampling, ensure the new interval captures all spectral features
- Check endpoint behavior: Cubic splines may oscillate near range boundaries if data is noisy
- Pre-filter noise: Consider using
rebininstead if your goal is noise reduction
Comparison with Rebin
| Feature | interpolate | rebin |
|---|---|---|
| Method | Cubic spline fitting | Binning + averaging |
| Noise reduction | No | Yes (averages reduce noise) |
| Speed | Moderate | Fast |
| Use case | Resampling to new grid | Noise reduction + downsampling |
See also: