spectre-core 0.0.8__py3-none-any.whl → 0.0.10__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/__init__.py +0 -3
- spectre_core/_file_io/__init__.py +15 -0
- spectre_core/_file_io/file_handlers.py +128 -0
- spectre_core/capture_configs/__init__.py +29 -0
- spectre_core/capture_configs/_capture_config.py +85 -0
- spectre_core/capture_configs/_capture_templates.py +222 -0
- spectre_core/capture_configs/_parameters.py +110 -0
- spectre_core/capture_configs/_pconstraints.py +82 -0
- spectre_core/capture_configs/_ptemplates.py +450 -0
- spectre_core/capture_configs/_pvalidators.py +173 -0
- spectre_core/chunks/__init__.py +17 -201
- spectre_core/chunks/{base.py → _base.py} +15 -60
- spectre_core/chunks/_chunks.py +200 -0
- spectre_core/chunks/{factory.py → _factory.py} +6 -7
- spectre_core/chunks/library/{callisto/chunk.py → _callisto.py} +4 -7
- spectre_core/chunks/library/{fixed/chunk.py → _fixed_center_frequency.py} +7 -64
- spectre_core/chunks/library/_swept_center_frequency.py +103 -0
- spectre_core/config/__init__.py +20 -0
- spectre_core/config/_paths.py +77 -0
- spectre_core/config/_time_formats.py +15 -0
- spectre_core/exceptions.py +4 -5
- spectre_core/logging/__init__.py +11 -0
- spectre_core/logging/_configure.py +35 -0
- spectre_core/logging/_decorators.py +19 -0
- spectre_core/{logging.py → logging/_log_handlers.py} +13 -58
- spectre_core/plotting/__init__.py +7 -1
- spectre_core/plotting/{base.py → _base.py} +40 -20
- spectre_core/plotting/_format.py +18 -0
- spectre_core/plotting/{panel_stack.py → _panel_stack.py} +50 -48
- spectre_core/plotting/_panels.py +234 -0
- spectre_core/post_processing/__init__.py +14 -0
- spectre_core/post_processing/_base.py +119 -0
- spectre_core/post_processing/_factory.py +23 -0
- spectre_core/post_processing/_post_processor.py +40 -0
- spectre_core/post_processing/library/_fixed_center_frequency.py +115 -0
- spectre_core/post_processing/library/_swept_center_frequency.py +382 -0
- spectre_core/receivers/__init__.py +12 -2
- spectre_core/receivers/_base.py +352 -0
- spectre_core/receivers/{factory.py → _factory.py} +2 -2
- spectre_core/receivers/_spec_names.py +20 -0
- spectre_core/receivers/gr/__init__.py +3 -0
- spectre_core/receivers/gr/_base.py +33 -0
- spectre_core/receivers/gr/_rsp1a.py +158 -0
- spectre_core/receivers/gr/_test.py +123 -0
- spectre_core/receivers/library/_rsp1a.py +61 -0
- spectre_core/receivers/library/_test.py +221 -0
- spectre_core/spectrograms/__init__.py +18 -0
- spectre_core/spectrograms/{analytical.py → _analytical.py} +29 -27
- spectre_core/spectrograms/{array_operations.py → _array_operations.py} +47 -1
- spectre_core/spectrograms/{spectrogram.py → _spectrogram.py} +62 -35
- spectre_core/spectrograms/{transform.py → _transform.py} +76 -89
- spectre_core/{receivers/library → wgetting}/__init__.py +4 -2
- spectre_core/wgetting/_callisto.py +155 -0
- {spectre_core-0.0.8.dist-info → spectre_core-0.0.10.dist-info}/METADATA +1 -1
- spectre_core-0.0.10.dist-info/RECORD +63 -0
- spectre_core/cfg.py +0 -116
- spectre_core/chunks/library/__init__.py +0 -8
- spectre_core/chunks/library/sweep/__init__.py +0 -0
- spectre_core/chunks/library/sweep/chunk.py +0 -400
- spectre_core/dynamic_imports.py +0 -22
- spectre_core/file_handlers/base.py +0 -68
- spectre_core/file_handlers/configs.py +0 -271
- spectre_core/file_handlers/json.py +0 -40
- spectre_core/file_handlers/text.py +0 -21
- spectre_core/plotting/factory.py +0 -26
- spectre_core/plotting/format.py +0 -19
- spectre_core/plotting/library/__init__.py +0 -7
- spectre_core/plotting/library/frequency_cuts/panel.py +0 -74
- spectre_core/plotting/library/integral_over_frequency/panel.py +0 -34
- spectre_core/plotting/library/spectrogram/panel.py +0 -92
- spectre_core/plotting/library/time_cuts/panel.py +0 -77
- spectre_core/plotting/panel_register.py +0 -13
- spectre_core/receivers/base.py +0 -415
- spectre_core/receivers/library/rsp1a/__init__.py +0 -0
- spectre_core/receivers/library/rsp1a/gr/__init__.py +0 -0
- spectre_core/receivers/library/rsp1a/gr/fixed.py +0 -104
- spectre_core/receivers/library/rsp1a/gr/sweep.py +0 -129
- spectre_core/receivers/library/rsp1a/receiver.py +0 -68
- spectre_core/receivers/library/rspduo/__init__.py +0 -0
- spectre_core/receivers/library/rspduo/gr/__init__.py +0 -0
- spectre_core/receivers/library/rspduo/gr/tuner_1_fixed.py +0 -114
- spectre_core/receivers/library/rspduo/gr/tuner_1_sweep.py +0 -131
- spectre_core/receivers/library/rspduo/gr/tuner_2_fixed.py +0 -120
- spectre_core/receivers/library/rspduo/gr/tuner_2_sweep.py +0 -119
- spectre_core/receivers/library/rspduo/receiver.py +0 -97
- spectre_core/receivers/library/test/__init__.py +0 -0
- spectre_core/receivers/library/test/gr/__init__.py +0 -0
- spectre_core/receivers/library/test/gr/cosine_signal_1.py +0 -83
- spectre_core/receivers/library/test/gr/tagged_staircase.py +0 -93
- spectre_core/receivers/library/test/receiver.py +0 -178
- spectre_core/receivers/validators.py +0 -193
- spectre_core/watchdog/__init__.py +0 -6
- spectre_core/watchdog/base.py +0 -105
- spectre_core/watchdog/factory.py +0 -22
- spectre_core/watchdog/library/__init__.py +0 -10
- spectre_core/watchdog/library/fixed/__init__.py +0 -0
- spectre_core/watchdog/library/fixed/event_handler.py +0 -41
- spectre_core/watchdog/library/sweep/event_handler.py +0 -55
- spectre_core/watchdog/post_processor.py +0 -50
- spectre_core/web_fetch/callisto.py +0 -101
- spectre_core-0.0.8.dist-info/RECORD +0 -74
- /spectre_core/chunks/{chunk_register.py → _register.py} +0 -0
- /spectre_core/{watchdog/event_handler_register.py → post_processing/_register.py} +0 -0
- /spectre_core/receivers/{receiver_register.py → _register.py} +0 -0
- /spectre_core/{chunks/library/callisto/__init__.py → receivers/gr/_rspduo.py} +0 -0
- /spectre_core/{chunks/library/fixed/__init__.py → receivers/library/_rspduo.py} +0 -0
- {spectre_core-0.0.8.dist-info → spectre_core-0.0.10.dist-info}/LICENSE +0 -0
- {spectre_core-0.0.8.dist-info → spectre_core-0.0.10.dist-info}/WHEEL +0 -0
- {spectre_core-0.0.8.dist-info → spectre_core-0.0.10.dist-info}/top_level.txt +0 -0
spectre_core/watchdog/base.py
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
# SPDX-FileCopyrightText: © 2024 Jimmy Fitzpatrick <jcfitzpatrick12@gmail.com>
|
2
|
-
# This file is part of SPECTRE
|
3
|
-
# SPDX-License-Identifier: GPL-3.0-or-later
|
4
|
-
|
5
|
-
from logging import getLogger
|
6
|
-
_LOGGER = getLogger(__name__)
|
7
|
-
|
8
|
-
import os
|
9
|
-
import time
|
10
|
-
from queue import Queue
|
11
|
-
from typing import Any
|
12
|
-
from abc import ABC, abstractmethod
|
13
|
-
from math import floor
|
14
|
-
|
15
|
-
from watchdog.events import FileSystemEventHandler
|
16
|
-
|
17
|
-
from spectre_core.chunks.factory import get_chunk_from_tag
|
18
|
-
from spectre_core.file_handlers.configs import CaptureConfig
|
19
|
-
from spectre_core.spectrograms.spectrogram import Spectrogram
|
20
|
-
from spectre_core.spectrograms.transform import join_spectrograms
|
21
|
-
from spectre_core.spectrograms.transform import (
|
22
|
-
time_average,
|
23
|
-
frequency_average
|
24
|
-
)
|
25
|
-
|
26
|
-
|
27
|
-
class BaseEventHandler(ABC, FileSystemEventHandler):
|
28
|
-
def __init__(self,
|
29
|
-
tag: str,
|
30
|
-
exception_queue: Queue,
|
31
|
-
extension: str):
|
32
|
-
self._tag = tag
|
33
|
-
self._Chunk = get_chunk_from_tag(tag)
|
34
|
-
|
35
|
-
self._capture_config = CaptureConfig(tag)
|
36
|
-
|
37
|
-
self._extension = extension
|
38
|
-
self._exception_queue = exception_queue # Queue to propagate exceptions
|
39
|
-
|
40
|
-
self._spectrogram: Spectrogram = None # spectrogram cache
|
41
|
-
|
42
|
-
|
43
|
-
@abstractmethod
|
44
|
-
def process(self, file_path: str) -> None:
|
45
|
-
pass
|
46
|
-
|
47
|
-
|
48
|
-
def on_created(self, event):
|
49
|
-
if not event.is_directory and event.src_path.endswith(self._extension):
|
50
|
-
_LOGGER.info(f"Noticed: {event.src_path}")
|
51
|
-
try:
|
52
|
-
self._wait_until_stable(event.src_path)
|
53
|
-
self.process(event.src_path)
|
54
|
-
except Exception as e:
|
55
|
-
_LOGGER.error(f"An error has occured while processing {event.src_path}",
|
56
|
-
exc_info=True)
|
57
|
-
self._flush_spectrogram() # flush the internally stored spectrogram
|
58
|
-
# Capture the exception and propagate it through the queue
|
59
|
-
self._exception_queue.put(e)
|
60
|
-
|
61
|
-
|
62
|
-
def _wait_until_stable(self, file_path: str):
|
63
|
-
_LOGGER.info(f"Waiting for file stability: {file_path}")
|
64
|
-
size = -1
|
65
|
-
while True:
|
66
|
-
current_size = os.path.getsize(file_path)
|
67
|
-
if current_size == size:
|
68
|
-
_LOGGER.info(f"File is now stable: {file_path}")
|
69
|
-
break # File is stable when the size hasn't changed
|
70
|
-
size = current_size
|
71
|
-
time.sleep(0.25)
|
72
|
-
|
73
|
-
|
74
|
-
def _average_in_time(self, spectrogram: Spectrogram) -> Spectrogram:
|
75
|
-
requested_time_resolution = self._capture_config.get('time_resolution') # [s]
|
76
|
-
if requested_time_resolution is None:
|
77
|
-
raise KeyError(f"Time resolution has not been specified in the capture config!")
|
78
|
-
average_over = floor(requested_time_resolution/spectrogram.time_resolution) if requested_time_resolution > spectrogram.time_resolution else 1
|
79
|
-
return time_average(spectrogram, average_over)
|
80
|
-
|
81
|
-
|
82
|
-
def _average_in_frequency(self, spectrogram: Spectrogram) -> Spectrogram:
|
83
|
-
frequency_resolution = self._capture_config.get('frequency_resolution') # [Hz]
|
84
|
-
if frequency_resolution is None:
|
85
|
-
raise KeyError(f"Frequency resolution has not been specified in the capture config!")
|
86
|
-
average_over = floor(frequency_resolution/spectrogram.frequency_resolution) if frequency_resolution > spectrogram.frequency_resolution else 1
|
87
|
-
return frequency_average(spectrogram, average_over)
|
88
|
-
|
89
|
-
|
90
|
-
def _join_spectrogram(self, spectrogram: Spectrogram) -> None:
|
91
|
-
if self._spectrogram is None:
|
92
|
-
self._spectrogram = spectrogram
|
93
|
-
else:
|
94
|
-
self._spectrogram = join_spectrograms([self._spectrogram, spectrogram])
|
95
|
-
|
96
|
-
if self._spectrogram.time_range >= self._capture_config.get("joining_time"):
|
97
|
-
self._flush_spectrogram()
|
98
|
-
|
99
|
-
|
100
|
-
def _flush_spectrogram(self) -> None:
|
101
|
-
if self._spectrogram:
|
102
|
-
_LOGGER.info(f"Flushing spectrogram to file with chunk start time {self._spectrogram.chunk_start_time}")
|
103
|
-
self._spectrogram.save()
|
104
|
-
_LOGGER.info("Flush successful, resetting spectrogram cache")
|
105
|
-
self._spectrogram = None # reset the cache
|
spectre_core/watchdog/factory.py
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# SPDX-FileCopyrightText: © 2024 Jimmy Fitzpatrick <jcfitzpatrick12@gmail.com>
|
2
|
-
# This file is part of SPECTRE
|
3
|
-
# SPDX-License-Identifier: GPL-3.0-or-later
|
4
|
-
|
5
|
-
from spectre_core.watchdog.event_handler_register import event_handler_map
|
6
|
-
from spectre_core.watchdog.base import BaseEventHandler
|
7
|
-
from spectre_core.file_handlers.configs import CaptureConfig
|
8
|
-
from spectre_core.exceptions import EventHandlerNotFoundError
|
9
|
-
|
10
|
-
def get_event_handler(event_handler_key: str) -> BaseEventHandler:
|
11
|
-
# try and fetch the capture config mount
|
12
|
-
EventHandler = event_handler_map.get(event_handler_key)
|
13
|
-
if EventHandler is None:
|
14
|
-
valid_event_handler_keys = list(event_handler_map.keys())
|
15
|
-
raise EventHandlerNotFoundError(f"No event handler found for the event handler key: {event_handler_key}. Please specify one of the following event handler keys {valid_event_handler_keys}")
|
16
|
-
return EventHandler
|
17
|
-
|
18
|
-
|
19
|
-
def get_event_handler_from_tag(tag: str) -> BaseEventHandler:
|
20
|
-
capture_config = CaptureConfig(tag)
|
21
|
-
event_handler_key = capture_config.get('event_handler_key')
|
22
|
-
return get_event_handler(event_handler_key)
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# SPDX-FileCopyrightText: © 2024 Jimmy Fitzpatrick <jcfitzpatrick12@gmail.com>
|
2
|
-
# This file is part of SPECTRE
|
3
|
-
# SPDX-License-Identifier: GPL-3.0-or-later
|
4
|
-
|
5
|
-
from spectre_core.dynamic_imports import import_target_modules
|
6
|
-
|
7
|
-
import_target_modules(__file__, __name__, "event_handler")
|
8
|
-
|
9
|
-
|
10
|
-
|
File without changes
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# SPDX-FileCopyrightText: © 2024 Jimmy Fitzpatrick <jcfitzpatrick12@gmail.com>
|
2
|
-
# This file is part of SPECTRE
|
3
|
-
# SPDX-License-Identifier: GPL-3.0-or-later
|
4
|
-
|
5
|
-
from logging import getLogger
|
6
|
-
_LOGGER = getLogger(__name__)
|
7
|
-
|
8
|
-
import os
|
9
|
-
|
10
|
-
from spectre_core.watchdog.base import BaseEventHandler
|
11
|
-
from spectre_core.watchdog.event_handler_register import register_event_handler
|
12
|
-
|
13
|
-
@register_event_handler("fixed")
|
14
|
-
class EventHandler(BaseEventHandler):
|
15
|
-
def __init__(self, *args, **kwargs):
|
16
|
-
super().__init__(*args, **kwargs)
|
17
|
-
|
18
|
-
|
19
|
-
def process(self, file_path: str):
|
20
|
-
_LOGGER.info(f"Processing: {file_path}")
|
21
|
-
file_name = os.path.basename(file_path)
|
22
|
-
chunk_start_time, _ = os.path.splitext(file_name)[0].split('_')
|
23
|
-
chunk = self._Chunk(chunk_start_time, self._tag)
|
24
|
-
|
25
|
-
_LOGGER.info("Creating spectrogram")
|
26
|
-
spectrogram = chunk.build_spectrogram()
|
27
|
-
|
28
|
-
_LOGGER.info("Averaging spectrogram")
|
29
|
-
spectrogram = self._average_in_time(spectrogram)
|
30
|
-
spectrogram = self._average_in_frequency(spectrogram)
|
31
|
-
|
32
|
-
_LOGGER.info("Joining spectrogram")
|
33
|
-
self._join_spectrogram(spectrogram)
|
34
|
-
|
35
|
-
bin_chunk = chunk.get_file('bin')
|
36
|
-
_LOGGER.info(f"Deleting {bin_chunk.file_path}")
|
37
|
-
bin_chunk.delete()
|
38
|
-
|
39
|
-
hdr_chunk = chunk.get_file('hdr')
|
40
|
-
_LOGGER.info(f"Deleting {hdr_chunk.file_path}")
|
41
|
-
hdr_chunk.delete()
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# SPDX-FileCopyrightText: © 2024 Jimmy Fitzpatrick <jcfitzpatrick12@gmail.com>
|
2
|
-
# This file is part of SPECTRE
|
3
|
-
# SPDX-License-Identifier: GPL-3.0-or-later
|
4
|
-
|
5
|
-
from logging import getLogger
|
6
|
-
_LOGGER = getLogger(__name__)
|
7
|
-
|
8
|
-
import os
|
9
|
-
|
10
|
-
from spectre_core.chunks.base import BaseChunk
|
11
|
-
from spectre_core.watchdog.base import BaseEventHandler
|
12
|
-
from spectre_core.watchdog.event_handler_register import register_event_handler
|
13
|
-
|
14
|
-
@register_event_handler("sweep")
|
15
|
-
class EventHandler(BaseEventHandler):
|
16
|
-
def __init__(self, *args, **kwargs):
|
17
|
-
super().__init__(*args, **kwargs)
|
18
|
-
|
19
|
-
self.previous_chunk: BaseChunk = None # cache for previous chunk
|
20
|
-
|
21
|
-
|
22
|
-
def process(self, file_path: str):
|
23
|
-
_LOGGER.info(f"Processing: {file_path}")
|
24
|
-
file_name = os.path.basename(file_path)
|
25
|
-
chunk_start_time, _ = os.path.splitext(file_name)[0].split('_')
|
26
|
-
chunk = self._Chunk(chunk_start_time, self._tag)
|
27
|
-
|
28
|
-
_LOGGER.info("Creating spectrogram")
|
29
|
-
spectrogram = chunk.build_spectrogram(previous_chunk = self.previous_chunk)
|
30
|
-
|
31
|
-
_LOGGER.info("Averaging spectrogram")
|
32
|
-
spectrogram = self._average_in_time(spectrogram)
|
33
|
-
spectrogram = self._average_in_frequency(spectrogram)
|
34
|
-
|
35
|
-
_LOGGER.info("Joining spectrogram")
|
36
|
-
self._join_spectrogram(spectrogram)
|
37
|
-
|
38
|
-
# if the previous chunk has not yet been set, it means we were processing the first chunk
|
39
|
-
# so we don't need to handle the previous chunk
|
40
|
-
if self.previous_chunk is None:
|
41
|
-
# instead, only set it for the next time this method is called
|
42
|
-
self.previous_chunk = chunk
|
43
|
-
|
44
|
-
# otherwise the previous chunk is defined (and by this point has already been processed)
|
45
|
-
else:
|
46
|
-
bin_chunk = self.previous_chunk.get_file('bin')
|
47
|
-
_LOGGER.info(f"Deleting {bin_chunk.file_path}")
|
48
|
-
bin_chunk.delete()
|
49
|
-
|
50
|
-
hdr_chunk = self.previous_chunk.get_file('hdr')
|
51
|
-
_LOGGER.info(f"Deleting {hdr_chunk.file_path}")
|
52
|
-
hdr_chunk.delete()
|
53
|
-
|
54
|
-
# and reassign the current chunk to be used as the previous chunk at the next call of this method
|
55
|
-
self.previous_chunk = chunk
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# SPDX-FileCopyrightText: © 2024 Jimmy Fitzpatrick <jcfitzpatrick12@gmail.com>
|
2
|
-
# This file is part of SPECTRE
|
3
|
-
# SPDX-License-Identifier: GPL-3.0-or-later
|
4
|
-
|
5
|
-
from logging import getLogger
|
6
|
-
_LOGGER = getLogger(__name__)
|
7
|
-
|
8
|
-
from queue import Queue, Empty
|
9
|
-
|
10
|
-
from watchdog.observers import Observer
|
11
|
-
|
12
|
-
from spectre_core.watchdog.factory import get_event_handler_from_tag
|
13
|
-
from spectre_core.cfg import CHUNKS_DIR_PATH
|
14
|
-
|
15
|
-
class PostProcessor:
|
16
|
-
def __init__(self,
|
17
|
-
tag: str):
|
18
|
-
self._observer: Observer = Observer()
|
19
|
-
self._exception_queue: Queue = Queue() # A thread-safe queue for exceptions
|
20
|
-
|
21
|
-
EventHandler = get_event_handler_from_tag(tag)
|
22
|
-
self._event_handler = EventHandler(tag,
|
23
|
-
self._exception_queue,
|
24
|
-
"bin")
|
25
|
-
|
26
|
-
|
27
|
-
def start(self):
|
28
|
-
_LOGGER.info("Starting post processor...")
|
29
|
-
|
30
|
-
# Schedule and start the observer
|
31
|
-
self._observer.schedule(self._event_handler,
|
32
|
-
CHUNKS_DIR_PATH,
|
33
|
-
recursive=True)
|
34
|
-
self._observer.start()
|
35
|
-
|
36
|
-
try:
|
37
|
-
# Monitor the observer and handle exceptions
|
38
|
-
while self._observer.is_alive():
|
39
|
-
try:
|
40
|
-
exc = self._exception_queue.get(block=True, timeout=0.25)
|
41
|
-
if exc:
|
42
|
-
raise exc # Propagate the exception
|
43
|
-
except Empty:
|
44
|
-
pass # Continue looping if no exception in queue
|
45
|
-
finally:
|
46
|
-
# Ensure the observer is properly stopped
|
47
|
-
self._observer.stop()
|
48
|
-
self._observer.join()
|
49
|
-
|
50
|
-
|
@@ -1,101 +0,0 @@
|
|
1
|
-
# SPDX-FileCopyrightText: © 2024 Jimmy Fitzpatrick <jcfitzpatrick12@gmail.com>
|
2
|
-
# This file is part of SPECTRE
|
3
|
-
# SPDX-License-Identifier: GPL-3.0-or-later
|
4
|
-
|
5
|
-
import os
|
6
|
-
import subprocess
|
7
|
-
import shutil
|
8
|
-
import gzip
|
9
|
-
from datetime import datetime
|
10
|
-
from typing import Optional
|
11
|
-
|
12
|
-
from spectre_core.cfg import (
|
13
|
-
DEFAULT_DATETIME_FORMAT,
|
14
|
-
CALLISTO_INSTRUMENT_CODES
|
15
|
-
)
|
16
|
-
from spectre_core.cfg import get_chunks_dir_path
|
17
|
-
|
18
|
-
temp_dir = os.path.join(os.environ['SPECTRE_DATA_DIR_PATH'], "tmp")
|
19
|
-
|
20
|
-
def get_chunk_name(station: str, date: str, time: str, instrument_code: str) -> str:
|
21
|
-
dt = datetime.strptime(f"{date}T{time}", '%Y%m%dT%H%M%S')
|
22
|
-
formatted_time = dt.strftime(DEFAULT_DATETIME_FORMAT)
|
23
|
-
return f"{formatted_time}_callisto-{station.lower()}-{instrument_code}.fits"
|
24
|
-
|
25
|
-
|
26
|
-
def get_chunk_components(gz_path: str):
|
27
|
-
file_name = os.path.basename(gz_path)
|
28
|
-
if not file_name.endswith(".fit.gz"):
|
29
|
-
raise ValueError(f"Unexpected file extension in {file_name}. Expected .fit.gz")
|
30
|
-
|
31
|
-
file_base_name = file_name.rstrip(".fit.gz")
|
32
|
-
parts = file_base_name.split('_')
|
33
|
-
if len(parts) != 4:
|
34
|
-
raise ValueError("Filename does not conform to the expected format of [station]_[date]_[time]_[instrument_code]")
|
35
|
-
|
36
|
-
return parts
|
37
|
-
|
38
|
-
|
39
|
-
def get_chunk_path(gz_path: str) -> str:
|
40
|
-
station, date, time, instrument_code = get_chunk_components(gz_path)
|
41
|
-
fits_chunk_name = get_chunk_name(station, date, time, instrument_code)
|
42
|
-
chunk_start_time = fits_chunk_name.split('_')[0]
|
43
|
-
chunk_start_datetime = datetime.strptime(chunk_start_time, DEFAULT_DATETIME_FORMAT)
|
44
|
-
chunk_parent_path = get_chunks_dir_path(year = chunk_start_datetime.year,
|
45
|
-
month = chunk_start_datetime.month,
|
46
|
-
day = chunk_start_datetime.day)
|
47
|
-
if not os.path.exists(chunk_parent_path):
|
48
|
-
os.makedirs(chunk_parent_path)
|
49
|
-
return os.path.join(chunk_parent_path, fits_chunk_name)
|
50
|
-
|
51
|
-
|
52
|
-
def unzip_file_to_chunks(gz_path: str):
|
53
|
-
fits_path = get_chunk_path(gz_path)
|
54
|
-
with gzip.open(gz_path, 'rb') as f_in, open(fits_path, 'wb') as f_out:
|
55
|
-
shutil.copyfileobj(f_in, f_out)
|
56
|
-
|
57
|
-
|
58
|
-
def unzip_to_chunks():
|
59
|
-
for entry in os.scandir(temp_dir):
|
60
|
-
if entry.is_file() and entry.name.endswith('.gz'):
|
61
|
-
unzip_file_to_chunks(entry.path)
|
62
|
-
os.remove(entry.path)
|
63
|
-
|
64
|
-
|
65
|
-
def download_callisto_data(instrument_code: str,
|
66
|
-
year: int,
|
67
|
-
month: int,
|
68
|
-
day: int):
|
69
|
-
date_str = f"{year:04d}/{month:02d}/{day:02d}"
|
70
|
-
base_url = f"http://soleil.i4ds.ch/solarradio/data/2002-20yy_Callisto/{date_str}/"
|
71
|
-
command = [
|
72
|
-
'wget', '-r', '-l1', '-nd', '-np',
|
73
|
-
'-R', '.tmp',
|
74
|
-
'-A', f'{instrument_code}*.fit.gz',
|
75
|
-
'-P', temp_dir,
|
76
|
-
base_url
|
77
|
-
]
|
78
|
-
|
79
|
-
try:
|
80
|
-
subprocess.run(command, check=True)
|
81
|
-
except subprocess.CalledProcessError as e:
|
82
|
-
print(f"An error occurred: {e}")
|
83
|
-
|
84
|
-
def fetch_chunks(instrument_code: Optional[str],
|
85
|
-
year: Optional[int],
|
86
|
-
month: Optional[int],
|
87
|
-
day: Optional[int]):
|
88
|
-
|
89
|
-
|
90
|
-
if (year is None) or (month is None) or (day is None):
|
91
|
-
raise ValueError(f"All of year, month and day should be specified")
|
92
|
-
|
93
|
-
if not os.path.exists(temp_dir):
|
94
|
-
os.mkdir(temp_dir)
|
95
|
-
|
96
|
-
if instrument_code not in CALLISTO_INSTRUMENT_CODES:
|
97
|
-
raise ValueError(f"No match found for \"{instrument_code}\". Expected one of {CALLISTO_INSTRUMENT_CODES}")
|
98
|
-
|
99
|
-
download_callisto_data(instrument_code, year, month, day)
|
100
|
-
unzip_to_chunks()
|
101
|
-
shutil.rmtree(temp_dir)
|
@@ -1,74 +0,0 @@
|
|
1
|
-
spectre_core/__init__.py,sha256=oFSWmGoXQLK5X5xHvWzTdNr9amuaiiGjZirXZVogACU,154
|
2
|
-
spectre_core/cfg.py,sha256=v9_yxV63rHMcSAsAFbWFBRDeElgcrDdY3yzGXFGJyxQ,3155
|
3
|
-
spectre_core/dynamic_imports.py,sha256=hZbFA9QSVUmAA779qrwHe6RylpjeAG_L2KTVrRZE-Qk,987
|
4
|
-
spectre_core/exceptions.py,sha256=i1uLL64DLESdzXTAPTsqc4Yg6LeU-ItOm5rhDlrDv7w,663
|
5
|
-
spectre_core/logging.py,sha256=wxhi9UubjfKtd5lpG3tklr8lJDDR0cUoA3y4GLK6wE8,6486
|
6
|
-
spectre_core/chunks/__init__.py,sha256=KqEz43Ifjbw_1cMdxt4s7iEUCOGmFruNN63qU2mgcmY,7148
|
7
|
-
spectre_core/chunks/base.py,sha256=wl2jqPTcmpK8uxnl85lDcEmpOrvZ55AvdmCdtphI3xs,5096
|
8
|
-
spectre_core/chunks/chunk_register.py,sha256=sS-T6d59zbh8_trr_7bYlq2O9Ak7k_XXHM6-yalwxaE,435
|
9
|
-
spectre_core/chunks/factory.py,sha256=gi0x7nsZZR8HUBxnpEfwZG5fI1jSzM2OVPwGR8i45YE,1133
|
10
|
-
spectre_core/chunks/library/__init__.py,sha256=w2G2Ew_yLK1q--1pwN-UsDSSa73Z6VHnn3jC-XXQNWE,272
|
11
|
-
spectre_core/chunks/library/callisto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
|
-
spectre_core/chunks/library/callisto/chunk.py,sha256=J_xZIL_9YChLZSK1pMjQZmNoUpcENPXeLlu7x7TbPZI,3931
|
13
|
-
spectre_core/chunks/library/fixed/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
|
-
spectre_core/chunks/library/fixed/chunk.py,sha256=ckBiEtSa6_S06d_H9LQ0ske5JT2ycF-LstWbDX1oo1c,6941
|
15
|
-
spectre_core/chunks/library/sweep/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
spectre_core/chunks/library/sweep/chunk.py,sha256=bXpC43kylsaAc88VEc0lnLy8AFXZivejqXUyovDz51U,21219
|
17
|
-
spectre_core/file_handlers/base.py,sha256=PbZkgCeZnkkO0TstuFf39oXh8VQDzwlEhwMWzplUDB0,1727
|
18
|
-
spectre_core/file_handlers/configs.py,sha256=5V_egP1R5uXsCbbG_NcHorpY6wJCderBk0KBT3LM3OI,8483
|
19
|
-
spectre_core/file_handlers/json.py,sha256=PBwjtM29jqfa9ozeRIuarkCJBD8uYIKyDCbM1V2GmtE,1230
|
20
|
-
spectre_core/file_handlers/text.py,sha256=K84BIab_qmbR5igCVJZu3uE47ykpM_bnsasd3WGNEuo,677
|
21
|
-
spectre_core/plotting/__init__.py,sha256=ZRQmBzZ0HWcVDaM5a8AneGbyHwx7dhtBs2z5H8VVspc,192
|
22
|
-
spectre_core/plotting/base.py,sha256=4HhPPP7BNe5_SUAl1Ee52_QP62Zzh3kmNJwLzCHKG3c,4808
|
23
|
-
spectre_core/plotting/factory.py,sha256=pYil7PbTs3e08ek6nq-y8mSEtNu7DI6uloiCwsuIoOw,940
|
24
|
-
spectre_core/plotting/format.py,sha256=Et-uc4juDl_2spLRZOzqaUVBP8-J3LPnV5M6CllM74E,512
|
25
|
-
spectre_core/plotting/panel_register.py,sha256=rsmG2hXnvVOy6vfWsEZlZQAXej7bRtqtvjnXObyUCg4,351
|
26
|
-
spectre_core/plotting/panel_stack.py,sha256=PxtoXp9WzSe38gG6dILoM__X_BxwNdydXRpzs3knsF0,5191
|
27
|
-
spectre_core/plotting/library/__init__.py,sha256=lQhj4kme2eKb-JSrHvLWkAjI7eVqexOxxUguo8LUXno,270
|
28
|
-
spectre_core/plotting/library/frequency_cuts/panel.py,sha256=LtCWNad4Z1gxBOxi_Ni1d6KZxsgoR5Mbm2tWXN7VDqI,2772
|
29
|
-
spectre_core/plotting/library/integral_over_frequency/panel.py,sha256=tvro2MCtY4Q0q7WdMUz9eW5Cvrweeqqse20q3x4D4fM,1274
|
30
|
-
spectre_core/plotting/library/spectrogram/panel.py,sha256=CAaPz7sDYoWZ3-4Jb1kVRu9bvJYaBRiXvoMkV7QXWqk,3556
|
31
|
-
spectre_core/plotting/library/time_cuts/panel.py,sha256=u9Sbnwy6ex61y5Jl-D77HlYvuuXdK8_YB-o2gCovCTY,2947
|
32
|
-
spectre_core/receivers/__init__.py,sha256=kKfhqrGs9sSPGLbrpTqScv816iPZOvT3ry3zSMcqLkM,227
|
33
|
-
spectre_core/receivers/base.py,sha256=UW2L28juLWyzI6t6Ub6Ws-K4J9U4HT4JSgdVtuiYP8k,16012
|
34
|
-
spectre_core/receivers/factory.py,sha256=aE-Yw_cnlkhRe5HxK0JqhDzd2AwZcKmB2QkAKwaq27Y,873
|
35
|
-
spectre_core/receivers/receiver_register.py,sha256=xHcRnT-3NQxyIWL3nyT3P9qT14Wl5liM9HbflOvOUAM,617
|
36
|
-
spectre_core/receivers/validators.py,sha256=aP8nbRWZxU5pOwBIXTojXuHd3i9yksHW_vIBn4cbKug,8481
|
37
|
-
spectre_core/receivers/library/__init__.py,sha256=xmtF5p3_ZkGfso_pKnxSgUcXXFLEBwERGPq1Pek7cOU,274
|
38
|
-
spectre_core/receivers/library/rsp1a/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
39
|
-
spectre_core/receivers/library/rsp1a/receiver.py,sha256=xs_aNMhwIYD83KwutizjBziyu9XsfHqGqvQXOFcglz4,2224
|
40
|
-
spectre_core/receivers/library/rsp1a/gr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
41
|
-
spectre_core/receivers/library/rsp1a/gr/fixed.py,sha256=P39JwuOe-ydk9m8BNOHFDpzaqjenRnTIA7tpECshfUM,3369
|
42
|
-
spectre_core/receivers/library/rsp1a/gr/sweep.py,sha256=9ZAoI0u1814lOM_cVwJnLUNSgM3VMstfvWKP67dVEV4,4741
|
43
|
-
spectre_core/receivers/library/rspduo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
44
|
-
spectre_core/receivers/library/rspduo/receiver.py,sha256=EMBFWwFjoIP2buwwamyb3uaYqMQwQHMzNi-we7_OfcU,3377
|
45
|
-
spectre_core/receivers/library/rspduo/gr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
46
|
-
spectre_core/receivers/library/rspduo/gr/tuner_1_fixed.py,sha256=xO9F_GBwgNnebrxoZYPwbXLL2HmH0CNLrVlpQ6Z7bx0,3887
|
47
|
-
spectre_core/receivers/library/rspduo/gr/tuner_1_sweep.py,sha256=gR5arbjvJBJjCdQnpAdwNd7bEtnvDbhL_ttUhKk0Zss,5066
|
48
|
-
spectre_core/receivers/library/rspduo/gr/tuner_2_fixed.py,sha256=O86R3tuJ-7cZXfVECuZkds-wCxKdBKJ8MhVACJFgzeo,4130
|
49
|
-
spectre_core/receivers/library/rspduo/gr/tuner_2_sweep.py,sha256=4JgJ2QRO5DFPfqUTHBojj8ERR_4QpHyTBqnAXhOzykE,4747
|
50
|
-
spectre_core/receivers/library/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
51
|
-
spectre_core/receivers/library/test/receiver.py,sha256=ihfmUFFFEcyjMnMrqP4ajgB1mdC0vWEe9LFkNYHZn_Y,8346
|
52
|
-
spectre_core/receivers/library/test/gr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
53
|
-
spectre_core/receivers/library/test/gr/cosine_signal_1.py,sha256=6XgYjYMh-QNPs_UUGUQcU_VQFr6BG4OLdsW-M-RU5Ww,2943
|
54
|
-
spectre_core/receivers/library/test/gr/tagged_staircase.py,sha256=5rJHbB-3vdXjqT8DrcAGUSebaAqZ5RQtYHBWgH9iU2E,3465
|
55
|
-
spectre_core/spectrograms/__init__.py,sha256=OFW82_itCktN8dFm_UO5gbgmzFs51v9KEHrSZWLuIUY,155
|
56
|
-
spectre_core/spectrograms/analytical.py,sha256=c5X40YgLlutP8sbz6dqODZaCmZ98sAjubO3PtWj7ZZw,8657
|
57
|
-
spectre_core/spectrograms/array_operations.py,sha256=6qKd3y2z6Pmu_U8yxTR4FN4eMhS10KgZ8rH60B_IXqw,2577
|
58
|
-
spectre_core/spectrograms/spectrogram.py,sha256=EqeQyvjzjoKaXou4vJbPbRx85BeMPB9iiJtFZcCyimI,19488
|
59
|
-
spectre_core/spectrograms/transform.py,sha256=xo7ch2lrRkJ54cfIqbkaTHNo_AptBuK0zRELPf7SfIE,13860
|
60
|
-
spectre_core/watchdog/__init__.py,sha256=gGjyC7MeCfarB9Yu0RycZs-Wh_of7Cbp_wIyovYvtOQ,232
|
61
|
-
spectre_core/watchdog/base.py,sha256=xDvWtt7fXeBQoZpR-ZxopAAKNHRa8YNSmfR63bYsSlU,4178
|
62
|
-
spectre_core/watchdog/event_handler_register.py,sha256=DwlkU92IFkZ1_qvGfhep_OfuqTOIR_efY5qFpn1perw,498
|
63
|
-
spectre_core/watchdog/factory.py,sha256=Uqx4nIZPVRxx7hRgm1M-1p2Sc7m3ObkIKWIC_ru9ObU,1115
|
64
|
-
spectre_core/watchdog/post_processor.py,sha256=rZwe4u_T-7F7_q485PtUUZMAxPPec35zXV81MyERIjg,1673
|
65
|
-
spectre_core/watchdog/library/__init__.py,sha256=vEwAnAV-sv7WcNYOdnjr1JVqZYr29Wr2cv01eoxwdmg,282
|
66
|
-
spectre_core/watchdog/library/fixed/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
67
|
-
spectre_core/watchdog/library/fixed/event_handler.py,sha256=yWWS80LukB-cTrKBsF4-pRvw2obkX2MzQ5ZGytOtmAg,1387
|
68
|
-
spectre_core/watchdog/library/sweep/event_handler.py,sha256=wDISZiQXBeqLDPxgEMo0a2QAXqQVOO7fng3yhZWSR74,2188
|
69
|
-
spectre_core/web_fetch/callisto.py,sha256=874osjbp61qFwRgV584fpSp7E-xz8g1FEelbNBKhCsw,3632
|
70
|
-
spectre_core-0.0.8.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
71
|
-
spectre_core-0.0.8.dist-info/METADATA,sha256=ltPXaVWUSk8ggdxRsRN9RLj3SIjRvNjGueNoIk3cst4,42150
|
72
|
-
spectre_core-0.0.8.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
73
|
-
spectre_core-0.0.8.dist-info/top_level.txt,sha256=-UsyjpFohXgZpgcZ9QbVeXhsIyF3Am8RxNFNDV_Ta2Y,13
|
74
|
-
spectre_core-0.0.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|