peakingduck.core module¶
-
class
peakingduck.core.
ChunkedSimplePeakFinder
(threshold=0.05, nchunks=10)[source]¶ Bases:
PEAKINGDUCK.core.IPeakFinder
Breaks the spectrum up into nchunks applying the threshold relative to that chunk
-
class
peakingduck.core.
ChunkedThresholdPeakFilter
¶ Bases:
PEAKINGDUCK.core.IProcess
Simple threshold local/chunked peak filter
-
class
peakingduck.core.
GlobalThresholdPeakFilter
¶ Bases:
PEAKINGDUCK.core.IProcess
Simple threshold global peak filter
-
class
peakingduck.core.
Histogram
¶ Bases:
pybind11_builtins.pybind11_object
Represents a basic 1D histogram
Energies vs values.
-
property
X
¶
-
property
Y
¶
-
property
-
class
peakingduck.core.
HistogramChannelBased
¶ Bases:
pybind11_builtins.pybind11_object
Represents a basic 1D histogram
Channels vs values.
-
property
X
¶
-
property
Y
¶
-
property
-
class
peakingduck.core.
IPeakFinder
¶ Bases:
pybind11_builtins.pybind11_object
Interface for peak finding algorithms
Operates on numerical data (filtered or unfiltered). Never mutates the input (always const process).
- Returns
A list of peaks
- Return type
PeakList
-
find
(self: PEAKINGDUCK.core.IPeakFinder, arg0: PEAKINGDUCK.core.NumericalData) → List[PEAKINGDUCK.core.PeakInfo]¶ Identifies potential peaks in the data
-
class
peakingduck.core.
IProcess
¶ Bases:
pybind11_builtins.pybind11_object
Interface for all process algorithms
Operates on numerical data. Never mutates the input (always const process).
- Returns
A new numerical array.
-
go
(self: PEAKINGDUCK.core.IProcess, arg0: PEAKINGDUCK.core.NumericalData) → PEAKINGDUCK.core.NumericalData¶
-
class
peakingduck.core.
IProcessManager
¶ Bases:
pybind11_builtins.pybind11_object
A general process manager interface
-
append
(self: PEAKINGDUCK.core.IProcessManager, arg0: PEAKINGDUCK.core.IProcess) → PEAKINGDUCK.core.IProcessManager¶
-
reset
(self: PEAKINGDUCK.core.IProcessManager) → None¶
-
run
(self: PEAKINGDUCK.core.IProcessManager, arg0: PEAKINGDUCK.core.NumericalData) → PEAKINGDUCK.core.NumericalData¶
-
-
class
peakingduck.core.
IntegerData
¶ Bases:
pybind11_builtins.pybind11_object
Represents a 1-dimensional data structure of ints (basically a 1D Eigen array)
Dynamic array - most use cases will be determined at runtime (I am assuming). We don’t want anyone to know we are using Eigen beyond this file, since (in theory) it should make it easier to change library if need be. We only really need the array datastructure from Eigen and not much else and instead of reinventing the wheel, we wrap Eigen array.
We wrap this with private inheritance on the Eigen type but there are a lot of methods to expose, easy to add when/if we need them.
Eigen array is pretty good, it has things like sqrt, exp on array coefficients, but we need to extend this to other functions, so we use CRTP to do this.
For all of this, you may ask why not just use Eigen and use an alias? Well for one, we don’t need all of Eigen just the array, and not all of the array type (we require a simpler interface). Additionally, at some point we may wish to use another data structure as std::array for example. In this case we just change the NumericalData class to wrap that instead. If we change the alias this could break existing interfaces and APIs, causing big changes later on. Since this datastructure is fundamental to everything we need to make sure that we have this sorted properly first!
-
from_list
(self: PEAKINGDUCK.core.IntegerData, arg0: List[int]) → None¶
-
maxCoeff
(self: PEAKINGDUCK.core.IntegerData) → int¶
-
minCoeff
(self: PEAKINGDUCK.core.IntegerData) → int¶
-
ramp
(self: PEAKINGDUCK.core.IntegerData, arg0: int) → PEAKINGDUCK.core.IntegerData¶ A simple function for filtering values above a certain threshold (>=). This is useful to remove entries that are negative for example.
- Returns
A new array.
-
rampInPlace
(self: PEAKINGDUCK.core.IntegerData, arg0: int) → PEAKINGDUCK.core.IntegerData¶ A simple function for filtering values above a certain threshold (>=). This is useful to remove entries that are negative for example.
Mutates underlyindg data.
-
reverse
(self: PEAKINGDUCK.core.IntegerData) → numpy.ndarray[int32[m, 1]]¶
-
reverseInPlace
(self: PEAKINGDUCK.core.IntegerData) → None¶
-
slice
(self: PEAKINGDUCK.core.IntegerData, arg0: int, arg1: int) → PEAKINGDUCK.core.IntegerData¶
-
sum
(self: PEAKINGDUCK.core.IntegerData) → int¶
-
to_list
(self: PEAKINGDUCK.core.IntegerData) → List[int]¶
-
-
class
peakingduck.core.
MovingAveragePeakFilter
¶ Bases:
PEAKINGDUCK.core.IProcess
Simple moving average peak filter
-
class
peakingduck.core.
MovingAverageSmoother
¶ Bases:
PEAKINGDUCK.core.IProcess
Simple moving average smoother
Can we support windowsize given at compile time too? It would certainly help with unit tests.
-
class
peakingduck.core.
NumericalData
¶ Bases:
pybind11_builtins.pybind11_object
Represents a 1-dimensional data structure of floats (basically a 1D Eigen array)
Dynamic array - most use cases will be determined at runtime (I am assuming). We don’t want anyone to know we are using Eigen beyond this file, since (in theory) it should make it easier to change library if need be. We only really need the array datastructure from Eigen and not much else and instead of reinventing the wheel, we wrap Eigen array.
We wrap this with private inheritance on the Eigen type but there are a lot of methods to expose, easy to add when/if we need them.
Eigen array is pretty good, it has things like sqrt, exp on array coefficients, but we need to extend this to other functions, so we use CRTP to do this.
For all of this, you may ask why not just use Eigen and use an alias? Well for one, we don’t need all of Eigen just the array, and not all of the array type (we require a simpler interface). Additionally, at some point we may wish to use another data structure as std::array for example. In this case we just change the NumericalData class to wrap that instead. If we change the alias this could break existing interfaces and APIs, causing big changes later on. Since this datastructure is fundamental to everything we need to make sure that we have this sorted properly first!
-
LLS
(self: PEAKINGDUCK.core.NumericalData) → PEAKINGDUCK.core.NumericalData¶ log(log(sqrt(value + 1) + 1) + 1)
- Returns
A new array.
-
LLSInPlace
(self: PEAKINGDUCK.core.NumericalData) → PEAKINGDUCK.core.NumericalData¶ log(log(sqrt(value + 1) + 1) + 1)
Changes the underlying array.
-
exp
(self: PEAKINGDUCK.core.NumericalData) → numpy.ndarray[float64[m, 1]]¶
-
from_list
(self: PEAKINGDUCK.core.NumericalData, arg0: List[float]) → None¶
-
inverseLLS
(self: PEAKINGDUCK.core.NumericalData) → PEAKINGDUCK.core.NumericalData¶ exp(exp(sqrt(value + 1) + 1) + 1)
- Returns
A new array.
-
inverseLLSInPlace
(self: PEAKINGDUCK.core.NumericalData) → PEAKINGDUCK.core.NumericalData¶ exp(exp(sqrt(value + 1) + 1) + 1)
Changes the underlying array.
-
log
(self: PEAKINGDUCK.core.NumericalData) → numpy.ndarray[float64[m, 1]]¶
-
maxCoeff
(self: PEAKINGDUCK.core.NumericalData) → float¶
-
mean
(self: PEAKINGDUCK.core.NumericalData) → float¶
-
midpoint
(self: PEAKINGDUCK.core.NumericalData, arg0: int) → PEAKINGDUCK.core.NumericalData¶ For each element calculate the midpoint value from the adjacent elements at a given order.
Take the i-order point and the i+order point and determine the average = (array[i-j]+array[i+j])/2.0. End points are not counted (stay as original) - max(0, i-j) and min(i+j, len(array))
Examples
- Given an array: [1, 4, 6, 2, 4, 2, 5]
we have the midpoints for order 0: [1, 4, 6, 2, 4, 2, 5]
we have the midpoints for order 1: [1, 3.5, 3, 5, 2, 4.5, 5]
we have the midpoints for order 2: [1, 4, 2.5, 3, 5.5, 2, 5]
we have the midpoints for order 3: [1, 4, 6, 3, 4, 2, 5]
we have the midpoints for order 4+: [1, 4, 6, 2, 4, 2, 5]
- Returns
A new array.
-
midpointInPlace
(self: PEAKINGDUCK.core.NumericalData, arg0: int) → PEAKINGDUCK.core.NumericalData¶ For each element calculate the midpoint value from the adjacent elements at a given order.
Mutates underlying array.
-
minCoeff
(self: PEAKINGDUCK.core.NumericalData) → float¶
-
pow
(self: PEAKINGDUCK.core.NumericalData, arg0: float) → numpy.ndarray[float64[m, 1]]¶
-
ramp
(self: PEAKINGDUCK.core.NumericalData, arg0: float) → PEAKINGDUCK.core.NumericalData¶ A simple function for filtering values above a certain threshold (>=). This is useful to remove entries that are negative for example.
- Returns
A new array.
-
rampInPlace
(self: PEAKINGDUCK.core.NumericalData, arg0: float) → PEAKINGDUCK.core.NumericalData¶ A simple function for filtering values above a certain threshold (>=). This is useful to remove entries that are negative for example.
Mutates underlyindg data.
-
reverse
(self: PEAKINGDUCK.core.NumericalData) → numpy.ndarray[float64[m, 1]]¶
-
reverseInPlace
(self: PEAKINGDUCK.core.NumericalData) → None¶
-
slice
(self: PEAKINGDUCK.core.NumericalData, arg0: int, arg1: int) → PEAKINGDUCK.core.NumericalData¶
-
snip
(*args, **kwargs)¶ Overloaded function.
snip(self: PEAKINGDUCK.core.NumericalData, arg0: List[int]) -> PEAKINGDUCK.core.NumericalData
Sensitive Nonlinear Iterative Peak (SNIP) algorithm for estimating backgrounds
ref needed here:
Allows any form of iterations given an iterator
- Returns:
A new array.
snip(self: PEAKINGDUCK.core.NumericalData, niterations: int = 20) -> PEAKINGDUCK.core.NumericalData
Sensitive Nonlinear Iterative Peak (SNIP) algorithm for estimating backgrounds ref needed here.
Does via increasing window only (ToDo: need to allow decreasing window)
Deprecate this!
- Returns:
A new array.
-
sqrt
(self: PEAKINGDUCK.core.NumericalData) → numpy.ndarray[float64[m, 1]]¶
-
square
(self: PEAKINGDUCK.core.NumericalData) → numpy.ndarray[float64[m, 1]]¶
-
stddev
(self: PEAKINGDUCK.core.NumericalData, ddof: int = 0) → float¶
-
sum
(self: PEAKINGDUCK.core.NumericalData) → float¶
-
to_list
(self: PEAKINGDUCK.core.NumericalData) → List[float]¶
-
-
class
peakingduck.core.
PeakInfo
¶ Bases:
pybind11_builtins.pybind11_object
Simple struct for holding peak info.
-
value
¶ value, i.e. count or flux.
-
index
¶ the corresponding index/channel of the data.
-
property
index
¶
-
property
value
¶
-
-
class
peakingduck.core.
PySimpleProcessManager
(processes=None)[source]¶ Bases:
PEAKINGDUCK.core.IProcessManager
Instead of using the C++ SimpleProcessManager we make a python native version to avoid ref counting issues
Easy to extend also.
-
class
peakingduck.core.
SavitzkyGolaySmoother
(windowsize, order=2)[source]¶ Bases:
PEAKINGDUCK.core.IProcess
-
class
peakingduck.core.
ScipyPeakFinder
(threshold=2.0, smoothsize=1001)[source]¶ Bases:
PEAKINGDUCK.core.IPeakFinder
Wrapper for scipy peak finder
TODO: pass smoother to constructor not just window size
-
class
peakingduck.core.
SimplePeakFinder
¶ Bases:
PEAKINGDUCK.core.IPeakFinder
-
find
(self: PEAKINGDUCK.core.SimplePeakFinder, arg0: PEAKINGDUCK.core.NumericalData) → List[PEAKINGDUCK.core.PeakInfo]¶
-
-
class
peakingduck.core.
SimpleProcessManager
¶ Bases:
PEAKINGDUCK.core.IProcessManager
A simple process manager
-
append
(self: PEAKINGDUCK.core.SimpleProcessManager, arg0: PEAKINGDUCK.core.IProcess) → PEAKINGDUCK.core.IProcessManager¶
-
reset
(self: PEAKINGDUCK.core.SimpleProcessManager) → None¶
-
run
(self: PEAKINGDUCK.core.SimpleProcessManager, arg0: PEAKINGDUCK.core.NumericalData) → PEAKINGDUCK.core.NumericalData¶
-
-
class
peakingduck.core.
SpectrumChannelBased
¶ Bases:
PEAKINGDUCK.core.HistogramChannelBased
Represents a basic 1D histogram
Channels vs values.
-
estimateBackground
(self: PEAKINGDUCK.core.SpectrumChannelBased, arg0: List[int]) → PEAKINGDUCK.core.NumericalData¶
-
removeBackground
(self: PEAKINGDUCK.core.SpectrumChannelBased, arg0: List[int]) → None¶
-
-
class
peakingduck.core.
SpectrumEnergyBased
¶ Bases:
PEAKINGDUCK.core.Histogram
Represents a basic 1D histogram
Energies vs values.
-
estimateBackground
(self: PEAKINGDUCK.core.SpectrumEnergyBased, arg0: List[int]) → PEAKINGDUCK.core.NumericalData¶
-
removeBackground
(self: PEAKINGDUCK.core.SpectrumEnergyBased, arg0: List[int]) → None¶
-
-
class
peakingduck.core.
WeightedMovingAverageNative
(windowsize)[source]¶ Bases:
PEAKINGDUCK.core.IProcess
We can extend the C++ classes here This is an example
-
go
(data)[source]¶ if N=1, weights=[1] -> [1/N] if N=2, weights=[1,1] -> [1/2, 1/2] if N=3, weights=[1,2,1] -> [1/4, 2/4, 1/4] if N=4, weights=[1,2,2,1] -> [1/6, 2/6, 2/6, 1/6] if N=5, weights=[1,2,3,2,1] -> [1/9, 2/9, 3/9, 2/9, 1/9] ….
weights=[1,2,…, ceil(n/2), …., 2, 1] = [1, …, ceil(n/2)] + [ceil(n/2), …, 1] weights = weights/sum(weights)
-
-
class
peakingduck.core.
WeightedMovingAverageSmoother
¶ Bases:
PEAKINGDUCK.core.IProcess
Simple moving average smoother
- Uses weights determined, with windowsize = N
if N=1, weights=[1] -> [1/N]
if N=2, weights=[1,1] -> [1/2, 1/2]
if N=3, weights=[1,2,1] -> [1/4, 2/4, 1/4]
if N=4, weights=[1,2,2,1] -> [1/6, 2/6, 2/6, 1/6]
if N=5, weights=[1,2,3,2,1] -> [1/9, 2/9, 3/9, 2/9, 1/9]
…
-
class
peakingduck.core.
WindowPeakFinder
(threshold=2.0, ninner=0, nouter=40, include_point=False, enforce_maximum=False, use_grad=False)[source]¶ Bases:
PEAKINGDUCK.core.IPeakFinder
A bespoke window method peak finder
-
peakingduck.core.
combine
(arg0: PEAKINGDUCK.core.NumericalData, arg1: PEAKINGDUCK.core.NumericalData) → PEAKINGDUCK.core.NumericalData¶
-
peakingduck.core.
peakwindow
()¶ window(values: PEAKINGDUCK.core.NumericalData, centerindex: int, nouter: int = 5, ninner: int = 0, includeindex: bool = True) -> PEAKINGDUCK.core.NumericalData
-
peakingduck.core.
window
(values: PEAKINGDUCK.core.NumericalData, centerindex: int, nouter: int = 5, ninner: int = 0, includeindex: bool = True) → PEAKINGDUCK.core.NumericalData¶