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

File reader class for the .tsv measurement files exported by the ODiSI 6100 series interrogators by Luna Inc LunaInnovations2020. More...

Inheritance diagram for fosanalysis.datahandling.filereader.TsvReader:

Public Member Functions

 __init__ (self, str filepath, *args, **kwargs)
 Initializes a tsv file reader.
 
 read_dat_file (self, dat_file)
 Reads only single file and returns all measurement data separated by channels.
 
tuple[list, dict] read_meta_infos (self)
 Method to get sensor data from file.
 
Generator[datetime, np.array] read_next_measurement (self, datetime start_time=None, datetime end_time=None, *args, **kwargs)
 Returns only single entry of measurement as generator to request for multiple times for parts or the whole file.
 
- Public Member Functions inherited from fosanalysis.datahandling.filereader.FileReader
 __init__ (self, *args, **kwargs)
 Constructs a FileReader object.
 
- Public Member Functions inherited from fosanalysis.utils.base.Base
 __init__ (self, *args, **kwargs)
 Construct the object and warn about unused/unknown arguments.
 

Public Attributes

 file = open(self.other_tsv)
 Create a file pointer to the TSV file.
 
 filename = filepath
 Filename given.
 
str itemsep = "\t"
 Stores the item separator, for tsv files it is "\t".
 
str other_tsv = self._locate_full_or_gage_file()
 Checks if both files (_full and _gage) are available, if not it is an empty string.
 

Protected Member Functions

str _locate_full_or_gage_file (self)
 Private method to look for both files (_full and _gage) in folder.
 
tuple[list, list, OrderedDict, OrderedDict] _read_base_data (self)
 Get the base data for all measurements.
 
tuple[list, list] _read_base_from_file (self, OrderedDict segments, OrderedDict gages)
 Read gage/segment, x-axis and tare line to discover related data.
 
 _read_gage_segments_info (self, list data, OrderedDict segments, OrderedDict gages)
 Read gage and segment line to discover the gages and segments.
 
dict _read_metadata (self)
 Retrieves the meta data of the sensor file.
 
 _set_pos_for_segments_gages (self, list data, OrderedDict segments, OrderedDict gages)
 Private method to determine the index of x-positions for segments and gages based on x_axis of full file.
 

Detailed Description

File reader class for the .tsv measurement files exported by the ODiSI 6100 series interrogators by Luna Inc LunaInnovations2020.

See [6]. Both - gage files (*_gages.tsv) and full (*_full.tsv) - are supported.

Definition at line 126 of file filereader.py.

Constructor & Destructor Documentation

◆ __init__()

fosanalysis.datahandling.filereader.TsvReader.__init__ ( self,
str filepath,
* args,
** kwargs )

Initializes a tsv file reader.

Parameters
filepathPath to the .tsv file to read all sensor information.
*argsAdditional positional arguments, will be passed to the superconstructor.
**kwargsAdditional keyword arguments, will be passed to the superconstructor.

Definition at line 133 of file filereader.py.

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

Member Function Documentation

◆ _locate_full_or_gage_file()

str fosanalysis.datahandling.filereader.TsvReader._locate_full_or_gage_file ( self)
protected

Private method to look for both files (_full and _gage) in folder.

If filename is 'gages.tsv' file search for 'full.tsv' and vice versa.

Returns
Path to the found .tsv file, otherwise empty string.

Definition at line 366 of file filereader.py.

◆ _read_base_data()

tuple[list, list, OrderedDict, OrderedDict] fosanalysis.datahandling.filereader.TsvReader._read_base_data ( self)
protected

Get the base data for all measurements.

It reads the segments, gages, x-axis and tare of the file. Search for '_gages' and '_full' files. In case of '_gages' file separate gages and segments. In case of only existing '_full' file no gages will returned.

Returns
X-axis gages of current measurement.
Tare values of measurement.
All segments with index and length available in the file as OrderedDict, empty if no segments available.
All gages with its index in the file as OrderedDict, empty if no gages available.

Definition at line 208 of file filereader.py.

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

◆ _read_base_from_file()

