diff --git a/src/luminol/algorithms/correlator_algorithms/cross_correlator.py b/src/luminol/algorithms/correlator_algorithms/cross_correlator.py index 0bbbb00..5c08b88 100644 --- a/src/luminol/algorithms/correlator_algorithms/cross_correlator.py +++ b/src/luminol/algorithms/correlator_algorithms/cross_correlator.py @@ -26,15 +26,15 @@ def __init__(self, time_series_a, time_series_b, max_shift_seconds=None, shift_i Initializer :param TimeSeries time_series_a: TimeSeries a. :param TimeSeries time_series_b: TimeSeries b. - :param int max_shift_milliseconds: allowed maximal shift seconds. + :param int max_shift_seconds: allowed maximal shift seconds. :param time_period: if given, correlate the data inside the time period only. """ super(CrossCorrelator, self).__init__(self.__class__.__name__, time_series_a, time_series_b) self.shift_impact = shift_impact or DEFAULT_SHIFT_IMPACT if max_shift_seconds is not None: - self.max_shift_milliseconds = max_shift_seconds + self.max_shift_seconds = max_shift_seconds else: - self.max_shift_milliseconds = DEFAULT_ALLOWED_SHIFT_SECONDS * 1000 + self.max_shift_seconds = DEFAULT_ALLOWED_SHIFT_SECONDS def _detect_correlation(self): """ @@ -73,8 +73,8 @@ def _detect_correlation(self): r = s / denom if denom != 0 else s correlations.append([delay_in_seconds, r]) # Take shift into account to create a "shifted correlation coefficient". - if self.max_shift_milliseconds: - shifted_correlations.append(r * (1 + float(delay_in_seconds) / self.max_shift_milliseconds * self.shift_impact)) + if self.max_shift_seconds: + shifted_correlations.append(r * (1 + float(delay_in_seconds) / self.max_shift_seconds * self.shift_impact)) else: shifted_correlations.append(r) max_correlation = list(max(correlations, key=lambda k: k[1])) @@ -84,13 +84,13 @@ def _detect_correlation(self): def _find_allowed_shift(self, timestamps): """ - Find the maximum allowed shift steps based on max_shift_milliseconds. + Find the maximum allowed shift steps based on max_shift_seconds. param list timestamps: timestamps of a time series. """ init_ts = timestamps[0] residual_timestamps = [ts - init_ts for ts in timestamps] n = len(residual_timestamps) - return self._find_first_bigger(residual_timestamps, self.max_shift_milliseconds, 0, n) + return self._find_first_bigger(residual_timestamps, self.max_shift_seconds, 0, n) def _find_first_bigger(self, timestamps, target, lower_bound, upper_bound): """