legacy — Legacy data#

This module provides support for legacy log files, where readout data are written in text format. More specifically, the AstroPixLogFile class provides a simple interface to log file that implements both the context manager and the iterator protocol, and parses at the same time all the metadata in the file header.

from astropix_analysis.legacy import AstroPixLogFile

with AstroPixLogFile('path/to/my/file.log') as input_file:
     header = input_file.header
     print(header)
     print(header.options().get('threshold'))
     for readout_id, readout_data in input_file:
         print(readout_id, readout_data)

The bin/apx_log2apx.py scripts is a simple tool to convert legacy .log files into new .apx binary files.

Module documentation#

Facilities for legacy .log data files.

class astropix_analysis.legacy.LogFileHeader(input_file: TextIO)[source]#

Convenience class to interact with the metadata at the top of a log file.

The class constructor will read just enough lines from the input file to populate the header content, and leave the file itself at the first line containing a readout. If an actual readout is instead encountered in the process (e.g., when the header information is missing, or incomplete), a RuntimeError is raised.

Note this class respect the contract that we have for the actual header of .apx file, i.e., it is a dictionary containing simple Python types that can be seamlessly serialized and deserialized. (This is necessary if we want to convert .log files into .apx files preserving the metadata.)

Note the typical structure of the file is

Voltagecard: {'thpmos': 0, 'cardConf2': 0, 'vcasc2': 1.1, 'BL': 1, ...
Digital: {'interrupt_pushpull': 0, 'clkmux': 0, 'timerend': 0, ...
Biasblock: {'DisHiDR': 0, 'q01': 0, 'qon0': 0, 'qon1': 1, 'qon2': 0, ...
iDAC: {'blres': 0, 'vpdac': 10, 'vn1': 20, 'vnfb': 1, 'vnfoll': 2, ...
vDAC: {'blpix': 568, 'thpix': 610, 'vcasc2': 625, 'vtest': 682, ...
Receiver: {'col0': 206158430206, 'col1': 68719476735, 'col2': 68719476734, ...
 Namespace(name='threshold_40mV',...
0       b'bcbce050fecd067cc500bcbcbcbcbcbcfffffffffffffffffffffffffffffffffffffffff
Parameters:

input_file (TextIO) – The input (text) file object, open in read mode.

_OPTIONS_KEY = 'options'#
options() dict[source]#

Return the dictionary with the command-line options.

class astropix_analysis.legacy.AstroPixLogFile(file_path: str, encoding: str = 'utf-8')[source]#

Minimal, read-only interface to legacy astropix .log files.

EXTENSION = '.log'#
astropix_analysis.legacy.log_to_apx(input_file_path: str, readout_class: type = <class 'astropix_analysis.fmt.AstroPix4Readout'>, output_file_path: str = None) str[source]#

Convert a .log (text) file to a .apx (binary) file.