fosanalysis
A framework to evaluate distributed fiber optic sensor data
Loading...
Searching...
No Matches
fosanalysis.protocols.ODiSI6100TSVFile Class Reference

Data inferface for the .tsv measurement files exported by the ODiSI 6100 series interrogators by Luna Inc [6]. More...

Inheritance diagram for fosanalysis.protocols.ODiSI6100TSVFile:

Public Member Functions

 __init__ (self, str file, bool only_header=False, str itemsep="\t", *args, **kwargs)
 Construct the interface object and parse a .tsv file.
 
tuple get_data (self, start=None, end=None, str name=None, bool is_gage=False, bool single=False)
 Get the positional data (x-axis), timestamps and strain data for a gage/segment and a time interval.
 
dict get_metadata (self)
 Get the metadata dictionary.
 
tuple get_record_from_time_stamp (self, datetime.datetime time_stamp, str name=None, bool is_gage=False, str position="closest")
 Get the SensorRecord and its index, which is closest to the given time_stamp.
 
list get_record_slice (self, start=None, end=None, str name=None, bool is_gage=False)
 Get a portion of the records in the table and return it as a list of SensorRecord.
 
np.array get_tare (self, str name=None, bool is_gage=False)
 Returns the values of the tare record (calibration data).
 
tuple get_time_series (self, float x=0.0, str name=None, bool is_gage=False)
 Get the strain time series for a fixed position.
 
list get_time_stamps (self, str name=None, bool is_gage=False, list record_list=None)
 Get the time stamps of all stored records.
 
np.array get_x_values (self, str name=None, bool is_gage=False)
 Returns the values of the x-axis record (location data).
 
list get_y_table (self, str name=None, bool is_gage=False, list record_list=None)
 Returns the table of the strain data.
 
 read_file (self, bool only_header)
 Parse the content of file and extract the measurement data.
 
- Public Member Functions inherited from fosanalysis.protocols.Protocol
 __init__ (self, *args, **kwargs)
 Constructs a Protocol 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 = file
 Fully specified file path, from which the data is read.
 
 gages = OrderedDict()
 Dictionary of gages Each gage is stored as a sub-dictionary with its name as a key.
 
 itemsep = itemsep
 String, which separates items (columns) in the file.
 
 only_header = only_header
 Switch to omit processing the complete file.
 
 segments = OrderedDict()
 Dictionary of segments.
 
- Public Attributes inherited from fosanalysis.protocols.Protocol
dict metadata = {}
 Dictionary containting metadata information.
 

Protected Member Functions

dict _get_dict (self, str name=None, bool is_gage=False)
 Private method to return the dictionary matching the search criteria.
 
 _read_gage_segment_data (self, dict gages, dict segments, str record_name, str message_type, str sensor_type, list data)
 Private method to run the extraction for all gages and segments.
 
 _read_gage_segments_info (self, dict gages, dict segments, list data)
 Read gage and segment line to discover the gages and segments.
 
 _store_data (self, dict gage_segment, str record_name, str message_type, str sensor_type, list data)
 Private method to store the data into the dictionary.
 

Detailed Description

Data inferface for the .tsv measurement files exported by the ODiSI 6100 series interrogators by Luna Inc [6].

Both gage files (*_gages.tsv) and full (*_full.tsv) are supported.

Deprecated
This class and its subclasses are deprecated and will be removed in the next release. Please update to the new interface, see datahandling.

Definition at line 83 of file protocols.py.

Constructor & Destructor Documentation

◆ __init__()

fosanalysis.protocols.ODiSI6100TSVFile.__init__ ( self,
str file,
bool only_header = False,
str itemsep = "\t",
* args,
** kwargs )

Construct the interface object and parse a .tsv file.

Parameters
fileFully specified file path, from which the data is read.

The file is parsed at instantiation on a ODiSI6100TSVFile object, but can be re-read with read_file(). It is immediately read by read_file().

Parameters
only_headerSwitch to omit processing the complete file.

Default is False (read whole file). If set to True, parsing is stopped at the first measurement and only header data (meta data, gages/segments, tare, x-axis) is read.

Parameters
itemsepFully specified file path, from which the data is read.

The file is parsed at instantiation on a ODiSI6100TSVFile object, but can be re-read with read_file().

Parameters
*argsAdditional positional arguments, will be passed to the superconstructor.
**kwargsAdditional keyword arguments, will be passed to the superconstructor.

Definition at line 92 of file protocols.py.

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

Member Function Documentation

◆ _get_dict()

dict fosanalysis.protocols.ODiSI6100TSVFile._get_dict ( self,
str name = None,
bool is_gage = False )
protected

Private method to return the dictionary matching the search criteria.

Parameters
nameName of the gage or segment. Defaults to the first gage or segment, depending on is_gage. This name needs to exactly match the key in the dictionary.
is_gageSwitch, whether name is a gage or a segment. Defaults to False. If True, look in gages for name. If False, look in segments for name.

If no matching segment/gage is found, a RuntimeError is raised.

Definition at line 312 of file protocols.py.

Here is the caller graph for this function:

◆ _read_gage_segment_data()

fosanalysis.protocols.ODiSI6100TSVFile._read_gage_segment_data ( self,
dict gages,
dict segments,
str record_name,
str message_type,
str sensor_type,
list data )
protected

Private method to run the extraction for all gages and segments.

Parameters
gagesDictionary, containing gage information. This includes, the position of the gage in the data.
segmentsDictionary, containing segment information. This includes, the start and the length of the segment.
record_nameThe first entry in line, passed to _store_data(). Contains the information such as:
  • "x-axis" for the coordinate line,
  • "tare" for the tare data,
  • a datetime string for regular measurement lines.
message_typeThe second entry in line, passed to _store_data(). For regular measurement lines this is "measurement". Else, it is emtpy.
sensor_typeThe third entry in line, passed to _store_data(). For regular measurement lines this is "strain". Else, it is emtpy.
dataThe rest of the line, split up as a list of str. This contains the measurement data.

Definition at line 236 of file protocols.py.

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

◆ _read_gage_segments_info()

fosanalysis.protocols.ODiSI6100TSVFile._read_gage_segments_info ( self,
dict gages,
dict segments,
list data )
protected

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

The gages are written into gages. The segments are written into segments. This information is used later on to split the data by _read_gage_segment_data().

Parameters
gagesDictionary, to which data of named gages is written.
segmentsDictionary, to which data of named segments is written.
dataList of split line, assumed to contain the gage and segment names.

Definition at line 202 of file protocols.py.

Here is the caller graph for this function:

◆ _store_data()

fosanalysis.protocols.ODiSI6100TSVFile._store_data ( self,
dict gage_segment,
str record_name,
str message_type,
str sensor_type,
list data )
protected

Private method to store the data into the dictionary.

Here, the differenciation between a gage and segment is done.

Parameters
gage_segmentDictionary, containing information, which data to extract. A segment is assumed, if the dictionary contains the key "length". Otherwise, it is assumed to be a gage.
record_nameThe first entry in line, passed to _store_data(). Contains the information such as:
  • "x-axis" for the coordinate line
  • "tare" for the tare data
  • a datetime string for regular measurement lines
message_typeThe second entry in line, passed to _store_data(). For regular measurement lines this is "measurement". Else, it is emtpy.
sensor_typeThe third entry in line, passed to _store_data(). For regular measurement lines this is "strain". Else, it is emtpy.
dataThe rest of the line, split up as a list of str. This contains the measurement data.

Definition at line 267 of file protocols.py.

Here is the caller graph for this function:

◆ get_data()

tuple fosanalysis.protocols.ODiSI6100TSVFile.get_data ( self,
start = None,
end = None,
str name = None,
bool is_gage = False,
bool single = False )

Get the positional data (x-axis), timestamps and strain data for a gage/segment and a time interval.

Parameters
startThe first record to be included. Defaults to None (no restriction), i.e., the first reading.
endThe first record to not be included anymore. Defaults to None (no restriction), i.e., the last reading.
nameName of the gage or segment. Defaults to the first gage or segment, depending on is_gage. This name needs to exactly match the key in the dictionary.
is_gageSwitch, whether name is a gage or a segment. Defaults to False. If True, look in gages for name. If False, look in segments for name.

If no matching segment/gage is found, a RuntimeError is raised.

Both start and end can be of the following types and be combined arbitrarily.

  • int: Index of the record according to Python indexing logic.
  • datetime.datetime: The first record after the given datetime.datetime is included for start and excluded for end.
  • datetime.timedelta: Time duration, in relation to the other parameter. If the parameter is None, it defaults to the first/last reading time. This works both for the other parameter being int or datetime.datetime. If both parameters are datetime.timedelta, the data section runs from start after the first reading until end before the last reading.

