qcodes.logger.log_analysis

This module defines a number of functions to make it easier to work with log messages from QCoDeS. Specifically it enables exports of logs and log files to a pandas.DataFrame

qcodes.logger.log_analysis.capture_dataframe(level: Union[int, str] = 10, logger: Optional[logging.Logger] = None) Iterator[Tuple[logging.StreamHandler, Callable[[], pandas.core.frame.DataFrame]]][source]

Context manager to capture the logs in a pandas.DataFrame

Example

>>> with logger.capture_dataframe() as (handler, cb):
>>>     qdac.ch01(1)  # some commands
>>>     data_frame = cb()
Parameters
  • level – Level at which to capture.

  • logger – Logger used to capture the data. Will default to root logger if None is supplied.

Returns

Tuple of handler that is used to capture the log messages and callback that returns the cumulative pandas.DataFrame at any given point (within the context)

qcodes.logger.log_analysis.log_to_dataframe(log: Sequence[str], columns: Optional[Sequence[str]] = None, separator: Optional[str] = None) pandas.core.frame.DataFrame[source]

Return the provided or default log string as a pandas.DataFrame.

Unless qcodes.logger.logger.LOGGING_SEPARATOR or qcodes.logger.logger.FORMAT_STRING_DICT have been changed using the default for the columns and separator arguments is encouraged.

Lines starting with a digit are ignored. In the log setup of qcodes.logger.logger.start_logger() Traceback messages are also logged. These start with a digit.

Parameters
Returns

A pandas.DataFrame containing the log content.

qcodes.logger.log_analysis.logfile_to_dataframe(logfile: Optional[str] = None, columns: Optional[Sequence[str]] = None, separator: Optional[str] = None) pandas.core.frame.DataFrame[source]

Return the provided or default logfile as a pandas.DataFrame.

Unless qcodes.logger.logger.LOGGING_SEPARATOR or qcodes.logger.logger.FORMAT_STRING_DICT have been changed using the default for the columns and separator arguments is encouraged.

Lines starting with a digit are ignored. In the log setup of qcodes.logger.logger.start_logger() Traceback messages are also logged. These start with a digit.

Parameters
  • logfile – Name of the logfile, defaults to current default log file.

  • columns – Column headers for the returned dataframe, defaults to columns used by handlers set up by qcodes.logger.logger.start_logger().

  • separator – Separator of the logfile to separate the columns, defaults to separator used by handlers set up by qcodes.logger.logger.start_logger().

Returns

A pandas.DataFrame containing the logfile content.

qcodes.logger.log_analysis.time_difference(firsttimes: pandas.core.series.Series, secondtimes: pandas.core.series.Series, use_first_series_labels: bool = True) pandas.core.series.Series[source]

Calculate the time differences between two series containing time stamp strings as their values.

Parameters
  • firsttimes – The oldest times

  • secondtimes – The youngest times

  • use_first_series_labels – If true, the returned Series has the same labels as firsttimes. Else it has the labels of secondtimes

Returns

A pandas.Series with float values of the time difference (s)