spectre-core 0.0.3__tar.gz → 0.0.5__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 (77) hide show
  1. {spectre_core-0.0.3 → spectre_core-0.0.5}/PKG-INFO +1 -1
  2. {spectre_core-0.0.3 → spectre_core-0.0.5}/pyproject.toml +1 -1
  3. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/cfg.py +3 -3
  4. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/chunks/base.py +4 -3
  5. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/file_handlers/base.py +5 -31
  6. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/file_handlers/configs.py +7 -5
  7. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/file_handlers/json.py +9 -5
  8. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/logging.py +2 -2
  9. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/base.py +10 -10
  10. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/test/receiver.py +6 -6
  11. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/validators.py +2 -14
  12. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/spectrograms/analytical.py +21 -14
  13. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/watchdog/library/fixed/event_handler.py +2 -2
  14. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/watchdog/library/sweep/event_handler.py +2 -2
  15. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/web_fetch/callisto.py +1 -1
  16. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core.egg-info/PKG-INFO +1 -1
  17. {spectre_core-0.0.3 → spectre_core-0.0.5}/LICENSE +0 -0
  18. {spectre_core-0.0.3 → spectre_core-0.0.5}/README.md +0 -0
  19. {spectre_core-0.0.3 → spectre_core-0.0.5}/setup.cfg +0 -0
  20. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/__init__.py +0 -0
  21. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/chunks/__init__.py +0 -0
  22. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/chunks/chunk_register.py +0 -0
  23. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/chunks/factory.py +0 -0
  24. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/chunks/library/__init__.py +0 -0
  25. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/chunks/library/callisto/__init__.py +0 -0
  26. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/chunks/library/callisto/chunk.py +0 -0
  27. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/chunks/library/fixed/__init__.py +0 -0
  28. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/chunks/library/fixed/chunk.py +0 -0
  29. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/chunks/library/sweep/__init__.py +0 -0
  30. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/chunks/library/sweep/chunk.py +0 -0
  31. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/dynamic_imports.py +0 -0
  32. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/exceptions.py +0 -0
  33. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/file_handlers/text.py +0 -0
  34. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/plotting/__init__.py +0 -0
  35. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/plotting/base.py +0 -0
  36. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/plotting/factory.py +0 -0
  37. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/plotting/format.py +0 -0
  38. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/plotting/library/__init__.py +0 -0
  39. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/plotting/library/frequency_cuts/panel.py +0 -0
  40. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/plotting/library/integral_over_frequency/panel.py +0 -0
  41. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/plotting/library/spectrogram/panel.py +0 -0
  42. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/plotting/library/time_cuts/panel.py +0 -0
  43. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/plotting/panel_register.py +0 -0
  44. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/plotting/panel_stack.py +0 -0
  45. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/__init__.py +0 -0
  46. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/factory.py +0 -0
  47. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/__init__.py +0 -0
  48. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/rsp1a/__init__.py +0 -0
  49. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/rsp1a/gr/__init__.py +0 -0
  50. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/rsp1a/gr/fixed.py +0 -0
  51. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/rsp1a/gr/sweep.py +0 -0
  52. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/rsp1a/receiver.py +0 -0
  53. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/rspduo/__init__.py +0 -0
  54. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/rspduo/gr/__init__.py +0 -0
  55. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/rspduo/gr/tuner_1_fixed.py +0 -0
  56. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/rspduo/gr/tuner_1_sweep.py +0 -0
  57. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/rspduo/receiver.py +0 -0
  58. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/test/__init__.py +0 -0
  59. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/test/gr/__init__.py +0 -0
  60. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/test/gr/cosine_signal_1.py +0 -0
  61. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/library/test/gr/tagged_staircase.py +0 -0
  62. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/receivers/receiver_register.py +0 -0
  63. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/spectrograms/__init__.py +0 -0
  64. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/spectrograms/array_operations.py +0 -0
  65. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/spectrograms/spectrogram.py +0 -0
  66. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/spectrograms/transform.py +0 -0
  67. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/watchdog/__init__.py +0 -0
  68. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/watchdog/base.py +0 -0
  69. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/watchdog/event_handler_register.py +0 -0
  70. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/watchdog/factory.py +0 -0
  71. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/watchdog/library/__init__.py +0 -0
  72. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/watchdog/library/fixed/__init__.py +0 -0
  73. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core/watchdog/watcher.py +0 -0
  74. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core.egg-info/SOURCES.txt +0 -0
  75. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core.egg-info/dependency_links.txt +0 -0
  76. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core.egg-info/requires.txt +0 -0
  77. {spectre_core-0.0.3 → spectre_core-0.0.5}/src/spectre_core.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spectre-core
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: The core Python package used by the spectre program.
5
5
  Maintainer-email: Jimmy Fitzpatrick <jcfitzpatrick12@gmail.com>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "spectre-core"
