Skip to content

Commit

Permalink
Merge pull request #3 from Ecpy/pulses
Browse files Browse the repository at this point in the history
Add support for pulses sequences synthesis
  • Loading branch information
MatthieuDartiailh authored Oct 19, 2016
2 parents 8e05216 + cdf1aec commit 8122a17
Show file tree
Hide file tree
Showing 18 changed files with 865 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ before_install:
- cd ..

# Install ecpy dependencies
- $CONDA_INSTALL pyqt=4 numpy ecpy h5py
- $CONDA_INSTALL pyqt=4 numpy ecpy h5py ecpy_pulses
- $PIP_INSTALL pyvisa


Expand Down
1 change: 1 addition & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ requirements:
- python
- future
run:
- python
- ecpy
- numpy
- h5py
Expand Down
13 changes: 12 additions & 1 deletion ecpy_hqc_legacy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ def list_manifests():
"""
import enaml

with enaml.imports():
from .manifest import HqcLegacyManifest
return [HqcLegacyManifest]

manifests = [HqcLegacyManifest]

try:
with enaml.imports():
from .pulses.manifest import HqcLegacyPulsesManifest
manifests.append(HqcLegacyPulsesManifest)
except ImportError:
pass

return manifests
89 changes: 82 additions & 7 deletions ecpy_hqc_legacy/conversion/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
#: Dependency id for task interfaces.
INTERFACE_DEP_TYPE = 'ecpy.tasks.interface'

#: Dependency id for the pulse sequences items.
ITEM_DEP_TYPE = 'ecpy.pulses.item'

#: Dependency id for the pulse sequences shapes.
SHAPE_DEP_TYPE = 'ecpy.pulses.shape'

#: Dependency id for pulse sequence contexts.
CONTEXT_DEP_TYPE = 'ecpy.pulses.context'


#: Mapping between task_class (in HQCMeas) and task_id (in ecpy)
TASKS = {'ComplexTask': 'ecpy.ComplexTask',
'WhileTask': 'ecpy.WhileTask',
Expand Down Expand Up @@ -54,7 +64,8 @@
'PNASweepTask': 'ecpy_hqc_legacy.PNASweepTask',
'PNAGetTraces': 'ecpy_hqc_legacy.PNAGetTraces',
'SetDCVoltageTask': 'ecpy_hqc_legacy.SetDCVoltageTask',
'DemodSPTask': 'ecpy_hqc_legacy.DemodSPTask'}
'DemodSPTask': 'ecpy_hqc_legacy.DemodSPTask',
'TransferPulseSequenceTask': 'ecpy_pulses.TransferPulseSequenceTask'}

#: Mapping between interface_class (in HQCMeas) and interface_id (in ecpy)
INTERFACES = {'IterableLoopInterface':
Expand All @@ -74,6 +85,18 @@
('ecpy_hqc_legacy.LoadArrayTask:'
'ecpy_hqc_legacy.CSVLoadInterface')}

#: Mapping between item_class (in HQCMeas) and item_id (in ecpy_pulses)
ITEMS = {'Pulse': 'ecpy_pulses.Pulse',
'Sequence': 'ecpy_pulses.BaseSequence',
'ConditionalSequence': 'ecpy_pulses.ConditionalSequence',
'RootSequence': 'ecpy_pulses.RootSequence'}

#: Mapping between shape_class (in HQCMeas) and shape_id (in ecpy_pulses)
SHAPES = {'SquareShape': 'ecpy_pulses.SquareShape'}

#: Mapping between context_class (in HQCMeas) and context_id (in ecpy_pulses)
CONTEXTS = {'AWGContext': 'ecpy_hqc_legacy.AWG5014Context'}

#: Mapping between monitor_class and monitor_id
MONITORS = {'hqc_meas.measure.monitors.text_monitor':
'ecpy.text_monitor'}
Expand Down Expand Up @@ -165,13 +188,59 @@ def update_task_interface(interface_config):
"""
old_id = interface_config['interface_class']
if old_id in ('AWGTransferInterface', 'TaborTransferInterface'):
interface_config['__to_clear__'] = True
return

if old_id not in INTERFACES:
raise ValueError('Unknown or unsupported interface found %s' % old_id)
interface_config['interface_id'] = INTERFACES[old_id]
del interface_config['interface_class']
interface_config['dep_type'] = INTERFACE_DEP_TYPE


def update_item(item_config):
"""Update a pulse sequence item.
"""
old_id = item_config['item_class']
if old_id not in ITEMS:
raise ValueError('Unknown or unsupported sequence found %s' % old_id)
item_config['item_id'] = ITEMS[old_id]
del item_config['item_class']
item_config['dep_type'] = ITEM_DEP_TYPE

