kopia lustrzana https://github.com/corrscope/corrscope
Don't add slope finder if slope strength is disabled
This makes triggering slightly faster in the usual case where slope triggering is disabled.pull/403/head
rodzic
7b4910fd1e
commit
9d2a55e6d1
|
@ -409,20 +409,23 @@ class CorrelationTrigger(MainTrigger):
|
||||||
step *= windows.gaussian(self.A + self.B, std=self.A / 3)
|
step *= windows.gaussian(self.A + self.B, std=self.A / 3)
|
||||||
return step
|
return step
|
||||||
|
|
||||||
def _calc_slope_finder(self, period: float) -> np.ndarray:
|
def _calc_slope_finder(self, period: float) -> Optional[np.ndarray]:
|
||||||
"""Called whenever period changes substantially.
|
"""Called whenever period changes substantially.
|
||||||
Returns a kernel to be correlated with input data to find positive slopes,
|
Returns a kernel to be correlated with input data to find positive slopes,
|
||||||
with length A+B."""
|
with length A+B."""
|
||||||
|
|
||||||
slope_finder = np.zeros(self.A + self.B)
|
|
||||||
|
|
||||||
cfg = self.cfg
|
cfg = self.cfg
|
||||||
slope_width = max(iround(cfg.slope_width * period), 1)
|
if cfg.slope_strength:
|
||||||
slope_strength = cfg.slope_strength * cfg.buffer_falloff
|
slope_finder = np.zeros(self.A + self.B)
|
||||||
|
|
||||||
slope_finder[self.A - slope_width : self.A] = -slope_strength
|
slope_width = max(iround(cfg.slope_width * period), 1)
|
||||||
slope_finder[self.A : self.A + slope_width] = slope_strength
|
slope_strength = cfg.slope_strength * cfg.buffer_falloff
|
||||||
return slope_finder
|
|
||||||
|
slope_finder[self.A - slope_width : self.A] = -slope_strength
|
||||||
|
slope_finder[self.A : self.A + slope_width] = slope_strength
|
||||||
|
return slope_finder
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
# end setup
|
# end setup
|
||||||
|
|
||||||
|
@ -482,7 +485,8 @@ class CorrelationTrigger(MainTrigger):
|
||||||
# array[A+B] Amplitude
|
# array[A+B] Amplitude
|
||||||
corr_kernel: np.ndarray = self._corr_buffer * self.cfg.buffer_strength
|
corr_kernel: np.ndarray = self._corr_buffer * self.cfg.buffer_strength
|
||||||
corr_kernel += self._edge_finder
|
corr_kernel += self._edge_finder
|
||||||
corr_kernel += slope_finder
|
if slope_finder is not None:
|
||||||
|
corr_kernel += slope_finder
|
||||||
|
|
||||||
# Don't pick peaks more than `period * trigger_radius_periods` away from the
|
# Don't pick peaks more than `period * trigger_radius_periods` away from the
|
||||||
# center.
|
# center.
|
||||||
|
|
Ładowanie…
Reference in New Issue