Skip to content

Commit

Permalink
Merge pull request #744 from qiboteam/fix_plot_chi2_protocols
Browse files Browse the repository at this point in the history
Solve missing plot for protocols involving chi2
  • Loading branch information
andrea-pasquale authored Mar 8, 2024
2 parents ddba2d3 + cfd1c08 commit 80b343a
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 237 deletions.
26 changes: 4 additions & 22 deletions src/qibocal/protocols/characterization/coherence/spin_echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,23 @@
from qibolab.pulses import PulseSequence
from qibolab.qubits import QubitId

from qibocal import update
from qibocal.auto.operation import Parameters, Results, Routine
from qibocal.auto.operation import Routine

from ..utils import chi2_reduced, table_dict, table_html
from . import t1
from .spin_echo_signal import SpinEchoSignalParameters, SpinEchoSignalResults, _update
from .utils import exp_decay, exponential_fit_probability


@dataclass
class SpinEchoParameters(Parameters):
class SpinEchoParameters(SpinEchoSignalParameters):
"""SpinEcho runcard inputs."""

delay_between_pulses_start: int
"""Initial delay between pulses [ns]."""
delay_between_pulses_end: int
"""Final delay between pulses [ns]."""
delay_between_pulses_step: int
"""Step delay between pulses [ns]."""
unrolling: bool = False
"""If ``True`` it uses sequence unrolling to deploy multiple sequences in a single instrument call.
Defaults to ``False``."""


@dataclass
class SpinEchoResults(Results):
class SpinEchoResults(SpinEchoSignalResults):
"""SpinEcho outputs."""

t2_spin_echo: dict[QubitId, float]
"""T2 echo for each qubit."""
fitted_parameters: dict[QubitId, dict[str, float]]
"""Raw fitting output."""
chi2: Optional[dict[QubitId, tuple[float, Optional[float]]]] = field(
default_factory=dict
)
Expand Down Expand Up @@ -228,9 +214,5 @@ def _plot(data: SpinEchoData, target: QubitId, fit: SpinEchoResults = None):
return figures, fitting_report


def _update(results: SpinEchoResults, platform: Platform, target: QubitId):
update.t2_spin_echo(results.t2_spin_echo[target], platform, target)


spin_echo = Routine(_acquisition, _fit, _plot, _update)
"""SpinEcho Routine object."""
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,37 @@
from qibolab.qubits import QubitId

from qibocal import update
from qibocal.auto.operation import Routine
from qibocal.auto.operation import Parameters, Results, Routine

from ..utils import table_dict, table_html
from . import spin_echo
from .t1_signal import CoherenceType, T1SignalData
from .utils import exp_decay, exponential_fit


@dataclass
class SpinEchoSignalParameters(spin_echo.SpinEchoParameters):
class SpinEchoSignalParameters(Parameters):
"""SpinEcho Signal runcard inputs."""

delay_between_pulses_start: int
"""Initial delay between pulses [ns]."""
delay_between_pulses_end: int
"""Final delay between pulses [ns]."""
delay_between_pulses_step: int
"""Step delay between pulses [ns]."""
unrolling: bool = False
"""If ``True`` it uses sequence unrolling to deploy multiple sequences in a single instrument call.
Defaults to ``False``."""


@dataclass
class SpinEchoSignalResults(spin_echo.SpinEchoResults):
class SpinEchoSignalResults(Results):
"""SpinEchoSignal outputs."""

t2_spin_echo: dict[QubitId, float]
"""T2 echo for each qubit."""
fitted_parameters: dict[QubitId, dict[str, float]]
"""Raw fitting output."""


class SpinEchoSignalData(T1SignalData):
"""SpinEcho acquisition outputs."""
Expand Down
26 changes: 5 additions & 21 deletions src/qibocal/protocols/characterization/coherence/t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,24 @@
from qibolab.qubits import QubitId
from qibolab.sweeper import Parameter, Sweeper, SweeperType

from qibocal import update
from qibocal.auto.operation import Data, Parameters, Results, Routine
from qibocal.auto.operation import Data, Routine

from ..utils import chi2_reduced, table_dict, table_html
from . import utils
from . import t1_signal, utils

