fosanalysis
A framework to evaluate distributed fiber optic sensor data
Loading...
Searching...
No Matches
filehandlerpattern.py
Go to the documentation of this file.
1r"""
2This script shows how to use the file handler to read ODiSI data files.
3For .dat files all channels can be read.
4A .tsv file is also supported.
5
6\author Anett Kielreiter
7\date 2024
8"""
9
10import typing
11
12from fosanalysis.datahandling.filehandler import FileHandler
13from fosanalysis.datahandling.filereader import SensorInfo
14
15filepath = "data/demofile.dat" # Path to .dat or .tsv file
16
17handler = FileHandler(filepath)
18testname = handler.metadata.get('test name', '')
19
20# Get all data of sensors in the measurement file
21for 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
44times, data = handler.get_measurements(channel=2)
45x_axis = data['All']['x_axis']
46tare = data['All']['tare']
47strain = data['All']['strain']
48
49# If it is a huge file use the generator
50for 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
55handler.close_file()
56
File handler class to get measurement data from sensors.
Contains class implementations to get file content of ODiSI generated data.
Definition filehandler.py:1
Contains class implementations to read ODiSI sensor data.
Definition filereader.py:1