pqopen-lib 0.8.0__tar.gz → 0.8.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pqopen-lib
3
- Version: 0.8.0
3
+ Version: 0.8.1
4
4
  Summary: A power quality processing library for calculating parameters from waveform data
5
5
  Project-URL: Homepage, https://github.com/DaqOpen/pqopen-lib
6
6
  Project-URL: Issues, https://github.com/DaqOpen/pqopen-lib/issues
@@ -672,13 +672,8 @@ class PowerSystem(object):
672
672
  self._calculation_mode = "FALLBACK"
673
673
  else:
674
674
  self._calculation_mode = "NORMAL"
675
-
676
- # Remove Non monotonic rising zero crossings
677
- filtered_zero_crossings = []
678
- for idx,zc in enumerate(zero_crossings):
679
- if (int(zc)+start_acq_sidx) >= self._zero_crossings[-1] or np.isnan(self._zero_crossings[-1]):
680
- filtered_zero_crossings.append(zc)
681
- return filtered_zero_crossings
675
+
676
+ return zero_crossings
682
677
 
683
678
  def get_aggregated_data(self, start_acq_sidx: int, stop_acq_sidx: int) -> dict:
684
679
  """
@@ -48,6 +48,7 @@ class ZeroCrossDetector:
48
48
  self._last_zc_p = None
49
49
  self._last_zc_n = None
50
50
  self._last_zc_n_val = None
51
+ self._last_zc = None
51
52
 
52
53
  # Calculate the filter delay in samples
53
54
  w, h = signal.freqz(self._filter_coeff[0], self._filter_coeff[1], worN=[self.f_cutoff], fs=self.samplerate)
@@ -111,9 +112,15 @@ class ZeroCrossDetector:
111
112
  k = (y2 - y1) / (x2 - x1)
112
113
  d = y1 - k * x1
113
114
  real_zc = -d/k
114
- #real_zc = (threshold_p_cross[p_idx] - threshold_n_cross[n_idx] + 1) / 2 + threshold_n_cross[n_idx]
115
- zero_crossings.append(real_zc + self.filter_delay_samples)
116
- last_used_p_idx = p_idx
115
+ if np.isnan(real_zc):
116
+ logger.warning("Detection Error: real_zc is NaN, ignoring")
117
+ else:
118
+ if self._last_zc and (real_zc <= self._last_zc):
119
+ logger.warning("Detected ZC before last one, ignoring")
120
+ else:
121
+ zero_crossings.append(real_zc + self.filter_delay_samples)
122
+ last_used_p_idx = p_idx
123
+ self._last_zc = real_zc
117
124
 
118
125
  # Update the last negative threshold-crossing for the next block
119
126
  if last_used_p_idx < len(threshold_p_cross) and len(threshold_n_cross) > 0:
@@ -126,4 +133,8 @@ class ZeroCrossDetector:
126
133
  else:
127
134
  self._last_zc_n = None
128
135
 
136
+ # Update Last Valid ZC Index
137
+ if self._last_zc:
138
+ self._last_zc -= len(data)
139
+
129
140
  return zero_crossings
@@ -12,7 +12,7 @@ packages = ["pqopen"]
12
12
 
13
13
  [project]
14
14
  name = "pqopen-lib"
15
- version = "0.8.0"
15
+ version = "0.8.1"
16
16
  dependencies = [
17
17
  "numpy",
18
18
  "daqopen-lib",
File without changes
File without changes
File without changes
File without changes
File without changes