SimbioReader 0.9.0__tar.gz → 0.9.2__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.
@@ -1,17 +1,15 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: SimbioReader
3
- Version: 0.9.0
3
+ Version: 0.9.2
4
4
  Summary: Python Reader for the data from SIMBIO-SYS instrument suite on-board the ESA mission BepiColombo
5
5
  Keywords: data reader,Space Mission,BepiColombo,SIMBIO-SYS
6
6
  Author: Romolo Politi
7
7
  Author-email: Romolo Politi <Romolo.Politi@inaf.it>
8
- Classifier: Programming Language :: Python :: 3.11
9
- Classifier: Programming Language :: Python :: 3.12
10
- Classifier: Programming Language :: Python :: 3.13
11
8
  Classifier: Programming Language :: Python :: 3.14
12
9
  Classifier: Development Status :: 4 - Beta
13
10
  Requires-Dist: numpy>=2.3.3,<3.0.0
14
11
  Requires-Dist: pandas>=3.0.1,<4.0.0
12
+ Requires-Dist: python-dateutil>=2.9,<3
15
13
  Requires-Dist: rich-click>=1.8.9,<2.0.0
16
14
  Requires-Dist: update-checker>=0.18.0,<0.19.0
17
15
  Requires-Dist: importlib-metadata>=8.7.0,<9.0.0
@@ -22,7 +20,7 @@ Requires-Python: >=3.14, <4.0
22
20
  Project-URL: Repository, https://github.com/SIMBIO-SYS/SimbioReader
23
21
  Description-Content-Type: text/markdown
24
22
 
