mantidimaging.core.io.csv_log_parser module#

class mantidimaging.core.io.csv_log_parser.CSVLogFileParser(lines: list[str])[source]#

Bases: InstrumentLogParser

Parser for instrument logs written following a strict CSV file format (header, row)

Requires a .csv suffix and an IMAGE COUNTER header. All other columns are optional. Known optional headers are parsed when present and unrecognised headers are logged.

COLUMN_DEFINITIONS: dict[str, tuple[LogColumn, Callable[[str], str | float | int]]] = {'COUNTS AFTER': (LogColumn.COUNTS_AFTER, <class 'int'>), 'COUNTS BEFORE': (LogColumn.COUNTS_BEFORE, <class 'int'>), 'IMAGE COUNTER': (LogColumn.PROJECTION_NUMBER, <class 'int'>), 'IMAGE TYPE': (LogColumn.IMAGE_TYPE_IMAGE_COUNTER, <class 'str'>), 'PIXEL SIZE': (LogColumn.PIXEL_SIZE, <class 'float'>), 'PROJECTION ANGLE DEG': (LogColumn.PROJECTION_ANGLE, <class 'float'>), 'TIME STAMP': (LogColumn.TIMESTAMP, <class 'str'>)}#
REQUIRED_HEADERS: frozenset[str] = frozenset({'IMAGE COUNTER'})#
classmethod match(lines: list[str], filename: str) → bool[source]#

Override InstrumentLogParser.match to return if lines and filename match expected format for a strict CSV log file. Robust against extra whitespace around headers.

parse() → dict[LogColumn, list[str | float | int]][source]#

Parse CSV log file to dictionary map, clearing headers of whitespace and checking for optional and unrecognised headers