Skip to content

Commit

Permalink
Merge 65d10f9 into 62729d2
Browse files Browse the repository at this point in the history
  • Loading branch information
terrorfisch committed Feb 10, 2023
2 parents 62729d2 + 65d10f9 commit 5ea9278
Showing 1 changed file with 26 additions and 0 deletions.
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

0 comments on commit 5ea9278

Please sign in to comment.