COLORBAND = "rgba(0,100,80,0.2)"
COLORBAND_LINE = "rgba(255,255,255,0)"


@dataclass
class T1Parameters(Parameters):
class T1Parameters(t1_signal.T1SignalParameters):
"""T1 runcard inputs."""

delay_before_readout_start: int
"""Initial delay before readout [ns]."""
delay_before_readout_end: int
"""Final delay before readout [ns]."""
delay_before_readout_step: int
"""Step delay before readout [ns]."""


@dataclass
class T1Results(Results):
class T1Results(t1_signal.T1SignalResults):
"""T1 outputs."""

t1: dict[QubitId, tuple[float]]
"""T1 for each qubit."""
fitted_parameters: dict[QubitId, dict[str, float]]
"""Raw fitting output."""
chi2: Optional[dict[QubitId, tuple[float, Optional[float]]]] = field(
default_factory=dict
)
Expand Down Expand Up @@ -232,9 +220,5 @@ def _plot(data: T1Data, target: QubitId, fit: T1Results = None):
return figures, fitting_report


def _update(results: T1Results, platform: Platform, target: QubitId):
update.t1(results.t1[target], platform, target)


t1 = Routine(_acquisition, _fit, _plot, _update)
t1 = Routine(_acquisition, _fit, _plot, t1_signal._update)
"""T1 Routine object."""
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from qibocal.auto.operation import Routine

from . import t1, t1_signal
from . import t1_signal