7
- version = "0.0.3"
7
+ version = "0.0.5"
8
8
  maintainers = [
9
9
  { name="Jimmy Fitzpatrick", email="jcfitzpatrick12@gmail.com" },
10
10
  ]
@@ -18,9 +18,9 @@ LOGS_DIR_PATH = os.environ.get("SPECTRE_LOGS_DIR_PATH",
18
18
  os.makedirs(LOGS_DIR_PATH,
19
19
  exist_ok=True)
20
20
 
21
- JSON_CONFIGS_DIR_PATH = os.environ.get("SPECTRE_JSON_CONFIGS_DIR_PATH",
22
- os.path.join(SPECTRE_DATA_DIR_PATH, "configs"))
23
- os.makedirs(JSON_CONFIGS_DIR_PATH,
21
+ CONFIGS_DIR_PATH = os.environ.get("SPECTRE_CONFIGS_DIR_PATH",
22
+ os.path.join(SPECTRE_DATA_DIR_PATH, "configs"))
23
+ os.makedirs(CONFIGS_DIR_PATH,
24
24
  exist_ok=True)
25
25
 
26
26
  DEFAULT_TIME_FORMAT = "%H:%M:%S"
@@ -147,6 +147,7 @@ class SPECTREChunk(BaseChunk):
147
147
 
148
148
 
149
149
  def __get_SFT_instance(self) -> ShortTimeFFT:
150
+ hop = self.capture_config.get("hop")
150
151
  window_type = self.capture_config.get("window_type")
151
152
  window_params = self.capture_config.get("window_kwargs").values()
152
153
  window_size = self.capture_config.get("window_size")
@@ -155,6 +156,6 @@ class SPECTREChunk(BaseChunk):
155
156
  window_size)
156
157
  samp_rate = self.capture_config.get("samp_rate")
157
158
  return ShortTimeFFT(window,
158
- fs=samp_rate,
159
- fft_mode="centered",
160
- **self.capture_config.get("STFFT_kwargs"))
159
+ hop,
160
+ samp_rate,
161
+ fft_mode = "centered")
@@ -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:
61
- if not self.exists:
62
- warn(f"{self.file_path} does not exist. No deletion taking place")
63
- return
59
+ def delete(self,
60
+ ignore_if_missing: bool = False) -> None:
61
+ if not self.exists and not ignore_if_missing:
62
+ raise FileNotFoundError(f"{self.file_name} does not exist, and so cannot be deleted")
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())
@@ -7,7 +7,7 @@ from abc import ABC
7
7
  import ast
8
8
 
9
9
  from spectre_core.file_handlers.json import JsonHandler
10
- from spectre_core.cfg import JSON_CONFIGS_DIR_PATH
10
+ from spectre_core.cfg import CONFIGS_DIR_PATH
11
11
  from spectre_core.exceptions import InvalidTagError
12
12
 
13
13
 
@@ -146,8 +146,8 @@ class SPECTREConfig(JsonHandler, ABC):
146
146
  self._config_type = config_type
147
147
 
148
148
  self._dict = None # cache