if old_id == 'Pulse':
if 'modulation' in item_config:
mod = item_config['modulation']
mod['dep_type'] = 'ecpy.pulses.modulation'
mod['modulation_id'] = 'ecpy_pulses.Modulation'


def update_shape(shape_config):
"""Update a pulse shape.
"""
old_id = shape_config['shape_class']
if old_id not in SHAPES:
raise ValueError('Unknown or unsupported shape found %s' % old_id)
shape_config['shape_id'] = SHAPES[old_id]
del shape_config['shape_class']
shape_config['dep_type'] = SHAPE_DEP_TYPE


def update_context(context_config):
"""Update a sequence context.
"""
old_id = context_config['context_class']
if old_id not in CONTEXTS:
raise ValueError('Unknown or unsupported context found %s' % old_id)
context_config['context_id'] = CONTEXTS[old_id]
del context_config['context_class']
context_config['dep_type'] = CONTEXT_DEP_TYPE


def update_monitor(config):
"""Update the informations related to a monitor.
Expand Down Expand Up @@ -206,17 +275,19 @@ def iterate_on_sections(section, action_mapping):
section under inspection.
"""
for s in section.sections:
s = section[s]
for s in list(section.sections):
s_config = section[s]
action = None
for t in action_mapping:
if t(s):
if t(s_config):
action = action_mapping[t]
break
if action is None:
raise ValueError('No matching action could be found for %s' % s)
action(s)
iterate_on_sections(s, action_mapping)
action(s_config)
if '__to_clear__' in s_config:
del section[s]
iterate_on_sections(s_config, action_mapping)


def convert_measure(meas_path, archive_folder=None, dest_folder=None):
Expand Down Expand Up @@ -246,7 +317,11 @@ def convert_measure(meas_path, archive_folder=None, dest_folder=None):
iterate_on_sections(config['root_task'],
{lambda x: 'task_class' in x: update_task,
lambda x: 'interface_class' in x:
update_task_interface})
update_task_interface,
lambda x: 'item_class' in x: update_item,
lambda x: 'shape_class' in x: update_shape,
lambda x: 'context_class' in x: update_context,
lambda x: 'modulation_id' in x: lambda x: x})

#: Update the monitors and delete the other non-existing tools
monitors = {}
Expand Down
30 changes: 16 additions & 14 deletions ecpy_hqc_legacy/instruments/drivers/visa/tektro_awg.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ def select_sequence(self, name):
name)
)

@secure_communication()
def clear_sequence(self):
"""Clear the sequence played by this channel.
"""
with self.secure():
self._AWG.write('SOURCE{}:WAVEFORM ""'.format(self._channel))

@contextmanager
def secure(self):
""" Lock acquire and release method
Expand Down Expand Up @@ -431,26 +439,20 @@ def get_channel(self, num):
return channel

@secure_communication()
def to_send(self, name, waveform, initialized):
def to_send(self, name, waveform):
"""Command to send to the instrument. waveform = string of a bytearray
"""
numbyte = len(waveform)
looplength = numbyte//2
if not initialized:
self.write("WLIST:WAVEFORM:DELETE '{}'".format(name))
self.write("WLIST:WAVEFORM:NEW '{}' , {}, INTeger" .format(name,
looplength))
initialized = True

numApresDiese = len('{}'.format(numbyte))
header = "WLIS:WAV:DATA '{}',0,{},#{}{}".format(name, looplength,
numApresDiese,
numbyte)
self.write('{}{}'.format(header, waveform))
self.write('*WAI')
self.write("WLIST:WAVEFORM:DELETE '{}'".format(name))
self.write("WLIST:WAVEFORM:NEW '{}' , {}, INTeger" .format(name,
looplength))

return initialized
header = "WLIS:WAV:DATA '{}',0,{},".format(name, looplength)
#
self._driver.write_binary_values(header, waveform, datatype='B')
self.write('*WAI')

@instrument_property
@secure_communication()
Expand Down
3 changes: 2 additions & 1 deletion ecpy_hqc_legacy/manifest.enaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ enamldef HqcLegacyManifest(PluginManifest):
kind = 'AWG'
connections = {'VisaGPIB': {'resource_class': 'INSTR'},
'VisaUSB': {'resource_class': 'INSTR'},
'VisaTCPIP': {'resource_class': 'INSTR'}
'VisaTCPIP': {'resource_class': 'INSTR',
'lan_device_name': 'inst0'}
}
Drivers:
manufacturer = 'Signal recovery'
Expand Down
1 change: 1 addition & 0 deletions ecpy_hqc_legacy/pulses/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#
1 change: 1 addition & 0 deletions ecpy_hqc_legacy/pulses/contexts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#
Loading

0 comments on commit 8122a17

Please sign in to comment.