Resampling (sofia_redux.toolkit.resampling
)¶
Introduction¶
The sofia_redux.toolkit.resampling
module allows the local fitting of polynomials
to N-dimensional data for resampling.
Samples (coordinates with associated value) are passed into the
Resample
class during initialization, and then resampled onto second
set of coordinates (points) during a call to the Resample
instance.
The resample()
function acts as wrapper on Resample
to directly
resample from a set of samples to points.
Numba¶
The numba package is used heavily to achieve C
performance using JIT (just-in-time) compilation. As a result, the initial
call to Resample
will introduce additional overhead while any JIT code
compiles. Compilation results are stored in a cache for future use so that
this overhead burden is only encountered once. For example:
>>> import numpy as np
>>> from sofia_redux.toolkit.resampling import Resample
>>> import time
>>> x = np.arange(10)
>>> y = np.arange(10)
>>> resampler = Resample(x, y)
>>> t1 = time.time()
>>> y2 = resampler(4.5)
>>> t2 = time.time()
>>> y2 = resampler(4.5)
>>> t3 = time.time()
>>> print("The 1st run-through took %.6f seconds" % (t2 - t1)) #doctest: +SKIP
The 1st run-through took 0.018941 seconds
>>> print("The 2nd run-through took %.6f seconds" % (t3 - t2)) #doctest: +SKIP
The 2nd run-through took 0.001095 seconds