149
- super().__init__(JSON_CONFIGS_DIR_PATH,
150
- f"{config_type}_config_{tag}",
149
+ super().__init__(CONFIGS_DIR_PATH,
150
+ f"{config_type}_{tag}",
151
151
  **kwargs)
152
152
 
153
153
 
@@ -239,12 +239,14 @@ class FitsConfig(SPECTREConfig):
239
239
 
240
240
  def save_params(self,
241
241
  params: list[str],
242
- doublecheck_overwrite: bool = True
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
- doublecheck_overwrite = doublecheck_overwrite)
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
- doublecheck_overwrite: bool = True) -> None:
29
+ force: bool = False) -> None:
30
30
  self.make_parent_path()
31
31
 
32
- if self.exists and doublecheck_overwrite:
33
- self.doublecheck_overwrite()
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
- json.dump(d, file, indent=4)
40
+ json.dump(d, file, indent=4)
@@ -22,8 +22,8 @@ from spectre_core.cfg import (
22
22
  )
23
23
 
24
24
  PROCESS_TYPES = [
25
- "USER",
26
- "WORKER"
25
+ "user",
26
+ "worker"
27
27
  ]
28
28
 
29
29
 
@@ -155,7 +155,7 @@ class BaseReceiver(ABC):
155
155
  def save_params(self,
156
156
  params: list[str],
157
157
  tag: str,
158
- doublecheck_overwrite: bool = True) -> None:
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
- doublecheck_overwrite=doublecheck_overwrite)
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
- doublecheck_overwrite: bool = True) -> None:
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
- doublecheck_overwrite = doublecheck_overwrite)
183
+ force = force)
184
184
 
185
185
 
186
186
  def load_capture_config(self,
@@ -239,7 +239,7 @@ class SPECTREReceiver(BaseReceiver):
239
239
  "window_type": str, # window type for STFFT
240
240
  "window_kwargs": dict, # keyword arguments for window function, must be in order as in scipy documentation.
241
241
  "window_size": int, # number of samples in STFFT window
242
- "STFFT_kwargs": dict, # keyword arguments for the scipy STFFT class
242
+ "hop": int, # STFFT window hops by so many samples
243
243
  "chunk_key": str, # tag will map to the chunk with this key
244
244
  "event_handler_key": str, # tag will map to event handler with this key during post processing
245
245
  },
@@ -259,7 +259,7 @@ class SPECTREReceiver(BaseReceiver):
259
259
  "window_type": str, # window type for STFFT
260
260
  "window_kwargs": dict, # keyword arguments for window function, must be in order as in scipy documentation.
261
261
  "window_size": int, # number of samples in STFFT window
262
- "STFFT_kwargs": dict, # keyword arguments for the scipy STFFT class
262
+ "hop": int, # keyword arguments for the scipy STFFT class
263
263
  "chunk_key": str, # tag will map to the chunk with this key
264
264
  "event_handler_key": str, # tag will map to event handler with this key during post processing
265
265
  }
@@ -289,7 +289,7 @@ class SPECTREReceiver(BaseReceiver):
289
289
  window_type = capture_config["window_type"]
290
290
  window_kwargs = capture_config["window_kwargs"]
291
291
  window_size = capture_config["window_size"]
292
- STFFT_kwargs = capture_config["STFFT_kwargs"]
292
+ hop = capture_config["hop"]
293
293
  chunk_key = capture_config["chunk_key"]
294
294
  event_handler_key = capture_config[ "event_handler_key"]
295
295
 
@@ -307,7 +307,7 @@ class SPECTREReceiver(BaseReceiver):
307
307
  window_size,
308
308
  chunk_size,
309
309
  samp_rate)
310
- validators.STFFT_kwargs(STFFT_kwargs)
310
+ validators.hop(hop)
311
311
  validators.chunk_key(chunk_key, "sweep")
312
312
  validators.event_handler_key(event_handler_key, "sweep")
313
313
  validators.gain_is_negative(IF_gain)
@@ -347,7 +347,7 @@ class SPECTREReceiver(BaseReceiver):
347
347
  window_type = capture_config["window_type"]
348
348
  window_kwargs = capture_config["window_kwargs"]
349
349
  window_size = capture_config["window_size"]
350
- STFFT_kwargs = capture_config["STFFT_kwargs"]
350
+ hop = capture_config["hop"]
351
351
  chunk_key = capture_config["chunk_key"]
352
352
  event_handler_key = capture_config["event_handler_key"]
353
353
 
@@ -362,7 +362,7 @@ class SPECTREReceiver(BaseReceiver):
362
362
  window_size,
363
363
  chunk_size,
364
364
  samp_rate)
365
- validators.STFFT_kwargs(STFFT_kwargs)
365
+ validators.hop(hop)
366
366
  validators.chunk_key(chunk_key,
367
367
  "fixed")
368
368
  validators.event_handler_key(event_handler_key,
@@ -43,7 +43,7 @@ class Receiver(SPECTREReceiver):
43
43
  'window_type': str, # the window type for the STFFT
44
44
  'window_kwargs': dict, # keyword arguments for scipy get window function. Must be in order as in scipy documentation.
45
45
  'window_size': int, # number of samples for the window
46
- 'STFFT_kwargs': dict, # keyword arguments for scipy STFFT class
46
+ 'hop': dict, # STFFT hop shifts window by so many samples
47
47
  'chunk_key': str, # tag will map to the chunk with this key
48
48
  'event_handler_key': str # tag will map to event handler with this key during post processing
49
49
  },
@@ -60,7 +60,7 @@ class Receiver(SPECTREReceiver):
60
60
  'window_type': str, # the window type for the STFFT
61
61
  'window_kwargs': dict, # keyword arguments for scipy get window function. Must be in order as in scipy documentation.
62
62
  'window_size': int, # number of samples for the window
63
- 'STFFT_kwargs': dict, # keyword arguments for scipy STFFT class
63
+ 'hop': int, # keyword arguments for scipy STFFT class
64
64
  'chunk_key': str, # tag will map to the chunk with this key
65
65
  'event_handler_key': str, # tag will map to event handler with this key during post processing
66
66
  }
@@ -87,7 +87,7 @@ class Receiver(SPECTREReceiver):
87
87
  chunk_size = capture_config["chunk_size"]
88
88
  window_type = capture_config["window_type"]
89
89
  window_size = capture_config["window_size"]
90
- STFFT_kwargs = capture_config["STFFT_kwargs"]
90
+ hop = capture_config["hop"]
91
91
  chunk_key = capture_config["chunk_key"]
92
92
  event_handler_key = capture_config["event_handler_key"]
93
93
  time_resolution = capture_config["time_resolution"]
@@ -101,7 +101,7 @@ class Receiver(SPECTREReceiver):
101
101
  window_size,
102
102
  chunk_size,
103
103
  samp_rate)
104
- validators.STFFT_kwargs(STFFT_kwargs)
104
+ validators.hop(hop)
105
105
  validators.chunk_key(chunk_key, "fixed")
106
106
  validators.event_handler_key(event_handler_key, "fixed")
107
107
 
@@ -145,7 +145,7 @@ class Receiver(SPECTREReceiver):
145
145
  window_type = capture_config["window_type"]
146
146
  window_kwargs = capture_config["window_kwargs"]
147
147
  window_size = capture_config["window_size"]
148
- STFFT_kwargs = capture_config["STFFT_kwargs"]
148
+ hop = capture_config["hop"]
149
149
  chunk_key = capture_config["chunk_key"]
150
150
  event_handler_key = capture_config["event_handler_key"]
151
151
  time_resolution = capture_config["time_resolution"]
@@ -154,7 +154,7 @@ class Receiver(SPECTREReceiver):
154
154
  validators.chunk_size_strictly_positive(chunk_size)
155
155
  validators.time_resolution(time_resolution, chunk_size)
156
156
  validators.window(window_type, window_kwargs, window_size, chunk_size, samp_rate)
157
- validators.STFFT_kwargs(STFFT_kwargs)
157
+ validators.hop(hop)
158
158
  validators.chunk_key(chunk_key, "sweep")
159
159
  validators.event_handler_key(event_handler_key, "sweep")
160
160
 
