laboneq-applications 1.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. laboneq_applications/__init__.py +6 -0
  2. laboneq_applications/analysis/__init__.py +4 -0
  3. laboneq_applications/analysis/amplitude_fine.py +490 -0
  4. laboneq_applications/analysis/amplitude_rabi.py +430 -0
  5. laboneq_applications/analysis/calibration_traces_rotation.py +318 -0
  6. laboneq_applications/analysis/dispersive_shift.py +392 -0
  7. laboneq_applications/analysis/drag_q_scaling.py +488 -0
  8. laboneq_applications/analysis/echo.py +413 -0
  9. laboneq_applications/analysis/fitting_helpers.py +415 -0
  10. laboneq_applications/analysis/iq_blobs.py +501 -0
  11. laboneq_applications/analysis/lifetime_measurement.py +352 -0
  12. laboneq_applications/analysis/plotting_helpers.py +209 -0
  13. laboneq_applications/analysis/qubit_spectroscopy.py +379 -0
  14. laboneq_applications/analysis/ramsey.py +461 -0
  15. laboneq_applications/analysis/resonator_spectroscopy.py +516 -0
  16. laboneq_applications/analysis/time_traces.py +720 -0
  17. laboneq_applications/contrib/__init__.py +4 -0
  18. laboneq_applications/contrib/analysis/__init__.py +4 -0
  19. laboneq_applications/contrib/analysis/amplitude_rabi_chevron.py +244 -0
  20. laboneq_applications/contrib/analysis/signal_propagation_delay.py +240 -0
  21. laboneq_applications/contrib/analysis/single_qubit_randomized_benchmarking.py +368 -0
  22. laboneq_applications/contrib/analysis/time_rabi.py +353 -0
  23. laboneq_applications/contrib/analysis/time_rabi_chevron.py +160 -0
  24. laboneq_applications/contrib/experiments/__init__.py +4 -0
  25. laboneq_applications/contrib/experiments/amplitude_rabi_chevron.py +230 -0
  26. laboneq_applications/contrib/experiments/signal_propagation_delay.py +191 -0
  27. laboneq_applications/contrib/experiments/single_qubit_randomized_benchmarking.py +339 -0
  28. laboneq_applications/contrib/experiments/spin_locking.py +306 -0
  29. laboneq_applications/contrib/experiments/time_rabi.py +213 -0
  30. laboneq_applications/contrib/experiments/time_rabi_chevron.py +230 -0
  31. laboneq_applications/core/__init__.py +4 -0
  32. laboneq_applications/core/validation.py +295 -0
  33. laboneq_applications/experiments/__init__.py +4 -0
  34. laboneq_applications/experiments/amplitude_fine.py +497 -0
  35. laboneq_applications/experiments/amplitude_rabi.py +275 -0
  36. laboneq_applications/experiments/dispersive_shift.py +247 -0
  37. laboneq_applications/experiments/drag_q_scaling.py +307 -0
  38. laboneq_applications/experiments/echo.py +279 -0
  39. laboneq_applications/experiments/iq_blobs.py +215 -0
  40. laboneq_applications/experiments/lifetime_measurement.py +268 -0
  41. laboneq_applications/experiments/options.py +317 -0
  42. laboneq_applications/experiments/qubit_spectroscopy.py +217 -0
  43. laboneq_applications/experiments/qubit_spectroscopy_amplitude.py +224 -0
  44. laboneq_applications/experiments/ramsey.py +305 -0
  45. laboneq_applications/experiments/resonator_spectroscopy.py +211 -0
  46. laboneq_applications/experiments/resonator_spectroscopy_amplitude.py +220 -0
  47. laboneq_applications/experiments/time_traces.py +231 -0
  48. laboneq_applications/qpu_types/__init__.py +7 -0
  49. laboneq_applications/qpu_types/tunable_transmon/__init__.py +15 -0
  50. laboneq_applications/qpu_types/tunable_transmon/demo_qpus.py +223 -0
  51. laboneq_applications/qpu_types/tunable_transmon/operations.py +1140 -0
  52. laboneq_applications/qpu_types/tunable_transmon/qubit_types.py +409 -0
  53. laboneq_applications/serializers/__init__.py +8 -0
  54. laboneq_applications/serializers/uncertainties.py +53 -0
  55. laboneq_applications/tasks/__init__.py +14 -0
  56. laboneq_applications/tasks/parameter_updating.py +111 -0
  57. laboneq_applications/testing/__init__.py +8 -0
  58. laboneq_applications/testing/experiment_verifier.py +327 -0
  59. laboneq_applications/typing.py +52 -0
  60. laboneq_applications-1.3.0.dist-info/LICENSE +201 -0
  61. laboneq_applications-1.3.0.dist-info/METADATA +97 -0
  62. laboneq_applications-1.3.0.dist-info/RECORD +64 -0
  63. laboneq_applications-1.3.0.dist-info/WHEEL +5 -0
  64. laboneq_applications-1.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,6 @@
