SimbioReader 0.6.0__tar.gz → 0.6.3__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.
- {simbioreader-0.6.0/src/SimbioReader.egg-info → simbioreader-0.6.3}/PKG-INFO +10 -5
- {simbioreader-0.6.0 → simbioreader-0.6.3}/README.md +7 -2
- {simbioreader-0.6.0 → simbioreader-0.6.3}/pyproject.toml +3 -3
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/constants.py +1 -1
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/filters.py +13 -1
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/filters_tools.py +6 -4
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/simbioInfo.py +1 -1
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/sr.py +106 -36
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/tools.py +23 -10
- {simbioreader-0.6.0 → simbioreader-0.6.3/src/SimbioReader.egg-info}/PKG-INFO +10 -5
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader.egg-info/requires.txt +1 -1
- {simbioreader-0.6.0 → simbioreader-0.6.3}/test/test_new_format.py +2 -2
- {simbioreader-0.6.0 → simbioreader-0.6.3}/LICENSE +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/setup.cfg +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/__init__.py +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/__main__.py +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/cli.py +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/exceptions.py +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/infocli.py +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/phases.py +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/subphases.py +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/tests.py +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader/version.py +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader.egg-info/SOURCES.txt +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader.egg-info/dependency_links.txt +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader.egg-info/entry_points.txt +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/src/SimbioReader.egg-info/top_level.txt +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/test/test_db.py +0 -0
- {simbioreader-0.6.0 → simbioreader-0.6.3}/test/test_tools.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: SimbioReader
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
4
4
|
Summary: Python Reader for the data from SIMBIO-SYS instrument suite on-board the ESA mission BepiColombo
|
|
5
5
|
Author-email: Romolo Politi <Romolo.Politi@inaf.it>
|
|
6
6
|
Project-URL: Repository, https://github.com/SIMBIO-SYS/SimbioReader
|
|
@@ -9,24 +9,23 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.12
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.13
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.14
|
|
12
|
-
Classifier: Development Status ::
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Requires-Python: >=3.11
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
16
|
Requires-Dist: numpy<3.0.0,>=2.3.3
|
|
17
17
|
Requires-Dist: pandas<3.0.0,>=2.3.2
|
|
18
18
|
Requires-Dist: rich-click<2.0.0,>=1.8.9
|
|
19
|
-
Requires-Dist: pillow<12.0.0,>=11.3.0
|
|
20
19
|
Requires-Dist: update-checker<0.19.0,>=0.18.0
|
|
21
20
|
Requires-Dist: importlib-metadata<9.0.0,>=8.7.0
|
|
21
|
+
Requires-Dist: pillow<13.0.0,>=12.0.0
|
|
22
22
|
Provides-Extra: docs
|
|
23
23
|
Requires-Dist: sphinx; extra == "docs"
|
|
24
24
|
Dynamic: license-file
|
|
25
25
|
|
|
26
|
-

|
|
27
27
|

|
|
28
28
|

