fosanalysis
A framework to evaluate distributed fiber optic sensor data
Toggle main menu visibility
Loading...
Searching...
No Matches
filehandlerpattern.py
Go to the documentation of this file.
1
r"""
2
This script shows how to use the file handler to read ODiSI data files.
3
For .dat files all channels can be read.
4
A .tsv file is also supported.
5
6
\author Anett Kielreiter
7
\date 2024
8
"""
9
10
import
typing
11
12
from
fosanalysis.datahandling.filehandler
import
FileHandler
13
from
fosanalysis.datahandling.filereader
import
SensorInfo
14
15
filepath =
"data/demofile.dat"
# Path to .dat or .tsv file
16
17
handler =
FileHandler
(filepath)
18
testname = handler.metadata.get(
'test name'
,
''
)
19
20
# Get all data of sensors in the measurement file
21
for
sensor
in
handler.sensors:
22
sensor = typing.cast(SensorInfo, sensor)
23
sensor_name = sensor.name
24
serial_number = sensor.serial_number
25
gages = sensor.gages
26
segments = sensor.segments
27
28
# get all data
29
times, data = handler.get_measurements(sensor.channel)
30
x_axis = data[
'All'
][
'x_axis'
]
31
tare = data[
'All'
][
'tare'
]
32
strain = data[
'All'
][
'strain'
]
33
34
# get all data of all gages
35
gage_names = list(gages.keys())
36
times, data = handler.get_measurements(sensor.channel,
37
segments_gages=gage_names)
38
for
name
in
gage_names:
39
x_axis = data[name][
'x_axis'
]
40
tare = data[name][
'tare'
]
41
strain = data[name][
'strain'
]
42
43
# Get all data of known channel
44
times, data = handler.get_measurements(channel=2)
45
x_axis = data[
'All'
][
'x_axis'
]
46
tare = data[
'All'
][
'tare'
]
47
strain = data[
'All'
][
'strain'
]
48
49
# If it is a huge file use the generator
50
for
timestamps, strain
in
handler.yield_measurements_in_chunks(10000,
51
channel=1):
52
# process timestamps and strain, e.g. write to database in chunks
53
print(len(timestamps))
54
55
handler.close_file()
56
fosanalysis.datahandling.filehandler.FileHandler
File handler class to get measurement data from sensors.
Definition
filehandler.py:17
fosanalysis.datahandling.filehandler
Contains class implementations to get file content of ODiSI generated data.
Definition
filehandler.py:1
fosanalysis.datahandling.filereader
Contains class implementations to read ODiSI sensor data.
Definition
filereader.py:1
examples
filehandlerpattern.py
Generated by
1.18.0