pqopen-lib 0.7.2__tar.gz → 0.7.3__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.7.2
3
+ Version: 0.7.3
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
@@ -493,13 +493,13 @@ class PowerSystem(object):
493
493
  if "w_pos" in self._calc_channels["multi_period"]["energy"]:
494
494
  prev_w_pos_value = self._calc_channels["multi_period"]["energy"]["w_pos"].last_sample_value
495
495
  energy = (stop_sidx - start_sidx)/self._samplerate/3600*p_sum if p_sum > 0 else 0.0 # Energy in Wh
496
- self._calc_channels["multi_period"]["energy"]["w_pos"].put_data_single(stop_sidx, prev_w_pos_value + energy)
496
+ self._calc_channels["multi_period"]["energy"]["w_pos"].put_data_single(stop_sidx, prev_w_pos_value + float(energy))
497
497
 
498
498
  # Calculate Negative Energy
499
499
  if "w_neg" in self._calc_channels["multi_period"]["energy"]:
500
500
  prev_w_neg_value = self._calc_channels["multi_period"]["energy"]["w_neg"].last_sample_value
501
501
  energy = -(stop_sidx - start_sidx)/self._samplerate/3600*p_sum if p_sum < 0 else 0.0 # Energy in Wh
502
- self._calc_channels["multi_period"]["energy"]["w_neg"].put_data_single(stop_sidx, prev_w_neg_value + energy)
502
+ self._calc_channels["multi_period"]["energy"]["w_neg"].put_data_single(stop_sidx, prev_w_neg_value + float(energy))
503
503
 
504
504
  # Calculate unbalance (3-phase)
505
505
  if "unbal_0" in self._calc_channels["multi_period"]["voltage"]:
@@ -12,7 +12,7 @@ packages = ["pqopen"]
12
12
 
13
13
  [project]
14
14
  name = "pqopen-lib"
15
- version = "0.7.2"
15
+ version = "0.7.3"
16
16
  dependencies = [
17
17
  "numpy",
18
18
  "daqopen-lib",
@@ -451,6 +451,37 @@ class TestPowerSystemCalculationThreePhase(unittest.TestCase):
451
451
  p_neg, sidx = self.power_system.output_channels["P_neg"].read_data_by_acq_sidx(0, u1_values.size)
452
452
  self.assertIsNone(np.testing.assert_allclose(p_neg, expected_p_neg, rtol=0.01))
453
453
 
454
+ def test_energy_calc_pos_highoffset(self):
455
+ t = np.linspace(0, 1, int(self.power_system._samplerate), endpoint=False)
456
+ u1_values = 1.0*np.sqrt(2)*np.sin(2*np.pi*50*t)
457
+ u2_values = 1.0*np.sqrt(2)*np.sin(2*np.pi*50*t - 120*np.pi/180)
458
+ u3_values = 1.0*np.sqrt(2)*np.sin(2*np.pi*50*t + 120*np.pi/180)
459
+ i1_values = 1.0*np.sqrt(2)*np.sin(2*np.pi*50*t)
460
+ i2_values = 1.0*np.sqrt(2)*np.sin(2*np.pi*50*t -120*np.pi/180)
461
+ i3_values = 1.0*np.sqrt(2)*np.sin(2*np.pi*50*t+ 120*np.pi/180)
462
+
463
+ Path(SCRIPT_DIR+"/data_files/energy.json").write_text(json.dumps({"W_pos": 1_000_000.1, "W_neg": 10}))
464
+
465
+ expected_w_pos = np.array([1, 2, 3, 4])*3*0.2/3600 + 1_000_000.1
466
+ expected_w_neg = np.array([1, 2, 3, 4])*0.0/3600 + 10
467
+
468
+ self.power_system.enable_energy_channels(Path(SCRIPT_DIR+"/data_files/energy.json"))
469
+ self.u1_channel.put_data(u1_values)
470
+ self.u2_channel.put_data(u2_values)
471
+ self.u3_channel.put_data(u3_values)
472
+
473
+ self.i1_channel.put_data(i1_values)
474
+ self.i2_channel.put_data(i2_values)
475
+ self.i3_channel.put_data(i3_values)
476
+
477
+ self.power_system.process()
478
+
479
+ # Check Energy W_pos
480
+ w_pos, sidx = self.power_system.output_channels["W_pos"].read_data_by_acq_sidx(0, u1_values.size)
481
+ self.assertIsNone(np.testing.assert_array_almost_equal(w_pos, expected_w_pos))
482
+ w_neg, sidx = self.power_system.output_channels["W_neg"].read_data_by_acq_sidx(0, u1_values.size)
483
+ self.assertIsNone(np.testing.assert_array_almost_equal(w_neg, expected_w_neg))
484
+
454
485
  class TestPowerSystemNperSync(unittest.TestCase):
455
486
  def setUp(self):
456
487
  self.u_channel = AcqBuffer()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes