diff --git a/lisainstrument/dynamic_delay_numpy.py b/lisainstrument/dynamic_delay_numpy.py index ee251be03fa1e34b533ed5357595965a761ac9f2..596ed69c698f38afddafce825a94a00fabac9e23 100644 --- a/lisainstrument/dynamic_delay_numpy.py +++ b/lisainstrument/dynamic_delay_numpy.py @@ -1,6 +1,48 @@ """Functions for applying dynamic real-valued shifts to numpy arrays using Lagrange interpolation -Use make_dynamic_shift_lagrange_numpy to create a Lagrange interpolator for numpy arrays. +The main class in this module is DynamicShiftNumpy. It allows to perform a time-shifting +opration on a numpy array, with time-dependent time shift. The main purpose of this +class is for testing another class lisainstrument.dynamic_delay_dask.DynamicShiftDask, +which is equivalent but based on dask arrays instead numpy arrays. Both are supposed to +yield exactly identical results. + +The interpolation method to be used is provided by the user in form of an object +implementing the RegularInterpolator protocol defined in the module +lisainstrument.regular_interpolators. This interpolation engine is based on numpy +arrays. It is used both by DynamicShiftNumpy and DynamicShiftDask for the main work. +The RegularInterpolator protocol is not responsible for setting up boundary conditions, +which is the responsability of DynamicShiftNumpy (and DynamicShiftDask). + +The other parameters that determine the DynamicShiftNumpy behavior are collected +in a class DynShiftCfg. It contains the left and right boundary conditions. The available +options are defined by the ShiftBC enum class. DynShiftCfg also contains limits +for the allowable minimum and maximum time shift. Those have to be supplied by the user +because they cannot be determined from the data in DynamicShiftDask and DynamicShiftNumpy +is required to behave exactly like DynamicShiftDask. + +The convenience functions make_dynamic_shift_lagrange_numpy() and +make_dynamic_shift_linear_numpy() return a DynamicShiftNumpy instance +employing Lagrange or linear interpolation, respectively. + +Example use: + +>>> op = make_dynamic_shift_lagrange_numpy( + order=31, + min_delay=-2., max_delay=21., + left_bound=ShiftBC.FLAT, right_bound=ShiftBC.EXCEPTION + ) +>>> delay = np.linspace(-1.2,20.4,100) +>>> data = np.linspace(0,1, len(delay) +>>> shifted_data = op(data, -delay) + + +Internally, the module works as follows. DynamicShiftNumpy contains a +user-provided RegularInterpolator. The latter can interpolate to points +within the given data, minus a margin size defined by RegularInterpolator +implementations. Before calling RegularInterpolator, DynamicShiftNumpy +extends the data by suitable margins filled according to the selected +boundary conditions. The margin size is computed from the margins needed +by the interpolator as well as the fixed limits specified for the timeshift. """ from __future__ import annotations