Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T2 experiment with Hahn echoes #365

Merged
merged 118 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
a4fa8ef
Add template for T2 exp, still need to check results
ItamarGoldman Aug 22, 2021
e638dca
Made the code cleaner
ItamarGoldman Aug 22, 2021
28271b9
cleared RB documantation
ItamarGoldman Aug 22, 2021
2838973
Merge branch 'main' into T2_Hahn_Echo
ItamarGoldman Aug 23, 2021
fbd95b3
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Aug 30, 2021
1f8c4ca
Fixed errors and for 1 echo the circuit is generated (need to work on…
ItamarGoldman Aug 30, 2021
d3af495
Changed the Echo pulse to pi instead of pi/2
ItamarGoldman Aug 30, 2021
94d0afc
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Sep 9, 2021
0a3935d
Changed the class to support only single qubit
ItamarGoldman Sep 9, 2021
cb84b37
added options instead of fields
ItamarGoldman Sep 13, 2021
d0f47c4
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Sep 13, 2021
a2be5f8
Pylint and Black
ItamarGoldman Sep 13, 2021
2d95f33
used base class attribute for qubit
ItamarGoldman Sep 13, 2021
91d63d9
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Sep 22, 2021
be3d352
Updated code to be as in other experiments
ItamarGoldman Sep 22, 2021
0dc3777
Added the Analysis class
ItamarGoldman Sep 22, 2021
600173b
Base analysis class draft + fixes
ItamarGoldman Sep 23, 2021
36854cc
Update T2Hahn.py
ItamarGoldman Sep 23, 2021
44befa8
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Sep 26, 2021
e23ee47
Update t2hahn.py
ItamarGoldman Sep 26, 2021
a269079
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Sep 29, 2021
231203f
Update t2hahn.py
ItamarGoldman Sep 29, 2021
b7dceae
Added Backend template from t2ramsey
ItamarGoldman Sep 29, 2021
bfa67e2
Update t2hahn_backend.py
ItamarGoldman Sep 29, 2021
3d8a1c7
fixed doc string and input check function
ItamarGoldman Oct 3, 2021
1db4e9e
the circuit is now working on qubit '0' exclusively
ItamarGoldman Oct 3, 2021
f2e4799
Update t2hahn.py
ItamarGoldman Oct 3, 2021
ae4ce88
Added operation for 'RX' gate
ItamarGoldman Oct 4, 2021
42d9f82
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Oct 21, 2021
f20a344
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Oct 24, 2021
1cf5e90
Removed duplicate length from verify parameters
ItamarGoldman Oct 24, 2021
047a430
changed documentation suggestions
ItamarGoldman Oct 24, 2021
8c9ca60
changed documanttion
ItamarGoldman Oct 24, 2021
95a28b2
Removed * from T_2
ItamarGoldman Oct 24, 2021
3ab1b85
changed basis gate 'h', 'p' to 'ry', 'rx'
ItamarGoldman Oct 24, 2021
17178d3
Update t2hahn_backend.py
ItamarGoldman Oct 24, 2021
6b8bc58
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Oct 25, 2021
bcaf380
Added Ry, Rx and measure gates
ItamarGoldman Oct 25, 2021
e9a0e3e
Changed every t2ramsy to t2hahn (WIP)
ItamarGoldman Oct 25, 2021
9c9548b
changed "T2Hahn" to "T2"
ItamarGoldman Oct 25, 2021
1f89a4d
added tests (still not working)
ItamarGoldman Oct 25, 2021
cfc6bdc
Delay now applied once
ItamarGoldman Nov 7, 2021
8818a34
added tests for T2hahn Echo
ItamarGoldman Nov 8, 2021
57bc001
Applied black
ItamarGoldman Nov 8, 2021
a91ed7d
Update t2hahn_backend.py
ItamarGoldman Nov 10, 2021
3039f1b
Update t2hahn_backend.py
ItamarGoldman Nov 10, 2021
75cbbae
Changed the gate op to be a function and added time evolution of the …
ItamarGoldman Nov 10, 2021
ea0068d
Added output types
ItamarGoldman Nov 10, 2021
96da63c
Added measurement on "ZY" plane in Z basis
ItamarGoldman Nov 14, 2021
29683f9
Added angle parameter for rotation and fixed bugs
ItamarGoldman Nov 15, 2021
5e14b8a
changed "==" to "np.isclose()"
ItamarGoldman Nov 15, 2021
8afaade
Pass pylint
ItamarGoldman Nov 15, 2021
3cfff22
Pylint + black
ItamarGoldman Nov 15, 2021
39ce1f4
cleaned code
ItamarGoldman Nov 15, 2021
f120136
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Nov 15, 2021
5564384
incomplete change to backend
ItamarGoldman Nov 17, 2021
a8ccda9
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Nov 17, 2021
4012463
deleted unnecessary fit parameters and changed input for backend
ItamarGoldman Nov 17, 2021
3512a29
changes to use only Rx without Ry
ItamarGoldman Nov 21, 2021
8419ab0
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Nov 22, 2021
cada640
Experiment Working Up to tau that is not correct
ItamarGoldman Nov 22, 2021
5f989d0
Update comment Y90 to X90
ItamarGoldman Nov 24, 2021
99fd9d5
Deleted extra space from measurement function in the backend
ItamarGoldman Nov 24, 2021
73f734c
changed the backend as Yael review comments
ItamarGoldman Nov 24, 2021
d53454e
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Nov 24, 2021
5addf45
Merge branch 'T2_Hahn_Echo' of github.com:ItamarGoldman/qiskit-experi…
ItamarGoldman Nov 24, 2021
010face
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Nov 28, 2021
588c6c2
Test are working
ItamarGoldman Nov 29, 2021
d85fdf2
Passed Black and Lint
ItamarGoldman Nov 29, 2021
6f1f04d
Update t2hahn_backend.py
ItamarGoldman Nov 29, 2021
643f7e7
deleted the abs as the projection is a real number
ItamarGoldman Nov 29, 2021
62b8163
Black and pylint
ItamarGoldman Nov 29, 2021
fce7229
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Dec 5, 2021
961a9dd
Added comments
ItamarGoldman Dec 5, 2021
7bd81d1
Added tutorial
ItamarGoldman Dec 5, 2021
d5aea87
Added tutorial and fix bug for echoes
ItamarGoldman Dec 6, 2021
7ddf41d
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Dec 8, 2021
48bc87c
Added Parallel experiment to the test and backend
ItamarGoldman Dec 8, 2021
2b87ab5
Changed that the analysis class will be passed to constructor
ItamarGoldman Dec 8, 2021
3c7627e
Added release notes
ItamarGoldman Dec 8, 2021
a8c48c2
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Dec 12, 2021
25a09c0
Changed the code dor recent changes (added config, removed unit, etc)
ItamarGoldman Dec 12, 2021
c567fb2
Passed black and pylint
ItamarGoldman Dec 12, 2021
ad8be9b
passed pylint and black
ItamarGoldman Dec 12, 2021
d55e950
fixed bug
ItamarGoldman Dec 12, 2021
c20d857
fixed docs
ItamarGoldman Dec 12, 2021
933d98c
Update t2hahn.py
ItamarGoldman Dec 12, 2021
a8028e2
Raising error when delay applied and the qubit isn't in the XY plain …
ItamarGoldman Dec 12, 2021
038be8a
Update test_t2hahn.py
ItamarGoldman Dec 12, 2021
7fb2b6e
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Dec 15, 2021
f74ef7c
edited comment and change 'plain' to 'plane'
ItamarGoldman Dec 15, 2021
b398466
added tests for number of echoes
ItamarGoldman Dec 26, 2021
a90bc26
Fixed Black
ItamarGoldman Dec 27, 2021
6184579
rerun pylint
ItamarGoldman Dec 27, 2021
06cf69c
Added to tutorial both experiments
ItamarGoldman Dec 27, 2021
0730710
updated code + tutorial per instructions
ItamarGoldman Jan 2, 2022
35527b6
fixed a bug for 0 echoes case.
ItamarGoldman Jan 3, 2022
ddef180
fixed issue
ItamarGoldman Jan 9, 2022
54d5ad4
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Jan 9, 2022
907ae9d
In the test excluded quality check for num_echoes=0
ItamarGoldman Jan 9, 2022
a0aa2ac
Changed tutorial text and a bit of code
ItamarGoldman Jan 12, 2022
6e334b8
Added bounds and removed p0 from analysis, finished tutorial
ItamarGoldman Jan 13, 2022
9b34c01
Edited tutorial as reviewed
ItamarGoldman Jan 16, 2022
787801f
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Jan 16, 2022
eba1bff
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Jan 24, 2022
92c6602
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Jan 24, 2022
16c04da
Update t2hahn_characterization.ipynb
ItamarGoldman Jan 24, 2022
8eb4f51
fixed test to be with "self.json_equiv" and fixed lint
ItamarGoldman Jan 24, 2022
377af03
added cosmetic fixes to the tutorial
ItamarGoldman Jan 24, 2022
978c0b3
Merge remote-tracking branch 'upstream/main' into T2_Hahn_Echo
ItamarGoldman Jan 30, 2022
a48b536
Added text and changed functions
ItamarGoldman Jan 30, 2022
3e9fd41
updated feature text.
ItamarGoldman Jan 30, 2022
968a2f1
black version 22.1.0 pass
ItamarGoldman Jan 30, 2022
29c67e6
fixed angles to be of absolute value and not previous ones.
ItamarGoldman Jan 30, 2022
1597f1e
updated text in the tutorial.
ItamarGoldman Jan 31, 2022
b12831b
changed doc string year to 2022
ItamarGoldman Jan 31, 2022
d95b3f9
updated tutorial text
ItamarGoldman Jan 31, 2022
8fc4849
fixed text
ItamarGoldman Jan 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 162 additions & 0 deletions qiskit_experiments/library/characterization/t2hahn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""
T2Hahn Echo Experiment class.

"""

from typing import Union, Iterable, List, Optional
import numpy as np

from qiskit import QuantumCircuit, QiskitError
from qiskit.utils import apply_prefix
from qiskit.providers.options import Options
from qiskit.providers import Backend
from qiskit_experiments.framework import BaseExperiment
from .t2hahn_analysis import T2HahnAnalysis




class T2Hahn(BaseExperiment):
r"""T2 Ramsey Experiment.
ItamarGoldman marked this conversation as resolved.
Show resolved Hide resolved

# section: overview

This experiment is used to estimate T2 noise of a single qubit.

See `Qiskit Textbook <https://qiskit.org/textbook/ch-quantum-hardware/\
calibrating-qubits-pulse.html>`_ for a more detailed explanation on
these properties.

This experiment consists of a series of circuits of the form

.. parsed-literal::

┌─────────┐┌──────────┐┌───────┐┌──────────┐┌──────────┐┌─┐
q_0: ┤ RY(π/2) ├┤ DELAY(t) ├┤ RX(π) ├┤ DELAY(t) ├┤ RY(-π/2) ├┤M├
└─────────┘└──────────┘└───────┘└──────────┘└──────────┘└╥┘
c: 1/═════════════════════════════════════════════════════════╩═
0
for each *t* from the specified delay times
and the delays are specified by the user.
The circuits are run on the device or on a simulator backend.

# section: tutorial
:doc:`/tutorials/t2hahn_characterization`

"""
__analysis_class__ = T2HahnAnalysis

@classmethod
def _default_experiment_options(cls) -> Options:
"""Default experiment options.

Experiment Options:
delays (Iterable[float]): Delay times of the experiments.
unit (str): Unit of the delay times. Supported units are
's', 'ms', 'us', 'ns', 'ps', 'dt'.
"""
options = super()._default_experiment_options()

options.delays = None
options.unit = "s"

return options

def __init__(
self,
qubit: Union[int, Iterable[int]],
delays: Union[List[float], np.array],
unit: str = "s",
):
"""
**T2 - Hahn Echo class**
ItamarGoldman marked this conversation as resolved.
Show resolved Hide resolved
Initialize the T2 - Hahn Echo class
Args:
qubit: the qubit under test.
delays: delay times of the experiments.
unit: Optional, time unit of `delays`.
Supported units: 's', 'ms', 'us', 'ns', 'ps', 'dt'. The unit is
ItamarGoldman marked this conversation as resolved.
Show resolved Hide resolved
used for both T2Ramsey and for the frequency.
ItamarGoldman marked this conversation as resolved.
Show resolved Hide resolved

Raises:
QiskitError : Error for invalid input.
"""
# Initialize base experiment
super().__init__([qubit])
# Set configurable options
self.set_experiment_options(delays=delays, unit=unit)
self._verify_parameters()

def _verify_parameters(self):
"""
Verify input correctness, raise QiskitError if needed.
Args:
ItamarGoldman marked this conversation as resolved.
Show resolved Hide resolved
qubit: the qubit under test.

Raises:
QiskitError : Error for invalid input.
"""
if any(delay < 0 for delay in self.experiment_options.delays):
raise QiskitError(
f"The lengths list {self.experiment_options.delays} should only contain "
"non-negative elements."
)
if len(set(self.experiment_options.delays)) != len(self.experiment_options.delays):
raise QiskitError(
f"The lengths list {self.experiment_options.delays} should not contain "
"duplicate elements."
ItamarGoldman marked this conversation as resolved.
Show resolved Hide resolved
)

def circuits(self, backend: Optional[Backend] = None) -> List[QuantumCircuit]:
"""
Args:
backend: Optional, a backend object.

Returns:
The experiment circuits.

Raises:
AttributeError: if unit is 'dt', but 'dt' parameter is missing in the backend configuration
"""
conversion_factor = 1
if self.experiment_options.unit == "dt":
try:
dt_factor = getattr(backend._configuration, "dt")
conversion_factor = dt_factor
except AttributeError as no_dt:
raise AttributeError("Dt parameter is missing in backend configuration") from no_dt
elif self.experiment_options.unit != "s":
conversion_factor = apply_prefix(1, self.experiment_options.unit)

circuits = []
for delay in self.experiment_options.delays:
circ = QuantumCircuit(1, 1)
# First Y rotation in 90 degrees
circ.ry(np.pi / 2, 0) # Bring to qubits to X Axis
circ.delay(delay, 0, self.experiment_options.unit)
circ.rx(np.pi, 0)
circ.delay(delay, 0, self.experiment_options.unit)
circ.ry(-np.pi / 2, 0) # Y90
circ.measure(0, 0) # measure
circ.metadata = {
"experiment_type": self._type,
"qubit": self.physical_qubits[0],
"xval": delay,
"unit": self.experiment_options.unit,
}
if self.experiment_options.unit == "dt":
circ.metadata["dt_factor"] = dt_factor
circuits.append(circ)

return circuits
228 changes: 228 additions & 0 deletions qiskit_experiments/library/characterization/t2hahn_analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""
T2Hahn analysis class.
"""

from typing import List, Optional, Tuple, Dict, Union, Any
import dataclasses
import numpy as np

from qiskit.utils import apply_prefix
from qiskit_experiments.framework import (
BaseAnalysis,
Options,
ExperimentData,
AnalysisResultData,
FitVal,
)
from qiskit_experiments.curve_analysis import curve_fit, plot_curve_fit, plot_errorbar, plot_scatter
from qiskit_experiments.curve_analysis.curve_fit import process_curve_data
from qiskit_experiments.curve_analysis.data_processing import level2_probability


# pylint: disable = invalid-name
class T2HahnAnalysis(BaseAnalysis):
r"""
T2 Hahn result analysis class.

# section: fit_model
This class is used to analyze the results of a T2 Hahn experiment.
ItamarGoldman marked this conversation as resolved.
Show resolved Hide resolved
The probability of measuring :math:`|+\rangle` state is assumed to be of the form

.. math::

f(t) = a\mathrm{e}^{-t / T_2^*} + b
ItamarGoldman marked this conversation as resolved.
Show resolved Hide resolved

# section: fit_parameters

defpar a:
desc: Amplitude. Height of the decay curve.
init_guess: 0.5
bounds: [-0.5, 1.5]

defpar b:
desc: Offset. Base line of the decay curve.
init_guess: 0.5
bounds: [-0.5, 1.5]

defpar T_2^*:
desc: Represents the rate of decay.
init_guess: the mean of the input delays.
bounds: [0, np.inf]

"""

@classmethod
def _default_options(cls):
r"""Default analysis options.

Analysis Options:
user_p0 (List[Float]): user guesses for the fit parameters
:math:`(a, b, T_2^*)`.
user_bounds (Tuple[List[float], List[float]]): Lower and upper bounds
for the fit parameters.
plot (bool): Create a graph if and only if True.
"""
return Options(user_p0=None, user_bounds=None)

# pylint: disable=arguments-differ, unused-argument
def _run_analysis(
self,
experiment_data: ExperimentData,
user_p0: Optional[Dict[str, float]] = None,
user_bounds: Optional[Tuple[List[float], List[float]]] = None,
plot: bool = False,
ax: Optional["AxesSubplot"] = None,
**kwargs,
) -> Tuple[List[AnalysisResultData], List["matplotlib.figure.Figure"]]:
r"""Calculate T2Hahn experiment.

Args:
experiment_data (ExperimentData): the experiment data to analyze
user_p0: contains initial values given by the user, for the
fit parameters :math:`(a, t2hahn, b)`
user_bounds: lower and upper bounds on the parameters in p0,
given by the user.
The first tuple is the lower bounds,
The second tuple is the upper bounds.
For both params, the order is :math:`a, t2hahn, b`.
plot: if True, create the plot, otherwise, do not create the plot.
ax: the plot object
**kwargs: additional parameters for curve fit.

Returns:
The analysis result with the estimated :math:`t2hahn`
The graph of the function.
"""

def T2_fit_fun(x, a, t2hahn, c):
"""Decay cosine fit function"""
return a * np.exp(-x / t2hahn) + c

def _format_plot(ax, unit, fit_result, conversion_factor):
"""Format curve fit plot"""
# Formatting
ax.tick_params(labelsize=14)
ax.set_xlabel("Delay (s)", fontsize=12)
ax.ticklabel_format(axis="x", style="sci", scilimits=(0, 0))
ax.set_ylabel("Probability of measuring 0", fontsize=12)
t2hahn = fit_result["popt"][1] / conversion_factor
t2hahn_err = fit_result["popt_err"][1] / conversion_factor
box_text = "$T_2Hahn$ = {:.2f} \u00B1 {:.2f} {}".format(t2hahn, t2hahn_err, unit)
bbox_props = dict(boxstyle="square,pad=0.3", fc="white", ec="black", lw=1)
ax.text(
0.6,
0.9,
box_text,
ha="center",
va="center",
size=12,
bbox=bbox_props,
transform=ax.transAxes,
)
return ax

# implementation of _run_analysis

data = experiment_data.data()
circ_metadata = data[0]["metadata"]
unit = circ_metadata["unit"]
conversion_factor = circ_metadata.get("dt_factor", None)
if conversion_factor is None:
conversion_factor = 1 if unit in ("s", "dt") else apply_prefix(1, unit)

xdata, ydata, sigma = process_curve_data(data, lambda datum: level2_probability(datum, "0"))

t2hahn_estimate = np.mean(xdata) # Maybe need to change?
p0, bounds = self._t2hahn_default_params(
conversion_factor, user_p0, user_bounds, t2hahn_estimate
)
xdata *= conversion_factor
fit_result = curve_fit(
T2_fit_fun, xdata, ydata, p0=list(p0.values()), sigma=sigma, bounds=bounds
)
fit_result = dataclasses.asdict(fit_result)
fit_result["circuit_unit"] = unit
if unit == "dt":
fit_result["dt"] = conversion_factor
quality = self._fit_quality(
fit_result["popt"], fit_result["popt_err"], fit_result["reduced_chisq"]
)
chisq = fit_result["reduced_chisq"]

if plot:
ax = plot_curve_fit(T2_fit_fun, fit_result, ax=ax)
ax = plot_scatter(xdata, ydata, ax=ax)
ax = plot_errorbar(xdata, ydata, sigma, ax=ax)
_format_plot(ax, unit, fit_result, conversion_factor)
figures = [ax.get_figure()]
else:
figures = None

# Output unit is 'sec', regardless of the unit used in the input
result_t2hahn = AnalysisResultData(
"T2hahn",
value=FitVal(fit_result["popt"][1], fit_result["popt_err"][1], "s"),
quality=quality,
chisq=chisq,
extra=fit_result,
)

return [result_t2hahn], figures

def _t2hahn_default_params(
self,
conversion_factor,
user_p0=None,
user_bounds=None,
t2hahn_input=None,
) -> Tuple[Dict[str, Union[float, Any]], Union[List[List[Union[Union[float, int], Any]]], Any]]:
"""Default fit parameters for oscillation data.

Note that :math:`T_2` unit is converted to 'sec' so the
output will be given in 'sec'.
"""
if user_p0 is None:
a = 0.5
t2hahn = t2hahn_input * conversion_factor
b = 0.5
else:
a = user_p0["A"]
t2hahn = user_p0["T2hahn"] * conversion_factor
b = user_p0["B"]
p0 = {"a_guess": a, "T2": t2hahn, "b_guess": b}

if user_bounds is None:
a_bounds = [-0.5, 1.5]
t2hahn_bounds = [0, np.inf]
b_bounds = [-0.5, 1.5]
bounds = [
[a_bounds[i], t2hahn_bounds[i], b_bounds[i]]
for i in range(2)
]
else:
bounds = user_bounds
return (p0, bounds)

@staticmethod
def _fit_quality(fit_out, fit_err, reduced_chisq):
# pylint: disable = too-many-boolean-expressions
if (
(reduced_chisq < 3)
and (fit_err[0] is None or fit_err[0] < 0.1 * fit_out[0])
and (fit_err[1] is None or fit_err[1] < 0.1 * fit_out[1])
and (fit_err[2] is None or fit_err[2] < 0.1 * fit_out[2])
):
return "good"
else:
return "bad"
Loading