SignalProcessingTools 1.2.1__tar.gz → 1.2.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.
Files changed (15) hide show
  1. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/PKG-INFO +3 -3
  2. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/SignalProcessingTools/__version__.py +1 -1
  3. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/SignalProcessingTools/time_signal.py +13 -5
  4. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/SignalProcessingTools.egg-info/PKG-INFO +3 -3
  5. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/SignalProcessingTools.egg-info/requires.txt +2 -2
  6. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/setup.cfg +2 -2
  7. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/tests/test_time_signal.py +28 -0
  8. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/ReadMe.md +0 -0
  9. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/SignalProcessingTools/__init__.py +0 -0
  10. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/SignalProcessingTools/space_signal.py +0 -0
  11. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/SignalProcessingTools.egg-info/SOURCES.txt +0 -0
  12. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/SignalProcessingTools.egg-info/dependency_links.txt +0 -0
  13. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/SignalProcessingTools.egg-info/top_level.txt +0 -0
  14. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/pyproject.toml +0 -0
  15. {signalprocessingtools-1.2.1 → signalprocessingtools-1.2.3}/tests/test_space_signal.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SignalProcessingTools
3
- Version: 1.2.1
3
+ Version: 1.2.3
4
4
  Summary: Signal processing tools
5
5
  Author: attr: SignalProcessingTools.__author__
6
6
  Author-email: bruno.zuadacoelho@deltares.nl, aron.noordam@deltares.nl
@@ -13,8 +13,8 @@ Requires-Dist: matplotlib>=3.10
13
13
  Requires-Dist: numpy>=2.2
14
14
  Requires-Dist: scipy>=1.15
15
15
  Provides-Extra: testing
16
- Requires-Dist: pytest>=8.3; extra == "testing"
17
- Requires-Dist: tox>=4.24; extra == "testing"
16
+ Requires-Dist: pytest>=8.0; extra == "testing"
17
+ Requires-Dist: tox>=4.13; extra == "testing"
18
18
 
19
19
  # SignalProcessingTools
20
20
 
@@ -1,3 +1,3 @@
1
1
  __title__ = "SignalProcessingTools"
2
- __version__ = "1.2.1"
2
+ __version__ = "1.2.3"
3
3
  __author__ = "Bruno Zuada Coelho, Aron Noordam"
@@ -191,12 +191,22 @@ class TimeSignalProcessing:
191
191
  nfft = self.window_size
192
192
  sig = self.signal
193
193
  odd_length = False
194
+ normalise_fct = np.sum(self.window)
194
195
  else:
195
196
  # if nb_points is None: nb_points is signal length
196
197
  if nb_points is None:
197
198
  nfft = len(self.signal)
198
199
  sig = self.signal
199
200
  odd_length = False
201
+ normalise_fct = np.sum(self.window)
202
+ else:
203
+ nfft = nb_points
204
+ sig = np.zeros(nfft)
205
+ sig[:len(self.signal)] = self.signal
206
+ odd_length = False
207
+ self.window = np.ones(nfft)
208
+ self.window_size = nfft
209
+ normalise_fct = len(self.signal)
200
210
 
201
211
  # if length is even
202
212
  if nfft % 2 != 0:
@@ -206,11 +216,6 @@ class TimeSignalProcessing:
206
216
  self.window_size = nfft
207
217
  odd_length = True
208
218
 
209
- # Normalize by the sum of the window samples.
210
- # This compensates for the energy reduction caused by non-rectangular windows, aiming to preserve the
211
- # peak amplitude of stationary sinusoids.
212
- normalise_fct = np.sum(self.window)
213
-
214
219
  spectrum_w = np.zeros((nfft, self.nb_windows), dtype="complex128")
215
220
  hop_size = int(self.window_size * (1 - 0.5))
216
221
 
@@ -224,6 +229,9 @@ class TimeSignalProcessing:
224
229
  signal_w = self.window * sig[idx_ini:idx_end]
225
230
 
226
231
  # fft window signal
232
+ # Normalize by the sum of the window samples.
233
+ # This compensates for the energy reduction caused by non-rectangular windows, aiming to preserve the
234
+ # peak amplitude of stationary sinusoids.
227
235
  spectrum_w[:, w] = np.fft.fft(signal_w, nfft) / normalise_fct
228
236
 
229
237
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SignalProcessingTools
3
- Version: 1.2.1
3
+ Version: 1.2.3
4
4
  Summary: Signal processing tools
5
5
  Author: attr: SignalProcessingTools.__author__
6
6
  Author-email: bruno.zuadacoelho@deltares.nl, aron.noordam@deltares.nl
@@ -13,8 +13,8 @@ Requires-Dist: matplotlib>=3.10
13
13
  Requires-Dist: numpy>=2.2
14
14
  Requires-Dist: scipy>=1.15
15
15
  Provides-Extra: testing
16
- Requires-Dist: pytest>=8.3; extra == "testing"
17
- Requires-Dist: tox>=4.24; extra == "testing"
16
+ Requires-Dist: pytest>=8.0; extra == "testing"
17
+ Requires-Dist: tox>=4.13; extra == "testing"
18
18
 
19
19
  # SignalProcessingTools
20
20
 
@@ -3,5 +3,5 @@ numpy>=2.2
3
3
  scipy>=1.15
4
4
 
5
5
  [testing]
6
- pytest>=8.3
7
- tox>=4.24
6
+ pytest>=8.0
7
+ tox>=4.13
@@ -22,8 +22,8 @@ python_requires = >=3.10
22
22
 
23
23
  [options.extras_require]
24
24
  testing =
25
- pytest>=8.3
26
- tox>=4.24
25
+ pytest>=8.0
26
+ tox>=4.13
27
27
 
28
28
  [egg_info]
29
29
  tag_build =
@@ -54,6 +54,34 @@ def test_fft(test_data):
54
54
  np.testing.assert_almost_equal(sig.frequency[np.argmax(sig.amplitude[:int(len(sig.amplitude) / 2)])], 2.675, 2)
55
55
  np.testing.assert_almost_equal(np.max(sig.amplitude[:int(len(sig.amplitude) / 2)]), 1.137, 2)
56
56
 
57
+ def test_fft_nb_points(test_data):
58
+ """
59
+ Test the fft function
60
+ """
61
+
62
+ # results half representation
63
+ x, y, _ = test_data
64
+ sig = TimeSignalProcessing(x, y)
65
+ sig.fft(nb_points=2**18)
66
+
67
+ # check if signal lenght has been adapted to window size
68
+ assert len(sig.amplitude) == (2**18)/2
69
+ assert len(sig.frequency) == (2**18)/2
70
+
71
+ np.testing.assert_almost_equal(sig.frequency[np.argmax(sig.amplitude)], FREQ, 2)
72
+ np.testing.assert_almost_equal(np.max(sig.amplitude), AMP, 2)
73
+
74
+ # results full representation
75
+ sig.fft(nb_points=2**18, half_representation=False)
76
+
77
+ # check if signal lenght has been adapted to window size
78
+ assert len(sig.amplitude) == 2**18
79
+ assert len(sig.frequency) == 2**18
80
+
81
+ np.testing.assert_almost_equal(sig.frequency[np.argmax(sig.amplitude[:int(len(sig.amplitude) / 2)])], FREQ, 2)
82
+ np.testing.assert_almost_equal(np.max(sig.amplitude[:int(len(sig.amplitude) / 2)]), AMP / 2, 2)
83
+
84
+
57
85
  def test_fft_window(test_data):
58
86
  """
59
87
  Test the fft function with window