exa.core.experiment.utils.analysis_utils.analyze_singles

exa.core.experiment.utils.analysis_utils.analyze_singles#

analyze_singles(run_result, analyzer, qubits=None, **analysis_kwargs)#

A helper tool to analyze data of independent qubits.

This function repeats the function analyzer on all single qubits in the experiment defined by run_result. The purpose of the analyzer is to modify the AnalyzeResult instance that is passed to it.

This assumes that the run_result.definition.additional_run_properties has the keys "qubits" and "readout_components", and the analysis is applied to qubits that appear in both lists.

analyzer will be called with arguments that match the signature in the following way:

  • The first argument result is a template AnalyzeResult which should be modified by analyzer. Most notably, it contains the full dataset of the run, where more data arrays can be added. It also contains the run_result so that the analysis function can access all the metadata.

  • The second argument is always qubit (str) which specifies the qubit.

  • target_name (str) is the key to the “target data” for that qubit, as defined by Experiment. This is to access the target array as result.run_result.dataset[target_name]. It is passed to analyzer only if target_name" is in the signature. Assumes that “target_data_parameters” come in the same order as flattened “subscribed components”. If “target_data_parameters” is not defined, uses “default_data_parameters” instead.

  • Other arguments can be passed with analysis_kwargs.

Parameters:
  • run_result (RunResult) – The run result containing the full dataset and run data.

  • analyzer (Callable[[...], None]) – Function that analyzes a single qubit.

  • qubits (Sequence[str] | None) – Optionally run analysis only for these qubits. By default, runs on all qubits.

  • analysis_kwargs – Additional arguments for analyzer.

Returns:

A new instance of AnalyzeResult, where repeated calls to analyzer have added content.

Return type:

AnalyzeResult