pqopen-lib 0.8.3__tar.gz → 0.8.4__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.3
3
+ Version: 0.8.4
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
@@ -659,7 +659,7 @@ class PowerSystem(object):
659
659
  List[int]: Detected zero-crossing indices.
660
660
  """
661
661
  zcd_data = self._zcd_channel.read_data_by_index(start_idx=start_acq_sidx, stop_idx=stop_acq_sidx)
662
- zero_crossings = self._zero_cross_detector.process(zcd_data)
662
+ zero_crossings = self._zero_cross_detector.process(zcd_data, self._zero_crossings[-1] - start_acq_sidx)
663
663
  if not zero_crossings:
664
664
  if (self._zero_crossings[-1] + self._samplerate/self._zcd_minimum_frequency - self._zero_cross_detector.filter_delay_samples) < stop_acq_sidx:
665
665
  zero_crossings.append(self._zero_crossings[-1] + self._samplerate/self._last_known_freq - start_acq_sidx)
@@ -675,9 +675,10 @@ class PowerSystem(object):
675
675
  if self._last_known_freq < self._zcd_minimum_frequency:
676
676
  self._last_known_freq = self.nominal_frequency
677
677
  self._calculation_mode = "FALLBACK"
678
+ elif self._calculation_mode == "FALLBACK":
679
+ self._calculation_mode = "NORMAL"
678
680
  else:
679
681
  self._calculation_mode = "NORMAL"
680
-
681
682
  return zero_crossings
682
683
 
683
684
  def get_aggregated_data(self, start_acq_sidx: int, stop_acq_sidx: int) -> dict:
@@ -55,7 +55,7 @@ class ZeroCrossDetector:
55
55
  self.filter_delay_samples = np.angle(h)[0] / (2 * np.pi) * self.samplerate / self.f_cutoff - 1 # due to adding sample in front for continuity
56
56
  self.filtered_data = []
57
57
 
58
- def process(self, data: np.ndarray)-> list:
58
+ def process(self, data: np.ndarray, abs_last_zc: int = None)-> list:
59
59
  """
60
60
  Processes a block of input data and detect zero-crossings.
61
61
 
@@ -117,6 +117,8 @@ class ZeroCrossDetector:
117
117
  else:
118
118
  if self._last_zc and (real_zc <= self._last_zc):
119
119
  logger.warning("Detected ZC before last one, ignoring")
120
+ elif (abs_last_zc is not None) and (self._last_zc and (real_zc <= abs_last_zc)):
121
+ logger.warning("Detected ZC before last one, ignoring")
120
122
  else:
121
123
  zero_crossings.append(real_zc + self.filter_delay_samples)
122
124
  last_used_p_idx = p_idx
@@ -12,7 +12,7 @@ packages = ["pqopen"]
12
12
 
13
13
  [project]
14
14
  name = "pqopen-lib"
15
- version = "0.8.3"
15
+ version = "0.8.4"
16
16
  dependencies = [
17
17
  "numpy",
18
18
  "daqopen-lib >= 0.7.4",
@@ -143,6 +143,22 @@ class TestPowerSystemZcd(unittest.TestCase):
143
143
  u_rms, _ = self.power_system.output_channels["U1_1p_rms"].read_data_by_acq_sidx(0, values.size)
144
144
  self.assertIsNone(np.testing.assert_array_almost_equal(u_rms[-10:], expected_u_rms[-10:], 3))
145
145
 
146
+ def test_one_period_calc_temp_fallback(self):
147
+ t = np.linspace(0, 10, int(self.power_system._samplerate)*10, endpoint=False)
148
+ values = np.sqrt(2)*np.sin(2*np.pi*50*t)
149
+
150
+ values[int(self.power_system._samplerate*3):int(self.power_system._samplerate*7)] *= 0
151
+
152
+ expected_u_rms = np.array(np.zeros(48)) + 1.0
153
+
154
+ calc_blocksize = 50
155
+ for i in range(values.size//calc_blocksize):
156
+ self.u_channel.put_data(values[i*calc_blocksize:(i+1)*calc_blocksize])
157
+ self.power_system.process()
158
+ # Check Voltage
159
+ u_rms, _ = self.power_system.output_channels["U1_1p_rms"].read_data_by_acq_sidx(values.size-self.power_system._samplerate, values.size)
160
+ self.assertIsNone(np.testing.assert_array_almost_equal(u_rms[-10:], expected_u_rms[-10:], 3))
161
+
146
162
  class TestPowerSystemCalculation(unittest.TestCase):
147
163
  def setUp(self):
148
164
  self.u_channel = AcqBuffer()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes