|
SELKIELogger
1.0.0
|
Represent a SELKIELogger data file and associated common operations. More...
Public Member Functions | |
| def | __init__ (self, filename, pcs=IDs.SLSOURCE_TIMER) |
| Create DatFile instance. More... | |
| def | addSourceMap (self, sm) |
| Associate an SLChannelMap instance with this file. More... | |
| def | prepConverters (self, force=False, includeTS=False) |
| Generate and cache functions to convert each channel into defined fields and corresponding field names suitable for creating a DataFrame later. More... | |
| def | buildRecord (self, msgStack) |
| Convert a group (stack) of messages into a single record, keyed by field names. More... | |
| def | messages (self, source=None, channel=None) |
| Process data file and yield messages, optionally restricted to those matching a specific source and/or channel ID. More... | |
| def | processMessages (self, includeTS=False, force=False, chunkSize=100000) |
| Process messages and return. More... | |
| def | yieldDataFrame (self, dropna=False, resample=None, convertEpoch=False) |
| Process file and yield results as dataframes that can be merged later. More... | |
| def | asDataFrame (self, dropna=False, resample=None, convertEpoch=False) |
| Wrapper around yieldDataFrame. More... | |
Static Public Member Functions | |
| def | tryParse (value) |
| Attempt to convert value to float. More... | |
Private Attributes | |
| _fn | |
| File name and path. | |
| _fields | |
| Cached conversion functions. | |
| _pcs | |
| Primary Clock Source ID. | |
| _sm | |
| Source/Channel Map. | |
| _records | |
| File data records (once parsed) | |
| _columnList | |
Represent a SELKIELogger data file and associated common operations.
Definition at line 106 of file SLFiles.py.
| def SELKIELogger.SLFiles.DatFile.__init__ | ( | self, | |
| filename, | |||
pcs = IDs.SLSOURCE_TIMER |
|||
| ) |
Create DatFile instance.
Does not open or parse file.
| filename | File name and path |
| pcs | Primary Clock Source (Source ID) |
Definition at line 111 of file SLFiles.py.
| def SELKIELogger.SLFiles.DatFile.addSourceMap | ( | self, | |
| sm | |||
| ) |
Associate an SLChannelMap instance with this file.
Used to map source and channel IDs to names.
| sm | SLChannelMap (see VarFile.getSourceMap) |
Definition at line 132 of file SLFiles.py.
| def SELKIELogger.SLFiles.DatFile.asDataFrame | ( | self, | |
dropna = False, |
|||
resample = None, |
|||
convertEpoch = False |
|||
| ) |
Wrapper around yieldDataFrame.
Processes all records and merges them into a single frame.
| dropna | Drop empty records. |
| resample | Resampling interval. |
Definition at line 524 of file SLFiles.py.
| def SELKIELogger.SLFiles.DatFile.buildRecord | ( | self, | |
| msgStack | |||
| ) |
Convert a group (stack) of messages into a single record, keyed by field names.
Field values default to None, and in the event that multiple values for a single field are received, the last value received will be stored.
| msgStack | Group of messages received for a specific interval |
Definition at line 343 of file SLFiles.py.
| def SELKIELogger.SLFiles.DatFile.messages | ( | self, | |
source = None, |
|||
channel = None |
|||
| ) |
Process data file and yield messages, optionally restricted to those matching a specific source and/or channel ID.
| source | Optional: Source ID to match |
| channel | Optional: Channel ID to match |
Definition at line 370 of file SLFiles.py.
| def SELKIELogger.SLFiles.DatFile.prepConverters | ( | self, | |
force = False, |
|||
includeTS = False |
|||
| ) |
Generate and cache functions to convert each channel into defined fields and corresponding field names suitable for creating a DataFrame later.
Names and functions are returned as a collection keyed by source and channel. As each message may produce multiple message, names and functions are each returned as lists containing a minimum of one entry.
Where input is an input SLMessage
| force | Regenerate fields rather than using cached values |
| includeTS | Retain timestamp field as data column as well as index |
Definition at line 167 of file SLFiles.py.
| def SELKIELogger.SLFiles.DatFile.processMessages | ( | self, | |
includeTS = False, |
|||
force = False, |
|||
chunkSize = 100000 |
|||
| ) |
Process messages and return.
Will yield data in chunks.
| includeTS | Passed to prepConverters() |
| force | Passed to prepConverters() |
| chunkSize | Yield records after this many timestamps |
Definition at line 406 of file SLFiles.py.
|
static |
Attempt to convert value to float.
If unsuccessful, parse as JSON and attempt to return a float from either a) the sole value within the object or b) the data associated with a key named "value".
| value | Input value |
Definition at line 144 of file SLFiles.py.
| def SELKIELogger.SLFiles.DatFile.yieldDataFrame | ( | self, | |
dropna = False, |
|||
resample = None, |
|||
convertEpoch = False |
|||
| ) |
Process file and yield results as dataframes that can be merged later.
Optionally drop empty records and perform naive averaging over a given resample interval.
| dropna | Drop rows consisting entirely of NaN/None vales |
| resample | Resampling interval |
Definition at line 461 of file SLFiles.py.