spectre-core 0.0.20__py3-none-any.whl → 0.0.21__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/batches/__init__.py +2 -2
- spectre_core/batches/_base.py +24 -2
- spectre_core/batches/_batches.py +3 -5
- spectre_core/logs/__init__.py +3 -3
- spectre_core/logs/_logs.py +16 -5
- spectre_core/wgetting/_callisto.py +5 -4
- {spectre_core-0.0.20.dist-info → spectre_core-0.0.21.dist-info}/METADATA +1 -2
- {spectre_core-0.0.20.dist-info → spectre_core-0.0.21.dist-info}/RECORD +11 -11
- {spectre_core-0.0.20.dist-info → spectre_core-0.0.21.dist-info}/WHEEL +1 -1
- {spectre_core-0.0.20.dist-info → spectre_core-0.0.21.dist-info}/licenses/LICENSE +0 -0
- {spectre_core-0.0.20.dist-info → spectre_core-0.0.21.dist-info}/top_level.txt +0 -0
spectre_core/batches/__init__.py
CHANGED
@@ -10,12 +10,12 @@ from .plugins._batch_keys import BatchKey
|
|
10
10
|
from .plugins._iq_stream import IQStreamBatch, IQMetadata
|
11
11
|
from .plugins._callisto import CallistoBatch
|
12
12
|
|
13
|
-
from ._base import BaseBatch, BatchFile
|
13
|
+
from ._base import BaseBatch, BatchFile, parse_batch_base_file_name
|
14
14
|
from ._batches import Batches
|
15
15
|
from ._factory import get_batch_cls, get_batch_cls_from_tag
|
16
16
|
|
17
17
|
__all__ = [
|
18
18
|
"IQStreamBatch", "IQMetadata", "CallistoBatch", "BaseBatch", "BatchFile",
|
19
|
-
"Batches", "get_batch_cls", "BatchKey", "get_batch_cls_from_tag"
|
19
|
+
"Batches", "get_batch_cls", "BatchKey", "get_batch_cls_from_tag", "parse_batch_base_file_name"
|
20
20
|
]
|
21
21
|
|
spectre_core/batches/_base.py
CHANGED
@@ -3,19 +3,33 @@
|
|
3
3
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
4
4
|
|
5
5
|
from datetime import datetime
|
6
|
-
from typing import TypeVar
|
6
|
+
from typing import TypeVar, Tuple
|
7
7
|
from base64 import b64encode
|
8
8
|
from functools import cached_property
|
9
9
|
from abc import ABC, abstractmethod
|
10
10
|
from dataclasses import dataclass
|
11
|
+
from os.path import splitext
|
11
12
|
|
12
13
|
from spectre_core._file_io import BaseFileHandler
|
13
14
|
from spectre_core.config import get_batches_dir_path, TimeFormat
|
14
15
|
from spectre_core.spectrograms import Spectrogram
|
15
16
|
|
16
17
|
|
18
|
+
def parse_batch_base_file_name(
|
19
|
+
base_file_name: str
|
20
|
+
) -> Tuple[str, str, str]:
|
21
|
+
"""Parse the base file name of a batch file into a start time, tag and extension.
|
22
|
+
"""
|
23
|
+
batch_name, extension = splitext(base_file_name)
|
24
|
+
# strip the dot from the extension
|
25
|
+
extension = extension.lstrip('.')
|
26
|
+
start_time, tag = batch_name.split("_", 1)
|
27
|
+
return start_time, tag, extension
|
28
|
+
|
29
|
+
|
17
30
|
T = TypeVar('T')
|
18
31
|
|
32
|
+
|
19
33
|
class BatchFile(BaseFileHandler[T]):
|
20
34
|
"""Abstract base class for files belonging to a batch, identified by their file extension.
|
21
35
|
|
@@ -283,4 +297,12 @@ class BaseBatch(ABC):
|
|
283
297
|
:return: The spectrogram stored by the batch `spectrogram_file`.
|
284
298
|
"""
|
285
299
|
return self.spectrogram_file.read()
|
286
|
-
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
spectre_core/batches/_batches.py
CHANGED
@@ -13,7 +13,7 @@ from spectre_core.config import get_batches_dir_path
|
|
13
13
|
from spectre_core.exceptions import (
|
14
14
|
BatchNotFoundError
|
15
15
|
)
|
16
|
-
from ._base import BaseBatch
|
16
|
+
from ._base import BaseBatch, parse_batch_base_file_name
|
17
17
|
|
18
18
|
T = TypeVar('T', bound=BaseBatch)
|
19
19
|
class Batches(Generic[T]):
|
@@ -144,9 +144,7 @@ class Batches(Generic[T]):
|
|
144
144
|
# get a list of all batch file names in the batches directory path
|
145
145
|
batch_file_names = [f for (_, _, files) in os.walk(self.batches_dir_path) for f in files]
|
146
146
|
for batch_file_name in batch_file_names:
|
147
|
-
|
148
|
-
batch_name, _ = os.path.splitext(batch_file_name)
|
149
|
-
start_time, tag = batch_name.split("_", 1)
|
147
|
+
start_time, tag, _ = parse_batch_base_file_name(batch_file_name)
|
150
148
|
if tag == self._tag:
|
151
149
|
self._batch_map[start_time] = self.batch_cls(start_time, tag)
|
152
150
|
|
@@ -207,7 +205,7 @@ class Batches(Generic[T]):
|
|
207
205
|
return self._get_from_start_time(subscript)
|
208
206
|
elif isinstance(subscript, int):
|
209
207
|
return self._get_from_index(subscript)
|
210
|
-
|
208
|
+
|
211
209
|
|
212
210
|
def get_spectrogram(
|
213
211
|
self,
|
spectre_core/logs/__init__.py
CHANGED
@@ -8,10 +8,10 @@
|
|
8
8
|
from ._process_types import ProcessType
|
9
9
|
from ._decorators import log_call
|
10
10
|
from ._configure import configure_root_logger, get_root_logger_state
|
11
|
-
from ._logs import Log, Logs
|
11
|
+
from ._logs import Log, Logs, parse_log_base_file_name
|
12
12
|
|
13
13
|
|
14
14
|
__all__ = [
|
15
15
|
"log_call", "configure_root_logger", "Log", "Logs", "ProcessType",
|
16
|
-
"get_root_logger_state"
|
17
|
-
]
|
16
|
+
"get_root_logger_state", "parse_log_base_file_name"
|
17
|
+
]
|
spectre_core/logs/_logs.py
CHANGED
@@ -6,7 +6,7 @@ from logging import getLogger
|
|
6
6
|
_LOGGER = getLogger(__name__)
|
7
7
|
|
8
8
|
import os
|
9
|
-
from typing import Optional, Iterator
|
9
|
+
from typing import Optional, Iterator, Tuple
|
10
10
|
from collections import OrderedDict
|
11
11
|
from datetime import datetime
|
12
12
|
|
@@ -14,6 +14,17 @@ from spectre_core._file_io import TextHandler
|
|
14
14
|
from spectre_core.config import get_logs_dir_path, TimeFormat
|
15
15
|
from ._process_types import ProcessType
|
16
16
|
|
17
|
+
|
18
|
+
def parse_log_base_file_name(
|
19
|
+
base_file_name: str
|
20
|
+
) -> Tuple[str, str, str]:
|
21
|
+
"""Parse the base file name of a log into a start time, process ID and process type.
|
22
|
+
"""
|
23
|
+
file_name, _ = os.path.splitext(base_file_name)
|
24
|
+
log_start_time, pid, process_type = file_name.split("_")
|
25
|
+
return log_start_time, pid, process_type
|
26
|
+
|
27
|
+
|
17
28
|
class Log(TextHandler):
|
18
29
|
"""Interface to read log files generated by `spectre`."""
|
19
30
|
def __init__(
|
@@ -177,13 +188,13 @@ class Logs:
|
|
177
188
|
log_files = [f for (_, _, files) in os.walk(self.logs_dir_path) for f in files]
|
178
189
|
|
179
190
|
for log_file in log_files:
|
180
|
-
|
181
|
-
log_start_time, pid, process_type =
|
191
|
+
|
192
|
+
log_start_time, pid, process_type = parse_log_base_file_name(log_file)
|
182
193
|
|
183
194
|
if self.process_type and process_type != self.process_type:
|
184
195
|
continue
|
185
196
|
|
186
|
-
self._log_map[
|
197
|
+
self._log_map[log_file] = Log(log_start_time, pid, ProcessType(process_type))
|
187
198
|
|
188
199
|
self._log_map = OrderedDict(sorted(self._log_map.items()))
|
189
200
|
|
@@ -225,4 +236,4 @@ class Logs:
|
|
225
236
|
for log in self.log_list:
|
226
237
|
if log.pid == pid:
|
227
238
|
return log
|
228
|
-
raise FileNotFoundError(f"Log handler for PID '{pid}' not
|
239
|
+
raise FileNotFoundError(f"Log handler for PID '{pid}' could not be identified")
|
@@ -6,7 +6,8 @@ import os
|
|
6
6
|
import subprocess
|
7
7
|
import shutil
|
8
8
|
import gzip
|
9
|
-
from datetime import datetime
|
9
|
+
from datetime import datetime, date
|
10
|
+
from typing import Tuple
|
10
11
|
|
11
12
|
from spectre_core.config import (
|
12
13
|
get_spectre_data_dir_path, get_batches_dir_path, TimeFormat
|
@@ -195,7 +196,7 @@ def download_callisto_data(
|
|
195
196
|
year: int,
|
196
197
|
month: int,
|
197
198
|
day: int
|
198
|
-
) -> list[str]:
|
199
|
+
) -> Tuple[list[str], date]:
|
199
200
|
"""
|
200
201
|
Download and decompress e-Callisto FITS files, saving them as `spectre` batch files.
|
201
202
|
|
@@ -203,7 +204,7 @@ def download_callisto_data(
|
|
203
204
|
:param year: Year of the observation.
|
204
205
|
:param month: Month of the observation.
|
205
206
|
:param day: Day of the observation.
|
206
|
-
:return: A list of file names of all newly created batch files, as absolute paths within the container's file system.
|
207
|
+
:return: A list of file names of all newly created batch files, as absolute paths within the container's file system. Additionally, return the start date shared by all batch files.
|
207
208
|
"""
|
208
209
|
tmp_dir = os.path.join(get_spectre_data_dir_path(), "tmp")
|
209
210
|
# if there are any residual files in the temporary directory, remove them.
|
@@ -212,4 +213,4 @@ def download_callisto_data(
|
|
212
213
|
os.makedirs(tmp_dir, exist_ok=True)
|
213
214
|
|
214
215
|
_wget_callisto_data(instrument_code.value, year, month, day, tmp_dir)
|
215
|
-
return sorted( _unzip_to_batches(tmp_dir) )
|
216
|
+
return sorted( _unzip_to_batches(tmp_dir) ), date(year, month, day)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: spectre-core
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.21
|
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
|
@@ -691,7 +691,6 @@ Requires-Dist: scipy==1.12.0
|
|
691
691
|
Requires-Dist: astropy==6.0.1
|
692
692
|
Requires-Dist: matplotlib==3.5.0
|
693
693
|
Requires-Dist: watchdog==4.0.0
|
694
|
-
Requires-Dist: mypy==1.14.1
|
695
694
|
Dynamic: license-file
|
696
695
|
|
697
696
|
# spectre-core
|
@@ -3,9 +3,9 @@ spectre_core/exceptions.py,sha256=ccr-n88W0c_DKcsKMAe09QHX1iG2LUEqOMYHcGB-_do,45
|
|
3
3
|
spectre_core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
spectre_core/_file_io/__init__.py,sha256=RZAtX8pFtdtTlxoxxttxJf1Wcg8lDFXgKMe1rcgaFP8,351
|
5
5
|
spectre_core/_file_io/file_handlers.py,sha256=dJ3rMcTGbNnEXbYZgVoaos4p6qKGs-rWNeY8nmluQCQ,6402
|
6
|
-
spectre_core/batches/__init__.py,sha256=
|
7
|
-
spectre_core/batches/_base.py,sha256=
|
8
|
-
spectre_core/batches/_batches.py,sha256=
|
6
|
+
spectre_core/batches/__init__.py,sha256=AIE3S3D3z__Ox557W95EILiv-BYoxjyRODMo2vu7My0,743
|
7
|
+
spectre_core/batches/_base.py,sha256=0-eYk7AINGMMUyecAqBEQ97tWi765MUHysGi2gvdVTI,9079
|
8
|
+
spectre_core/batches/_batches.py,sha256=2tgP2Mfwlay2bkblruS2mAfgfmdP3Doq841tKb8rq1U,7670
|
9
9
|
spectre_core/batches/_factory.py,sha256=ApshWhbhZ-CSoQBrlcYaC5W5p_w_v4pxOdOdlrF7YIA,2277
|
10
10
|
spectre_core/batches/_register.py,sha256=dSQC8KXj_jG8EiPwmKPdV0HSSalIZLaWt-8E29sczJM,1085
|
11
11
|
spectre_core/batches/plugins/_batch_keys.py,sha256=8v0KE1n0NAQX0i9SwwB4Lgkct7Q_jna-H5S0Gs6p1qg,544
|
@@ -26,10 +26,10 @@ spectre_core/config/_time_formats.py,sha256=gS0j5zIvBhnV7KMYvTloloIbVwmCYn8MMKn3
|
|
26
26
|
spectre_core/jobs/__init__.py,sha256=WKTvxvpciedm6tsKjU02iXJhIdNsMDt-BnMVwVme2Bo,412
|
27
27
|
spectre_core/jobs/_jobs.py,sha256=gGpxsLZZ7EdXBYGH-r_pKnRGWSapr78E5SK_VnulaGg,3844
|
28
28
|
spectre_core/jobs/_workers.py,sha256=9GPEJVqIFuOAXpY9gfJxX-0_UPJ6RBtUe5qC5JLiYNw,5023
|
29
|
-
spectre_core/logs/__init__.py,sha256=
|
29
|
+
spectre_core/logs/__init__.py,sha256=cUIjKXzxT9pzITVOsv5zkX97WnMZNHEUt9_orKuaHMw,539
|
30
30
|
spectre_core/logs/_configure.py,sha256=NlR3BEwhj5k0qlTooOLb6OFRbYcDT05eWN-9Sl9Hkbk,2208
|
31
31
|
spectre_core/logs/_decorators.py,sha256=u_Ixpr6aeKiSjM0mtqHuGXVGawNjgJPRvIpAj0zPSdQ,1169
|
32
|
-
spectre_core/logs/_logs.py,sha256=
|
32
|
+
spectre_core/logs/_logs.py,sha256=ZNYtJN_A_StRfJJFkv5rTmQ2z2427YIxXGkd_6NQY1Y,6900
|
33
33
|
spectre_core/logs/_process_types.py,sha256=qnKfeXPk-6NOlNf4XtD8D3tYbA_ZVhHSZAKSd2MiVmY,488
|
34
34
|
spectre_core/plotting/__init__.py,sha256=9zhmCphR4DSHlWfJhHeWPbvIrh8Kycov5Ta6woSrUZg,517
|
35
35
|
spectre_core/plotting/_base.py,sha256=yRZ6pf_d1mm35yn4AU8Hu2X50rCeB0KX1yEygDbpYo4,8547
|
@@ -70,9 +70,9 @@ spectre_core/spectrograms/_array_operations.py,sha256=79vddwWqR5i6OkeD5L_84t8svs
|
|
70
70
|
spectre_core/spectrograms/_spectrogram.py,sha256=WhHEt_QpmzspDqYlzdZcJ8CAXxRfs8-JfP0T3NHpjLQ,28205
|
71
71
|
spectre_core/spectrograms/_transform.py,sha256=_Kw9XfGNuhBqHfwPxNL4d-KIZJgzEX449ew1e17_k00,11698
|
72
72
|
spectre_core/wgetting/__init__.py,sha256=UkS0Z0wuuqpoZ1EL35wJcDpjBiAaZgdZ7064yGESxNE,341
|
73
|
-
spectre_core/wgetting/_callisto.py,sha256=
|
74
|
-
spectre_core-0.0.
|
75
|
-
spectre_core-0.0.
|
76
|
-
spectre_core-0.0.
|
77
|
-
spectre_core-0.0.
|
78
|
-
spectre_core-0.0.
|
73
|
+
spectre_core/wgetting/_callisto.py,sha256=jMvv75d6152KmasZlydc4nXxuX0nAl4snSXzXOVwVGU,7597
|
74
|
+
spectre_core-0.0.21.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
75
|
+
spectre_core-0.0.21.dist-info/METADATA,sha256=HcteVzzTLeZCUSUnCfqHNud70AutsvI6tgztzBPokzE,42094
|
76
|
+
spectre_core-0.0.21.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
77
|
+
spectre_core-0.0.21.dist-info/top_level.txt,sha256=-UsyjpFohXgZpgcZ9QbVeXhsIyF3Am8RxNFNDV_Ta2Y,13
|
78
|
+
spectre_core-0.0.21.dist-info/RECORD,,
|
File without changes
|
File without changes
|