befordata-cli 0.1.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.
- befordata_cli-0.1.0/PKG-INFO +13 -0
- befordata_cli-0.1.0/README.md +0 -0
- befordata_cli-0.1.0/pyproject.toml +22 -0
- befordata_cli-0.1.0/src/befordata_cli/__init__.py +8 -0
- befordata_cli-0.1.0/src/befordata_cli/__main__.py +4 -0
- befordata_cli-0.1.0/src/befordata_cli/cli.py +72 -0
- befordata_cli-0.1.0/src/befordata_cli/xdf.py +24 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: befordata-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Add your description here
|
|
5
|
+
Author: Oliver Lindemann
|
|
6
|
+
Author-email: Oliver Lindemann <lindemann@essb.eur.nl>
|
|
7
|
+
Requires-Dist: befordata>=0.4.5
|
|
8
|
+
Requires-Dist: icecream>=2.2.0
|
|
9
|
+
Requires-Dist: pandas>=3.0.3
|
|
10
|
+
Requires-Dist: pyxdf>=1.17.4
|
|
11
|
+
Requires-Python: >=3.12
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "befordata-cli"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Add your description here"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Oliver Lindemann", email = "lindemann@essb.eur.nl" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.12"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"befordata>=0.4.5",
|
|
12
|
+
"icecream>=2.2.0",
|
|
13
|
+
"pandas>=3.0.3",
|
|
14
|
+
"pyxdf>=1.17.4",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[build-system]
|
|
18
|
+
requires = ["uv_build>=0.11.15,<0.12.0"]
|
|
19
|
+
build-backend = "uv_build"
|
|
20
|
+
|
|
21
|
+
[project.scripts]
|
|
22
|
+
befordata_cli = "befordata_cli.cli:run"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from os.path import isfile
|
|
3
|
+
|
|
4
|
+
from befordata import xdf
|
|
5
|
+
|
|
6
|
+
from . import __version__
|
|
7
|
+
from .xdf import load_xdf, xdf_info
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def run() -> None:
|
|
11
|
+
|
|
12
|
+
parser = argparse.ArgumentParser(
|
|
13
|
+
prog="befordata_cli",
|
|
14
|
+
description="Command-line tool for befordata",
|
|
15
|
+
)
|
|
16
|
+
parser.add_argument(
|
|
17
|
+
"--version", action="version", version=f"%(prog)s {__version__}"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
parser.add_argument("FILE", default="", help="data file")
|
|
21
|
+
|
|
22
|
+
parser.add_argument(
|
|
23
|
+
"-o", "--output",
|
|
24
|
+
metavar="dest",
|
|
25
|
+
help="Output file",
|
|
26
|
+
)
|
|
27
|
+
parser.add_argument(
|
|
28
|
+
"-i", "--info",
|
|
29
|
+
action="store_true",
|
|
30
|
+
default=False,
|
|
31
|
+
help="Print detailed stream info",
|
|
32
|
+
)
|
|
33
|
+
parser.add_argument(
|
|
34
|
+
"--arrow",
|
|
35
|
+
action="store_true",
|
|
36
|
+
default=False,
|
|
37
|
+
help="Convert file to Arrow format (.arrow)",
|
|
38
|
+
)
|
|
39
|
+
parser.add_argument(
|
|
40
|
+
"--csv",
|
|
41
|
+
action="store_true",
|
|
42
|
+
default=False,
|
|
43
|
+
help="Convert file to CSV format (.csv)",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
args = parser.parse_args()
|
|
47
|
+
|
|
48
|
+
if len(args.FILE) < 2:
|
|
49
|
+
print("No data FILE specified.")
|
|
50
|
+
parser.print_help()
|
|
51
|
+
exit()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
if not isfile(args.FILE):
|
|
55
|
+
print(f"File {args.FILE} does not exist.")
|
|
56
|
+
|
|
57
|
+
elif args.FILE.endswith(".xdf"):
|
|
58
|
+
xdf_info(args.FILE, info_dict=args.info)
|
|
59
|
+
|
|
60
|
+
if args.arrow or args.csv:
|
|
61
|
+
streams, header = load_xdf(args.FILE)
|
|
62
|
+
rec = xdf.before_record(streams, args.force_stream, 1000)
|
|
63
|
+
|
|
64
|
+
if args.arrow:
|
|
65
|
+
print(f"Converting to Arrow")
|
|
66
|
+
|
|
67
|
+
if args.csv:
|
|
68
|
+
print(f"Converting to CSV")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
run()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from icecream import ic
|
|
2
|
+
from pyxdf import load_xdf
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def xdf_info(filepath: str, info_dict:bool = False) -> tuple:
|
|
6
|
+
"""
|
|
7
|
+
Extract metadata from an xdf file
|
|
8
|
+
|
|
9
|
+
Args:
|
|
10
|
+
filepath: path to the xdf file
|
|
11
|
+
info_dict: if True, return a dictionary containing the metadata extracted from the xdf file
|
|
12
|
+
Return:
|
|
13
|
+
metadata: dict containing the metadata extracted from the xdf file
|
|
14
|
+
"""
|
|
15
|
+
data, header = load_xdf(filepath)
|
|
16
|
+
for stream in data:
|
|
17
|
+
n = len(stream['time_series'])
|
|
18
|
+
stream_time = stream['time_stamps'][-1] - stream['time_stamps'][0]
|
|
19
|
+
print(f"{stream['info']['name'][0]}: {n} samples, duration {stream_time:.2f} seconds")
|
|
20
|
+
|
|
21
|
+
if info_dict:
|
|
22
|
+
ic(stream['info'])
|
|
23
|
+
return data, header
|
|
24
|
+
|