pywavelet 0.0.5__tar.gz → 0.1.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. {pywavelet-0.0.5 → pywavelet-0.1.0}/CHANGELOG.rst +19 -0
  2. {pywavelet-0.0.5 → pywavelet-0.1.0}/PKG-INFO +1 -1
  3. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/_version.py +2 -2
  4. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/types/__init__.py +1 -0
  5. pywavelet-0.1.0/src/pywavelet/transforms/types/wavelet_mask.py +34 -0
  6. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/utils.py +17 -5
  7. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet.egg-info/PKG-INFO +1 -1
  8. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet.egg-info/SOURCES.txt +3 -0
  9. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/conftest.py +28 -5
  10. pywavelet-0.1.0/tests/test_lnl.py +32 -0
  11. pywavelet-0.1.0/tests/test_mask.py +51 -0
  12. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/test_snr.py +24 -26
  13. {pywavelet-0.0.5 → pywavelet-0.1.0}/.github/workflows/ci.yml +0 -0
  14. {pywavelet-0.0.5 → pywavelet-0.1.0}/.github/workflows/docs.yml +0 -0
  15. {pywavelet-0.0.5 → pywavelet-0.1.0}/.github/workflows/pypi.yml +0 -0
  16. {pywavelet-0.0.5 → pywavelet-0.1.0}/.gitignore +0 -0
  17. {pywavelet-0.0.5 → pywavelet-0.1.0}/.pre-commit-config.yaml +0 -0
  18. {pywavelet-0.0.5 → pywavelet-0.1.0}/CITATION.cff +0 -0
  19. {pywavelet-0.0.5 → pywavelet-0.1.0}/README.rst +0 -0
  20. {pywavelet-0.0.5 → pywavelet-0.1.0}/docs/_config.yml +0 -0
  21. {pywavelet-0.0.5 → pywavelet-0.1.0}/docs/_static/demo.gif +0 -0
  22. {pywavelet-0.0.5 → pywavelet-0.1.0}/docs/_toc.yml +0 -0
  23. {pywavelet-0.0.5 → pywavelet-0.1.0}/docs/api.rst +0 -0
  24. {pywavelet-0.0.5 → pywavelet-0.1.0}/docs/example.ipynb +0 -0
  25. {pywavelet-0.0.5 → pywavelet-0.1.0}/docs/index.rst +0 -0
  26. {pywavelet-0.0.5 → pywavelet-0.1.0}/docs/logo.png +0 -0
  27. {pywavelet-0.0.5 → pywavelet-0.1.0}/docs/roundtrip_freq.png +0 -0
  28. {pywavelet-0.0.5 → pywavelet-0.1.0}/docs/roundtrip_time.png +0 -0
  29. {pywavelet-0.0.5 → pywavelet-0.1.0}/pyproject.toml +0 -0
  30. {pywavelet-0.0.5 → pywavelet-0.1.0}/setup.cfg +0 -0
  31. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/__init__.py +0 -0
  32. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/logger.py +0 -0
  33. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/__init__.py +0 -0
  34. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/forward/__init__.py +0 -0
  35. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/forward/from_freq.py +0 -0
  36. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/forward/from_time.py +0 -0
  37. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/forward/main.py +0 -0
  38. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/forward/wavelet_bins.py +0 -0
  39. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/inverse/__init__.py +0 -0
  40. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/inverse/main.py +0 -0
  41. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/inverse/to_freq.py +0 -0
  42. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/inverse/to_time.py +0 -0
  43. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/phi_computer.py +0 -0
  44. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/types/common.py +0 -0
  45. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/types/frequencyseries.py +0 -0
  46. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/types/plotting.py +0 -0
  47. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/types/timeseries.py +0 -0
  48. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet/transforms/types/wavelet.py +0 -0
  49. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet.egg-info/dependency_links.txt +0 -0
  50. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet.egg-info/requires.txt +0 -0
  51. {pywavelet-0.0.5 → pywavelet-0.1.0}/src/pywavelet.egg-info/top_level.txt +0 -0
  52. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/test_data/roundtrip_chirp_freq.npz +0 -0
  53. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/test_data/roundtrip_chirp_time.npz +0 -0
  54. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/test_data/roundtrip_pure_f0_freq.npz +0 -0
  55. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/test_data/roundtrip_sine_freq.npz +0 -0
  56. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/test_data/roundtrip_sine_time.npz +0 -0
  57. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/test_phi.py +0 -0
  58. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/test_psd.py +0 -0
  59. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/test_roundtrip_conversion.py +0 -0
  60. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/test_timefreq_type.py +0 -0
  61. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/test_version.py +0 -0
  62. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/test_wavelet_plot.py +0 -0
  63. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/utils/__init__.py +0 -0
  64. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/utils/generate_data.py +0 -0
  65. {pywavelet-0.0.5 → pywavelet-0.1.0}/tests/utils/plotting.py +0 -0
