Data and IO¶
ssdaq.core¶
-
class
ssdaq.core.io.BaseFileWriter(file_prefix: str, writer, file_ext: str, folder: str = '', file_enumerator: str = None, filesize_lim: int = None)¶ A data file writer wrapper class that handles filename enumerators and size limits.
Filename enumerators can be date-time or order starting at
000. A new file is started if the preceeding file exceeds the filesize limit or if the methoddata_cond()returns true. This method may be overidden by inheriting classes-
close()¶ Closes the file writer
-
data_cond(data)¶ A callback method which starts a new file when True is returned
Parameters: () (data) – received data Returns: if true a new file will be started Return type: bool
-
write(data)¶ Write data to file
Parameters: data (TYPE) – The data to be written to file
-
-
class
ssdaq.core.io.RawObjectReaderBase(filename: str)¶ This class
-
read() → bytes¶ Reads one object at the position of the file pointer.
Returns: Bytes that represent the object Return type: bytes
-
read_at(ind: int) → bytes¶ Reads one object at the index indicated by ind
Parameters: ind (int) – the index of the object to be read Returns: that represent the object Return type: bytes Raises: IndexError– if index out of range
-
reload()¶ Reload the index table. Useful if the file is being written too when read
-
resetfp()¶ Resets file pointer to the first object in file
-
-
class
ssdaq.core.io.RawObjectWriterBase(filename: str, protocol=1, compressor='bz2', **kwargs)¶ Acts as a file object for writing chunks of serialized data to file. Prepends each chunk with: chunk length in bytes (4 bytes) and a crc32 hash (4 bytes)
-
write(data: bytes)¶ Writes a stream of bytes to file
Parameters: data (bytes) – bytes to be writen to file
-
-
class
ssdaq.core.io.RawObjectWriterV0(filename: str, header: int = 0)¶ Acts as a file object for writing chunks of serialized data to file. Prepends each chunk with: chunk length in bytes (4 bytes) and a crc32 hash (4 bytes)
The file header is 24 bytes long and has the following layout
bytes: field: 0-7 Custom field for file format specifications (set by the header parameter) 8-11 Protocol version 12-15 Not used 16-19 Not used 20-23 Not used- General file structure:
File Header Chunk Header Data Chunk Header Data
-
write(data: bytes)¶ Writes a stream of bytes to file
Parameters: data (bytes) – bytes to be writen to file
-
class
ssdaq.core.io.RawObjectWriterV1(filename: str, header_ext: bytes = None, marker_ext: str = '', compressor=None, bunchsize: int = 1000000)¶ Acts as a file object for writing chunks of serialized data to file. Prepends each chunk with: chunk length in bytes (4 bytes) and a crc32 hash (4 bytes)
The file header is 24 bytes long and has the following layout
bytes: field: 0-7 Custom field for file format specifications (set by the header parameter) 8-11 Protocol version 12-15 Not used 16-19 Not used 20-23 Not used- General file structure:
File Header Chunk Header Data Chunk Header Data
-
write(data: bytes)¶ Writes a stream of bytes to file
Parameters: data (bytes) – bytes to be writen to file
ssdaq.data.io¶
-
class
ssdaq.data.io.SSDataWriter(filename: str, attrs: dict = None, filters: tables.filters.Filters = None, buffer: int = 1000, tel_table=True)¶ A writer for Slow Signal data
-
close_file()¶ Closes file handle
-
-
class
ssdaq.data.io.SSDataReader(filename, mapping='ssl2asic_ch')¶ A reader for Slow Signal data
-
close_file()¶ Closes file handle
-
load_all_data(tm, calib=None, mapping=None)¶ Loads all rows of data for a particular target moduel into memory (in the future a selection of modules)
Parameters: tm (int) – The slot number of the target module - Kwargs:
calib (arraylike): an array with calibration coefficient that should be applied to the data mapping (str or arraylike): a string to select a mapping or an array with the mapping
[‘ssl2colrow’,’ssl2asic_ch’,’raw’]
-
read(start=None, stop=None, step=None)¶ A data file iterator for reading data rows.
Parameters: - start (int) – starting row number
- stop (int) – stopping row number
- step (int) – size of the step at each iteration
-
-
class
ssdaq.data.io.DataReader(filename: str)¶ -
read()¶ Reads one object at the position of the file pointer.
Returns: Bytes that represent the object Return type: bytes
-
read_at(ind: int)¶ Reads one object at the index indicated by ind
Parameters: ind (int) – the index of the object to be read Returns: that represent the object Return type: bytes Raises: IndexError– if index out of range
-
reload()¶ Reload the index table. Useful if the file is being written too when read
-
resetfp()¶ Resets file pointer to the first object in file
-