added rf_pulse method to Experiment class (gating, sources, etc include)
This commit is contained in:
parent
b1025a3ff2
commit
f03ae25e4f
@ -77,14 +77,19 @@ class Experiment:
|
|||||||
|
|
||||||
job_id = 0
|
job_id = 0
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, gating=None, rf_sources=[], rf_gates=[]):
|
||||||
self.job_id = Experiment.job_id
|
self.job_id = Experiment.job_id
|
||||||
Experiment.job_id += 1
|
Experiment.job_id += 1
|
||||||
|
|
||||||
self.state_list = StateList()
|
self.state_list = StateList()
|
||||||
self.list_stack = []
|
self.list_stack = []
|
||||||
self.description = { }
|
self.description = { }
|
||||||
|
self.gating = gating
|
||||||
|
assert type(rf_sources) == type(list()), "rf_sources needs to be a list with the channels"
|
||||||
|
assert type(rf_gates) == type(list()), "rf_gates needs to be a list with the channels"
|
||||||
|
assert len(rf_gates) == len(rf_sources), "rf_sources and rf_gates must have equal number of entries"
|
||||||
|
self.rf_sources = rf_sources
|
||||||
|
self.rf_gates = rf_gates
|
||||||
|
|
||||||
# Commands -------------------------------------------------------------------------------------
|
# Commands -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -129,6 +134,23 @@ class Experiment:
|
|||||||
self.state_list.append(StateSimple(length, s_content))
|
self.state_list.append(StateSimple(length, s_content))
|
||||||
else:
|
else:
|
||||||
self.state_list.append(s_content)
|
self.state_list.append(s_content)
|
||||||
|
|
||||||
|
## Same as ttl_pulse, but no *channel* keyword
|
||||||
|
def rf_pulse(self, length=None, phase=0, source=0):
|
||||||
|
"""
|
||||||
|
make an rf pulse, including gating and phase switching
|
||||||
|
|
||||||
|
:param float length: pulse length
|
||||||
|
:param float phase: pulse phase
|
||||||
|
:param int source: source id
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
if not self.gating:
|
||||||
|
raise SyntaxError("Can not use rf_pulse without configuration: Experiment(gating=None, rf_sources=[], rf_gates=[]")
|
||||||
|
self.set_phase(phase, ttls=self.rf_gates[source])
|
||||||
|
self.ttls(length=self.gating-0.5e-6,value=self.rf_gates[source])
|
||||||
|
self.ttls(length=length, value=self.rf_gates[source]+self.rf_sources[source])
|
||||||
|
|
||||||
## Beginning of a new state
|
## Beginning of a new state
|
||||||
def state_start(self, time):
|
def state_start(self, time):
|
||||||
"""
|
"""
|
||||||
@ -147,14 +169,17 @@ class Experiment:
|
|||||||
## An empty state doing nothing
|
## An empty state doing nothing
|
||||||
# @param time Duration of this state
|
# @param time Duration of this state
|
||||||
# @param ttls Additinional ttl channels
|
# @param ttls Additinional ttl channels
|
||||||
def wait(self, time, ttls=None):
|
def wait(self, time, ttls=None, gating=False):
|
||||||
"""
|
"""
|
||||||
Wait specified **time** doing nothing.
|
Wait specified **time** doing nothing.
|
||||||
|
|
||||||
:param float time: seconds to wait
|
:param float time: seconds to wait
|
||||||
:param int ttls: lines to set (integer)
|
:param int ttls: lines to set (integer)
|
||||||
|
:param bool gating: reduce time by gating, i.e. wat in front of rf_pulse
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
if gating:
|
||||||
|
time -= self.gating
|
||||||
if ttls is not None:
|
if ttls is not None:
|
||||||
s_content = '<ttlout value="0x%06x"/>' % ttls
|
s_content = '<ttlout value="0x%06x"/>' % ttls
|
||||||
self.state_list.append(StateSimple(time,s_content))
|
self.state_list.append(StateSimple(time,s_content))
|
||||||
@ -500,7 +525,7 @@ def self_test():
|
|||||||
e.set_description("key", "value")
|
e.set_description("key", "value")
|
||||||
e.set_frequency(85e6, 90, ttls=16)
|
e.set_frequency(85e6, 90, ttls=16)
|
||||||
e.wait(1e-6)
|
e.wait(1e-6)
|
||||||
e.rf_pulse(1, 1e-6/3) # val = 1
|
#e.rf_pulse(1, 1e-6/3) # val = 1
|
||||||
e.ttl_pulse(1e-6/3, 1) # val = 2
|
e.ttl_pulse(1e-6/3, 1) # val = 2
|
||||||
e.ttl_pulse(1e-6/3, None, 7) # val = 7
|
e.ttl_pulse(1e-6/3, None, 7) # val = 7
|
||||||
if True:
|
if True:
|
||||||
|
Loading…
Reference in New Issue
Block a user