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

Add way to associate a hardware channel with a channel mask #752

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Changes from all commits
Commits
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
26 changes: 26 additions & 0 deletions qupulse/hardware/dacs/alazar2.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import dataclasses
from typing import Union, Iterable, Dict, Tuple, Mapping, Optional
from types import MappingProxyType
import logging
Expand Down Expand Up @@ -30,6 +31,13 @@ def __init__(self, atsaverage_card: 'atsaverage.core.AlazarCard'):
self._raw_data_mask = None
self.default_buffer_strategy: Optional[BufferStrategySettings] = None

# sadly this is required to associate masks with their corresponding channels
# the better place for this would be in the MeasurementMask class but we do not want to touch it
# to avoid breaking experiments
# TODO: possible improvement is wildcard/regex support but this is complicated to maintain
# (competing matches etc)
self._mask_name_to_hw_channel = {}

@property
def atsaverage_card(self):
return self._atsaverage_card
Expand Down Expand Up @@ -74,6 +82,13 @@ def _make_scanline_definition(self, program: AlazarProgram):
sample_rate_in_hz = int(sample_rate_in_ghz * 10 ** 9)

masks = program.masks(make_best_mask)
for mask in masks:
try:
mask.channel = self._mask_name_to_hw_channel[mask.identifier]
except KeyError as err:
raise KeyError(f"There was no hardware channel registered for the mask {mask!r}",
mask.identifier) from err

if sample_rate_in_ghz != program.sample_rate:
raise RuntimeError("Masks were registered with a different sample rate")
return create_scanline_definition(masks, program.operations,
Expand Down Expand Up @@ -130,3 +145,14 @@ def get_input_range(operation_id: str):
input_range = get_input_range(op_name)
data[op_name] = scanline_data.operationResults[op_name].getAsVoltage(input_range)
return data

def register_mask_for_channel(self, mask_id: str, hw_channel: int) -> None:
"""

Args:
mask_id: Identifier of the measurement windows
hw_channel: Associated hardware channel (0, 1, 2, 3)
"""
if hw_channel not in range(4):
raise ValueError('{} is not a valid hw channel'.format(hw_channel))
self._mask_name_to_hw_channel[mask_id] = hw_channel