escope.peakx module
- class escope.peakx.ENDTYPE
Bases:
object- DROP_PARTIAL = 0
- BROKEN_PARTIAL = 1
- INCLUDE_PARTIAL = 2
- escope.peakx.schmitt(data: ndarray, thr_on: float | None = None, thr_off: float | None = None, endtype: int = 2, starttype: int = 1) Tuple[array, array]
Schmitt trigger of a continuous process
Parameters
- data
The data to trawl for threshold crossings
- thr_on
The upward threshold. If not given, defaults to 2/3.
- thr_off
The downward threshold. If not given, defaults to ½ thr_on
- endtype
If DATA is high at the end, the last downward crossing will be len(DATA). This optional argument modifies this behavior:
If set to ENDTYPE.DROP_PARTIAL (0), the last upward crossing is ignored if there is no following downward crossing.
If set to ENDTYPE.BROKEN_PARTIAL (1), the last upward crossing may be reported without a corresponding downward crossing, so the two return values do not have the same length.
- starttype
If DATA is high at the beginning, the first ION value will be 0. This optional argument modifies this behavior:
If set to STARTTYPE.DROP_PARTIAL (0), such a “partial peak” is dropped.
Returns
- ion
The indices where DATA crosses up through thr_on coming from below thr_off
- ioff
The indices where DATA crosses down through thr_off coming from above thr_on
- escope.peakx.schmitt2(data: array, thr_a: float, thr_b: float) Tuple[array, array, array, array]
Double Schmitt triggering
Arguments
- data
The data to trawl for threshold crossings
- thr_a
The “high” threshold
- thr_b
The “low” threshold
Returns
- on_a
the up crossings through thr_a
- off_a
the down crossings through thr_a
- on_b
the up crossings through thr_b
- off_b
the down corssings through thr_b
Notes
It is required that THR_B < THR_A.
There are two equivalent ways to think about the result:
on_a, off_a are the up and down crossings through thr_a; on_b, off_b are the up and down crossings through thr_b.
on_a, off_a describe the broadest possible peak above thr_a; on_b, off_b describe the narrowest possible peak above thr_b. (But on_b, off_b describe wider peaks than on_a, off_a, since thr_b < thr_a.)
A peak that exceeds thr_b but never exceeds thr_a is not reported.
- escope.peakx.schmittpeak(data: array, iup: array, idn: array) array
Find peaks in data after Schmitt triggering
Arguments
- data
The data to trawl for threshold crossings
- ion
The indices where DATA crosses up through thr_on coming from below thr_off, as returned by a previous call to schmitt
- ioff
The indices where DATA crosses down through thr_off coming from above thr_on, as returned by a previous call to schmitt
Returns
Indices of peaks between pairs of upward and downward threshold crossings.
Notes
To avoid partial peaks at the beginning and end of data, consider using starttype = STARTTYPE.DROP_PARTIAL and/or endtype = ENDTYPE.DROP_PARTIAL when calling schmitt.