SimbioReader 0.2.2__tar.gz → 0.5.0__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.2.2/src/SimbioReader.egg-info → simbioreader-0.5.0}/PKG-INFO +13 -11
- {simbioreader-0.2.2 → simbioreader-0.5.0}/README.md +3 -2
- {simbioreader-0.2.2 → simbioreader-0.5.0}/pyproject.toml +12 -8
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader/__main__.py +44 -5
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader/constants.py +1 -1
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader/tools.py +57 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0/src/SimbioReader.egg-info}/PKG-INFO +13 -11
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader.egg-info/SOURCES.txt +2 -1
- simbioreader-0.5.0/src/SimbioReader.egg-info/requires.txt +9 -0
- simbioreader-0.5.0/test/test_tools.py +19 -0
- simbioreader-0.2.2/src/SimbioReader.egg-info/requires.txt +0 -12
- {simbioreader-0.2.2 → simbioreader-0.5.0}/LICENSE +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/setup.cfg +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader/__init__.py +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader/exceptions.py +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader/filters.py +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader/filters_tools.py +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader/infocli.py +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader/phases.py +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader/simbioInfo.py +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader/subphases.py +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader/tests.py +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader/version.py +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader.egg-info/dependency_links.txt +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader.egg-info/entry_points.txt +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/src/SimbioReader.egg-info/top_level.txt +0 -0
- {simbioreader-0.2.2 → simbioreader-0.5.0}/test/test_db.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: SimbioReader
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
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
|
License: GNU GPL ver3
|
|
@@ -8,23 +8,25 @@ Project-URL: Repository, https://github.com/SIMBIO-SYS/SimbioReader
|
|
|
8
8
|
Keywords: data reader,Space Mission,BepiColombo,SIMBIO-SYS
|
|
9
9
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
10
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
11
|
+
Requires-Python: >=3.11
|
|
11
12
|
Description-Content-Type: text/markdown
|
|
12
13
|
License-File: LICENSE
|
|
13
|
-
Requires-Dist: numpy
|
|
14
|
-
Requires-Dist: pandas
|
|
15
|
-
Requires-Dist: rich
|
|
16
|
-
Requires-Dist:
|
|
17
|
-
Requires-Dist:
|
|
18
|
-
Requires-Dist:
|
|
19
|
-
Requires-Dist: importlib-metadata; python_version > "3.10"
|
|
14
|
+
Requires-Dist: numpy<3.0.0,>=2.3.3
|
|
15
|
+
Requires-Dist: pandas<3.0.0,>=2.3.2
|
|
16
|
+
Requires-Dist: rich-click<2.0.0,>=1.8.9
|
|
17
|
+
Requires-Dist: pillow<12.0.0,>=11.3.0
|
|
18
|
+
Requires-Dist: update-checker<0.19.0,>=0.18.0
|
|
19
|
+
Requires-Dist: importlib-metadata<9.0.0,>=8.7.0
|
|
20
20
|
Provides-Extra: docs
|
|
21
21
|
Requires-Dist: sphinx; extra == "docs"
|
|
22
|
+
Dynamic: license-file
|
|
22
23
|
|
|
23
|
-

|
|
25
|
+

|
|
25
26
|