25
- ![Version 0.9.0](https://img.shields.io/badge/version-0.9.0-blue?style=plastic)
23
+ ![Version 0.9.2](https://img.shields.io/badge/version-0.9.2-blue?style=plastic)
26
24
  ![Language Python 3.14](https://img.shields.io/badge/python-3.14-orange?style=plastic&logo=python)
27
25
  ![BepiColombo SIMBIO-SYS](https://img.shields.io/badge/BepiColombo-SIMBIO--SYS-blue?style=plastic)
28
26
  [![SimbioReader Test](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/test.yml/badge.svg)](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/test.yml)
@@ -1,4 +1,4 @@
1
- ![Version 0.9.0](https://img.shields.io/badge/version-0.9.0-blue?style=plastic)
1
+ ![Version 0.9.2](https://img.shields.io/badge/version-0.9.2-blue?style=plastic)
2
2
  ![Language Python 3.14](https://img.shields.io/badge/python-3.14-orange?style=plastic&logo=python)
3
3
  ![BepiColombo SIMBIO-SYS](https://img.shields.io/badge/BepiColombo-SIMBIO--SYS-blue?style=plastic)
4
4
  [![SimbioReader Test](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/test.yml/badge.svg)](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/test.yml)
@@ -0,0 +1,99 @@
1
+ [project]
2
+ name = "SimbioReader"
3
+ version = "0.9.2"
4
+ description = "Python Reader for the data from SIMBIO-SYS instrument suite on-board the ESA mission BepiColombo"
5
+ dependencies = [
6
+ "numpy (>=2.3.3,<3.0.0)",
7
+ "pandas (>=3.0.1,<4.0.0)",
8
+ "python-dateutil>=2.9,<3",
9
+ "rich-click (>=1.8.9,<2.0.0)",
10
+ "update-checker (>=0.18.0,<0.19.0)",
11
+ "importlib-metadata (>=8.7.0,<9.0.0)",
12
+ "pillow (>=12.0.0,<13.0.0)",
13
+ "semantic-version-tools (>=1.4.1,<2.0.0)",
14
+ "mystrtools (>=0.1.0,<0.2.0)",
15
+ ]
16
+ requires-python = ">=3.14, <4.0"
17
+ readme = "README.md"
18
+ keywords = [
19
+ "data reader",
20
+ "Space Mission",
21
+ "BepiColombo",
22
+ "SIMBIO-SYS",
23
+ ]
24
+ classifiers = [
25
+ "Programming Language :: Python :: 3.14",
26
+ "Development Status :: 4 - Beta",
27
+ ]
28
+
29
+ [[project.authors]]
30
+ name = "Romolo Politi"
31
+ email = "Romolo.Politi@inaf.it"
32
+
33
+ [project.urls]
34
+ Repository = "https://github.com/SIMBIO-SYS/SimbioReader"
35
+
36
+ [project.scripts]
37
+ simbioReader = "SimbioReader.cli:cli"
38
+ simbioInfo = "SimbioReader.infocli:cli"
39
+
40
+ [tool.uv.build-backend]
41
+ module-name = "SimbioReader"
42
+
43
+ [tool.pytest.ini_options]
44
+ markers = [
45
+ "caldb: mark a test as a caldb test",
46
+ "config: mark a test as a config test",
47
+ "pipeline: mark a test as a pipeline test",
48
+ "pipeline_L0: mark a test as a pipeline L0 test",
49
+ "pipeline_step: mark a test as a pipeline step test",
50
+ ]
51
+ addopts = [
52
+ "--basetemp=/tmp/pytest",
53
+ "--verbosity=3",
54
+ "--tb=line",
55
+ "--capture=sys",
56
+ "--show-capture=all",
57
+ "--cov=SimbioReader",
58
+ "--cov-report=term",
59
+ "--cov-report=html:coverage/coverage_html",
60
+ "--cov-report=xml:coverage/coverage.xml",
61
+ "--cov-report=json:coverage/coverage.json",
62
+ ]
63
+ testpaths = ["test/"]
64
+ log_file = "output/log/pytest_log.log"
65
+ log_file_level = "DEBUG"
66
+ log_file_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
67
+ log_file_date_format = "%Y-%m-%d %H:%M:%S"
68
+ pythonpath = ["."]
69
+
70
+ [tool.coverage.run]
71
+ branch = true
72
+ omit = [
73
+ "test/*",
74
+ "./prova.py",
75
+ ]
76
+
77
+ [tool.ruff]
78
+ target-version = "py314"
79
+
80
+ [tool.pyright]
81
+ pythonVersion = "3.14"
82
+ typeCheckingMode = "basic"
83
+ include = ["src"]
84
+ venvPath = "."
85
+ venv = ".venv"
86
+
87
+ [build-system]
88
+ requires = ["uv_build>=0.11.28,<0.12.0"]
89
+ build-backend = "uv_build"
90
+
91
+ [dependency-groups]
92
+ test = [
93
+ "pytest (>=9.0.2,<10.0.0)",
94
+ "pytest-cov (>=7.0.0,<8.0.0)",
95
+ ]
96
+ devel = [
97
+ "ruff (>=0.15.4,<0.16.0)",
98
+ "pyright (>=1.1.408,<2.0.0)",
99
+ ]
@@ -1,11 +1,12 @@
1
1
  [project]
2
2
  name = "SimbioReader"
3
- version = "0.9.0"
3
+ version = "0.9.2"
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 (>=3.0.1,<4.0.0)",
9
+ "python-dateutil>=2.9,<3",
9
10
  "rich-click (>=1.8.9,<2.0.0)",
10
11
  "update-checker (>=0.18.0,<0.19.0)",
11
12
  "importlib-metadata (>=8.7.0,<9.0.0)",
@@ -21,9 +22,6 @@ readme = "README.md"
21
22
 
22
23
  keywords = ["data reader", "Space Mission", "BepiColombo", "SIMBIO-SYS"]
23
24
  classifiers = [
24
- "Programming Language :: Python :: 3.11",
25
- "Programming Language :: Python :: 3.12",
26
- "Programming Language :: Python :: 3.13",
27
25
  "Programming Language :: Python :: 3.14",
28
26
  "Development Status :: 4 - Beta",
29
27
 
@@ -0,0 +1,4 @@
1
+ from SimbioReader.sr import SimbioReader, DataStructure, Data, Detector, HK
2
+ from SimbioReader.sr import __version__
3
+
4
+ __all__ = ["SimbioReader", "DataStructure", "Data", "Detector", "HK", "__version__"]
@@ -2,7 +2,7 @@
2
2
  import rich_click as click
3
3
  from rich.console import Console
4
4
  from functools import wraps
5
- from SimbioReader.constants import FMODE, MSG, CONTEXT_SETTINGS, progEpilog, data_types, datamodel
5
+ from SimbioReader.constants import MSG, CONTEXT_SETTINGS, progEpilog
6
6
 
7
7
  click.rich_click.USE_RICH_MARKUP = True
8
8
  click.rich_click.FOOTER_TEXT = progEpilog
@@ -51,7 +51,7 @@ def phases(ctx,all: bool, date: str, name: str):
51
51
 
52
52
  if date:
53
53
  try:
54
- ndt = parse(date, ignoretz=True)
54
+ parse(date, ignoretz=True)
55
55
  except Exception as e:
56
56
  console.print(f"{MSG.ERROR}Cant convert to date the string: {str(e)}")
57
57
  all = True
@@ -80,7 +80,7 @@ def subphases(all: bool, date: str, name: str):
80
80
  all = True
81
81
  if date:
82
82
  try:
83
- ndt = parse(date, ignoretz=True)
83
+ parse(date, ignoretz=True)
84
84
  except Exception as e:
85
85
  console.print(
86
86
  f"{MSG.ERROR}Cant convert to date the string: {str(e)}")
@@ -117,7 +117,7 @@ def tests(ctx,all: bool = None, date: str = None, name: str = None, phase: str =
117
117
  # console.print(Test.show(key=name))
118
118
  try:
119
119
  console.print(Test(name, subphase=subphase).show())
120
- except:
120
+ except ValueError:
121
121
  if not subphase:
122
122
  console.print(f"{MSG.WARNING}Test {name.title()} not found. Please try to specific a subphase.")
123
123
  ctx.exit()
@@ -25,7 +25,21 @@ phases = {
25
25
  "LPName": "Mercury Gravity Assist 6",
26
26
  }
27
27
  ],
28
- "None": [
29
- {"start": "2030-04-08 04:00:01", "end": "2030-12-31 23:59:59", "LPName": "None"}
28
+ "mocp": [
29
+ {
30
+ "start": "2027-03-13 00:00:00",
31
+ "end": "2027-04-05 23:59:59",
32
+ "LPName": "Mercury Orbit Commissioning Phase",
33
+ }
34
+ ],
35
+ "msp": [
36
+ {
37
+ "start": "2027-04-06 00:00:00",
38
+ "end": "2030-04-08 04:00:00",
39
+ "LPName": "Mercury Science Phase",
40
+ }
41
+ ],
42
+ "none": [
43
+ {"start": "2030-04-08 04:00:01", "end": "2030-12-31 23:59:59", "LPName": "none"}
30
44
  ],
31
45
  }
@@ -379,7 +379,7 @@ class Test:
379
379
  test_data = tests.get(name)
380
380
  if not test_data:
381
381
  if not subphase:
382
- raise ValueError(f"To search a Test by name a subphase name is required.")
382
+ raise ValueError("To search a Test by name a subphase name is required.")
383
383
  sub_list = get_test_by_subphase(subphase)
384
384
  if not sub_list:
385
385
  raise ValueError(f"Test {name} not found.")
@@ -494,7 +494,7 @@ class Test:
494
494
  if not start <=date <=end:
495
495
  continue
496
496
  if phase:
497
- if not test_data['subphase'].lower() in get_subphases_by_phase(phase):
497
+ if test_data['subphase'].lower() not in get_subphases_by_phase(phase):
498
498
  continue
499
499
  tb.add_row(test_data['name'],
500
500
  test_data['subphase'],
@@ -18,7 +18,7 @@ from rich.table import Table
18
18
  from semantic_version_tools import Vers
19
19
  from update_checker import UpdateChecker
20
20
 
21
- from SimbioReader.constants import MSG, data_types
21
+ from SimbioReader.constants import MSG
22
22
  from SimbioReader.exceptions import SizeError
23
23
  from SimbioReader.filters_tools import Filter
24
24
  from SimbioReader.tools import (
@@ -68,7 +68,7 @@ class Detector:
68
68
  Returns:
69
69
  str: A string representation of the Detector object.
70
70
  """
71
- return f"Detector object"
71
+ return "Detector object"
72
72
 
73
73
  def __repr__(self) -> str:
74
74
  """
@@ -132,17 +132,22 @@ class DataStructure:
132
132
  self.band = None
133
133
  if self.axes == 3 and channel != "vihi":
134
134
  raise ValueError("The number of axes is wrong for the channel")
135
+ self.axis_order = []
136
+ self.axis_names = {}
135
137
  for i in range(self.axes):
136
138
  axis = getElement(dat, "Axis_Array", i)
137
- setattr(
138
- self,
139
- getValue(axis, "axis_name").lower(),
140
- int(getValue(axis, "elements")),
141
- )
139
+ axis_name = getValue(axis, "axis_name").lower()
140
+ elements = int(getValue(axis, "elements"))
141
+ sequence = int(getValue(axis, "sequence_number"))
142
+ self.axis_order.append((sequence, elements))
143
+ self.axis_names[sequence] = axis_name
144
+ setattr(self, axis_name, elements)
142
145
  if self.axes == 3:
143
146
  dat = getElement(dat, "Array_3D_Spectrum")
144
147
  elif self.axes == 2:
145
148
  dat = getElement(dat, "Array_2D_Image")
149
+ self.offset = int(getValue(dat, "offset"))
150
+ self.axis_index_order = getValue(dat, "axis_index_order")
146
151
  self.data_type = getValue(dat, "data_type")
147
152
  if self.band is None:
148
153
  self.band = 1
@@ -314,53 +319,36 @@ class SimbioObject:
314
319
  channel=self.channel, name=getValue(flt, "img:filter_name")
315
320
  )
316
321
  self.detector = Detector(imaging)
317
- if self.data_structure.data_type == "UnsignedLSB2":
318
- dtype = np.int16
319
- elif self.data_structure.data_type == "IEEE754LSBSingle":
320
- dtype = np.float32
321
-
322
+ dtypes = {"UnsignedLSB2": np.dtype("<u2"), "IEEE754LSBSingle": np.dtype("<f4")}
323
+ try:
324
+ dtype = dtypes[self.data_structure.data_type]
325
+ except KeyError as exc:
326
+ raise ValueError(f"Unsupported data type: {self.data_structure.data_type}") from exc
327
+ shape = tuple(size for _, size in sorted(self.data_structure.axis_order))
328
+ count = int(np.prod(shape))
329
+ offset = self.data_structure.offset
330
+ expected = offset + count * dtype.itemsize
331
+ actual = self.file_name.stat().st_size
332
+ if offset < 0:
333
+ raise ValueError("Array offset cannot be negative")
334
+ if actual < expected:
335
+ raise SizeError(actual * 8, expected * 8)
322
336
  if verbose:
323
337
  console.print(f"{MSG.INFO}Loading: {self.file_name}")
324
- if self.data_structure.axes == 3:
325
- console.print(
326
- f"{MSG.INFO}Image size: {self.samples}x{self.lines}x{self.bands}"
327
- )
328
- imgSize = (
329
- self.samples
330
- * self.lines
331
- * self.bands
332
- * data_types[self.data_structure.data_type]["bits"]
333
- )
334
- else:
335
- console.print(f"{MSG.INFO}Image size: {self.samples}x{self.lines}")
336
- imgSize = (
337
- self.samples
338
- * self.lines
339
- * data_types[self.data_structure.data_type]["bits"]
340
- )
341
-
342
- console.print(f"{MSG.INFO}File size: {self.file_name.stat().st_size * 8}")
343
- console.print(f"{MSG.INFO}Computed File Size: {imgSize}")
344
- if self.file_name.stat().st_size * 8 != imgSize:
345
- raise SizeError(self.file_name.stat().st_size * 8, imgSize)
346
- # print(img_data['samples'],img_data['lines'],img_data['bands'])
347
- if self.data_structure.axes == 3:
348
- self.img = np.fromfile(
349
- self.file_name,
350
- dtype=dtype,
351
- count=self.samples * self.lines * self.bands,
338
+ console.print(f"{MSG.INFO}Image size: {shape}")
339
+ orders = {"Last Index Fastest": "C", "First Index Fastest": "F"}
340
+ try:
341
+ order = orders[self.data_structure.axis_index_order]
342
+ except KeyError as exc:
343
+ raise ValueError("Unsupported axis index order") from exc
344
+ self.img = np.fromfile(self.file_name, dtype=dtype, count=count, offset=offset)
345
+ self.img = self.img.reshape(shape, order=order)
346
+ if self.data_structure.axes == 3 and self.lines == 1:
347
+ line_axis = next(
348
+ index for index, (sequence, _) in enumerate(sorted(self.data_structure.axis_order))
349
+ if self.data_structure.axis_names[sequence] == "line"
352
350
  )
353
- else:
354
- self.img = np.fromfile(
355
- self.file_name, dtype=dtype, count=self.samples * self.lines
356
- )
357
- if self.data_structure.axes == 3:
358
- if self.lines == 1:
359
- self.img.shape = (self.samples, self.bands)
360
- else:
361
- self.img.shape = (self.lines, self.samples, self.bands)
362
- else:
363
- self.img.shape = (self.samples, self.lines)
351
+ self.img = self.img.squeeze(axis=line_axis)
364
352
  if verbose:
365
353
  self.console.print(
366
354
  f"{MSG.INFO}Dimension of the old image array: {self.img.ndim}"
@@ -656,7 +644,7 @@ class SimbioReader:
656
644
  )
657
645
 
658
646
  self.start_scet = getValue(label, "psa:spacecraft_clock_start_count")
659
- self.stop_scet = getValue(label, "psa:spacecraft_clock_start_count")
647
+ self.stop_scet = getValue(label, "psa:spacecraft_clock_stop_count")
660
648
  if debug:
661
649
  self.console.print(
662
650
  f"{MSG.DEBUG}Observation start time: {self.startTime}, stop time: {self.stopTime}"
@@ -738,16 +726,14 @@ class SimbioReader:
738
726
 
739
727
  def show(self, hk:bool=False, detector:bool=False, data_structure:bool=False, filters:bool=False, all_info:bool=False) -> Panel:
740
728
  columns=[self.info(), self.target.show()]
741
- if hk or all_info:
729
+ if (hk or all_info) and hasattr(self.data, "hk"):
742
730
  columns.append(self.data.hk.show())
743
731
  if detector or all_info:
744
- for item in self.data.filters:
745
- disp = getattr(self.data, f"filter_{item.lower()}")
746
- columns.append(disp.detector.show(title=f"Detector Info - Filter {item.upper()}"))
732
+ for name, disp in self._data_items():
733
+ columns.append(disp.detector.show(title=f"Detector Info - {name.upper()}"))
747
734
  if data_structure or all_info:
748
- for item in self.data.filters:
749
- disp = getattr(self.data, f"filter_{item.lower()}")
750
- columns.append(disp.data_structure.show(title=f"Data Structure Info - Filter {item.upper()}"))
735
+ for name, disp in self._data_items():
736
+ columns.append(disp.data_structure.show(title=f"Data Structure Info - {name.upper()}"))
751
737
 
752
738
  if filters and hasattr(self.data, "filters"):
753
739
  for item in self.data.filters:
@@ -786,11 +772,16 @@ class SimbioReader:
786
772
 
787
773
  return Panel(dt, title="SimbioReader Info", border_style="green", expand=False)
788
774
 
775
+ def _data_items(self):
776
+ if self.channel == "vihi":
777
+ return [(name, getattr(self.data, name)) for name in self.data.segments]
778
+ return [(name, getattr(self.data, f"filter_{name.lower()}")) for name in self.data.filters]
779
+
789
780
  def filters_summary(self) -> Panel:
790
781
  tb= Table()
791
782
  tb.add_column("",style="yellow", justify="right")
792
783
  tb.add_column("Filter Names",style="yellow", justify="center")
793
- for item in self.data.filters:
784
+ for item in getattr(self.data, "filters", []):
794
785
  tb.add_row(':green_circle:',item.upper())
795
786
  # disp = getattr(self.data, f"filter_{item.lower()}")
796
787
 
@@ -803,10 +794,6 @@ class SimbioReader:
803
794
  )
804
795
 
805
796
  def summary(self) -> Panel:
806
- filters = []
807
- for item in self.data.filters:
808
- disp = getattr(self.data, f"filter_{item.lower()}")
809
- filters.append(disp.show())
810
797
  col = Columns(
811
798
  [self.info(), self.target.show(), self.filters_summary()],#, self.data.hk.show(), *filters],
812
799
  expand=True,
@@ -139,18 +139,18 @@ subphases = {
139
139
  "phase": "cruise",
140
140
  "LPName": "Instrument Check-Out #17",
141
141
  },
142
- "fimgs": {
142
+ "first_images": {
143
143
  "start": "2026-10-18 07:00:00",
144
144
  "end": "2026-10-18 21:00:00",
145
- "name": "fimgs",
145
+ "name": "first_images",
146
146
  "phase": "cruise",
147
147
  "LPName": "Mercury First Images",
148
148
  },
149
- "None": {
149
+ "none": {
150
150
  "start": "2026-09-16 09:00:01",
151
151
  "end": "2028-12-31 23:59:59",
152
- "name": "None",
153
- "phase": "None",
154
- "LPName": "None",
152
+ "name": "none",
153
+ "phase": "none",
154
+ "LPName": "none",
155
155
  },
156
156
  }
@@ -663,6 +663,6 @@ tests = {
663
663
  "name": "Mercury first images",
664
664
  "start": "2026-10-18T07:00:00",
665
665
  "end": "2026-10-18T21:00:00",
666
- "subphase": "fimgs",
666
+ "subphase": "first_images",
667
667
  },
668
668
  }
@@ -1,5 +1,4 @@
1
1
  import xml.dom.minidom as md
2
- from re import sub
3
2
  from pathlib import Path
4
3
  import copy
5
4
 
@@ -1,2 +0,0 @@
1
- from SimbioReader.sr import SimbioReader, DataStructure, Data, Detector, HK
2
- from SimbioReader.sr import __version__