pywavelet 0.0.5__py3-none-any.whl → 0.1.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
pywavelet/_version.py CHANGED
@@ -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
pywavelet/utils.py CHANGED
@@ -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/
@@ -1,7 +1,7 @@
1
1
  pywavelet/__init__.py,sha256=zcK3Qj4wTrGZF1rU3aT6yA9LvliAOD4DVOY7gNfHhCI,53
2
- pywavelet/_version.py,sha256=EJB7__SNK9kQS_SWZB_U4DHJ3P8ftF6etZEihTYnuXE,411
2
+ pywavelet/_version.py,sha256=IMl2Pr_Sy4LVRKy_Sm4CdwUl1Gryous6ncL96EMYsnM,411
3
3
  pywavelet/logger.py,sha256=u5Et6QLUU0IuTnPnxfev5-4GYmihTo7_yBCTf-rVUsA,377
4
- pywavelet/utils.py,sha256=rbmZ-PrnFstq05kh6xj8emuQ3-7oXqZinU03bpg3N7A,1746
4
+ pywavelet/utils.py,sha256=-fZULV8ze1cxs0SP03Di-naYPgNvHbADsFrJ6Vzi7aE,1918
5
5
  pywavelet/transforms/__init__.py,sha256=FolK8WiVEJmGDC9xMupYVI_essXaXS4LYWKbqEqGx6o,289
6
6
  pywavelet/transforms/phi_computer.py,sha256=vo1PK9Z70kKV-1lfyRoxWdhSYqwIgJK5CRCCJVei3xI,4545
7
7
  pywavelet/transforms/forward/__init__.py,sha256=Yq4Tg3Ze98-17C9FIkOqMUdiLHe9x_YoyuRvxOxMOP0,176
@@ -13,13 +13,14 @@ pywavelet/transforms/inverse/__init__.py,sha256=J4KIzPzbHNg_8fV_c1MpPq3slSqHQV0j
13
13
  pywavelet/transforms/inverse/main.py,sha256=l5yFvzmWObrO5Xt_8KYp62w829ab0pQLxcv0-QxkvG0,3015
14
14
  pywavelet/transforms/inverse/to_freq.py,sha256=SExZMax-8A-tJpIA86pYY61X2qvlZ2MrZY27uzCQSV0,2778
15
15
  pywavelet/transforms/inverse/to_time.py,sha256=BAYvrr41QHIbzwYMPyMnzv5mqSx40YigmBruWBwtZwc,5041
16
- pywavelet/transforms/types/__init__.py,sha256=4wUTVBk6A02xjZUY_w056eUZurYI9vVfa--I3Q6Udng,109
16
+ pywavelet/transforms/types/__init__.py,sha256=bNw6gb1S7aA1-wl38LEL7j0BhJBJveYDt2ERn-0kU4k,147
17
17
  pywavelet/transforms/types/common.py,sha256=sLBn2d9cuL6NYeIv6NIogDjY6rYPZAPzCtWGwMlAwkI,1290
18
18
  pywavelet/transforms/types/frequencyseries.py,sha256=Rtwt486UL0-TgMAdcMMVpyfi5PSLzxFcdE_RsYuyxQk,7463
19
19
  pywavelet/transforms/types/plotting.py,sha256=aEIFoSuQRYwYc2639yLkbujXx_aav5A5tXG29rOSMOQ,10275
20
20
  pywavelet/transforms/types/timeseries.py,sha256=Nl1tiKZ7kwu-EZ5JtubwgzgyjQZR86eGU3C3kElIPNg,9296
21
21
  pywavelet/transforms/types/wavelet.py,sha256=raODhyegBd1_esuv2YP6tK_Nj9fYaLQ6O4pxpiFAVZU,10790
22
- pywavelet-0.0.5.dist-info/METADATA,sha256=BaLK8jbUqss_8BeGWOlf_031PoCAlEV4rmuSaitQd0E,1307
23
- pywavelet-0.0.5.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
24
- pywavelet-0.0.5.dist-info/top_level.txt,sha256=g0Ezt0Rg0X-nrd-a0pAXKVRkuWNsF2M9Ynsjb9b2UYQ,10
25
- pywavelet-0.0.5.dist-info/RECORD,,
22
+ pywavelet/transforms/types/wavelet_mask.py,sha256=Qst9NQmvr6vx0Tg8TMABRnDdD3iQgiwgaQKqyf0lwfU,937
23
+ pywavelet-0.1.0.dist-info/METADATA,sha256=sCAmMS5b2zEqsetgkkFgb7DopcPjn_V1o1y3uzIAEEE,1307
24
+ pywavelet-0.1.0.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
25
+ pywavelet-0.1.0.dist-info/top_level.txt,sha256=g0Ezt0Rg0X-nrd-a0pAXKVRkuWNsF2M9Ynsjb9b2UYQ,10
26
+ pywavelet-0.1.0.dist-info/RECORD,,