lezargus.library.stitch module#
Stitch spectra, images, and cubes together.
Stitching spectra, images, and cubes consistently, while keeping all of the pitfalls in check, is not trivial. We group these three stitching functions, and the required spin-off functions, here.
- lezargus.library.stitch.stitch_spectra_functional(wavelength_functions: list[Callable[[numpy.ndarray], numpy.ndarray]], data_functions: list[Callable[[numpy.ndarray], numpy.ndarray]], uncertainty_functions: list[Callable[[numpy.ndarray], numpy.ndarray]], weight_functions: list[Callable[[numpy.ndarray], numpy.ndarray]], average_routine: Callable[[ndarray, ndarray, ndarray], tuple[float, float]] = None, reference_points: ndarray = None) tuple[Callable[[numpy.ndarray], numpy.ndarray], Callable[[numpy.ndarray], numpy.ndarray], Callable[[numpy.ndarray], numpy.ndarray]] [source]#
Stitch spectra functions together.
We take functional forms of the wavelength, data, uncertainty, and weight (in the form of f(wave) = result), and determine the average spectra. We assume that the all of the functional forms properly handle any bounds, gaps, and interpolative limits. The input lists of functions should be parallel and all of them should be of the same (unit) scale.
For more information, the formal method is described in [[TODO]].
- Parameters:
wavelength_functions (list[Callable]) – The list of the wavelength function. The inputs to these functions should be the wavelength.
data_functions (list[Callable]) – The list of the data function. The inputs to these functions should be the wavelength.
uncertainty_functions (list[Callable]) – The list of the uncertainty function. The inputs to these functions should be the wavelength.
weight_functions (list[Callable]) – The list of the weight function. The weights are passed to the averaging routine to properly weight the average.
average_routine (Callable, default = None) – The averaging function. It must be able to support the propagation of uncertainties and weights. As such, it should have the form of \(f(x, \sigma, w) = \bar{x} \pm \sigma\). If None, we used a standard weighted average.
reference_points (ndarray, default = None) –
The reference points which we are going to evaluate the above functions at. The values should be of the same (unit) scale as the input of the above functions. If None, we default to a uniformly distributed set:
\[\left\{ x \in \mathbb{R}, N=10^6 \;|\; 0.30 \leq x \leq 5.50 \right\}\]Otherwise, we use the points provided. We remove any non-finite points and sort.
- Returns:
average_wavelength_function (Callable) – The functional form of the average wavelength.
average_data_function (Callable) – The functional form of the average data.
average_uncertainty_function (Callable) – The functional form of the propagated uncertainties.