@@ -5,6 +5,19 @@ CHANGELOG
5
5
  =========
6
6
 
7
7
 
8
+ .. _changelog-v0.1.0:
9
+
10
+ v0.1.0 (2025-01-15)
11
+ ===================
12
+
13
+ Features
14
+ --------
15
+
16
+ * feat: add wavelet mask and more tests (`e009903`_)
17
+
18
+ .. _e009903: https://github.com/pywavelet/pywavelet/commit/e00990300d9c013438580c2bc47ea93570fd95be
19
+
20
+
8
21
  .. _changelog-v0.0.5:
9
22
 
10
23
  v0.0.5 (2024-12-12)
@@ -15,7 +28,13 @@ Bug Fixes
15
28
 
16
29
  * fix: update changelog generator (`884c87b`_)
17
30
 
31
+ Chores
32
+ ------
33
+
34
+ * chore(release): 0.0.5 (`4ed6b03`_)
35
+
18
36
  .. _884c87b: https://github.com/pywavelet/pywavelet/commit/884c87bcd36b5d21eb1a8e10ee9e0edf6f65d744
37
+ .. _4ed6b03: https://github.com/pywavelet/pywavelet/commit/4ed6b03618347cc179195feec57b05e04a004100
19
38
 
20
39
 
21
40
  .. _changelog-v0.0.4:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pywavelet
3
- Version: 0.0.5
3
+ Version: 0.1.0
4
4
  Summary: WDM wavelet transform your time/freq series!
5
5
  Author-email: Pywavelet Team <avi.vajpeyi@gmail.com>
6
6
  Project-URL: Homepage, https://pywavelet.github.io/pywavelet/
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.0.5'
16
- __version_tuple__ = version_tuple = (0, 0, 5)
15
+ __version__ = version = '0.1.0'
16
+ __version_tuple__ = version_tuple = (0, 1, 0)
@@ -1,3 +1,4 @@
1
1
  from .frequencyseries import FrequencySeries
2
2
  from .timeseries import TimeSeries
3
3
  from .wavelet import Wavelet
4
+ from .wavelet_mask import WaveletMask
@@ -0,0 +1,34 @@
1
+ from typing import List
2
+
3
+ from .common import fmt_timerange, is_documented_by, xp
4
+
5
+
6
+ class WaveletMask:
7
+ def __init__(
8
+ self,
9
+ mask: xp.ndarray,
10
+ time: xp.ndarray,
11
+ freq: xp.ndarray,
12
+ ):
13
+ self.mask = mask
14
+ self.time = time
15
+ self.freq = freq
16
+
17
+ def __repr__(self):
18
+ return f"WaveletMask({self.mask.shape}, {fmt_timerange(self.time)}, {self.freq})"
19
+
20
+ @classmethod
21
+ def from_grid(cls, time_grid: xp.ndarray, freq_grid: xp.ndarray):
22
+ nt, nf = len(time_grid), len(freq_grid)
23
+ mask = xp.zeros((nf, nt), dtype=bool)
24
+ return cls(mask, time_grid, freq_grid)
25
+
26
+ @classmethod
27
+ def from_frange(
28
+ cls, time_grid: xp.ndarray, freq_grid: xp.ndarray, frange: List[float]
29
+ ):
30
+ self = cls.from_grid(time_grid, freq_grid)
31
+ self.mask[
32
+ (freq_grid >= frange[0]) & (freq_grid <= frange[1]), :
33
+ ] = True
34
+ return self
@@ -3,7 +3,7 @@ from typing import Union
3
3
  import numpy as np
4
4
  from scipy.interpolate import interp1d
5
5
 
6
- from .transforms.types import FrequencySeries, TimeSeries, Wavelet
6
+ from .transforms.types import FrequencySeries, TimeSeries, Wavelet, WaveletMask
7
7
 
8
8
  DATA_TYPE = Union[TimeSeries, FrequencySeries, Wavelet]
9
9
 