def _acquisition(
Expand Down Expand Up @@ -83,5 +83,5 @@ def _acquisition(
return data


t1_sequences = Routine(_acquisition, t1_signal._fit, t1_signal._plot, t1._update)
t1_sequences = Routine(_acquisition, t1_signal._fit, t1_signal._plot, t1_signal._update)
"""T1 Routine object."""
29 changes: 23 additions & 6 deletions src/qibocal/protocols/characterization/coherence/t1_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,34 @@
from qibolab.qubits import QubitId
from qibolab.sweeper import Parameter, Sweeper, SweeperType

from qibocal.auto.operation import Data, Routine
from qibocal import update
from qibocal.auto.operation import Data, Parameters, Results, Routine

from ..utils import table_dict, table_html
from . import t1, utils
from . import utils


@dataclass
class T1SignalParameters(t1.T1Parameters):
"""T1 Signal runcard inputs."""
class T1SignalParameters(Parameters):
"""T1 runcard inputs."""

delay_before_readout_start: int
"""Initial delay before readout [ns]."""
delay_before_readout_end: int
"""Final delay before readout [ns]."""
delay_before_readout_step: int
"""Step delay before readout [ns]."""


@dataclass
class T1SignalResults(t1.T1Results):
class T1SignalResults(Results):
"""T1 Signal outputs."""

t1: dict[QubitId, tuple[float]]
"""T1 for each qubit."""
fitted_parameters: dict[QubitId, dict[str, float]]
"""Raw fitting output."""


CoherenceType = np.dtype(
[("wait", np.float64), ("signal", np.float64), ("phase", np.float64)]
Expand Down Expand Up @@ -180,5 +193,9 @@ def _plot(data: T1SignalData, target: QubitId, fit: T1SignalResults = None):
return figures, fitting_report


t1_signal = Routine(_acquisition, _fit, _plot, t1._update)
def _update(results: T1SignalResults, platform: Platform, target: QubitId):
update.t1(results.t1[target], platform, target)


t1_signal = Routine(_acquisition, _fit, _plot, _update)
"""T1 Signal Routine object."""
19 changes: 5 additions & 14 deletions src/qibocal/protocols/characterization/coherence/t2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
from qibolab.qubits import QubitId
from qibolab.sweeper import Parameter, Sweeper, SweeperType

from qibocal import update
from qibocal.auto.operation import Parameters, Results, Routine
from qibocal.auto.operation import Routine

from ..utils import chi2_reduced, table_dict, table_html
from . import t1, utils
from . import t1, t2_signal, utils


@dataclass
class T2Parameters(Parameters):
class T2Parameters(t2_signal.T2SignalParameters):
"""T2 runcard inputs."""

delay_between_pulses_start: int
Expand All @@ -29,13 +28,9 @@ class T2Parameters(Parameters):


@dataclass
class T2Results(Results):
class T2Results(t2_signal.T2SignalResults):
"""T2 outputs."""

t2: dict[QubitId, float]
"""T2 for each qubit [ns]."""
fitted_parameters: dict[QubitId, dict[str, float]]
"""Raw fitting output."""
chi2: Optional[dict[QubitId, tuple[float, Optional[float]]]] = field(
default_factory=dict
)
Expand Down Expand Up @@ -205,9 +200,5 @@ def _plot(data: T2Data, target: QubitId, fit: T2Results = None):
return figures, fitting_report


def _update(results: T2Results, platform: Platform, target: QubitId):
update.t2(results.t2[target], platform, target)


t2 = Routine(_acquisition, _fit, _plot, _update)
t2 = Routine(_acquisition, _fit, _plot, t2_signal._update)
"""T2 Routine object."""
23 changes: 20 additions & 3 deletions src/qibocal/protocols/characterization/coherence/t2_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,42 @@
from qibolab.sweeper import Parameter, Sweeper, SweeperType

from qibocal import update
from qibocal.auto.operation import Routine
from qibocal.auto.operation import Parameters, Results, Routine

from ..utils import table_dict, table_html
from . import t1_signal, t2, utils


@dataclass
class T2SignalParameters(t2.T2Parameters):
class T2SignalParameters(Parameters):
"""T2Signal runcard inputs."""

delay_between_pulses_start: int
"""Initial delay between RX(pi/2) pulses in ns."""
delay_between_pulses_end: int
"""Final delay between RX(pi/2) pulses in ns."""
delay_between_pulses_step: int
"""Step delay between RX(pi/2) pulses in ns."""


@dataclass
class T2SignalResults(t2.T2Results):
class T2SignalResults(Results):
"""T2Signal outputs."""

t2: dict[QubitId, float]
"""T2 for each qubit [ns]."""
fitted_parameters: dict[QubitId, dict[str, float]]
"""Raw fitting output."""


class T2SignalData(t1_signal.T1SignalData):
"""T2Signal acquisition outputs."""

t2: dict[QubitId, float]
"""T2 for each qubit [ns]."""
fitted_parameters: dict[QubitId, dict[str, float]]
"""Raw fitting output."""


def _acquisition(
params: T2SignalParameters,
Expand Down
19 changes: 4 additions & 15 deletions src/qibocal/protocols/characterization/coherence/zeno.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@
from qibolab.pulses import PulseSequence
from qibolab.qubits import QubitId

from qibocal import update
from qibocal.auto.operation import Parameters, Results, Routine
from qibocal.auto.operation import Routine

from ..utils import chi2_reduced, table_dict, table_html
from . import t1, utils
from .zeno_signal import ZenoSignalParameters, ZenoSignalResults, _update


@dataclass
class ZenoParameters(Parameters):
class ZenoParameters(ZenoSignalParameters):
"""Zeno runcard inputs."""

readouts: int
"Number of readout pulses"


@dataclass
class ZenoData(t1.T1Data):
Expand All @@ -30,13 +27,9 @@ class ZenoData(t1.T1Data):


@dataclass
class ZenoResults(Results):
class ZenoResults(ZenoSignalResults):
"""Zeno outputs."""

zeno_t1: dict[QubitId, int]
"""T1 for each qubit."""
fitted_parameters: dict[QubitId, dict[str, float]]
"""Raw fitting output."""
chi2: dict[QubitId, tuple[float, Optional[float]]]
"""Chi squared estimate mean value and error."""

Expand Down Expand Up @@ -202,8 +195,4 @@ def _plot(data: ZenoData, fit: ZenoResults, target: QubitId):
return figures, fitting_report


def _update(results: ZenoResults, platform: Platform, target: QubitId):
update.t1(results.zeno_t1[target], platform, target)


zeno = Routine(_acquisition, _fit, _plot, _update)
Loading

0 comments on commit 80b343a

Please sign in to comment.