Skip to content

Commit

Permalink
feat: Extract qblox-specific info in converter
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Dec 2, 2024
1 parent 9fc3998 commit 9624d60
Showing 1 changed file with 45 additions and 7 deletions.
52 changes: 45 additions & 7 deletions convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json
from dataclasses import dataclass
from pathlib import Path
from typing import Optional
from typing import Callable, Optional

from pydantic import TypeAdapter
from qibolab._core.serialize import NdArray
Expand Down Expand Up @@ -219,19 +219,57 @@ def qm(conf: dict, instruments: dict, instrument_channels: dict) -> dict:
return conf


def qblox(configs: dict, instruments: dict):
return configs


def device_specific(o: dict, configs: dict, connections: Optional[dict]):
def qblox(configs: dict, instruments: dict, channels: dict) -> dict:
MODS = {"qcm_bb", "qcm_rf", "qrm_rf"}
c = (
configs
| {
f"{inst}/{port}/lo": {
"kind": "oscillator",
"frequency": settings["lo_frequency"],
}
for inst, ports in instruments.items()
if any(mod in inst for mod in MODS)
for port, settings in ports.items()
if "lo_frequency" in settings
}
| {
f"{inst}/{port}/mixer": {
"kind": "iq-mixer",
"offset_i": settings["mixer_calibration"][0],
"offset_q": settings["mixer_calibration"][1],
}
for inst, ports in instruments.items()
if any(mod in inst for mod in MODS)
for port, settings in ports.items()
if "mixer_calibration" in settings
}
)
for inst, ports in instruments.items():
if any(mod in inst for mod in MODS):
for port, settings in ports.items():
if "attenuation" in settings:
chs = ["drive", "drive12"] if "qcm" in inst else ["probe"]
for q in channels[inst][port[1:]]:
for ch in chs:
d = c[f"{q[1:]}/{ch}"]
d["kind"] = "qblox-iq"
d["attenuation"] = settings["attenuation"]

return c


def device_specific(
o: dict, configs: dict, connections: Optional[dict]
) -> dict | Callable:
return (
configs
if connections is None
else (
qm(configs, o["instruments"], connections["channels"])
if connections["kind"] == "qm"
else (
qblox(configs, o["instruments"])
qblox(configs, o["instruments"], connections["channels"])
if connections["kind"] == "qblox"
else NONSERIAL
)
Expand Down

0 comments on commit 9624d60

Please sign in to comment.