@@ -34,10 +34,13 @@ def evolutionary_psd_from_stationary_psd(
34
34
  return Wavelet(psd_grid.T, time=t_grid, freq=f_grid)
35
35
 
36
36
 
37
- def noise_weighted_inner_product(d: Wavelet, h: Wavelet, PSD: Wavelet) -> float:
37
+ def noise_weighted_inner_product(
38
+ d: Wavelet, h: Wavelet, PSD: Wavelet
39
+ ) -> float:
38
40
  return np.nansum((d.data * h.data) / PSD.data)
39
41
 
40
- def compute_snr(d:Wavelet, h: Wavelet, PSD: Wavelet) -> float:
42
+
43
+ def compute_snr(d: Wavelet, h: Wavelet, PSD: Wavelet) -> float:
41
44
  """Compute the SNR of a model h[ti,fi] given freqseries d[ti,fi] and PSD[ti,fi].
42
45
 
43
46
  SNR(h) = Sum_{ti,fi} [ h_hat[ti,fi] d[ti,fi] / PSD[ti,fi]
@@ -60,5 +63,14 @@ def compute_snr(d:Wavelet, h: Wavelet, PSD: Wavelet) -> float:
60
63
  return np.sqrt(noise_weighted_inner_product(d, h, PSD))
61
64
 
62
65
 
63
- def compute_likelihood(data:Wavelet, template:Wavelet, psd:Wavelet) -> float:
64
- return -0.5 * np.nansum((data.data - template.data) ** 2 / psd.data)
66
+ def compute_likelihood(
67
+ data: Wavelet, template: Wavelet, psd: Wavelet, mask: WaveletMask = None
68
+ ) -> float:
69
+ d = data.data
70
+ h = template.data
71
+ p = psd.data
72
+ if mask is not None:
73
+ m = mask.mask
74
+ d, h, p = d * m, h * m, p * m
75
+
76
+ return -0.5 * np.nansum((d - h) ** 2 / p)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pywavelet
3
- Version: 0.0.5
3
+ Version: 0.1.0
4
4
  Summary: WDM wavelet transform your time/freq series!
5
5
  Author-email: Pywavelet Team <avi.vajpeyi@gmail.com>
6
6
  Project-URL: Homepage, https://pywavelet.github.io/pywavelet/
@@ -42,7 +42,10 @@ src/pywavelet/transforms/types/frequencyseries.py
42
42
  src/pywavelet/transforms/types/plotting.py
43
43
  src/pywavelet/transforms/types/timeseries.py
44
44
  src/pywavelet/transforms/types/wavelet.py
45
+ src/pywavelet/transforms/types/wavelet_mask.py
45
46
  tests/conftest.py
47
+ tests/test_lnl.py
48
+ tests/test_mask.py
46
49
  tests/test_phi.py
47
50
  tests/test_psd.py
48
51
  tests/test_roundtrip_conversion.py
@@ -1,13 +1,16 @@
1
1
  import os
2
2
 
3
- import pytest
4
3
  import numpy as np
4
+ import pytest
5
5
  from utils import (
6
+ BRANCH,
6
7
  generate_chirp_time_domain_signal,
7
8
  generate_sine_time_domain_signal,
8
- BRANCH
9
9
  )
10
10
 
11
+ from pywavelet.transforms import compute_bins
12
+ from pywavelet.transforms.types import Wavelet
13
+
11
14
  # set global env var "NUMBA_DISABLE_JIT=1"
12
15
  os.environ["NUMBA_DISABLE_JIT"] = "1"
13
16
 
@@ -18,8 +21,8 @@ fs = 1024
18
21
  fmax = 50
19
22
  frange = [10, fmax]
20
23
  dt = 1 / fs
21
- Nt = 2 ** 6
22
- Nf = 2 ** 7
24
+ Nt = 2**6
25
+ Nf = 2**7
23
26
  mult = 16
24
27
  ND = Nt * Nf
25
28
  ts = np.arange(0, ND) * dt
@@ -49,4 +52,24 @@ def sine_time():
49
52
 
50
53
  @pytest.fixture()
51
54
  def sine_freq():
52
- return generate_sine_time_domain_signal(ts, ND, f_true=10).to_frequencyseries()
55
+ return generate_sine_time_domain_signal(
56
+ ts, ND, f_true=10
57
+ ).to_frequencyseries()
58
+
59
+
60
+ def monochromatic_wnm(
61
+ f0: float = 20,
62
+ dt: float = 0.0125,
63
+ A: float = 2,
64
+ Nt: int = 128,
65
+ Nf: int = 256,
66
+ ):
67
+ T = Nt * Nf * dt
68
+ N = Nt * Nf
69
+ t_bins, f_bins = compute_bins(Nf, Nt, T)
70
+ wnm = np.zeros((Nt, Nf))
71
+ m0 = int(f0 * N * dt)
72
+ f0_bin_idx = int(2 * m0 / Nt)
73
+ odd_t_indices = np.arange(Nt) % 2 != 0
74
+ wnm[odd_t_indices, f0_bin_idx] = A * np.sqrt(2 * Nf)
75
+ return Wavelet(wnm.T, t_bins, f_bins)
@@ -0,0 +1,32 @@
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+ from conftest import monochromatic_wnm
4
+
5
+ from pywavelet.transforms import (
6
+ compute_bins,
7
+ from_freq_to_wavelet,
8
+ from_time_to_wavelet,
9
+ )
10
+ from pywavelet.transforms.types import (
11
+ FrequencySeries,
12
+ TimeSeries,
13
+ Wavelet,
14
+ WaveletMask,
15
+ )
16
+ from pywavelet.utils import (
17
+ compute_likelihood,
18
+ compute_snr,
19
+ evolutionary_psd_from_stationary_psd,
20
+ )
21
+
22
+
23
+ def test_lnl(plot_dir):
24
+ f0 = 20
25
+ d = monochromatic_wnm(f0=f0)
26
+ h = monochromatic_wnm(f0=f0)
27
+ h2 = monochromatic_wnm(f0=f0 + 1)
28
+ psd = Wavelet(np.ones((h.Nf, h.Nt)), h.time, h.freq)
29
+ lnl = compute_likelihood(d, h, psd)
30
+ lnl2 = compute_likelihood(d, h2, psd)
31
+ assert lnl == 0
32
+ assert lnl > lnl2
@@ -0,0 +1,51 @@
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+ from conftest import monochromatic_wnm
4
+
5
+ from pywavelet.transforms import (
6
+ compute_bins,
7
+ from_freq_to_wavelet,
8
+ from_time_to_wavelet,
9
+ )
10
+ from pywavelet.transforms.types import (
11
+ FrequencySeries,
12
+ TimeSeries,
13
+ Wavelet,
14
+ WaveletMask,
15
+ )
16
+ from pywavelet.utils import (
17
+ compute_likelihood,
18
+ compute_snr,
19
+ evolutionary_psd_from_stationary_psd,
20
+ )
21
+
22
+
23
+ def test_mask(plot_dir):
24
+ f0 = 20
25
+ d = monochromatic_wnm(f0=f0)
26
+ h = monochromatic_wnm(f0=f0)
27
+ psd = Wavelet(np.ones((h.Nf, h.Nt)), h.time, h.freq)
28
+ assert compute_likelihood(d, h, psd) == 0
29
+
30
+ mask = WaveletMask.from_frange(h.time, h.freq, [f0 - 0.5, f0 + 0.5])
31
+ assert np.isclose(compute_likelihood(d, h, psd, mask), 0)
32
+
33
+ mask1 = WaveletMask.from_frange(h.time, h.freq, [f0 + 0.5, f0 + 1.5])
34
+ # assert np.isclose(compute_likelihood(d, h, psd, mask1), 0) == False
35
+
36
+ # plt the 3 differnet datasets
37
+ fig, axes = plt.subplots(1, 3, figsize=(12, 4), sharex=True, sharey=True)
38
+ kwgs = dict(
39
+ cmap="viridis",
40
+ aspect="auto",
41
+ origin="lower",
42
+ extent=[d.time[0], d.time[-1], d.freq[0], d.freq[-1]],
43
+ )
44
+ axes[0].imshow(d.data, **kwgs)
45
+ axes[0].set_title("data")
46
+ axes[1].imshow(d.data * mask.mask, **kwgs)
47
+ axes[1].set_title("data*mask[f0-0.5, f0+0.5]")
48
+ axes[2].imshow(d.data * mask1.mask, **kwgs)
49
+ axes[2].set_title("data*mask[f0+0.5, f0+1.5]")
50
+ plt.tight_layout()
51
+ fig.savefig(f"{plot_dir}/test_mask.png")
@@ -1,19 +1,14 @@
1
+ import matplotlib.pyplot as plt
1
2
  import numpy as np
2
-
3
- from pywavelet.transforms import from_time_to_wavelet, from_freq_to_wavelet, compute_bins
4
- from pywavelet.transforms.types import TimeSeries, Wavelet, FrequencySeries
3
+ from conftest import monochromatic_wnm
4
+
5
+ from pywavelet.transforms import (
6
+ compute_bins,
7
+ from_freq_to_wavelet,
8
+ from_time_to_wavelet,
9
+ )
10
+ from pywavelet.transforms.types import FrequencySeries, TimeSeries, Wavelet
5
11
  from pywavelet.utils import compute_snr, evolutionary_psd_from_stationary_psd
6
- import matplotlib.pyplot as plt
7
-
8
- def monochromatic_wnm(f0:float, dt:float, A:float, T:float, Nt:int, Nf:int):
9
- N = Nt * Nf
10
- t_bins, f_bins = compute_bins(Nf, Nt, T)
11
- wnm = np.zeros((Nt, Nf))
12
- m0 = int(f0 * N * dt)
13
- f0_bin_idx = int( 2 * m0 / Nt)
14
- odd_t_indices = np.arange(Nt) % 2 != 0
15
- wnm[odd_t_indices, f0_bin_idx] = A * np.sqrt(2 * Nf)
16
- return Wavelet(wnm.T, t_bins, f_bins)
17
12
 
18
13
 
19
14
  def test_toy_model_snr(plot_dir):
@@ -59,7 +54,7 @@ def test_toy_model_snr(plot_dir):
59
54
  ########################################
60
55
  ND = len(y)
61
56
  Nt = ND // Nf
62
- assert Nt > 1 , f"Nt={Nt} must be greater than 1 (ND={ND}, Nf={Nf})"
57
+ assert Nt > 1, f"Nt={Nt} must be greater than 1 (ND={ND}, Nf={Nf})"
63
58
  signal_timeseries = TimeSeries(y, t)
64
59
 
65
60
  # time --> wavelet
@@ -71,13 +66,17 @@ def test_toy_model_snr(plot_dir):
71
66
  t_grid=signal_wavelet.time,
72
67
  dt=dt,
73
68
  )
74
- time2wavelet_snr2 = compute_snr(signal_wavelet, signal_wavelet, psd_wavelet_time) ** 2
69
+ time2wavelet_snr2 = (
70
+ compute_snr(signal_wavelet, signal_wavelet, psd_wavelet_time) ** 2
71
+ )
75
72
 
76
73
  # freq --> wavelet
77
74
  signal_freq = signal_timeseries.to_frequencyseries()
78
- psd_freq = FrequencySeries(PSD_AMP * np.ones(len(signal_freq)), signal_freq.freq)
75
+ psd_freq = FrequencySeries(
76
+ PSD_AMP * np.ones(len(signal_freq)), signal_freq.freq
77
+ )
79
78
  np.testing.assert_almost_equal(
80
- signal_freq.optimal_snr(psd_freq)**2, SNR2_f
79
+ signal_freq.optimal_snr(psd_freq) ** 2, SNR2_f
81
80
  )
82
81
 
83
82
  # assert len(signal_freq) == (ND // 2 ) + 1 , f"Not one sided spectrum {len(signal_freq)}!={(ND // 2 ) + 1}"
@@ -89,12 +88,15 @@ def test_toy_model_snr(plot_dir):
89
88
  t_grid=signal_wavelet_f.time,
90
89
  dt=dt,
91
90
  )
92
- freq2wavelet_snr2 = compute_snr(signal_wavelet_f, signal_wavelet_f, psd_wavelet_freq) ** 2
91
+ freq2wavelet_snr2 = (
92
+ compute_snr(signal_wavelet_f, signal_wavelet_f, psd_wavelet_freq) ** 2
93
+ )
93
94
 
94
95
  # analytical wavelet
95
- analytical_wnm = monochromatic_wnm(f0, dt, A, T, Nt, Nf)
96
- analytical_wavelet_snr2 = compute_snr(analytical_wnm, analytical_wnm, psd_wavelet_time) ** 2
97
-
96
+ analytical_wnm = monochromatic_wnm(f0, dt, A, Nt, Nf)
97
+ analytical_wavelet_snr2 = (
98
+ compute_snr(analytical_wnm, analytical_wnm, psd_wavelet_time) ** 2
99
+ )
98
100
 
99
101
  assert np.isclose(
100
102
  time2wavelet_snr2, SNR2_t, atol=1e-2
@@ -106,7 +108,6 @@ def test_toy_model_snr(plot_dir):
106
108
  analytical_wavelet_snr2, SNR2_t, atol=1e-2
107
109
  ), f"SNRs dont match {analytical_wavelet_snr2:.2f}!={SNR2_t:.2f} (factor:{SNR2_t/analytical_wavelet_snr2:.2f})"
108
110
 
109
-
110
111
  #### PLOTTING
111
112
  fig, axes = plt.subplots(1, 3, figsize=(10, 5))
112
113
  signal_wavelet.plot(ax=axes[0], absolute=False)
@@ -123,6 +124,3 @@ def test_toy_model_snr(plot_dir):
123
124
  # axes[0].set_ylabel("Frequency [Hz]")
124
125
  plt.tight_layout()
125
126
  fig.savefig(f"{plot_dir}/snr_comparison.png")
126
-
127
-
128
-
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes