|
fosanalysis
A framework to evaluate distributed fiber optic sensor data
|
Data inferface for the .tsv measurement files exported by the ODiSI 6100 series interrogators by Luna Inc [6].
More...
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. | |
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.
Definition at line 83 of file protocols.py.
| 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.
| 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(). It is immediately read by read_file().
| 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.
| itemsep | 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().
| *args | Additional positional arguments, will be passed to the superconstructor. |
| **kwargs | Additional keyword arguments, will be passed to the superconstructor. |
Definition at line 92 of file protocols.py.
|
protected |
Private method to return the dictionary matching the search criteria.
| name | Name 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_gage | Switch, 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.
|
protected |
Private method to run the extraction for all gages and segments.
| gages | Dictionary, containing gage information. This includes, the position of the gage in the data. |
| segments | Dictionary, containing segment information. This includes, the start and the length of the segment. |
| record_name | The first entry in line, passed to _store_data(). Contains the information such as:
|
| message_type | The second entry in line, passed to _store_data(). For regular measurement lines this is "measurement". Else, it is emtpy. |
| sensor_type | The third entry in line, passed to _store_data(). For regular measurement lines this is "strain". Else, it is emtpy. |
| data | The rest of the line, split up as a list of str. This contains the measurement data. |
Definition at line 236 of file protocols.py.
|
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().
| gages | Dictionary, to which data of named gages is written. |
| segments | Dictionary, to which data of named segments is written. |
| data | List of split line, assumed to contain the gage and segment names. |
Definition at line 202 of file protocols.py.
|
protected |
Private method to store the data into the dictionary.
Here, the differenciation between a gage and segment is done.
| gage_segment | Dictionary, 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_name | The first entry in line, passed to _store_data(). Contains the information such as:
|
| message_type | The second entry in line, passed to _store_data(). For regular measurement lines this is "measurement". Else, it is emtpy. |
| sensor_type | The third entry in line, passed to _store_data(). For regular measurement lines this is "strain". Else, it is emtpy. |
| data | The rest of the line, split up as a list of str. This contains the measurement data. |
Definition at line 267 of file protocols.py.
| 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.
| start | The first record to be included. Defaults to None (no restriction), i.e., the first reading. |
| end | The first record to not be included anymore. Defaults to None (no restriction), i.e., the last reading. |
| name | Name 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_gage | Switch, 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)\) |
| single | Switch, 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. |
(x, timestamps, strain). | x | Array of positional data for the chosen gage/segment. |
| timestamps | Array of time stamps for the chosen time interval. |
| strain | Array of strain data for the chosen gage/segment and time interval. |
Definition at line 366 of file protocols.py.
| dict fosanalysis.protocols.ODiSI6100TSVFile.get_metadata | ( | self | ) |
Get the metadata dictionary.
Definition at line 592 of file protocols.py.
| 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.
| time_stamp | The time stamp, for which the closest SensorRecord should be returned. |
| name | Name 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_gage | Switch, 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.
| position | Position of the data. Available options:
|
(sensor_record, index) with | sensor_record | the SensorRecord, which time stamp is closest to the given time_stamp and |
| index | the corresponding index in of the SensorRecord. |
Definition at line 418 of file protocols.py.
| 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.
| start | The first record to be included. Defaults to None (no restriction), i.e., the first reading. |
| end | The first record to not be included anymore. Defaults to None (no restriction), i.e., the last reading. |
| name | Name 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_gage | Switch, 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.
| np.array fosanalysis.protocols.ODiSI6100TSVFile.get_tare | ( | self, | |
| str | name = None, | ||
| bool | is_gage = False ) |
Returns the values of the tare record (calibration data).
| name | Name 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_gage | Switch, 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.
| 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.
| x | Position, 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. |
| name | Name 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_gage | Switch, 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.
(x_value, time_stamps, time_series). | x_value | The accurate position, that was found. |
| time_stamps | List of time stamps. |
| time_series | List of strain values for at the position of x_value. |
Definition at line 563 of file protocols.py.
| 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.
| name | Name 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_gage | Switch, 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.
| record_list | List of records, defaults to to the first segment found. |
Definition at line 405 of file protocols.py.
| 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).
| name | Name 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_gage | Switch, 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.
| 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.
| name | Name 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_gage | Switch, 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.
| record_list | List of records, defaults to to the first segment found. |
Reimplemented from fosanalysis.protocols.Protocol.
Definition at line 353 of file protocols.py.
| 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.
| 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 141 of file protocols.py.
| 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.
| 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 gagex: Positional data for the gage.y_data: List of SensorRecord for the measurement data. Definition at line 123 of file protocols.py.
| 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.
| 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.
| 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 segmentlength: 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.