resample_linear¶
Resample a spectrum onto a uniform wavelength grid by linear interpolation.
| Category | Resampling |
| Backend | numpy - implemented here on top of numpy primitives |
| Version | 2.1.0 |
| Reads | ctx.spectrum (a Spectrum1D) |
| Writes | spectrum |
Linear interpolation is fast and adequate when the target sampling is similar to the source. For large changes in resolution prefer a flux-conserving method. v2.0.0 — uncertainty propagation : σ_out = sqrt(interp(σ²)), the linear interpolation of the VARIANCE onto the new grid (v1.x interpolated σ itself, which is not a propagation rule). For an output sample at fraction t between two inputs the exact variance of the interpolant is (1−t)² σ_a² + t² σ_b² ≤ (1−t) σ_a² + t σ_b², so the per-sample value is conservative ; the covariance between neighbouring output samples (they share input samples, and oversampling duplicates information) is NOT tracked, which under-states the errors of anything fitted to the resampled spectrum. Without an input uncertainty the brick is unchanged. v2.1.0 — oversampling: the grid holds round((npix − 1) · oversampling) + 1 samples over the same bounds, i.e. oversampling output samples per input sample (2 doubles the sampling, 0.5 halves it) ; mutually exclusive with step and n_points. The step, n_points and default paths are byte-identical to 2.0.0.
Parameters¶
| Parameter | Default | Required | Description |
|---|---|---|---|
wavelength_min |
None |
- | Lower bound of the new grid (Å); null keeps the input minimum. |
wavelength_max |
None |
- | Upper bound of the new grid (Å); null keeps the input maximum. |
step |
None |
- | Constant sampling step (Å). Mutually exclusive with n_points. |
n_points |
None |
- | Number of samples in the new grid. Mutually exclusive with step. |
oversampling |
None |
- | Output samples per input sample: the grid holds round((npix - 1) * oversampling) + 1 samples over the same bounds. Mutually exclusive with step and n_points. |
Use it¶
References¶
- numpy.interp — piecewise-linear interpolation
- For large resolution changes, prefer flux-conserving resampling (specutils.manipulation.FluxConservingResampler)
- Bevington & Robinson 2003, Data Reduction and Error Analysis for the Physical Sciences, 3rd ed., McGraw-Hill — §3.2, variance of a linear combination.
Related algorithms¶
resample_flux_conserving- Resample onto a new wavelength grid while preserving integrated flux.