fosanalysis
A framework to evaluate distributed fiber optic sensor data
Loading...
Searching...
No Matches
fosanalysis.datahandling.filehandler.FileHandler Class Reference

File handler class to get measurement data from sensors. More...

Public Member Functions

 __init__ (self, str filename, int chunk_size=1000)
 Provides the handler for parsing measuring data files.
 
 close_file (self)
 Close the handle to the file and reset all function variables.
 
tuple[list, dict] get_measurements (self, int channel=None, datetime start_time=None, datetime end_time=None, segments_gages=None)
 
Generator[dict] yield_dat_file_values (self)
 Generator to iterate over all .dat files of current measurement.
 
Generator[list, dict] yield_gages_segments_in_chunks (self, segments_gages, int chunk_size=None, int channel=None, datetime start_time=None, datetime end_time=None)
 Generator to iterate over a dictionary with all strain data, x-axis and tare for the given segment or gage names of chunk_size.
 
Generator[list, list] yield_measurements_in_chunks (self, int chunk_size=None, int channel=None, datetime start_time=None, datetime end_time=None)
 Generator to iterate over the whole file and yields data with size of chunk.
 

Public Attributes

 chunk_size = chunk_size
 Size of chunks when reading multiple readings at once.
 
 metadata = None
 Dictionary, which stores metadata for each file imported.
 
 reader = None
 Holds the file reader for selected file.
 
 sensors = None
 List of SensorInfo object available in file, contains all sensor specific infos (incl.
 

Protected Member Functions

tuple[int, int] _get_range_of_segment_gage (self, str name, filereader.SensorInfo sensor)
 Get start and end index of gage/segment.
 
 _split_to_gages_segments (self, dict meas_dict, filereader.SensorInfo sensor, segments_gages, list strain)
 Fill the meas_dict dictionary with all strain data, x-axis and tare for the given segment or gage names.
 

Detailed Description

File handler class to get measurement data from sensors.

Currently raw data and exported TSV files from ODiSI 6100 series interrogators by Luna Inc LunaInnovations2020 are supported, see [6].

Definition at line 17 of file filehandler.py.

Constructor & Destructor Documentation

◆ __init__()

fosanalysis.datahandling.filehandler.FileHandler.__init__ ( self,
str filename,
int chunk_size = 1000 )

Provides the handler for parsing measuring data files.

Different types of files are supported (atm *.dat and *.tsv )

Parameters
filenamePath to file to get measurement data.
chunk_sizeSize of chunks when reading multiple readings at once. For more, see chunk_size.

Definition at line 24 of file filehandler.py.

Member Function Documentation

◆ _get_range_of_segment_gage()

tuple[int, int] fosanalysis.datahandling.filehandler.FileHandler._get_range_of_segment_gage ( self,
str name,
filereader.SensorInfo sensor )
protected

Get start and end index of gage/segment.

Parameters
nameName of the segment/gage.
sensorSensor object with axis, tare, etc.
Returns
start Start index of segment or index of gage.
end End index of segment or index+1 if gage.

Definition at line 242 of file filehandler.py.

Here is the caller graph for this function:

◆ _split_to_gages_segments()

fosanalysis.datahandling.filehandler.FileHandler._split_to_gages_segments ( self,
dict meas_dict,
filereader.SensorInfo sensor,
segments_gages,
list strain )
protected

Fill the meas_dict dictionary with all strain data, x-axis and tare for the given segment or gage names.

Parameters
meas_dictDict with all measurement data of segment/gage.
sensorSensor object with axis, tare, etc.
segments_gagesString or list of gage/segment name(s).
strainStrain values as list of arrays.

Definition at line 213 of file filehandler.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ close_file()

fosanalysis.datahandling.filehandler.FileHandler.close_file ( self)

Close the handle to the file and reset all function variables.

Definition at line 56 of file filehandler.py.

◆ get_measurements()

tuple[list, dict] fosanalysis.datahandling.filehandler.FileHandler.get_measurements ( self,
int channel = None,
datetime start_time = None,
datetime end_time = None,
segments_gages = None )
    Reads all measurement files and returns the strain values, x_axis, 
    tare and timestamps filtered by given parameters.
    The values are read in blocks to avoid memory issues.
    The values will be split to gages/segments, 
    if segments_gages are given.
    \param channel Selected channel of the file, defines the sensor.
    \param start_time Read measurements from given timestamp.
    \param end_time Read measurements till given timestamp.
    \param segments_gages String or list of strings of gages/segments.
    \return List of available timestamps.
    \return Data of measurement (strain, xaxis, tare) as dict.

If no segment/gage selected, the dict contains ['All'] key.

Definition at line 68 of file filehandler.py.

Here is the call graph for this function:

◆ yield_dat_file_values()

Generator[dict] fosanalysis.datahandling.filehandler.FileHandler.yield_dat_file_values ( self)

Generator to iterate over all .dat files of current measurement.

Reads all values of the file and separate it to the channels.

Returns
Dict with all measurement data (timestamps, strain) by channel.

Definition at line 122 of file filehandler.py.

◆ yield_gages_segments_in_chunks()

Generator[list, dict] fosanalysis.datahandling.filehandler.FileHandler.yield_gages_segments_in_chunks ( self,
segments_gages,
int chunk_size = None,
int channel = None,
datetime start_time = None,
datetime end_time = None )

Generator to iterate over a dictionary with all strain data, x-axis and tare for the given segment or gage names of chunk_size.

Separately from it, it returns the timestamps of file.

Parameters
segments_gagesString or list of gage/segment name(s).
chunk_sizeNumber of lines to be read in one chunk as int.
channelSelected channel of the file, defines the sensor.
start_timeRead measurements from given timestamp.
end_timeRead measurements till given timestamp.
Returns
timestamps List of available timestamps.
meas_dict Dict with all measurement data of segment/gage.

Definition at line 173 of file filehandler.py.

Here is the call graph for this function:

◆ yield_measurements_in_chunks()

Generator[list, list] fosanalysis.datahandling.filehandler.FileHandler.yield_measurements_in_chunks ( self,
int chunk_size = None,
int channel = None,
datetime start_time = None,
datetime end_time = None )

Generator to iterate over the whole file and yields data with size of chunk.

Returns lists of timestamps and strain values.

Parameters
chunk_sizeMaximum number of lines to read in lists, see chunk_size.
channelSelected channel of the file, defines the sensor.
start_timeRead measurements from given timestamp.
end_timeRead measurements till given timestamp.
Returns
List of available timestamps.
Strain data as list.

Definition at line 135 of file filehandler.py.

Here is the caller graph for this function:

Member Data Documentation

◆ chunk_size

fosanalysis.datahandling.filehandler.FileHandler.chunk_size = chunk_size

Size of chunks when reading multiple readings at once.

This is equivalent to the number of lines parsed in one go. The higher this value, the more data is held in memory. If the device is tight on memory, reduce it. Defaults to 1000.

Definition at line 44 of file filehandler.py.

◆ metadata

fosanalysis.datahandling.filehandler.FileHandler.metadata = None

Dictionary, which stores metadata for each file imported.

The field name is used as key.

Definition at line 35 of file filehandler.py.

◆ reader

fosanalysis.datahandling.filehandler.FileHandler.reader = None

Holds the file reader for selected file.

Definition at line 32 of file filehandler.py.

◆ sensors

fosanalysis.datahandling.filehandler.FileHandler.sensors = None

List of SensorInfo object available in file, contains all sensor specific infos (incl.

tare, x-axis, segments...).

Definition at line 38 of file filehandler.py.


The documentation for this class was generated from the following file: