/
__init__.py
98 lines (71 loc) · 2.3 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"""
IO
==
Read/write Vallen Systeme database and setup files.
Database classes
----------------
Classes to read/write pridb, tradb and trfdb database files.
.. warning:: Writing is still experimental
.. autosummary::
:toctree: generated
PriDatabase
TraDatabase
TrfDatabase
All database classes implement two different interfaces to access data:
**Standard** ``read_*``
Read data to `pandas.DataFrame`, e.g. with `PriDatabase.read_hits`
>>> pridb = vae.io.PriDatabase("./examples/steel_plate/sample.pridb")
>>> df = pridb.read_hits() # save all hits to pandas dataframe
>>> df[["time", "channel"]] # output columns hit and channel
time channel
set_id
10 3.992771 3
11 3.992775 2
12 3.992813 4
13 3.992814 1
**Streaming** ``iread_*``
Iterate through the data row by row.
This is a memory-efficient solution ideal for batch processing.
The return types are specific `typing.NamedTuple`, see :ref:`datatypes`.
Example with `PriDatabase.iread_hits`:
>>> pridb = vae.io.PriDatabase("./examples/steel_plate/sample.pridb")
>>> for hit in pridb.iread_hits():
... print(f"time: {hit.time:0.4f}, channel: {hit.channel}")
...
time: 3.9928, channel: 3
time: 3.9928, channel: 2
time: 3.9928, channel: 4
time: 3.9928, channel: 1
>>> type(hit)
<class 'vallenae.io.datatypes.HitRecord'>
.. _datatypes:
Data types
----------
Records of the database are represented as `typing.NamedTuple`.
Each record implements a class method ``from_sql`` to init from a SQLite
row dictionary (column name: value).
.. autosummary::
:toctree: generated
HitRecord
MarkerRecord
StatusRecord
ParametricRecord
TraRecord
Compression
-----------
Transient signals in the tradb are stored as BLOBs of 16-bit ADC values --
either uncompressed or compressed (`FLAC <https://xiph.org/flac/>`_).
Following functions convert between BLOBs and arrays of voltage values.
.. autosummary::
:toctree: generated
decode_data_blob
encode_data_blob
"""
# flake8: noqa
from .datatypes import *
from .types import *
from .compression import *
from .pridb import *
from .tradb import *
from .trfdb import *
__all__ = [_ for _ in dir() if not _.startswith("_")]