tuple[list, list] fosanalysis.datahandling.filereader.TsvReader._read_base_from_file ( self,
OrderedDict segments,
OrderedDict gages )
protected

Read gage/segment, x-axis and tare line to discover related data.

The segments are written into given segments dictionary. The gages are written into given gages dictionary. This information is used later on to split the data.

Parameters
segmentsDictionary with named segments is written.
gagesDictionary, with named gages is written.
Returns
Array with gages of x-axis existing in file.
Array with whole tare of file, empty if not exist.

Definition at line 278 of file filereader.py.

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

◆ _read_gage_segments_info()

fosanalysis.datahandling.filereader.TsvReader._read_gage_segments_info ( self,
list data,
OrderedDict segments,
OrderedDict gages )
protected

Read gage and segment line to discover the gages and segments.

The gages are written into given gages dictionary. The segments are written into given segments dictionary. This information is used later on to split the data.

Parameters
dataList of line elements, contain the gage and segment names.
segmentsDictionary with named segments is written.
gagesDictionary, with named gages is written.

Definition at line 311 of file filereader.py.

Here is the caller graph for this function:

◆ _read_metadata()

dict fosanalysis.datahandling.filereader.TsvReader._read_metadata ( self)
protected

Retrieves the meta data of the sensor file.

Reads the header data like sensor name, length, gage_pitch, ...

Returns
Metadata as dictionary.

Definition at line 187 of file filereader.py.

Here is the caller graph for this function:

◆ _set_pos_for_segments_gages()

fosanalysis.datahandling.filereader.TsvReader._set_pos_for_segments_gages ( self,
list data,
OrderedDict segments,
OrderedDict gages )
protected

Private method to determine the index of x-positions for segments and gages based on x_axis of full file.

This method will only be called if both files available. This information is used later to split the data.

Parameters
dataList of line elements, contain the x-axis data.
segmentsDictionary with named segments.
gagesDictionary, with named gages.

Definition at line 338 of file filereader.py.

Here is the caller graph for this function:

◆ read_dat_file()

fosanalysis.datahandling.filereader.TsvReader.read_dat_file ( self,
dat_file )

Reads only single file and returns all measurement data separated by channels.

Reimplemented from fosanalysis.datahandling.filereader.FileReader.

Definition at line 275 of file filereader.py.

◆ read_meta_infos()

tuple[list, dict] fosanalysis.datahandling.filereader.TsvReader.read_meta_infos ( self)

Method to get sensor data from file.

For TSV only one sensor exists in the file.

Returns
List with all sensor infos.
Dictionary with measurement specific data.

Reimplemented from fosanalysis.datahandling.filereader.FileReader.

Definition at line 158 of file filereader.py.

Here is the call graph for this function:

◆ read_next_measurement()

Generator[datetime, np.array] fosanalysis.datahandling.filereader.TsvReader.read_next_measurement ( self,
datetime start_time = None,
datetime end_time = None,
* args,
** kwargs )

Returns only single entry of measurement as generator to request for multiple times for parts or the whole file.

Parameters
start_timeRead measurements from given timestamp.
end_timeRead measurements till given timestamp.
Returns
Datetime object of current line.
Strain values of the current line as array.

Reimplemented from fosanalysis.datahandling.filereader.FileReader.

Definition at line 250 of file filereader.py.

Member Data Documentation

◆ file

fosanalysis.datahandling.filereader.TsvReader.file = open(self.other_tsv)

Create a file pointer to the TSV file.

Definition at line 154 of file filereader.py.

◆ filename

fosanalysis.datahandling.filereader.TsvReader.filename = filepath

Filename given.

Definition at line 144 of file filereader.py.

◆ itemsep

str fosanalysis.datahandling.filereader.TsvReader.itemsep = "\t"

Stores the item separator, for tsv files it is "\t".

Definition at line 146 of file filereader.py.

◆ other_tsv

str fosanalysis.datahandling.filereader.TsvReader.other_tsv = self._locate_full_or_gage_file()

Checks if both files (_full and _gage) are available, if not it is an empty string.

Definition at line 150 of file filereader.py.


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