Skip to content

Commit

Permalink
Merge pull request #569 from qiboteam/fix_report_dispersive
Browse files Browse the repository at this point in the history
Minor fixes for some protocols
  • Loading branch information
andrea-pasquale authored Oct 23, 2023
2 parents d12808d + d8476ce commit e322b4e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/qibocal/cli/acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ def acquire(card, folder, force):
# run protocols
list(executor.run(mode=ExecutionMode.acquire))

e = datetime.datetime.now(datetime.timezone.utc)
meta["end-time"] = e.strftime("%H:%M:%S")
# stop and disconnect platform
if platform is not None:
platform.stop()
platform.disconnect()

# dump updated meta
meta = add_timings_to_meta(meta, executor.history)
e = datetime.datetime.now(datetime.timezone.utc)
meta["end-time"] = e.strftime("%H:%M:%S")
(path / META).write_text(json.dumps(meta, indent=4))
4 changes: 2 additions & 2 deletions src/qibocal/cli/autocalibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def autocalibrate(card, folder, force, update):
platform.setup()
platform.start()

e = datetime.datetime.now(datetime.timezone.utc)
meta["end-time"] = e.strftime("%H:%M:%S")
# run protocols
for task_uid in executor.run(mode=ExecutionMode.autocalibration):
report = ReportBuilder(path, runcard.qubits, executor, meta, executor.history)
Expand All @@ -71,6 +73,4 @@ def autocalibrate(card, folder, force, update):

# dump updated meta
meta = add_timings_to_meta(meta, executor.history)
e = datetime.datetime.now(datetime.timezone.utc)
meta["end-time"] = e.strftime("%H:%M:%S")
(path / META).write_text(json.dumps(meta, indent=4))
2 changes: 1 addition & 1 deletion src/qibocal/protocols/characterization/coherence/t2.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def _plot(data: T2Data, qubit, fit: T2Results = None):
)
)
fitting_report = table_html(
table_dict(qubit, ["T2"], [fit.t2[qubit]], display_error=True)
table_dict(qubit, ["T2 [ns]"], [fit.t2[qubit]], display_error=True)
)
fig.update_layout(
showlegend=True,
Expand Down
2 changes: 1 addition & 1 deletion src/qibocal/protocols/characterization/coherence/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def exponential_fit(data, zeno=None):
popt = [
(y_max - y_min) * popt[0] + y_min,
(y_max - y_min) * popt[1] * np.exp(x_min * popt[2] / (x_max - x_min)),
popt[2] / (x_max - x_min),
popt[2] * (x_max - x_min),
]
t2 = popt[2]

Expand Down
21 changes: 12 additions & 9 deletions src/qibocal/protocols/characterization/dispersive_shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ def _fit(data: DispersiveShiftData) -> DispersiveShiftResults:
np.linalg.norm(iq_couples[0][idx] - iq_couples[1][idx], axis=-1)
)
best_freqs[qubit] = frequencies[max_index]

return DispersiveShiftResults(
frequency_state_zero=frequency_0,
frequency_state_one=frequency_1,
Expand Down Expand Up @@ -318,25 +317,29 @@ def _plot(data: DispersiveShiftData, qubit, fit: DispersiveShiftResults):
fitting_report = table_html(
table_dict(
qubit,
["State zero freq", "State one freq", "ChiBest", "Frequency"],
[
"State Zero Frequency [Hz]",
"State One Frequency [Hz]",
"Chi Best [Hz]",
"Best Frequency [Hz]",
],
np.round(
[
fit_data_0["frequency_state_zero"][qubit],
fit_data_1["frequency_state_one"][qubit],
fit_data_0["frequency_state_zero"][qubit] * GHZ_TO_HZ,
fit_data_1["frequency_state_one"][qubit] * GHZ_TO_HZ,
(
fit_data_0["frequency_state_zero"][qubit]
- fit_data_1["frequency_state_one"][qubit]
)
/ 2,
fit.best_freq[qubit],
/ 2
* GHZ_TO_HZ,
fit.best_freq[qubit] * GHZ_TO_HZ,
]
)
* GHZ_TO_HZ,
),
)
)
fig.update_layout(
showlegend=True,
uirevision="0", # ``uirevision`` allows zooming while live plotting
xaxis_title="Frequency (GHz)",
yaxis_title="MSR (uV)",
xaxis2_title="Frequency (GHz)",
Expand Down
4 changes: 2 additions & 2 deletions src/qibocal/protocols/characterization/ramsey.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from qibocal import update
from qibocal.auto.operation import Data, Parameters, Qubits, Results, Routine

from .utils import GHZ_TO_HZ, chi2_reduced, table_dict, table_html
from .utils import GHZ_TO_HZ, HZ_TO_GHZ, chi2_reduced, table_dict, table_html

POPT_EXCEPTION = [0, 0, 0, 0, 0]
"""Fit parameters output to handle exceptions"""
Expand Down Expand Up @@ -340,7 +340,7 @@ def _plot(data: RamseyData, qubit, fit: RamseyResults = None):


def _update(results: RamseyResults, platform: Platform, qubit: QubitId):
update.drive_frequency(results.frequency[qubit], platform, qubit)
update.drive_frequency(results.frequency[qubit][0] * HZ_TO_GHZ, platform, qubit)


ramsey = Routine(_acquisition, _fit, _plot, _update)
Expand Down

0 comments on commit e322b4e

Please sign in to comment.