@@ -69,20 +69,8 @@ def window(window_type: str,
69
69
  raise Exception(f"An error has occurred while validating the window. Received: {str(e)}")
70
70
 
71
71
 
72
- def STFFT_kwargs(STFFT_kwargs: dict):
73
- if len(STFFT_kwargs) == 0:
74
- raise ValueError("STFFT kwargs cannot be empty")
75
-
76
- STFFT_keys = STFFT_kwargs.keys()
77
- if "hop" not in STFFT_keys:
78
- raise KeyError(f"\"hop\" is a required key in STFFT kwargs. Received: {STFFT_keys}")
79
-
80
- hop_value = STFFT_kwargs.get("hop")
81
- hop_value_type = type(hop_value)
82
- if hop_value_type != int:
83
- raise TypeError(f"\"hop\" must be specified as an integer. Received: {hop_value_type}")
84
-
85
- if hop_value < 0:
72
+ def hop(hop: int):
73
+ if hop < 0:
86
74
  raise ValueError(f"\"hop\" must be strictly positive. Received: {hop_value}")
87
75
 
88
76
 
@@ -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
+ "times_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:
@@ -82,7 +92,7 @@ class _AnalyticalFactory:
82
92
  samp_rate = capture_config['samp_rate']
83
93
  amplitude = capture_config['amplitude']
84
94
  frequency = capture_config['frequency']
85
- hop = capture_config['STFFT_kwargs']['hop']
95
+ hop = capture_config['hop']
86
96
 
87
97
  # Calculate derived parameters a (sampling rate ratio) and p (sampled periods).
88
98
  a = int(samp_rate / frequency)
@@ -182,24 +192,21 @@ def validate_analytically(spectrogram: Spectrogram,
182
192
 
183
193
  test_results = TestResults()
184
194
 
185
- if is_close(analytical_spectrogram.times,
186
- spectrogram.times,
187
- absolute_tolerance):
188
- test_results.times_validated = True
189
-
195
+ test_results.times_validated = bool(is_close(analytical_spectrogram.times,
196
+ spectrogram.times,
197
+ absolute_tolerance))
190
198
 
191
- if is_close(analytical_spectrogram.frequencies,
192
- spectrogram.frequencies,
193
- absolute_tolerance):
194
- test_results.frequencies_validated = True
199
+ test_results.frequencies_validated = bool(is_close(analytical_spectrogram.frequencies,
200
+ spectrogram.frequencies,
201
+ absolute_tolerance))
195
202
 
196
203
  test_results.spectrum_validated = {}
197
204
  for i in range(spectrogram.num_times):
198
205
  time = spectrogram.times[i]
199
206
  analytical_spectrum = analytical_spectrogram.dynamic_spectra[:, i]
200
207
  spectrum = spectrogram.dynamic_spectra[:, i]
201
- test_results.spectrum_validated[time] = is_close(analytical_spectrum,
202
- spectrum,
203
- absolute_tolerance)
208
+ test_results.spectrum_validated[time] = bool(is_close(analytical_spectrum,
209
+ spectrum,
210
+ absolute_tolerance))
204
211
 
205
212
  return test_results
@@ -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(doublecheck_delete = False)
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(doublecheck_delete = False)
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(doublecheck_delete = False)
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(doublecheck_delete = False)
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
@@ -15,7 +15,7 @@ from spectre_core.cfg import (
15
15
  )
16
16
  from spectre_core.cfg import get_chunks_dir_path
17
17
 
18
- temp_dir = os.path.join(os.environ['SPECTRE_DIR_PATH'], "tmp")
18
+ temp_dir = os.path.join(os.environ['SPECTRE_DATA_DIR_PATH'], "tmp")
19
19
 
20
20
  def get_chunk_name(station: str, date: str, time: str, instrument_code: str) -> str:
21
21
  dt = datetime.strptime(f"{date}T{time}", '%Y%m%dT%H%M%S')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spectre-core
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: The core Python package used by the spectre program.
5
5
  Maintainer-email: Jimmy Fitzpatrick <jcfitzpatrick12@gmail.com>
6
6
  License: GNU GENERAL PUBLIC LICENSE
File without changes
File without changes
File without changes