|
|
26
27
|
[](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/python-publish.yml)
|
|
27
28
|
[](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/test.yml)
|
|
29
|
+
[](https://simbioreader.readthedocs.io/en/latest/?badge=latest)
|
|
28
30
|
|
|
29
31
|
# SimbioReader
|
|
30
32
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-

|
|
2
|
+

|
|
3
3
|

|
|
4
4
|
[](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/python-publish.yml)
|
|
5
5
|
[](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/test.yml)
|
|
6
|
+
[](https://simbioreader.readthedocs.io/en/latest/?badge=latest)
|
|
6
7
|
|
|
7
8
|
# SimbioReader
|
|
8
9
|
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "SimbioReader"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.5.0"
|
|
4
4
|
description="Python Reader for the data from SIMBIO-SYS instrument suite on-board the ESA mission BepiColombo"
|
|
5
5
|
dependencies = [
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
6
|
+
|
|
7
|
+
"numpy (>=2.3.3,<3.0.0)",
|
|
8
|
+
"pandas (>=2.3.2,<3.0.0)",
|
|
9
|
+
"rich-click (>=1.8.9,<2.0.0)",
|
|
10
|
+
"pillow (>=11.3.0,<12.0.0)",
|
|
11
|
+
"update-checker (>=0.18.0,<0.19.0)",
|
|
12
|
+
"importlib-metadata (>=8.7.0,<9.0.0)",
|
|
13
13
|
]
|
|
14
|
+
requires-python = ">=3.11"
|
|
14
15
|
|
|
15
16
|
authors = [{name="Romolo Politi", email ="Romolo.Politi@inaf.it" }]
|
|
16
17
|
license = {text = "GNU GPL ver3"}
|
|
@@ -37,3 +38,6 @@ simbioInfo = "SimbioReader.infocli:cli"
|
|
|
37
38
|
requires = ["setuptools"]
|
|
38
39
|
build-backend = "setuptools.build_meta"
|
|
39
40
|
|
|
41
|
+
[tool.poetry.group.test.dependencies]
|
|
42
|
+
pytest = "^8.4.2"
|
|
43
|
+
|
|
@@ -4,6 +4,7 @@ from datetime import datetime
|
|
|
4
4
|
from os import path
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from xml.dom.minidom import Element, parse
|
|
7
|
+
from shutil import copyfile
|
|
7
8
|
|
|
8
9
|
import numpy as np
|
|
9
10
|
import pandas as pd
|
|
@@ -22,7 +23,7 @@ from SimbioReader.constants import (CONTEXT_SETTINGS, FMODE, MSG, data_types,
|
|
|
22
23
|
datamodel, progEpilog)
|
|
23
24
|
from SimbioReader.exceptions import SizeError
|
|
24
25
|
from SimbioReader.filters_tools import Filter
|
|
25
|
-
from SimbioReader.tools import
|
|
26
|
+
from SimbioReader.tools import (getElement, getValue, snake_case,gen_filename, lidUpdate, updateXML, lvidUpdate, pretty_print)
|
|
26
27
|
from SimbioReader.version import version
|
|
27
28
|
|
|
28
29
|
# from functools import wraps
|
|
@@ -636,20 +637,24 @@ class SimbioReader:
|
|
|
636
637
|
"""
|
|
637
638
|
return self.__str__()
|
|
638
639
|
|
|
640
|
+
|
|
639
641
|
|
|
640
|
-
def savePreview(self,img_type:str='png',quality:int=100, outFolder:Path=None):
|
|
642
|
+
def savePreview(self,img_type:str='png',quality:int=100, outFolder:Path=None, template:Path=None, description:str = "This is the first version."):
|
|
641
643
|
"""Saves a preview image of the loaded data.
|
|
642
644
|
|
|
643
645
|
Args:
|
|
644
646
|
img_type: The desired image format. Supported formats are 'png', 'tif', and 'jpg'. Defaults to 'png'.
|
|
645
647
|
quality: The quality of the saved image (applicable for 'png' and 'jpg' formats only). Ranges from 0 (worst) to 100 (best). Defaults to 100.
|
|
646
648
|
out_folder: The output folder path where the preview image will be saved. Defaults to the same directory as the original Simbio file.
|
|
649
|
+
template: name of the PDS4 template that will be generated. If None no template will be written. If the template is not none the img_type
|
|
650
|
+
is forced to png
|
|
647
651
|
|
|
648
652
|
Raises:
|
|
649
653
|
ValueError: If the provided image format is not supported.
|
|
650
654
|
TypeError: If the `out_folder` argument is not a `Path` object.
|
|
651
655
|
"""
|
|
652
|
-
|
|
656
|
+
if template:
|
|
657
|
+
img_type = 'png'
|
|
653
658
|
if outFolder is None:
|
|
654
659
|
dest = self.fileName.parent
|
|
655
660
|
else:
|
|
@@ -659,8 +664,42 @@ class SimbioReader:
|
|
|
659
664
|
if img_type in ['png','tif']:
|
|
660
665
|
data = im.fromarray(self.img)
|
|
661
666
|
# print(data.getpixel((50, 50)))
|
|
662
|
-
|
|
663
|
-
|
|
667
|
+
new_filename=gen_filename(self.fileName)
|
|
668
|
+
# data_filename=self.fileName.stem
|
|
669
|
+
# new_filename=copy.copy(data_filename)
|
|
670
|
+
# if 'raw' in data_filename:
|
|
671
|
+
# new_filename.replace('raw','browse_raw')
|
|
672
|
+
image_file= f"{dest}/{new_filename}.{img_type}"
|
|
673
|
+
data.save(image_file, quality=quality)
|
|
674
|
+
if template:
|
|
675
|
+
if not isinstance(template,Path):
|
|
676
|
+
template = Path(template)
|
|
677
|
+
if not template.exists():
|
|
678
|
+
raise FileNotFoundError(f"The template {template.name} was not found")
|
|
679
|
+
new_label=f"{dest}/{new_filename}.lblx"
|
|
680
|
+
copyfile(template,new_label)
|
|
681
|
+
from xml.dom.minidom import parse, parseString, Element
|
|
682
|
+
import hashlib
|
|
683
|
+
tree = parse(new_label)
|
|
684
|
+
lidUpdate(tree, new_label)
|
|
685
|
+
creatTime=datetime.now()
|
|
686
|
+
updateXML(tree, "modification_date", creatTime.strftime("%Y-%m-%d"), idx=0)
|
|
687
|
+
file_version=new_filename.split('__')[1].split('.')[0]
|
|
688
|
+
file_version=file_version.replace('_','.')
|
|
689
|
+
updateXML(tree,"version_id",file_version, idx=0)
|
|
690
|
+
updateXML(tree,"version_id",file_version, idx=1)
|
|
691
|
+
updateXML(tree,"description",description, idx=0)
|
|
692
|
+
lvidUpdate(tree,self.fileName, file_version)
|
|
693
|
+
image_file= Path(image_file)
|
|
694
|
+
updateXML(tree, 'file_name', image_file.name, idx=0)
|
|
695
|
+
updateXML(tree, 'creation_date_time',
|
|
696
|
+
creatTime.strftime("%Y-%m-%d"), idx=0)
|
|
697
|
+
updateXML(tree, 'file_size', image_file.stat().st_size, idx=0)
|
|
698
|
+
updateXML(tree, 'md5_checksum', hashlib.md5(
|
|
699
|
+
open(image_file, 'rb').read()).hexdigest(), idx=0)
|
|
700
|
+
dom2 = parseString(pretty_print(tree))
|
|
701
|
+
with open(new_label, "w") as xmlFile:
|
|
702
|
+
dom2.writexml(xmlFile, encoding="utf-8")
|
|
664
703
|
elif img_type == 'jpg':
|
|
665
704
|
data = im.fromarray(self.img,mode='L')
|
|
666
705
|
# print(data.getpixel((50,50)))
|
|
@@ -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,
|
|
22
|
+
VERSION = (0,5,0,'d',1)
|
|
23
23
|
|
|
24
24
|
datamodel='1.15.0.0'
|
|
25
25
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import xml.dom.minidom as md
|
|
2
2
|
from re import sub
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import copy
|
|
3
5
|
|
|
4
6
|
def getValue(nodeList: md.Element, label: str) -> str:
|
|
5
7
|
"""Get the value from a tag
|
|
@@ -83,3 +85,58 @@ def snake_case(text)->str:
|
|
|
83
85
|
sub('([A-Z][a-z]+)', r' \1',
|
|
84
86
|
sub('([A-Z]+)', r' \1',
|
|
85
87
|
text.replace('-', ' '))).split()).lower()
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def gen_filename(old_filename:Path)->str:
|
|
91
|
+
new_filename=copy.copy(old_filename.stem)
|
|
92
|
+
# new_filename=new_filename.split('__')[0]
|
|
93
|
+
if 'raw' in new_filename:
|
|
94
|
+
new_filename=new_filename.replace('raw','browse_raw')
|
|
95
|
+
else:
|
|
96
|
+
new_filename=new_filename.replace('_cal_','_browse_cal_')
|
|
97
|
+
return new_filename
|
|
98
|
+
|
|
99
|
+
def updateXML(xml: md.Element, label: str, value: str | int | float, idx: int = 0) -> None:
|
|
100
|
+
a = xml.getElementsByTagName(label)[idx]
|
|
101
|
+
a.firstChild.nodeValue = value
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def getFromXml(xml:md.Element, label, idx=0):
|
|
106
|
+
a = xml.getElementsByTagName(label)[idx]
|
|
107
|
+
return a.firstChild.nodeValue
|
|
108
|
+
|
|
109
|
+
def lidGenerator(self, old_lid: str , file_name: Path, calib:bool=False)-> str:
|
|
110
|
+
parts = old_lid.split(':')
|
|
111
|
+
if calib:
|
|
112
|
+
parts[-2] = 'data_calibrated'
|
|
113
|
+
parts[-1] = file_name.stem.split('__')[0]
|
|
114
|
+
newLid = ':'.join(parts)
|
|
115
|
+
return newLid
|
|
116
|
+
|
|
117
|
+
def lidUpdate(tree, fileName, calib: bool = False):
|
|
118
|
+
# conf.log.debug("LID update", verbosity=3)
|
|
119
|
+
oldLid = getFromXml(tree, "logical_identifier")
|
|
120
|
+
# parts = oldLid.split(':')
|
|
121
|
+
# if calib:
|
|
122
|
+
# parts[-2] = 'data_calibrated'
|
|
123
|
+
# parts[-1] = fileName.stem.split('__')[0]
|
|
124
|
+
# newLid = ':'.join(parts)
|
|
125
|
+
newLid =lidGenerator(oldLid,fileName, calib)
|
|
126
|
+
updateXML(tree, "logical_identifier", newLid)
|
|
127
|
+
|
|
128
|
+
def new_lvid(old:str, file_name: Path, file_version:str):
|
|
129
|
+
parts=old.split('::')
|
|
130
|
+
new_main=parts[0].split(':')
|
|
131
|
+
newLVID=f"{':'.join(new_main[0:-1])}:{file_name.stem.split('__')[0]}::{file_version}"
|
|
132
|
+
return newLVID
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def lvidUpdate(tree:str, file_name: Path, file_version:str):
|
|
136
|
+
oldLVID = getFromXml(tree, "lidvid_reference")
|
|
137
|
+
newLVID=new_lvid(oldLVID, file_name, file_version)
|
|
138
|
+
updateXML(tree, "lidvid_reference", newLVID)
|
|
139
|
+
pass
|
|
140
|
+
|
|
141
|
+
def pretty_print(dom):
|
|
142
|
+
return '\n'.join([line for line in dom.toprettyxml(indent=' '*4).split('\n') if line.strip()])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: SimbioReader
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
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
|
License: GNU GPL ver3
|
|
@@ -8,23 +8,25 @@ Project-URL: Repository, https://github.com/SIMBIO-SYS/SimbioReader
|
|
|
8
8
|
Keywords: data reader,Space Mission,BepiColombo,SIMBIO-SYS
|
|
9
9
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
10
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
11
|
+
Requires-Python: >=3.11
|
|
11
12
|
Description-Content-Type: text/markdown
|
|
12
13
|
License-File: LICENSE
|
|
13
|
-
Requires-Dist: numpy
|
|
14
|
-
Requires-Dist: pandas
|
|
15
|
-
Requires-Dist: rich
|
|
16
|
-
Requires-Dist:
|
|
17
|
-
Requires-Dist:
|
|
18
|
-
Requires-Dist:
|
|
19
|
-
Requires-Dist: importlib-metadata; python_version > "3.10"
|
|
14
|
+
Requires-Dist: numpy<3.0.0,>=2.3.3
|
|
15
|
+
Requires-Dist: pandas<3.0.0,>=2.3.2
|
|
16
|
+
Requires-Dist: rich-click<2.0.0,>=1.8.9
|
|
17
|
+
Requires-Dist: pillow<12.0.0,>=11.3.0
|
|
18
|
+
Requires-Dist: update-checker<0.19.0,>=0.18.0
|
|
19
|
+
Requires-Dist: importlib-metadata<9.0.0,>=8.7.0
|
|
20
20
|
Provides-Extra: docs
|
|
21
21
|
Requires-Dist: sphinx; extra == "docs"
|
|
22
|
+
Dynamic: license-file
|
|
22
23
|
|
|
23
|
-

|
|
25
|
+

|
|
25
26
|

|
|
26
27
|
[](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/python-publish.yml)
|
|
27
28
|
[](https://github.com/SIMBIO-SYS/SimbioReader/actions/workflows/test.yml)
|
|
29
|
+
[](https://simbioreader.readthedocs.io/en/latest/?badge=latest)
|
|
28
30
|
|
|
29
31
|
# SimbioReader
|
|
30
32
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from SimbioReader.tools import gen_filename, new_lvid
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
def test_filename():
|
|
5
|
+
old_name=Path("sim_raw_sc_hric_cust0_internal_cruise_cruise_2021-04-24_001__0_1.dat")
|
|
6
|
+
new_name=gen_filename(old_name)
|
|
7
|
+
assert new_name == "sim_browse_raw_sc_hric_cust0_internal_cruise_cruise_2021-04-24_001__0_1"
|
|
8
|
+
|
|
9
|
+
def test_filename_cal():
|
|
10
|
+
old_name=Path("sim_cal_sc_hric_cust0_internal_cruise_cruise_2021-04-24_001__0_1.dat")
|
|
11
|
+
new_name=gen_filename(old_name)
|
|
12
|
+
assert new_name == "sim_browse_cal_sc_hric_cust0_internal_cruise_cruise_2021-04-24_001__0_1"
|
|
13
|
+
|
|
14
|
+
def test_lvid():
|
|
15
|
+
oldLVID="urn:esa:psa:bc_mpo_sim:data_raw:sim_raw_sc_hric_template::0.1"
|
|
16
|
+
file_name=Path("sim_cal_sc_hric_cust0_internal_cruise_cruise_2021-04-24_001__0_1.dat")
|
|
17
|
+
file_version='0.1'
|
|
18
|
+
newLVID=new_lvid(oldLVID, file_name, file_version)
|
|
19
|
+
assert newLVID == "urn:esa:psa:bc_mpo_sim:data_raw:sim_cal_sc_hric_cust0_internal_cruise_cruise_2021-04-24_001::0.1"
|
|
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
|