In the following table, the possible combinations are shown. There, \(i\) is an index according to the Python indexing logic (the first is \(0\) and the last is \(-1\)), \(t\) is a time stamp (datetime.datetime), \(\Delta t\) is a time delta (datetime.timedelta), \(t(i)\) is the time stamp of the \(i\)th reading, and \(i(t)\) is index of the reading with the smallest time stamp bigger than \(t\).

start end Start index End index
None None \(0\) \(-1\)
None \(i_e\) \(0\) \(i_e\)
None \(t_e\) \(0\) \(i(t_e)\)
None \(\Delta t_e\) \(0\) \(i(t(0) + \Delta t_e)\)
\(i_s\) None \(i_s\) \(-1\)
\(i_s\) \(i_e\) \(i_s\) \(i_e\)
\(i_s\) \(t_e\) \(i_s\) \(i(t_e)\)
\(i_s\) \(\Delta t_e\) \(i_s\) \(i(t(i_s) + \Delta t_e)\)
\(t_s\) None \(i(t_s)\) \(-1\)
\(t_s\) \(i_e\) \(i(t_s)\) \(i_e\)
\(t_s\) \(t_e\) \(i(t_s)\) \(i(t_e)\)
\(t_s\) \(\Delta t_e\) \(i(t_s)\) \(i(t_s + \Delta t_e)\)
\(\Delta t_s\) None \(i(t(-1)-\Delta t_s)\) -1
\(\Delta t_s\) \(i_e\) \(i(t(i_e)-\Delta t_s)\) \(i_e\)
\(\Delta t_s\) \(t_e\) \(i(t_e - \Delta t_s)\) \(i(t_e)\)
\(\Delta t_s\) \(\Delta t_e\) \(i(t(0) + \Delta t_s)\) \(i(t(-1) - \Delta t_e)\)
Parameters
singleSwitch, whether a single reading is requested. Defaults to False, requesting a range of readings. If set to True, only start is required, which is expected either an int or a datetime.datetime. For the datetime, the closest reading is returned. The strain will then be a 1D array.
Returns
Returns a tuple like (x, timestamps, strain).
Return values
xArray of positional data for the chosen gage/segment.
timestampsArray of time stamps for the chosen time interval.
strainArray of strain data for the chosen gage/segment and time interval.

Definition at line 366 of file protocols.py.

Here is the call graph for this function:

◆ get_metadata()

dict fosanalysis.protocols.ODiSI6100TSVFile.get_metadata ( self)

Get the metadata dictionary.

Definition at line 592 of file protocols.py.

◆ get_record_from_time_stamp()

tuple fosanalysis.protocols.ODiSI6100TSVFile.get_record_from_time_stamp ( self,
datetime.datetime time_stamp,
str name = None,
bool is_gage = False,
str position = "closest" )

Get the SensorRecord and its index, which is closest to the given time_stamp.

Parameters
time_stampThe time stamp, for which the closest SensorRecord should be returned.
nameName of the gage or segment. Defaults to the first gage or segment, depending on is_gage. This name needs to exactly match the key in the dictionary.
is_gageSwitch, whether name is a gage or a segment. Defaults to False. If True, look in gages for name. If False, look in segments for name.

If no matching segment/gage is found, a RuntimeError is raised.

Parameters
positionPosition of the data. Available options:
  • "closest" (default) get the entry, which is closest to the given value.
  • "searchsorted" get the entry as reported by np.searchsorted. If the time_stamp is larger that any time stamp, the last record is returned but the index is equal to the length of the time stamp list (does not have a corresponding value).
Returns
Returns a tuple like (sensor_record, index) with
Return values
sensor_recordthe SensorRecord, which time stamp is closest to the given time_stamp and
indexthe corresponding index in of the SensorRecord.

Definition at line 418 of file protocols.py.

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

◆ get_record_slice()

list fosanalysis.protocols.ODiSI6100TSVFile.get_record_slice ( self,
start = None,
end = None,
str name = None,
bool is_gage = False )

Get a portion of the records in the table and return it as a list of SensorRecord.

Parameters
startThe first record to be included. Defaults to None (no restriction), i.e., the first reading.
endThe first record to not be included anymore. Defaults to None (no restriction), i.e., the last reading.
nameName of the gage or segment. Defaults to the first gage or segment, depending on is_gage. This name needs to exactly match the key in the dictionary.
is_gageSwitch, whether name is a gage or a segment. Defaults to False. If True, look in gages for name. If False, look in segments for name.

If no matching segment/gage is found, a RuntimeError is raised.

Both start and end can be of the following types and be combined arbitrarily.

  • int: Index of the record according to Python indexing logic.
  • datetime.datetime: The first record after the given datetime.datetime is included for start and excluded for end.
  • datetime.timedelta: Time duration, in relation to the other parameter. If the parameter is None, it defaults to the first/last reading time. This works both for the other parameter being int or datetime.datetime. If both parameters are datetime.timedelta, the data section runs from start after the first reading until end before the last reading.

In the following table, the possible combinations are shown. There, \(i\) is an index according to the Python indexing logic (the first is \(0\) and the last is \(-1\)), \(t\) is a time stamp (datetime.datetime), \(\Delta t\) is a time delta (datetime.timedelta), \(t(i)\) is the time stamp of the \(i\)th reading, and \(i(t)\) is index of the reading with the smallest time stamp bigger than \(t\).

start end Start index End index
None None \(0\) \(-1\)
None \(i_e\) \(0\) \(i_e\)
None \(t_e\) \(0\) \(i(t_e)\)
None \(\Delta t_e\) \(0\) \(i(t(0) + \Delta t_e)\)
\(i_s\) None \(i_s\) \(-1\)
\(i_s\) \(i_e\) \(i_s\) \(i_e\)
\(i_s\) \(t_e\) \(i_s\) \(i(t_e)\)
\(i_s\) \(\Delta t_e\) \(i_s\) \(i(t(i_s) + \Delta t_e)\)
\(t_s\) None \(i(t_s)\) \(-1\)
\(t_s\) \(i_e\) \(i(t_s)\) \(i_e\)
\(t_s\) \(t_e\) \(i(t_s)\) \(i(t_e)\)
\(t_s\) \(\Delta t_e\) \(i(t_s)\) \(i(t_s + \Delta t_e)\)
\(\Delta t_s\) None \(i(t(-1)-\Delta t_s)\) -1
\(\Delta t_s\) \(i_e\) \(i(t(i_e)-\Delta t_s)\) \(i_e\)
\(\Delta t_s\) \(t_e\) \(i(t_e - \Delta t_s)\) \(i(t_e)\)
\(\Delta t_s\) \(\Delta t_e\) \(i(t(0) + \Delta t_s)\) \(i(t(-1) - \Delta t_e)\)

Definition at line 451 of file protocols.py.

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

◆ get_tare()

np.array fosanalysis.protocols.ODiSI6100TSVFile.get_tare ( self,
str name = None,
bool is_gage = False )

Returns the values of the tare record (calibration data).

Parameters
nameName of the gage or segment. Defaults to the first gage or segment, depending on is_gage. This name needs to exactly match the key in the dictionary.
is_gageSwitch, whether name is a gage or a segment. Defaults to False. If True, look in gages for name. If False, look in segments for name.

If no matching segment/gage is found, a RuntimeError is raised.

Definition at line 335 of file protocols.py.

Here is the call graph for this function:

◆ get_time_series()

tuple fosanalysis.protocols.ODiSI6100TSVFile.get_time_series ( self,
float x = 0.0,
str name = None,
bool is_gage = False )

Get the strain time series for a fixed position.

Therefore, the closest x-value to the given position is found and the according strain values are collected.

Parameters
xPosition, for which the time series should be retrieved. This is used to search the nearest position in the segment. For time series of gages (is_gage=True), this has no influence.
nameName of the gage or segment. Defaults to the first gage or segment, depending on is_gage. This name needs to exactly match the key in the dictionary.
is_gageSwitch, whether name is a gage or a segment. Defaults to False. If True, look in gages for name. If False, look in segments for name.

If no matching segment/gage is found, a RuntimeError is raised.

Returns
Returns a tuple of (x_value, time_stamps, time_series).
Return values
x_valueThe accurate position, that was found.
time_stampsList of time stamps.
time_seriesList of strain values for at the position of x_value.

Definition at line 563 of file protocols.py.

Here is the call graph for this function:

