spectre-core 0.0.3__py3-none-any.whl → 0.0.4__py3-none-any.whl
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.
- spectre_core/file_handlers/base.py +2 -28
- spectre_core/file_handlers/configs.py +4 -2
- spectre_core/file_handlers/json.py +9 -5
- spectre_core/receivers/base.py +4 -4
- spectre_core/spectrograms/analytical.py +11 -1
- spectre_core/watchdog/library/fixed/event_handler.py +2 -2
- spectre_core/watchdog/library/sweep/event_handler.py +2 -2
- {spectre_core-0.0.3.dist-info → spectre_core-0.0.4.dist-info}/METADATA +1 -1
- {spectre_core-0.0.3.dist-info → spectre_core-0.0.4.dist-info}/RECORD +12 -12
- {spectre_core-0.0.3.dist-info → spectre_core-0.0.4.dist-info}/LICENSE +0 -0
- {spectre_core-0.0.3.dist-info → spectre_core-0.0.4.dist-info}/WHEEL +0 -0
- {spectre_core-0.0.3.dist-info → spectre_core-0.0.4.dist-info}/top_level.txt +0 -0
@@ -56,39 +56,13 @@ class BaseFileHandler(ABC):
|
|
56
56
|
os.makedirs(self.parent_path, exist_ok=True)
|
57
57
|
|
58
58
|
|
59
|
-
def delete(self
|
60
|
-
doublecheck_delete = True) -> None:
|
59
|
+
def delete(self) -> None:
|
61
60
|
if not self.exists:
|
62
61
|
warn(f"{self.file_path} does not exist. No deletion taking place")
|
63
62
|
return
|
64
63
|
else:
|
65
|
-
if doublecheck_delete:
|
66
|
-
self.doublecheck_delete()
|
67
64
|
os.remove(self.file_path)
|
68
65
|
|
69
66
|
|
70
67
|
def cat(self) -> None:
|
71
|
-
print(self.read())
|
72
|
-
|
73
|
-
|
74
|
-
def _doublecheck_action(self,
|
75
|
-
action_message: str) -> None:
|
76
|
-
proceed_with_action = False
|
77
|
-
while not proceed_with_action:
|
78
|
-
user_input = input(f"{action_message} [y/n]: ").strip().lower()
|
79
|
-
if user_input == "y":
|
80
|
-
proceed_with_action = True
|
81
|
-
elif user_input == "n":
|
82
|
-
print("Operation cancelled by the user")
|
83
|
-
raise exit(1)
|
84
|
-
else:
|
85
|
-
print(f"Please enter one of [y/n], received {user_input}")
|
86
|
-
proceed_with_action = False
|
87
|
-
|
88
|
-
|
89
|
-
def doublecheck_overwrite(self) -> None:
|
90
|
-
self._doublecheck_action(action_message=f"The file '{self.file_path}' already exists. Overwrite?")
|
91
|
-
|
92
|
-
|
93
|
-
def doublecheck_delete(self) -> None:
|
94
|
-
self._doublecheck_action(action_message=f"Are you sure you would like to delete '{self.file_path}'?")
|
68
|
+
print(self.read())
|
@@ -239,12 +239,14 @@ class FitsConfig(SPECTREConfig):
|
|
239
239
|
|
240
240
|
def save_params(self,
|
241
241
|
params: list[str],
|
242
|
-
|
242
|
+
force: bool = False
|
243
243
|
) -> None:
|
244
244
|
d = type_cast_params(params,
|
245
245
|
self.type_template)
|
246
|
+
validate_against_type_template(d,
|
247
|
+
self.type_template)
|
246
248
|
self.save(d,
|
247
|
-
|
249
|
+
force = force)
|
248
250
|
|
249
251
|
|
250
252
|
class CaptureConfig(SPECTREConfig):
|
@@ -26,11 +26,15 @@ class JsonHandler(BaseFileHandler):
|
|
26
26
|
|
27
27
|
def save(self,
|
28
28
|
d: dict,
|
29
|
-
|
29
|
+
force: bool = False) -> None:
|
30
30
|
self.make_parent_path()
|
31
31
|
|
32
|
-
if self.exists
|
33
|
-
|
34
|
-
|
32
|
+
if self.exists:
|
33
|
+
if force:
|
34
|
+
pass
|
35
|
+
else:
|
36
|
+
raise RuntimeError((f"{self.file_name} already exists, write has been abandoned. "
|
37
|
+
f"You can override this functionality with `force`"))
|
38
|
+
|
35
39
|
with open(self.file_path, 'w') as file:
|
36
|
-
|
40
|
+
json.dump(d, file, indent=4)
|
spectre_core/receivers/base.py
CHANGED
@@ -155,7 +155,7 @@ class BaseReceiver(ABC):
|
|
155
155
|
def save_params(self,
|
156
156
|
params: list[str],
|
157
157
|
tag: str,
|
158
|
-
|
158
|
+
force: bool = False) -> None:
|
159
159
|
d = type_cast_params(params,
|
160
160
|
self.type_template)
|
161
161
|
|
@@ -164,13 +164,13 @@ class BaseReceiver(ABC):
|
|
164
164
|
|
165
165
|
self.save_capture_config(d,
|
166
166
|
tag,
|
167
|
-
|
167
|
+
force = force)
|
168
168
|
|
169
169
|
|
170
170
|
def save_capture_config(self,
|
171
171
|
d: dict[str, Any],
|
172
172
|
tag: str,
|
173
|
-
|
173
|
+
force: bool = False) -> None:
|
174
174
|
|
175
175
|
self.validate_capture_config(d)
|
176
176
|
|
@@ -180,7 +180,7 @@ class BaseReceiver(ABC):
|
|
180
180
|
|
181
181
|
capture_config = CaptureConfig(tag)
|
182
182
|
capture_config.save(d,
|
183
|
-
|
183
|
+
force = force)
|
184
184
|
|
185
185
|
|
186
186
|
def load_capture_config(self,
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# This file is part of SPECTRE
|
3
3
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
4
4
|
|
5
|
-
from typing import Callable
|
5
|
+
from typing import Callable, Any
|
6
6
|
from dataclasses import dataclass
|
7
7
|
|
8
8
|
import numpy as np
|
@@ -23,15 +23,25 @@ class TestResults:
|
|
23
23
|
# Maps each time to whether the corresponding spectrum matched analytically
|
24
24
|
spectrum_validated: dict[float, bool] = None
|
25
25
|
|
26
|
+
|
26
27
|
@property
|
27
28
|
def num_validated_spectrums(self) -> int:
|
28
29
|
"""Counts the number of validated spectrums."""
|
29
30
|
return sum(is_validated for is_validated in self.spectrum_validated.values())
|
30
31
|
|
32
|
+
|
31
33
|
@property
|
32
34
|
def num_invalid_spectrums(self) -> int:
|
33
35
|
"""Counts the number of spectrums that are not validated."""
|
34
36
|
return len(self.spectrum_validated) - self.num_validated_spectrums
|
37
|
+
|
38
|
+
|
39
|
+
def jsonify(self) -> dict[str, Any]:
|
40
|
+
return {
|
41
|
+
"time_validated": self.times_validated,
|
42
|
+
"frequencies_validated": self.frequencies_validated,
|
43
|
+
"spectrum_validated": self.spectrum_validated
|
44
|
+
}
|
35
45
|
|
36
46
|
|
37
47
|
class _AnalyticalFactory:
|
@@ -34,8 +34,8 @@ class EventHandler(BaseEventHandler):
|
|
34
34
|
|
35
35
|
bin_chunk = chunk.get_file('bin')
|
36
36
|
_LOGGER.info(f"Deleting {bin_chunk.file_path}")
|
37
|
-
bin_chunk.delete(
|
37
|
+
bin_chunk.delete()
|
38
38
|
|
39
39
|
hdr_chunk = chunk.get_file('hdr')
|
40
40
|
_LOGGER.info(f"Deleting {hdr_chunk.file_path}")
|
41
|
-
hdr_chunk.delete(
|
41
|
+
hdr_chunk.delete()
|
@@ -45,11 +45,11 @@ class EventHandler(BaseEventHandler):
|
|
45
45
|
else:
|
46
46
|
bin_chunk = self.previous_chunk.get_file('bin')
|
47
47
|
_LOGGER.info(f"Deleting {bin_chunk.file_path}")
|
48
|
-
bin_chunk.delete(
|
48
|
+
bin_chunk.delete()
|
49
49
|
|
50
50
|
hdr_chunk = self.previous_chunk.get_file('hdr')
|
51
51
|
_LOGGER.info(f"Deleting {hdr_chunk.file_path}")
|
52
|
-
hdr_chunk.delete(
|
52
|
+
hdr_chunk.delete()
|
53
53
|
|
54
54
|
# and reassign the current chunk to be used as the previous chunk at the next call of this method
|
55
55
|
self.previous_chunk = chunk
|
@@ -14,9 +14,9 @@ spectre_core/chunks/library/fixed/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeR
|
|
14
14
|
spectre_core/chunks/library/fixed/chunk.py,sha256=ckBiEtSa6_S06d_H9LQ0ske5JT2ycF-LstWbDX1oo1c,6941
|
15
15
|
spectre_core/chunks/library/sweep/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
16
|
spectre_core/chunks/library/sweep/chunk.py,sha256=bXpC43kylsaAc88VEc0lnLy8AFXZivejqXUyovDz51U,21219
|
17
|
-
spectre_core/file_handlers/base.py,sha256=
|
18
|
-
spectre_core/file_handlers/configs.py,sha256=
|
19
|
-
spectre_core/file_handlers/json.py,sha256=
|
17
|
+
spectre_core/file_handlers/base.py,sha256=V1R6Vbp3mjA29TI_y4bpslhVvCQT7nzmGY4lDLlN2iI,1653
|
18
|
+
spectre_core/file_handlers/configs.py,sha256=CiNHfy5lGrXDAcxCrKS9VE5Z1Aonp0CP9-SxlyP-ZHI,8500
|
19
|
+
spectre_core/file_handlers/json.py,sha256=PBwjtM29jqfa9ozeRIuarkCJBD8uYIKyDCbM1V2GmtE,1230
|
20
20
|
spectre_core/file_handlers/text.py,sha256=K84BIab_qmbR5igCVJZu3uE47ykpM_bnsasd3WGNEuo,677
|
21
21
|
spectre_core/plotting/__init__.py,sha256=ZRQmBzZ0HWcVDaM5a8AneGbyHwx7dhtBs2z5H8VVspc,192
|
22
22
|
spectre_core/plotting/base.py,sha256=4HhPPP7BNe5_SUAl1Ee52_QP62Zzh3kmNJwLzCHKG3c,4808
|
@@ -30,7 +30,7 @@ spectre_core/plotting/library/integral_over_frequency/panel.py,sha256=tvro2MCtY4
|
|
30
30
|
spectre_core/plotting/library/spectrogram/panel.py,sha256=CAaPz7sDYoWZ3-4Jb1kVRu9bvJYaBRiXvoMkV7QXWqk,3556
|
31
31
|
spectre_core/plotting/library/time_cuts/panel.py,sha256=u9Sbnwy6ex61y5Jl-D77HlYvuuXdK8_YB-o2gCovCTY,2947
|
32
32
|
spectre_core/receivers/__init__.py,sha256=kKfhqrGs9sSPGLbrpTqScv816iPZOvT3ry3zSMcqLkM,227
|
33
|
-
spectre_core/receivers/base.py,sha256=
|
33
|
+
spectre_core/receivers/base.py,sha256=Hx-jH7pnFyeSjaajujmzAYjODUNRgCBo3maHw9rIsyM,16149
|
34
34
|
spectre_core/receivers/factory.py,sha256=aE-Yw_cnlkhRe5HxK0JqhDzd2AwZcKmB2QkAKwaq27Y,873
|
35
35
|
spectre_core/receivers/receiver_register.py,sha256=xHcRnT-3NQxyIWL3nyT3P9qT14Wl5liM9HbflOvOUAM,617
|
36
36
|
spectre_core/receivers/validators.py,sha256=udwOw92oCFR84JMaaOmWn_Ve9G4RKfzdqhpSpGDPqnY,8974
|
@@ -51,7 +51,7 @@ spectre_core/receivers/library/test/gr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JC
|
|
51
51
|
spectre_core/receivers/library/test/gr/cosine_signal_1.py,sha256=6XgYjYMh-QNPs_UUGUQcU_VQFr6BG4OLdsW-M-RU5Ww,2943
|
52
52
|
spectre_core/receivers/library/test/gr/tagged_staircase.py,sha256=5rJHbB-3vdXjqT8DrcAGUSebaAqZ5RQtYHBWgH9iU2E,3465
|
53
53
|
spectre_core/spectrograms/__init__.py,sha256=OFW82_itCktN8dFm_UO5gbgmzFs51v9KEHrSZWLuIUY,155
|
54
|
-
spectre_core/spectrograms/analytical.py,sha256=
|
54
|
+
spectre_core/spectrograms/analytical.py,sha256=36XWstSNP4n_8EOi8BFNHl_h2k5JrrtWTXN0CRGVZcI,8535
|
55
55
|
spectre_core/spectrograms/array_operations.py,sha256=6qKd3y2z6Pmu_U8yxTR4FN4eMhS10KgZ8rH60B_IXqw,2577
|
56
56
|
spectre_core/spectrograms/spectrogram.py,sha256=EqeQyvjzjoKaXou4vJbPbRx85BeMPB9iiJtFZcCyimI,19488
|
57
57
|
spectre_core/spectrograms/transform.py,sha256=xo7ch2lrRkJ54cfIqbkaTHNo_AptBuK0zRELPf7SfIE,13860
|
@@ -62,11 +62,11 @@ spectre_core/watchdog/factory.py,sha256=Uqx4nIZPVRxx7hRgm1M-1p2Sc7m3ObkIKWIC_ru9
|
|
62
62
|
spectre_core/watchdog/watcher.py,sha256=eRAuWAw-0JvfcH3b7qn6lRZVLhmPwubCduRCrV2gLhk,1660
|
63
63
|
spectre_core/watchdog/library/__init__.py,sha256=vEwAnAV-sv7WcNYOdnjr1JVqZYr29Wr2cv01eoxwdmg,282
|
64
64
|
spectre_core/watchdog/library/fixed/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
65
|
-
spectre_core/watchdog/library/fixed/event_handler.py,sha256
|
66
|
-
spectre_core/watchdog/library/sweep/event_handler.py,sha256=
|
65
|
+
spectre_core/watchdog/library/fixed/event_handler.py,sha256=yWWS80LukB-cTrKBsF4-pRvw2obkX2MzQ5ZGytOtmAg,1387
|
66
|
+
spectre_core/watchdog/library/sweep/event_handler.py,sha256=wDISZiQXBeqLDPxgEMo0a2QAXqQVOO7fng3yhZWSR74,2188
|
67
67
|
spectre_core/web_fetch/callisto.py,sha256=qiww6IURqNI0Dg5nc4uT8f4GFagWcapSgYkrBoRVmlg,3627
|
68
|
-
spectre_core-0.0.
|
69
|
-
spectre_core-0.0.
|
70
|
-
spectre_core-0.0.
|
71
|
-
spectre_core-0.0.
|
72
|
-
spectre_core-0.0.
|
68
|
+
spectre_core-0.0.4.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
69
|
+
spectre_core-0.0.4.dist-info/METADATA,sha256=KMnQMpsW1dD3TvZtn0wC-xKLjY-WyfnIgm4QHo7is94,42149
|
70
|
+
spectre_core-0.0.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
71
|
+
spectre_core-0.0.4.dist-info/top_level.txt,sha256=-UsyjpFohXgZpgcZ9QbVeXhsIyF3Am8RxNFNDV_Ta2Y,13
|
72
|
+
spectre_core-0.0.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|