Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, name, model, gates=['c%d' % i for i in range(1, 17)], **kwargs):
super().__init__(name, model=model, **kwargs)
self._gates = gates
logging.debug('add gates')
for i, g in enumerate(gates):
cmdbase = g # 'c{}'.format(i)
logging.debug('add gate %s' % g )
self.add_parameter(g,
label='Gate {} (mV)'.format(g),
get_cmd=cmdbase + '?',
set_cmd=cmdbase + ':{:.4f}',
get_parser=float,
vals=Numbers(-2000, 2000))
self.add_function('reset', call_cmd='rst')
logging.debug('add gates function')
for i, g in enumerate(gates):
self.add_function(
'get_{}'.format(g), call_cmd=partial(self.get, g))
logging.debug('add gates function %s: %s' % (self.name, g) )
def __init__(self, awg: Tektronix_AWG5014) -> None:
""" The VirtualAWG backend for the Tektronix 5014C AWG.
Args:
awg: The Tektronix 5014C AWG instance.
Raises:
ValueError: The provided AWG is not of type Tektronix_AWG5014.
"""
super().__init__('Tektronix_AWG5014', channel_numbers=[1, 2, 3, 4], marker_numbers=[1, 2])
if type(awg).__name__ is not self._awg_name:
raise ValueError(f'The AWG type does not correspond with {self._awg_name}')
self.__settings = [Parameter(name='marker_low', unit='V', initial_value=0.0,
vals=Numbers(-1.0, 2.6), set_cmd=None),
Parameter(name='marker_high', unit='V', initial_value=1.0,
vals=Numbers(-0.9, 2.7), set_cmd=None),
Parameter(name='amplitudes', unit='V', initial_value=1.0,
vals=Numbers(0.02, 4.5), set_cmd=None),
Parameter(name='offset', unit='V', initial_value=0,
vals=Numbers(-2.25, 2.25), set_cmd=None)]
self.__awg = awg
def __init__(self, name, address, reset=False, **kwargs):
super().__init__(name, **kwargs)
self.add_parameter('dummy',
get_cmd=self.get_dummy,
set_cmd=self.set_dummy,
vals=NumbersValidator())
self.add_function('readnext', call_cmd=self.readnext_function, unit='arb.unit')
def _create_parameters(self):
for g in self._virts_list:
self.add_parameter(g,
label='%s' % g,
unit='mV',
get_cmd=partial(self._get, gate=g),
set_cmd=partial(self._set, gate=g),
vals=Numbers())
self.add_parameter('virtual_matrix', get_cmd=self.get_crosscap_matrix)
self._update_virt_parameters()
def __init__(self, name='settings'):
super().__init__(name)
awg_gates = {'P1': (0, 0), 'P2': (0, 1)}
awg_markers = {'m4i_mk': (0, 4, 0)}
self.awg_map = {**awg_gates, **awg_markers}
for awg_gate in self.awg_map:
parameter_name = 'awg_to_{}'.format(awg_gate)
parameter_label = '{} (factor)'.format(parameter_name)
self.add_parameter(parameter_name, parameter_class=ManualParameter,
initial_value=1000, label=parameter_label, vals=Numbers(1, 1000))
def __init__(self, awg):
super().__init__('Keysight_M3201A', channel_numbers=[1, 2, 3, 4], marker_numbers=[1])
if not Keysight_M3201A:
raise AwgCommonError('The Keysight SD drivers can not be found!')
if type(awg).__name__ is not self._awg_name:
raise AwgCommonError('The AWG does not correspond with {}'.format(self._awg_name))
self.__settings = [Parameter(name='enabled_outputs', initial_value=0b0000,
set_cmd=None),
Parameter(name='amplitude', unit='Volt', initial_value=1.0,
vals=Numbers(0.0, 1.5), set_cmd=None),
Parameter(name='offset', unit='seconds', initial_value=0.0,
vals=Numbers(0.0, 2.0), set_cmd=None),
Parameter(name='wave_shape', initial_value=6,
set_cmd=None),
Parameter(name='delay', unit='seconds', initial_value=0,
vals=Numbers(0, 10), set_cmd=None),
Parameter(name='auto_trigger', unit='', initial_value=0,
set_cmd=None),
Parameter(name='cycles', initial_value=0,
set_cmd=None),
Parameter(name='prescaler', initial_value=10,
set_cmd=None)]
self.__awg = awg
Args:
awg: The Tektronix 5014C AWG instance.
Raises:
ValueError: The provided AWG is not of type Tektronix_AWG5014.
"""
super().__init__('Tektronix_AWG5014', channel_numbers=[1, 2, 3, 4], marker_numbers=[1, 2])
if type(awg).__name__ is not self._awg_name:
raise ValueError(f'The AWG type does not correspond with {self._awg_name}')
self.__settings = [Parameter(name='marker_low', unit='V', initial_value=0.0,
vals=Numbers(-1.0, 2.6), set_cmd=None),
Parameter(name='marker_high', unit='V', initial_value=1.0,
vals=Numbers(-0.9, 2.7), set_cmd=None),
Parameter(name='amplitudes', unit='V', initial_value=1.0,
vals=Numbers(0.02, 4.5), set_cmd=None),
Parameter(name='offset', unit='V', initial_value=0,
vals=Numbers(-2.25, 2.25), set_cmd=None)]
self.__awg = awg
gate_boundaries (dict): a range of allowed values per parameter.
"""
for g, bnds in gate_boundaries.items():
logging.debug('gate %s: %s' % (g, bnds))
if bnds[0] >= bnds[1]:
raise ValueError(f'boundary {bnds} for gate {g} is invalid')
gx = self._gate_map.get(g, None)
if gx is None:
warnings.warn(f'instrument {self} has no gate {g}')
continue
instrument = self._instruments[self._instrument_index(gx[0])]
param = self.get_instrument_parameter(g)
param.vals = Numbers(bnds[0], max_value=bnds[1])
if hasattr(instrument, 'adjust_parameter_validator'):
instrument.adjust_parameter_validator(param)
def _make_gate(self, gate):
self.add_parameter(gate,
label='%s' % gate, # (\u03bcV)',
unit='mV',
get_cmd=partial(self._get, gate=gate),
set_cmd=partial(self._set, gate=gate))
self.add_function(
'get_{}'.format(gate), call_cmd=partial(self.get, param_name=gate))
self.add_function('set_{}'.format(gate), call_cmd=partial(
self._set_wrap, gate=gate), args=[Numbers()])