|
|
29
|
-
[](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/python-publish.yml)
|
|
30
29
|
[](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/test.yml)
|
|
31
30
|
[](https://simbioreader.readthedocs.io/en/latest/?badge=latest)
|
|
32
31
|
|
|
@@ -45,6 +44,12 @@ To install the reader you can use the command:
|
|
|
45
44
|
$ python3 -m pip install SimbioReader
|
|
46
45
|
```
|
|
47
46
|
|
|
47
|
+
or using poetry
|
|
48
|
+
|
|
49
|
+
```console
|
|
50
|
+
$ poetry add SimbioReader
|
|
51
|
+
```
|
|
52
|
+
|
|
48
53
|
## Usage
|
|
49
54
|
|
|
50
55
|
The package contain a class that read and decode the SIMBIO-SYS image
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-

|
|
2
2
|

|
|
3
3
|

|
|
4
|
-
[](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/python-publish.yml)
|
|
5
4
|
[](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/test.yml)
|
|
6
5
|
[](https://simbioreader.readthedocs.io/en/latest/?badge=latest)
|
|
7
6
|
|
|
@@ -20,6 +19,12 @@ To install the reader you can use the command:
|
|
|
20
19
|
$ python3 -m pip install SimbioReader
|
|
21
20
|
```
|
|
22
21
|
|
|
22
|
+
or using poetry
|
|
23
|
+
|
|
24
|
+
```console
|
|
25
|
+
$ poetry add SimbioReader
|
|
26
|
+
```
|
|
27
|
+
|
|
23
28
|
## Usage
|
|
24
29
|
|
|
25
30
|
The package contain a class that read and decode the SIMBIO-SYS image
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "SimbioReader"
|
|
3
|
-
version = "0.6.
|
|
3
|
+
version = "0.6.3"
|
|
4
4
|
description="Python Reader for the data from SIMBIO-SYS instrument suite on-board the ESA mission BepiColombo"
|
|
5
5
|
dependencies = [
|
|
6
6
|
|
|
7
7
|
"numpy (>=2.3.3,<3.0.0)",
|
|
8
8
|
"pandas (>=2.3.2,<3.0.0)",
|
|
9
9
|
"rich-click (>=1.8.9,<2.0.0)",
|
|
10
|
-
"pillow (>=11.3.0,<12.0.0)",
|
|
11
10
|
"update-checker (>=0.18.0,<0.19.0)",
|
|
12
11
|
"importlib-metadata (>=8.7.0,<9.0.0)",
|
|
12
|
+
"pillow (>=12.0.0,<13.0.0)",
|
|
13
13
|
]
|
|
14
14
|
requires-python = ">=3.11"
|
|
15
15
|
|
|
@@ -23,7 +23,7 @@ classifiers = [
|
|
|
23
23
|
"Programming Language :: Python :: 3.12",
|
|
24
24
|
"Programming Language :: Python :: 3.13",
|
|
25
25
|
"Programming Language :: Python :: 3.14",
|
|
26
|
-
"Development Status ::
|
|
26
|
+
"Development Status :: 4 - Beta",
|
|
27
27
|
|
|
28
28
|
]
|
|
29
29
|
|
|
@@ -19,7 +19,7 @@ CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
|
|
|
19
19
|
progEpilog = "- For any information or suggestion please contact " \
|
|
20
20
|
"[bold magenta]Romolo.Politi@inaf.it[/bold magenta]"
|
|
21
21
|
|
|
22
|
-
VERSION = (0,6,
|
|
22
|
+
VERSION = (0,6,2,'f',1)
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
datamodel='1.22.0.0'
|
|
@@ -139,7 +139,19 @@ hricFilters={
|
|
|
139
139
|
"cust0":{
|
|
140
140
|
"name" : "PAN-L - custom",
|
|
141
141
|
"desc" : "Fraction of the CCD used by the PAN-L filter",
|
|
142
|
-
"id" : "
|
|
142
|
+
"id" : "CUST-0",
|
|
143
|
+
"bandwidth" : "204.3",
|
|
144
|
+
"centerFilter" : "699.5",
|
|
145
|
+
"interframeDel": "0.8",
|
|
146
|
+
"fistLine" : "1227",
|
|
147
|
+
"firstSample" : "576",
|
|
148
|
+
"line" : "384",
|
|
149
|
+
"sample" : "896"
|
|
150
|
+
},
|
|
151
|
+
"cust1":{
|
|
152
|
+
"name" : "PAN-L - custom",
|
|
153
|
+
"desc" : "Fraction of the CCD used by the PAN-L filter",
|
|
154
|
+
"id" : "CUST-1",
|
|
143
155
|
"bandwidth" : "204.3",
|
|
144
156
|
"centerFilter" : "699.5",
|
|
145
157
|
"interframeDel": "0.8",
|
|
@@ -15,11 +15,13 @@ class Filter:
|
|
|
15
15
|
raise ValueError("Invalid channel.")
|
|
16
16
|
itm = [elem for elem in flt.values() if elem['name']==name]
|
|
17
17
|
if len(itm)==0:
|
|
18
|
-
|
|
18
|
+
itm=[elem for elem in flt.values() if elem['id']=='CUST-0']
|
|
19
|
+
# raise ValueError("No filters found.")
|
|
19
20
|
elif len(itm)>1:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
pass
|
|
22
|
+
# raise ValueError("Multiple filters found. Please provide a detailed filter name.")
|
|
23
|
+
# elif len(itm)==1:
|
|
24
|
+
itm=itm[0]
|
|
23
25
|
|
|
24
26
|
for key, value in itm.items():
|
|
25
27
|
setattr(self, key, value)
|
|
@@ -44,7 +44,7 @@ class Phase:
|
|
|
44
44
|
dt = parse(dt,ignoretz=True)
|
|
45
45
|
phase_data = self._find_phase_by_date(dt)
|
|
46
46
|
if not phase_data:
|
|
47
|
-
raise ValueError("No phase found for the given date.")
|
|
47
|
+
raise ValueError(f"No phase found for the given date. (dt: {dt})")
|
|
48
48
|
else:
|
|
49
49
|
raise ValueError("You must provide a phase name or a date.")
|
|
50
50
|
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
from datetime import datetime
|
|
1
3
|
from pathlib import Path
|
|
4
|
+
from xml.dom.minidom import Document, Element, parse, parseString
|
|
5
|
+
|
|
2
6
|
import numpy as np
|
|
7
|
+
import pandas as pd
|
|
8
|
+
from dateutil import parser
|
|
3
9
|
from PIL import Image as im
|
|
10
|
+
from rich.columns import Columns
|
|
4
11
|
from rich.console import Console
|
|
5
|
-
from xml.dom.minidom import Element, parse
|
|
6
|
-
from SimbioReader.tools import getElement, getValue, camel_case
|
|
7
|
-
from dateutil import parser
|
|
8
|
-
import pandas as pd
|
|
9
12
|
from rich.panel import Panel
|
|
10
13
|
from rich.table import Table
|
|
11
|
-
from
|
|
12
|
-
|
|
13
|
-
from SimbioReader.
|
|
14
|
+
from update_checker import UpdateChecker
|
|
15
|
+
|
|
16
|
+
from SimbioReader.constants import MSG, data_types
|
|
14
17
|
from SimbioReader.exceptions import SizeError
|
|
15
|
-
from SimbioReader.
|
|
16
|
-
from
|
|
17
|
-
|
|
18
|
-
import hashlib
|
|
18
|
+
from SimbioReader.filters_tools import Filter
|
|
19
|
+
from SimbioReader.tools import (camel_case, gen_filename, getElement, getValue,
|
|
20
|
+
lidUpdate, lvidUpdate, pretty_print, updateXML)
|
|
19
21
|
from SimbioReader.version import version
|
|
22
|
+
|
|
20
23
|
__version__ = version.full()
|
|
21
24
|
|
|
22
25
|
class Detector:
|
|
@@ -113,7 +116,7 @@ class DataStructure:
|
|
|
113
116
|
self.md5 = getValue(fl,'md5_checksum')
|
|
114
117
|
self.axes = int(getValue(dat,'axes'))
|
|
115
118
|
self.band= None
|
|
116
|
-
if self.axes == 3 and channel != '
|
|
119
|
+
if self.axes == 3 and channel != 'vihi':
|
|
117
120
|
raise ValueError("The number of axes is wrong for the channel")
|
|
118
121
|
for i in range(self.axes):
|
|
119
122
|
axis = getElement(dat,'Axis_Array',i)
|
|
@@ -256,17 +259,18 @@ class Target:
|
|
|
256
259
|
return self.__str__()
|
|
257
260
|
|
|
258
261
|
class SimbioObject:
|
|
259
|
-
def __init__(self, file_name: str,
|
|
260
|
-
imaging: Element, geometry: Element,file_obs: Element, console: Console = None, debug:bool=False, verbose:bool=False):
|
|
262
|
+
def __init__(self, file_name: str, channel: str,
|
|
263
|
+
imaging: Element, geometry: Element,file_obs: Element, filter_name: str= None,console: Console = None, debug:bool=False, verbose:bool=False):
|
|
261
264
|
if console is None:
|
|
262
265
|
self.console = Console()
|
|
263
266
|
else:
|
|
264
267
|
self.console = console
|
|
265
|
-
self.file_name = file_name
|
|
268
|
+
self.file_name = Path(file_name)
|
|
266
269
|
self.filter_name = filter_name
|
|
267
270
|
self.channel = channel
|
|
268
271
|
self.imaging = imaging
|
|
269
272
|
self.geometry = geometry
|
|
273
|
+
self.debug=debug
|
|
270
274
|
self.exposure_time = getValue(imaging, "img:exposure_duration")
|
|
271
275
|
subFrame = getElement(imaging, "img:Subframe")
|
|
272
276
|
self.firstLine = int(getValue(subFrame, 'img:first_line'))
|
|
@@ -279,7 +283,7 @@ class SimbioObject:
|
|
|
279
283
|
self.samples=self.data_stucture.sample
|
|
280
284
|
self.lines=self.data_stucture.line
|
|
281
285
|
self.bands=self.data_stucture.band
|
|
282
|
-
if self.channel != 'VIHI':
|
|
286
|
+
if self.channel.upper() != 'VIHI':
|
|
283
287
|
flt = getElement(imaging, 'img:Optical_Filter')
|
|
284
288
|
self.filter=Filter(channel=self.channel,name=getValue(flt,'img:filter_name'))
|
|
285
289
|
self.detector = Detector(imaging)
|
|
@@ -346,6 +350,10 @@ class SimbioObject:
|
|
|
346
350
|
if img_type in ['png','tif']:
|
|
347
351
|
data = im.fromarray(self.img)
|
|
348
352
|
image_file= f"{outFolder}/{new_filename}.{img_type}"
|
|
353
|
+
if self.debug:
|
|
354
|
+
self.console.print(
|
|
355
|
+
f"{MSG.DEBUG}Saving image {Path(image_file).name} with quality {quality}"
|
|
356
|
+
)
|
|
349
357
|
if 'cal' in self.file_name.stem:
|
|
350
358
|
data.convert('RGB').save(image_file, quality=quality)
|
|
351
359
|
else:
|
|
@@ -362,6 +370,7 @@ class SimbioObject:
|
|
|
362
370
|
fl.appendChild(fl_ct)
|
|
363
371
|
fl_fs=tree.createElement("file_size")
|
|
364
372
|
fl_fs.appendChild(tree.createTextNode(str(Path(image_file).stat().st_size)))
|
|
373
|
+
fl_fs.setAttribute("unit","byte")
|
|
365
374
|
fl.appendChild(fl_fs)
|
|
366
375
|
fl_md5=tree.createElement("md5_checksum")
|
|
367
376
|
fl_md5.appendChild(tree.createTextNode(hashlib.md5(
|
|
@@ -371,10 +380,10 @@ class SimbioObject:
|
|
|
371
380
|
|
|
372
381
|
|
|
373
382
|
|
|
374
|
-
enc_img=tree.createElement("
|
|
383
|
+
enc_img=tree.createElement("Encoded_Image")
|
|
375
384
|
enc_offset=tree.createElement("offset")
|
|
376
385
|
enc_offset.appendChild(tree.createTextNode("0"))
|
|
377
|
-
enc_offset.setAttribute("unit","
|
|
386
|
+
enc_offset.setAttribute("unit","byte")
|
|
378
387
|
enc_stid=tree.createElement("encoding_standard_id")
|
|
379
388
|
enc_stid.appendChild(tree.createTextNode("PNG"))
|
|
380
389
|
enc_img.appendChild(enc_offset)
|
|
@@ -406,9 +415,15 @@ class Data:
|
|
|
406
415
|
self.console = Console()
|
|
407
416
|
else:
|
|
408
417
|
self.console = console
|
|
409
|
-
self.filters =[]
|
|
410
|
-
self.items_number = len(file_obs)
|
|
411
418
|
self.channel = channel
|
|
419
|
+
if self.channel == 'vihi':
|
|
420
|
+
self.segments = []
|
|
421
|
+
self.seg_number=0
|
|
422
|
+
else:
|
|
423
|
+
self.filters =[]
|
|
424
|
+
|
|
425
|
+
self.items_number = len(file_obs)
|
|
426
|
+
|
|
412
427
|
self.level = level
|
|
413
428
|
for i, fo in enumerate(file_obs):
|
|
414
429
|
file_name = source_path.joinpath(getValue(fo, "file_name"))
|
|
@@ -439,15 +454,24 @@ class Data:
|
|
|
439
454
|
)
|
|
440
455
|
pass
|
|
441
456
|
else:
|
|
442
|
-
|
|
457
|
+
self.seg_number +=1
|
|
458
|
+
self.segments.append(f"segment_{self.seg_number:03}")
|
|
459
|
+
setattr(self, f"segment_{self.seg_number:03}", SimbioObject(file_name,channel=channel,imaging=imaging[i],geometry=geometry[i],file_obs=file_obs[i],console=self.console,debug=debug,verbose=verbose ))
|
|
443
460
|
pass
|
|
444
461
|
|
|
445
462
|
def savePreview(self,img_type:str='png',quality:int=100, outFolder:Path=None,tree:Document=None)->str|None:
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
463
|
+
if self.channel == 'vihi':
|
|
464
|
+
seg_prevs=[]
|
|
465
|
+
for item in self.segments:
|
|
466
|
+
disp=getattr(self,f'{item}')
|
|
467
|
+
seg_prevs.append(disp.savePreview(img_type=img_type,quality=quality,outFolder=outFolder,tree=tree) )
|
|
468
|
+
return seg_prevs
|
|
469
|
+
else:
|
|
470
|
+
filter_prevs=[]
|
|
471
|
+
for item in self.filters:
|
|
472
|
+
disp=getattr(self,f'filter_{item.lower()}')
|
|
473
|
+
filter_prevs.append(disp.savePreview(img_type=img_type,quality=quality,outFolder=outFolder,tree=tree) )
|
|
474
|
+
return filter_prevs
|
|
451
475
|
|
|
452
476
|
|
|
453
477
|
def __str__(self):
|
|
@@ -459,14 +483,21 @@ class Data:
|
|
|
459
483
|
|
|
460
484
|
class SimbioReader:
|
|
461
485
|
def __init__(
|
|
462
|
-
self, file_path: Path, debug: bool = False, verbose: bool = False, console=None
|
|
486
|
+
self, file_path: Path, debug: bool = False, verbose: bool = False, console=None, updateCheck: bool = True
|
|
463
487
|
):
|
|
464
488
|
# Initialize the SimbioReader with a file path and optional console for output
|
|
465
489
|
self.pdsLabel: Path = None
|
|
490
|
+
self.debug=debug
|
|
466
491
|
if console is None:
|
|
467
492
|
self.console = Console()
|
|
468
493
|
else:
|
|
469
494
|
self.console = console
|
|
495
|
+
if updateCheck:
|
|
496
|
+
checker = UpdateChecker()
|
|
497
|
+
result = checker.check('SimbioReader', version.short())
|
|
498
|
+
if result:
|
|
499
|
+
# TODO: Check this part after the delivery on pypi.org
|
|
500
|
+
self.console.print(result)
|
|
470
501
|
|
|
471
502
|
if debug:
|
|
472
503
|
self.console.print(
|
|
@@ -511,8 +542,8 @@ class SimbioReader:
|
|
|
511
542
|
|
|
512
543
|
obsArea = getElement(label, "Observation_Area")
|
|
513
544
|
timeCoords = getElement(obsArea, "Time_Coordinates")
|
|
514
|
-
self.startTime = parser.parse(getValue(timeCoords, "start_date_time"))
|
|
515
|
-
self.stopTime = parser.parse(getValue(timeCoords, "stop_date_time"))
|
|
545
|
+
self.startTime = parser.parse(getValue(timeCoords, "start_date_time"),ignoretz=True)
|
|
546
|
+
self.stopTime = parser.parse(getValue(timeCoords, "stop_date_time"),ignoretz=True)
|
|
516
547
|
|
|
517
548
|
self.start_scet = getValue(label, "psa:spacecraft_clock_start_count")
|
|
518
549
|
self.stop_scet = getValue(label, "psa:spacecraft_clock_start_count")
|
|
@@ -573,12 +604,21 @@ class SimbioReader:
|
|
|
573
604
|
return lst[0]
|
|
574
605
|
elif file_path.is_file():
|
|
575
606
|
if not file_path.suffix == ".lblx":
|
|
576
|
-
self.
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
607
|
+
if self.debug:
|
|
608
|
+
self.console.print(
|
|
609
|
+
f"{MSG.WARNING}The file {file_path} does not have a .lblx extension."
|
|
610
|
+
)
|
|
611
|
+
if "_cal_" in file_path.stem:
|
|
612
|
+
|
|
613
|
+
parts = file_path.stem.split("_")
|
|
614
|
+
if len(parts) == 12:
|
|
615
|
+
pdsLabel = f"{('_').join(parts[:-4])}__{'_'.join(parts[-2:])}.lblx"
|
|
616
|
+
else:
|
|
617
|
+
pdsLabel = f"{('_').join(parts[:-5])}__{'_'.join(parts[-2:])}.lblx"
|
|
618
|
+
return file_path.parent.joinpath(pdsLabel)
|
|
619
|
+
else:
|
|
620
|
+
if file_path.with_suffix('.lblx').exists():
|
|
621
|
+
return file_path.with_suffix('.lblx')
|
|
582
622
|
else:
|
|
583
623
|
return file_path
|
|
584
624
|
|
|
@@ -633,6 +673,24 @@ class SimbioReader:
|
|
|
633
673
|
self.console.print(f"{MSG.ERROR}Attribute [blue]{name}[/blue] not available. The current Channel id is {self.channel.upper()}.")
|
|
634
674
|
|
|
635
675
|
return None
|
|
676
|
+
|
|
677
|
+
def get_filter_by_file(self,file_name:Path)->SimbioObject|None:
|
|
678
|
+
if isinstance(file_name,str):
|
|
679
|
+
file_name=Path(file_name)
|
|
680
|
+
for item in self.data.filters:
|
|
681
|
+
disp=getattr(self.data,f'filter_{item.lower()}')
|
|
682
|
+
if disp.file_name.name == file_name.name:
|
|
683
|
+
return disp
|
|
684
|
+
return None
|
|
685
|
+
|
|
686
|
+
def get_segment_by_file(self,file_name:Path)->SimbioObject|None:
|
|
687
|
+
if isinstance(file_name,str):
|
|
688
|
+
file_name=Path(file_name)
|
|
689
|
+
for item in self.data.segments:
|
|
690
|
+
disp=getattr(self.data,f'{item}')
|
|
691
|
+
if disp.file_name.name == file_name.name:
|
|
692
|
+
return disp
|
|
693
|
+
return None
|
|
636
694
|
|
|
637
695
|
|
|
638
696
|
|
|
@@ -651,6 +709,10 @@ class SimbioReader:
|
|
|
651
709
|
ValueError: If the provided image format is not supported.
|
|
652
710
|
TypeError: If the `out_folder` argument is not a `Path` object.
|
|
653
711
|
"""
|
|
712
|
+
if self.debug:
|
|
713
|
+
self.console.print(
|
|
714
|
+
f"{MSG.DEBUG}Saving preview image with type: {img_type}, for {self.pdsLabel.name}"
|
|
715
|
+
)
|
|
654
716
|
if template:
|
|
655
717
|
img_type = 'png'
|
|
656
718
|
if outFolder is None:
|
|
@@ -661,7 +723,9 @@ class SimbioReader:
|
|
|
661
723
|
dest=outFolder
|
|
662
724
|
if dest.exists() is False:
|
|
663
725
|
dest.mkdir(parents=True, exist_ok=True)
|
|
664
|
-
ret=self.data.savePreview(img_type=img_type,quality=quality,outFolder=dest)
|
|
726
|
+
# ret=self.data.savePreview(img_type=img_type,quality=quality,outFolder=dest)
|
|
727
|
+
if 'vihi' in self.channel:
|
|
728
|
+
self.console.print('VIHI')
|
|
665
729
|
if template:
|
|
666
730
|
if not isinstance(template,Path):
|
|
667
731
|
template = Path(template)
|
|
@@ -716,4 +780,10 @@ class SimbioReader:
|
|
|
716
780
|
"""
|
|
717
781
|
data = im.fromarray(self.img)
|
|
718
782
|
return data
|
|
783
|
+
|
|
784
|
+
def __str__(self) -> str:
|
|
785
|
+
return f"SimbioReader(channel={self.channel}, level={self.level}, lid={self.lid}, version={self.version})"
|
|
786
|
+
|
|
787
|
+
def __repr__(self) -> str:
|
|
788
|
+
return self.__str__()
|
|
719
789
|
|
|
@@ -4,23 +4,36 @@ from pathlib import Path
|
|
|
4
4
|
import copy
|
|
5
5
|
|
|
6
6
|
def getValue(nodeList: md.Element, label: str) -> str:
|
|
7
|
-
"""
|
|
8
|
-
|
|
7
|
+
"""Extracts and returns the text content of the first matching XML element.
|
|
8
|
+
This function searches for an XML element with the specified tag name within
|
|
9
|
+
a given node list and returns the text data of the first matching element's
|
|
10
|
+
first child node.
|
|
9
11
|
Args:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
nodeList (md.Element): The parent XML element to search within.
|
|
13
|
+
label (str): The tag name of the XML element to retrieve.
|
|
12
14
|
Returns:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
str: The text content of the first matching element's first child node.
|
|
16
|
+
Raises:
|
|
17
|
+
IndexError: If no element with the specified label is found.
|
|
18
|
+
AttributeError: If the found element has no firstChild or the firstChild
|
|
19
|
+
has no data attribute.
|
|
20
|
+
Example:
|
|
21
|
+
>>> import xml.dom.minidom as md
|
|
22
|
+
>>> xml_string = '<root><name>John Doe</name><age>30</age></root>'
|
|
23
|
+
>>> doc = md.parseString(xml_string)
|
|
24
|
+
>>> root = doc.documentElement
|
|
25
|
+
>>> getValue(root, 'name')
|
|
26
|
+
'John Doe'
|
|
27
|
+
>>> getValue(root, 'age')
|
|
28
|
+
'30'
|
|
15
29
|
"""
|
|
16
|
-
|
|
17
|
-
# print(item)
|
|
30
|
+
|
|
18
31
|
elem = nodeList.getElementsByTagName(label)
|
|
19
32
|
return elem[0].firstChild.data
|
|
20
|
-
|
|
33
|
+
|
|
21
34
|
|
|
22
35
|
|
|
23
|
-
def getElement(doc, label, el=0) -> md.Element:
|
|
36
|
+
def getElement(doc:md.Document, label:str, el:int=0) -> md.Element:
|
|
24
37
|
"""Get a Block of a dom
|
|
25
38
|
|
|
26
39
|
Args:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: SimbioReader
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
4
4
|
Summary: Python Reader for the data from SIMBIO-SYS instrument suite on-board the ESA mission BepiColombo
|
|
5
5
|
Author-email: Romolo Politi <Romolo.Politi@inaf.it>
|
|
6
6
|
Project-URL: Repository, https://github.com/SIMBIO-SYS/SimbioReader
|
|
@@ -9,24 +9,23 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.12
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.13
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.14
|
|
12
|
-
Classifier: Development Status ::
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Requires-Python: >=3.11
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
16
|
Requires-Dist: numpy<3.0.0,>=2.3.3
|
|
17
17
|
Requires-Dist: pandas<3.0.0,>=2.3.2
|
|
18
18
|
Requires-Dist: rich-click<2.0.0,>=1.8.9
|
|
19
|
-
Requires-Dist: pillow<12.0.0,>=11.3.0
|
|
20
19
|
Requires-Dist: update-checker<0.19.0,>=0.18.0
|
|
21
20
|
Requires-Dist: importlib-metadata<9.0.0,>=8.7.0
|
|
21
|
+
Requires-Dist: pillow<13.0.0,>=12.0.0
|
|
22
22
|
Provides-Extra: docs
|
|
23
23
|
Requires-Dist: sphinx; extra == "docs"
|
|
24
24
|
Dynamic: license-file
|
|
25
25
|
|
|
26
|
-

|
|
27
27
|

|
|
28
28
|

|
|
29
|
-
[](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/python-publish.yml)
|
|
30
29
|
[](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/test.yml)
|
|
31
30
|
[](https://simbioreader.readthedocs.io/en/latest/?badge=latest)
|
|
32
31
|
|
|
@@ -45,6 +44,12 @@ To install the reader you can use the command:
|
|
|
45
44
|
$ python3 -m pip install SimbioReader
|
|
46
45
|
```
|
|
47
46
|
|
|
47
|
+
or using poetry
|
|
48
|
+
|
|
49
|
+
```console
|
|
50
|
+
$ poetry add SimbioReader
|
|
51
|
+
```
|
|
52
|
+
|
|
48
53
|
## Usage
|
|
49
54
|
|
|
50
55
|
The package contain a class that read and decode the SIMBIO-SYS image
|
|
@@ -71,8 +71,8 @@ def test_simbio_reader_init_datamodel_version():
|
|
|
71
71
|
def test_simbio_reader_init_start_stop_time():
|
|
72
72
|
file_path = Path("test/data/sim_cal_stc_cruise_ico11_2024-04-08_001/sim_cal_sc_stc_cruise_ico11_2024-04-08_001__0_1.lblx")
|
|
73
73
|
reader = SimbioReader(file_path=file_path)
|
|
74
|
-
assert reader.startTime.isoformat() == "2024-04-08T01:05:18.055390
|
|
75
|
-
assert reader.stopTime.isoformat() == "2024-04-08T01:05:18.055390
|
|
74
|
+
assert reader.startTime.isoformat() == "2024-04-08T01:05:18.055390"
|
|
75
|
+
assert reader.stopTime.isoformat() == "2024-04-08T01:05:18.055390"
|
|
76
76
|
|
|
77
77
|
def test_simbio_reader_init_start_stop_scet():
|
|
78
78
|
file_path = Path("test/data/sim_cal_stc_cruise_ico11_2024-04-08_001/sim_cal_sc_stc_cruise_ico11_2024-04-08_001__0_1.lblx")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|