◆ get_time_stamps()

list fosanalysis.protocols.ODiSI6100TSVFile.get_time_stamps ( self,
str name = None,
bool is_gage = False,
list record_list = None )

Get the time stamps of all stored records.

Parameters
nameName of the gage or segment. Defaults to the first gage or segment, depending on is_gage. This name needs to exactly match the key in the dictionary.
is_gageSwitch, whether name is a gage or a segment. Defaults to False. If True, look in gages for name. If False, look in segments for name.

If no matching segment/gage is found, a RuntimeError is raised.

Parameters
record_listList of records, defaults to to the first segment found.

Definition at line 405 of file protocols.py.

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

◆ get_x_values()

np.array fosanalysis.protocols.ODiSI6100TSVFile.get_x_values ( self,
str name = None,
bool is_gage = False )

Returns the values of the x-axis record (location data).

Parameters
nameName of the gage or segment. Defaults to the first gage or segment, depending on is_gage. This name needs to exactly match the key in the dictionary.
is_gageSwitch, whether name is a gage or a segment. Defaults to False. If True, look in gages for name. If False, look in segments for name.

If no matching segment/gage is found, a RuntimeError is raised.

Reimplemented from fosanalysis.protocols.Protocol.

Definition at line 344 of file protocols.py.

Here is the call graph for this function:

◆ get_y_table()

list fosanalysis.protocols.ODiSI6100TSVFile.get_y_table ( self,
str name = None,
bool is_gage = False,
list record_list = None )

Returns the table of the strain data.

Parameters
nameName of the gage or segment. Defaults to the first gage or segment, depending on is_gage. This name needs to exactly match the key in the dictionary.
is_gageSwitch, whether name is a gage or a segment. Defaults to False. If True, look in gages for name. If False, look in segments for name.

If no matching segment/gage is found, a RuntimeError is raised.

Parameters
record_listList of records, defaults to to the first segment found.

Reimplemented from fosanalysis.protocols.Protocol.

Definition at line 353 of file protocols.py.

Here is the call graph for this function:

◆ read_file()

fosanalysis.protocols.ODiSI6100TSVFile.read_file ( self,
bool only_header )

Parse the content of file and extract the measurement data.

It can be called multiple times for reading base data or the whole file. The content is added to the gages and segments dictionaries. The metadata is stored as dictionary in metadata.

Parameters
only_headerSwitch to omit processing the complete file.

Default is False (read whole file). If set to True, parsing is stopped at the first measurement and only header data (meta data, gages/segments, tare, x-axis) is read.

Definition at line 141 of file protocols.py.

Here is the call graph for this function:

Member Data Documentation

◆ file

fosanalysis.protocols.ODiSI6100TSVFile.file = file

Fully specified file path, from which the data is read.

The file is parsed at instantiation on a ODiSI6100TSVFile object, but can be re-read with read_file().

Definition at line 129 of file protocols.py.

◆ gages

fosanalysis.protocols.ODiSI6100TSVFile.gages = OrderedDict()

Dictionary of gages Each gage is stored as a sub-dictionary with its name as a key.

Each sub-dictionary requires the following keys:

  • index: Start index of the gage
  • x: Positional data for the gage.
  • y_data: List of SensorRecord for the measurement data.

Definition at line 123 of file protocols.py.

◆ itemsep

fosanalysis.protocols.ODiSI6100TSVFile.itemsep = itemsep

String, which separates items (columns) in the file.

Defaults to "\t" (tab).

Definition at line 132 of file protocols.py.

◆ only_header

fosanalysis.protocols.ODiSI6100TSVFile.only_header = only_header

Switch to omit processing the complete file.

Default is False (read whole file). If set to True, parsing is stopped at the first measurement and only header data (meta data, gages/segments, tare, x-axis) is read.

Definition at line 138 of file protocols.py.

◆ segments

fosanalysis.protocols.ODiSI6100TSVFile.segments = OrderedDict()

Dictionary of segments.

Each segment is stored as a sub-dictionary with its name as a key. Each sub-dictionary requires the following keys:

  • start: Start index of the segment
  • length: Number of measurement points in the segment.
  • end: End index of the segment (not strictly required). As it is used as the ending slicing index, actually one more.
  • x: Positional data for the segment.
  • y_data: List of SensorRecord for the measurement data.

Definition at line 116 of file protocols.py.


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