convolve¶
- tayph.convolve(array, kernel, edge_degree=1, fit_width=2)[source] [edit on github]¶
It’s unbelievable, but I could not find the python equivalent of IDL’s /edge_truncate keyword, which truncates the kernel at the edge of the convolution. Therefore, unfortunately, I need to code a convolution operation myself. Stand by to be slowed down by an order of magnitude #thankspython.
Nope! Because I can just use np.convolve for most of the array, just not the edge…
So the strategy is to extrapolate the edge of the array using a polynomial fit to the edge elements. By default, I fit over a range that is twice the length of the kernel; but this value can be modified using the fit_width parameter.
In rare cases, the polynomial fit doesn’t converge. In this case, the fit_width is automatically increased by one (see Issue #99).
This function assumes that array is free of NaN values.
- Parameters
- arraylist, np.ndarray
The horizontal axis.
- kernellist, np.ndarray
The convolution kernel. It is required to have a length that is less than 25% of the size of the array.
- edge_degreeint
The polynomial degree by which the array is extrapolated in order to
- fit_widthint
The length of the area at the edges of array used to fit the polynomial, in units of the length of the kernel. Increase this number for small kernels or noisy arrays.
- Returns
- ——-
- array_convolvednp.array
The input array convolved with the kernel