Skip to content

Commit

Permalink
add plot of corrected waveform
Browse files Browse the repository at this point in the history
  • Loading branch information
ElStabilini committed Jan 8, 2025
1 parent ea72c44 commit 9491b76
Showing 1 changed file with 44 additions and 7 deletions.
51 changes: 44 additions & 7 deletions src/qibocal/protocols/two_qubit_interaction/cryoscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
PulseSequence,
)
from scipy.optimize import curve_fit
from scipy.signal import lfilter, lfilter_zi

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

from ..ramsey.utils import fitting
from qibocal.protocols.ramsey.utils import fitting
from qibocal.protocols.utils import table_dict, table_html

FULL_WAVEFORM = np.concatenate([np.zeros(10), np.ones(90)])
"""Full waveform to be played."""
Expand Down Expand Up @@ -386,8 +387,6 @@ def _fit(data: CryoscopeData) -> CryoscopeResults:
# original total_len is computed as follows: total_len = const_flux_len + zeros_before_pulse + zeros_after_pulse
# so in this case should be computed as the len of the FULL_WAVEFORM to be played
total_len = len(FULL_WAVEFORM)
## Fit step response with exponential
# pdb.set_trace()

[A, tau], _ = curve_fit(
expdecay,
Expand Down Expand Up @@ -432,6 +431,8 @@ def _plot(data: CryoscopeData, fit: CryoscopeResults, target: QubitId):
),
)

fitting_report = None

if fit is not None:
fig.add_trace(
go.Scatter(
Expand All @@ -440,9 +441,45 @@ def _plot(data: CryoscopeData, fit: CryoscopeResults, target: QubitId):
name="derived waveform",
),
)
# add table back when results attributes are not empty

return [fig], ""
zi = (
lfilter_zi(fit.fir[target], fit.iir[target]) * fit.step_response[target][0]
) # to review
signal, _ = lfilter(
fit.fir[target], fit.iir[target], fit.step_response[target], zi=zi
)

fig.add_trace(
go.Scatter(
x=duration,
y=fit.step_response[target],
name="derived waveform",
),
)

A = fit.A[target]
tau = fit.tau[target]
fir = np.array(fit.fir[target])
iir = np.array(fit.iir[target])

fitting_report = table_html(
table_dict(
target,
["A", "tau", "FIR", "IIR"],
[
(A,),
(tau,),
(fir,),
(iir,),
],
)
)

return [fig], fitting_report


def _update(results: CryoscopeResults, platform: Platform, target: QubitId):
pass


cryoscope = Routine(_acquisition, _fit, _plot)
cryoscope = Routine(_acquisition, _fit, _plot, _update)

0 comments on commit 9491b76

Please sign in to comment.