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

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

Inheritance diagram for fosanalysis.datahandling.filereader.DatReader:

Public Member Functions

 __init__ (self, str filepath, *args, **kwargs)
 Initializes a .dat file reader.
 
 read_dat_file (self, dat_file)
 Reads single .dat file and parses timestamps and data for each channel Returns a dictionary with channel as key.
 
tuple[list, dict] read_meta_infos (self)
 Method to get sensor data from file.
 
Generator[datetime, np.array] read_next_measurement (self, int channel, datetime start_time=None, datetime end_time=None, *args, **kwargs)
 Returns only single entry of a measurement file 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(filepath)
 Create a file pointer to the raw data .hdr file.
 
int file_version = self.DEFAULT_FILE_VERSION
 Stores the file version of .dat file.
 
 filename = filepath
 File object which is already opened.
 
str itemsep = ","
 Stores the item separator, for dat files the "," is used.
 
list measurement_files = []
 List of files where the measurement data stores.
 

Static Public Attributes

int DEFAULT_FILE_VERSION = 9
 

Protected Member Functions

tuple[OrderedDict, OrderedDict] _extract_segments_gages (self, dict sensor_dict)
 Private method to extract the gages and segments from metadata dictionary.
 
np.array _parse_data (self, strain_data)
 
 _read_base_data (self, dict line_dict, list sensor_list)
 Reads one line of base data file, parse for channel and record type.
 
dict _read_metadata (self, dict meta_dict)
 Retrieves the meta data of the sensor file with multi channels.
 
list _replace_none (self, list values)
 Private method to replace all 'None' values as NaN values.
 

Detailed Description

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

See [6]. The file contains the raw data from measurement, mostly from different channels (1-8 possible).

Definition at line 387 of file filereader.py.

Constructor & Destructor Documentation

◆ __init__()

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

Initializes a .dat file reader.

Parameters
filepathPath to file object to read in sensor data.
*argsAdditional positional arguments, will be passed to the superconstructor.
**kwargsAdditional keyword arguments, will be passed to the superconstructor.

Definition at line 397 of file filereader.py.

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

Member Function Documentation

◆ _extract_segments_gages()

tuple[OrderedDict, OrderedDict] fosanalysis.datahandling.filereader.DatReader._extract_segments_gages ( self,
dict sensor_dict )
protected

Private method to extract the gages and segments from metadata dictionary.

The gages/segments are stored in the first line of the .dat files.

Parameters
sensor_dictDictionary with gages and segments.
Returns
Segments of the sensor as ordered dict.
Gages of the sensor as ordered dict.

Definition at line 552 of file filereader.py.

Here is the caller graph for this function:

◆ _parse_data()

np.array fosanalysis.datahandling.filereader.DatReader._parse_data ( self,
strain_data )
protected
Private method to parse the measurement data 
dependent on type and file version.
File version = 7: Data provided as bytecode, type is string.
File version = 9: Data provided as list with a divisor of 10.

\param strain_data Strain data provided by raw data file, 

maybe string or list.

Returns
Array with converted strain values according to file version.

Definition at line 579 of file filereader.py.

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

◆ _read_base_data()

fosanalysis.datahandling.filereader.DatReader._read_base_data ( self,
dict line_dict,
list sensor_list )
protected

Reads one line of base data file, parse for channel and record type.

The method reads the x-axis and tare if available and adds it to the corresponding SensorInfo object of given list.

Parameters
line_dictCurrent line of hdr.dat with x-axis or tare data.
sensor_listList of SensorInfo objects created by first line.

Definition at line 473 of file filereader.py.

Here is the caller graph for this function:

◆ _read_metadata()

dict fosanalysis.datahandling.filereader.DatReader._read_metadata ( self,
dict meta_dict )
protected

Retrieves the meta data of the sensor file with multi channels.

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

Parameters
meta_dictDictionary with meta infos of first line.
Returns
Metadata as dictionary without sensor info.
List of SensorInfo objects for each channel.

Definition at line 442 of file filereader.py.

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

◆ _replace_none()

list fosanalysis.datahandling.filereader.DatReader._replace_none ( self,
list values )
protected

Private method to replace all 'None' values as NaN values.

Parameters
valuesList with strain data.
Returns
List with np.nan values instead of 'None'.

Definition at line 616 of file filereader.py.

Here is the caller graph for this function:

◆ read_dat_file()

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

Reads single .dat file and parses timestamps and data for each channel Returns a dictionary with channel as key.

Parameters
dat_filePath of the .dat file to read from.
Returns
data_dict Dictionary with timestamps and data for each channel in file.

Reimplemented from fosanalysis.datahandling.filereader.FileReader.

Definition at line 526 of file filereader.py.

Here is the call graph for this function:

◆ read_meta_infos()

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

Method to get sensor data from file.

Returns all sensor data available in the .dat file.

Returns
List of available sensors.
Dictionary with measurement specific data.

Reimplemented from fosanalysis.datahandling.filereader.FileReader.

Definition at line 418 of file filereader.py.

Here is the call graph for this function:

◆ read_next_measurement()

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

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

Checks the given channel first.

Parameters
channelChannel of the selected sensor.
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 492 of file filereader.py.

Here is the call graph for this function:

Member Data Documentation

◆ DEFAULT_FILE_VERSION

int fosanalysis.datahandling.filereader.DatReader.DEFAULT_FILE_VERSION = 9
static

Definition at line 395 of file filereader.py.

◆ file

fosanalysis.datahandling.filereader.DatReader.file = open(filepath)

Create a file pointer to the raw data .hdr file.

Definition at line 416 of file filereader.py.

◆ file_version

int fosanalysis.datahandling.filereader.DatReader.file_version = self.DEFAULT_FILE_VERSION

Stores the file version of .dat file.

Definition at line 414 of file filereader.py.

◆ filename

fosanalysis.datahandling.filereader.DatReader.filename = filepath

File object which is already opened.

Definition at line 408 of file filereader.py.

◆ itemsep

str fosanalysis.datahandling.filereader.DatReader.itemsep = ","

Stores the item separator, for dat files the "," is used.

Definition at line 410 of file filereader.py.

◆ measurement_files

list fosanalysis.datahandling.filereader.DatReader.measurement_files = []

List of files where the measurement data stores.

Definition at line 412 of file filereader.py.


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