1
+ # Copyright 2024 Zurich Instruments AG
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ """LabOne Q Applications Library."""
5
+
6
+ __version__ = "1.3.0"
@@ -0,0 +1,4 @@
1
+ # Copyright 2024 Zurich Instruments AG
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ """A collection of analyses for transmon-qubit experiments."""
@@ -0,0 +1,490 @@
1
+ # Copyright 2024 Zurich Instruments AG
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ """This module defines the analysis for an amplitude-fine experiment.
5
+
6
+ The experiment is defined in laboneq_applications.experiments.
7
+
8
+ In this analysis, we first interpret the raw data into qubit populations using
9
+ principle-component analysis or rotation and projection on the measured calibration
10
+ states. Then we fit a cosine model to the qubit population and extract ...
11
+ . Finally, we plot the data and the fit.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import logging
17
+ from typing import TYPE_CHECKING
18
+
19
+ import matplotlib.pyplot as plt
20
+ import numpy as np
21
+ import uncertainties as unc
22
+ from laboneq import workflow
23
+
24
+ from laboneq_applications.analysis.calibration_traces_rotation import (
25
+ calculate_qubit_population,
26
+ )
27
+ from laboneq_applications.analysis.fitting_helpers import cosine_oscillatory_fit
28
+ from laboneq_applications.analysis.plotting_helpers import (
29
+ plot_raw_complex_data_1d,
30
+ timestamped_title,
31
+ )
32
+ from laboneq_applications.core.validation import validate_and_convert_qubits_sweeps
33
+ from laboneq_applications.experiments.options import (
34
+ TuneupAnalysisOptions,
35
+ TuneUpAnalysisWorkflowOptions,
36
+ )
37
+
38
+ if TYPE_CHECKING:
39
+ import lmfit
40
+ import matplotlib as mpl
41
+ from laboneq.workflow.tasks import RunExperimentResults
42
+ from numpy.typing import ArrayLike
43
+
44
+ from laboneq_applications.typing import Qubits, QubitSweepPoints
45
+
46
+
47
+ @workflow.workflow
48
+ def analysis_workflow(
49
+ result: RunExperimentResults,
50
+ qubits: Qubits,
51
+ amplification_qop: str,
52
+ repetitions: QubitSweepPoints,
53
+ target_angle: float,
54
+ phase_offset: float,
55
+ parameter_to_update: str | None = None,
56
+ options: TuneUpAnalysisWorkflowOptions | None = None,
57
+ ) -> None:
58
+ """The amplitude-fine analysis Workflow.
59
+
60
+ The workflow consists of the following steps:
61
+
62
+ - [calculate_qubit_population]()
63
+ - [fit_data]()
64
+ - [extract_qubit_parameters]()
65
+ - [plot_raw_complex_data_1d]()
66
+ - [plot_population]()
67
+
68
+ Arguments:
69
+ result:
70
+ The experiment results returned by the run_experiment task.
71
+ qubits:
72
+ The qubits on which to run the analysis. May be either a single qubit or
73
+ a list of qubits. The UIDs of these qubits must exist in the result.
74
+ amplification_qop:
75
+ str to identify the quantum operation to repeat to produce error
76
+ amplification.
77
+ repetitions:
78
+ Number of times to repeat the quantum operations used to amplify the
79
+ rotation errors. If `qubits` is a single qubit, `repetitions` must be a
80
+ list of integers. Otherwise it must be a list of lists of integers.
81
+ target_angle:
82
+ target angle the specified quantum operation shuould rotate.
83
+ The target_angle is used as initial guess for fitting.
84
+ phase_offset:
85
+ initial guess for phase_offset of fit.
86
+ parameter_to_update:
87
+ str that defines the qubit parameter to be updated.
88
+ options:
89
+ The options for building the workflow, passed as an instance of
90
+ [TuneUpAnalysisWorkflowOptions]. See the docstring of this class
91
+ for more information.
92
+
93
+ Returns:
94
+ WorkflowBuilder:
95
+ The builder for the analysis workflow.
96
+
97
+ Example:
98
+ ```python
99
+ options = analysis_workflow.options()
100
+ options.close_figures(False)
101
+ result = analysis_workflow(
102
+ results=results
103
+ qubits=[q0, q1],
104
+ amplification_qop='x180',
105
+ repetitions=[
106
+ [1,2,3,4],
107
+ [1,2,3,4],
108
+ ],
109
+ options=options,
110
+ ).run()
111
+ ```
112
+ """
113
+ processed_data_dict = calculate_qubit_population(qubits, result, repetitions)
114
+ fit_results = fit_data(qubits, processed_data_dict, target_angle, phase_offset)
115
+ processed_fit_results = process_fit_results(qubits, fit_results, target_angle)
116
+ qubit_parameters = extract_qubit_parameters(
117
+ qubits,
118
+ fit_results,
119
+ processed_fit_results,
120
+ parameter_to_update,
121
+ )
122
+ with workflow.if_(options.do_plotting):
123
+ with workflow.if_(options.do_raw_data_plotting):
124
+ xlabel = xaxis_label(amplification_qop)
125
+ plot_raw_complex_data_1d(
126
+ qubits,
127
+ result,
128
+ repetitions,
129
+ xlabel=xlabel,
130
+ )
131
+ with workflow.if_(options.do_qubit_population_plotting):
132
+ plot_population(
133
+ qubits,
134
+ processed_data_dict,
135
+ amplification_qop,
136
+ fit_results,
137
+ processed_fit_results,
138
+ parameter_to_update,
139
+ qubit_parameters,
140
+ )
141
+
142
+ workflow.return_(qubit_parameters)
143
+
144
+
145
+ @workflow.task
146
+ def xaxis_label(amplification_qop: str) -> str:
147
+ """Small task to create the x-axis label based on amplification_qop.
148
+
149
+ Arguments:
150
+ amplification_qop:
151
+ str to identify the quantum operation to repeat to produce error
152
+ amplification.
153
+
154
+ Returns:
155
+ strings with the x-axis label for the amplitude-fine experiment
156
+ """
157
+ return f"Number of Repetitions {amplification_qop}"
158
+
159
+
160
+ @workflow.task
161
+ def fit_data(
162
+ qubits: Qubits,
163
+ processed_data_dict: dict[str, dict[str, ArrayLike]],
164
+ target_angle: float,
165
+ phase_offset: float,
166
+ options: TuneupAnalysisOptions | None = None,
167
+ ) -> dict[str, lmfit.model.ModelResult]:
168
+ """Perform a fit of a cosine model to the data.
169
+
170
+ Arguments:
171
+ qubits:
172
+ The qubits on which to run the analysis. May be either a single qubit or
173
+ a list of qubits. The UIDs of these qubits must exist in the
174
+ processed_data_dict.
175
+ processed_data_dict: the processed data dictionary returned by process_raw_data
176
+ target_angle:
177
+ target angle the specified quantum operation shuould rotate.
178
+ The target_angle is used as initial guess for fitting.
179
+ phase_offset:
180
+ initial guess for phase_offset of fit.
181
+ options:
182
+ The options for processing the raw data.
183
+ See [TuneupAnalysisOptions], [TuneupExperimentOptions] and
184
+ [BaseExperimentOptions] for accepted options.
185
+ Overwrites the options from [TuneupAnalysisOptions],
186
+ [TuneupExperimentOptions] and [BaseExperimentOptions].
187
+
188
+ Returns:
189
+ dict with qubit UIDs as keys and the fit results for each qubit as keys.
190
+ """
191
+ opts = TuneupAnalysisOptions() if options is None else options
192
+ qubits = validate_and_convert_qubits_sweeps(qubits)
193
+ fit_results = {}
194
+ if not opts.do_fitting:
195
+ return fit_results
196
+
197
+ for q in qubits:
198
+ swpts_fit = processed_data_dict[q.uid]["sweep_points"]
199
+ data_to_fit = processed_data_dict[q.uid]["population"]
200
+ try:
201
+ if opts.fit_parameters_hints is None:
202
+ opts.fit_parameters_hints = {
203
+ "frequency": {"value": target_angle, "min": 0},
204
+ "phase": {"value": phase_offset},
205
+ "amplitude": {"value": 0.5, "vary": False},
206
+ "offset": {"value": 0.5, "vary": False},
207
+ }
208
+ fit_res = cosine_oscillatory_fit(
209
+ swpts_fit,
210
+ data_to_fit,
211
+ param_hints=opts.fit_parameters_hints,
212
+ )
213
+ fit_results[q.uid] = fit_res
214
+
215
+ except ValueError as err:
216
+ workflow.log(logging.ERROR, "Fit failed for %s: %s.", q.uid, err)
217
+
218
+ return fit_results
219
+
220
+
221
+ @workflow.task
222
+ def process_fit_results(
223
+ qubits: Qubits,
224
+ fit_results: dict[str, lmfit.model.ModelResult] | None,
225
+ target_angle: float,
226
+ options: TuneupAnalysisOptions | None = None,
227
+ ) -> dict[str, unc.core.Variable]:
228
+ """Process fit results to extract correction factor.
229
+
230
+ Arguments:
231
+ qubits:
232
+ The qubits on which to run the analysis. May be either a single qubit or
233
+ a list of qubits. The UIDs of these qubits must exist in the
234
+ processed_data_dict.
235
+ fit_results:
236
+ the fit-results dictionary returned by fit_data
237
+ target_angle:
238
+ target angle the specified quantum operation shuould rotate.
239
+ The target_angle is used as initial guess for fitting.
240
+ options:
241
+ The options for processing the raw data.
242
+ See [TuneupAnalysisOptions], [TuneupExperimentOptions] and
243
+ [BaseExperimentOptions] for accepted options.
244
+ Overwrites the options from [TuneupAnalysisOptions],
245
+ [TuneupExperimentOptions] and [BaseExperimentOptions].
246
+
247
+ Returns:
248
+ dict with qubit UIDs as keys and the processed fit results for each qubit
249
+ as keys.
250
+ """
251
+ opts = TuneupAnalysisOptions() if options is None else options
252
+ qubits = validate_and_convert_qubits_sweeps(qubits)
253
+ processed_fit_results = {}
254
+ if not opts.do_fitting:
255
+ return processed_fit_results
256
+
257
+ for q in qubits:
258
+ processed_fit_results[q.uid] = {}
259
+ # Extract and store the correction factor from the fit
260
+ correction_factor = unc.ufloat(
261
+ fit_results[q.uid].params["frequency"].value / target_angle,
262
+ fit_results[q.uid].params["frequency"].stderr / target_angle,
263
+ )
264
+ processed_fit_results[q.uid]["correction_factor"] = correction_factor
265
+
266
+ return processed_fit_results
267
+
268
+
269
+ @workflow.task
270
+ def extract_qubit_parameters(
271
+ qubits: Qubits,
272
+ fit_results: dict[str, lmfit.model.ModelResult],
273
+ processed_fit_results: dict[str, unc.core.Variable] | None,
274
+ parameter_to_update: str | None = None,
275
+ options: TuneupAnalysisOptions | None = None,
276
+ ) -> dict[str, dict[str, dict[str, int | float | unc.core.Variable | None]]]:
277
+ """Extract the qubit parameters from the fit results.
278
+
279
+ Arguments:
280
+ qubits:
281
+ The qubits on which to run the analysis. May be either a single qubit or
282
+ a list of qubits. The UIDs of these qubits must exist in the
283
+ processed_data_dict and fit_results.
284
+ fit_results: the fit-results dictionary returned by fit_data
285
+ processed_fit_results:
286
+ the processed fit-results dictionary returned by process_fit_data
287
+ parameter_to_update:
288
+ str that defines the parameter to be updated.
289
+ options:
290
+ The options for extracting the qubit parameters.
291
+ See [TuneupAnalysisOptions], [TuneupExperimentOptions] and
292
+ [BaseExperimentOptions] for accepted options.
293
+ Overwrites the options from [TuneupAnalysisOptions],
294
+ [TuneupExperimentOptions] and [BaseExperimentOptions].
295
+
296
+ Returns:
297
+ dict with extracted qubit parameters and the previous values for those qubit
298
+ parameters. The dictionary has the following form:
299
+ ```python
300
+ {
301
+ "new_parameter_values": {
302
+ q.uid: {
303
+ qb_param_name: qb_param_value
304
+ },
305
+ }
306
+ "old_parameter_values": {
307
+ q.uid: {
308
+ qb_param_name: qb_param_value
309
+ },
310
+ }
311
+ }
312
+ ```
313
+ Raises:
314
+ ValueError:
315
+ If fit_results are empty (have length 0).
316
+ """
317
+ opts = TuneupAnalysisOptions() if options is None else options
318
+ qubits = validate_and_convert_qubits_sweeps(qubits)
319
+ qubit_parameters = {
320
+ "old_parameter_values": {q.uid: {} for q in qubits},
321
+ "new_parameter_values": {q.uid: {} for q in qubits},
322
+ }
323
+ if not opts.do_fitting:
324
+ return qubit_parameters
325
+
326
+ for q in qubits:
327
+ if q.uid not in fit_results:
328
+ continue
329
+
330
+ if parameter_to_update is not None:
331
+ old_parameter_value = (
332
+ getattr(q.parameters, f"ef_{parameter_to_update}")
333
+ if "f" in opts.transition
334
+ else getattr(q.parameters, f"ge_{parameter_to_update}")
335
+ )
336
+ qubit_parameters["old_parameter_values"][q.uid] = {
337
+ f"{opts.transition}_{parameter_to_update}": old_parameter_value,
338
+ }
339
+
340
+ # Calculate new parameter value from correction factor
341
+ new_parameter_value = unc.ufloat(
342
+ old_parameter_value
343
+ / processed_fit_results[q.uid]["correction_factor"].nominal_value,
344
+ processed_fit_results[q.uid]["correction_factor"].std_dev
345
+ * old_parameter_value
346
+ / processed_fit_results[q.uid]["correction_factor"].nominal_value,
347
+ )
348
+
349
+ qubit_parameters["new_parameter_values"][q.uid] = {
350
+ f"{opts.transition}_{parameter_to_update}": new_parameter_value,
351
+ }
352
+
353
+ return qubit_parameters
354
+
355
+
356
+ @workflow.task
357
+ def plot_population(
358
+ qubits: Qubits,
359
+ processed_data_dict: dict[str, dict[str, ArrayLike]],
360
+ amplification_qop: str,
361
+ fit_results: dict[str, lmfit.model.ModelResult] | None,
362
+ processed_fit_results: dict[str, unc.core.Variable] | None,
363
+ parameter_to_update: str,
364
+ qubit_parameters: dict[
365
+ str,
366
+ dict[str, dict[str, int | float | unc.core.Variable | None]],
367
+ ]
368
+ | None,
369
+ options: TuneupAnalysisOptions | None = None,
370
+ ) -> dict[str, mpl.figure.Figure]:
371
+ """Create the amplitude-Rabi plots.
372
+
373
+ Arguments:
374
+ qubits:
375
+ The qubits on which to run the analysis. May be either a single qubit or
376
+ a list of qubits. The UIDs of these qubits must exist in the
377
+ processed_data_dict, fit_results and qubit_parameters.
378
+ processed_data_dict:
379
+ the processed data dictionary returned by process_raw_data
380
+ fit_results:
381
+ the fit-results dictionary returned by fit_data
382
+ amplification_qop:
383
+ str to identify the quantum operation to repeat.
384
+ processed_fit_results:
385
+ the processed fit-results dictionary returned by process_fit_data
386
+ parameter_to_update:
387
+ str that defines the parameter to be updated.
388
+ qubit_parameters: the qubit-parameters dictionary returned by
389
+ extract_qubit_parameters
390
+ options:
391
+ The options for processing the raw data.
392
+ See [TuneupAnalysisOptions], [TuneupExperimentOptions] and
393
+ [BaseExperimentOptions] for accepted options.
394
+ Overwrites the options from [TuneupAnalysisOptions],
395
+ [TuneupExperimentOptions] and [BaseExperimentOptions].
396
+
397
+ Returns:
398
+ dict with qubit UIDs as keys and the figures for each qubit as values.
399
+ """
400
+ opts = TuneupAnalysisOptions() if options is None else options
401
+ qubits = validate_and_convert_qubits_sweeps(qubits)
402
+ figures = {}
403
+ for q in qubits:
404
+ sweep_points = processed_data_dict[q.uid]["sweep_points"]
405
+ data = processed_data_dict[q.uid][
406
+ "population" if opts.do_rotation else "data_raw"
407
+ ]
408
+ num_cal_traces = processed_data_dict[q.uid]["num_cal_traces"]
409
+
410
+ fig, ax = plt.subplots()
411
+ ax.set_title(timestamped_title(f"Amplitude Fine {amplification_qop} {q.uid}"))
412
+ ax.set_xlabel(xaxis_label(amplification_qop))
413
+ ax.set_ylabel(
414
+ "Principal Component (a.u)"
415
+ if (num_cal_traces == 0 or opts.do_pca)
416
+ else f"$|{opts.cal_states[-1]}\\rangle$-State Population",
417
+ )
418
+ ax.plot(sweep_points, data, "o", zorder=2, label="data")
419
+ if processed_data_dict[q.uid]["num_cal_traces"] > 0:
420
+ # plot lines at the calibration traces
421
+ xlims = ax.get_xlim()
422
+ ax.hlines(
423
+ processed_data_dict[q.uid]["population_cal_traces"],
424
+ *xlims,
425
+ linestyles="--",
426
+ colors="gray",
427
+ zorder=0,
428
+ label="calib.\ntraces",
429
+ )
430
+ ax.set_xlim(xlims)
431
+
432
+ if opts.do_fitting:
433
+ if q.uid not in fit_results:
434
+ continue
435
+ fit_res_qb = fit_results[q.uid]
436
+
437
+ # plot fit
438
+ swpts_fine = np.linspace(sweep_points[0], sweep_points[-1], 501)
439
+ ax.plot(
440
+ swpts_fine,
441
+ fit_res_qb.model.func(swpts_fine, **fit_res_qb.best_values),
442
+ "r-",
443
+ zorder=1,
444
+ label="fit",
445
+ )
446
+
447
+ # corrected parameters
448
+ if parameter_to_update is not None:
449
+ param_name = (
450
+ "$A_{\\pi/2}$" if "pi2" in parameter_to_update else "$A_{\\pi}$"
451
+ )
452
+ new_parameter_value = qubit_parameters["new_parameter_values"][q.uid][
453
+ f"{opts.transition}_{parameter_to_update}"
454
+ ]
455
+ # textbox
456
+ old_parameter_value = qubit_parameters["old_parameter_values"][q.uid][
457
+ f"{opts.transition}_{parameter_to_update}"
458
+ ]
459
+ textstr = (
460
+ f"{param_name} = "
461
+ f"{new_parameter_value.nominal_value:.4f} $\\pm$ "
462
+ f"{new_parameter_value.std_dev:.4f}"
463
+ )
464
+ textstr += f"\nOld {param_name} = " + f"{old_parameter_value:.4f}"
465
+ ax.text(0, -0.15, textstr, ha="left", va="top", transform=ax.transAxes)
466
+ else:
467
+ correction_factor = processed_fit_results[q.uid]["correction_factor"]
468
+ textstr = (
469
+ "Pulse-Amplitude Correction Factor, $c$ = "
470
+ f"{correction_factor.nominal_value:.4f} $\\pm$ "
471
+ f"{correction_factor.std_dev:.4f}"
472
+ )
473
+ ax.text(0, -0.15, textstr, ha="left", va="top", transform=ax.transAxes)
474
+
475
+ ax.legend(
476
+ loc="center left",
477
+ bbox_to_anchor=(1, 0.5),
478
+ handlelength=1.5,
479
+ frameon=False,
480
+ )
481
+
482
+ if opts.save_figures:
483
+ workflow.save_artifact(f"Amplitude_Fine_{q.uid}", fig)
484
+
485
+ if opts.close_figures:
486
+ plt.close(fig)
487
+
488
+ figures[q.uid] = fig
489
+
490
+ return figures