Skip to content

Commit

Permalink
Name all the args
Browse files Browse the repository at this point in the history
  • Loading branch information
rpanderson committed Jun 25, 2020
1 parent 255d74e commit 39c6f0b
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@

# The time (in seconds) we wish the pineblaster pseudoclock to start after
# the master pseudoclock (the pulseblaster)
pineblaster_0.set_initial_trigger_time(0.9)
pineblaster_0.set_initial_trigger_time(t=0.9)

# Start the experiment!
start()
Expand All @@ -176,32 +176,32 @@
# Analog Acquisitions are acquired at the sample rate specified when the *device* is
# instantiated (eg NI_PCIE_6363() above)
# Acquire an analog trace on this channel from t=0s to t=1s
input1.acquire('measurement1', 0, 1)
input1.acquire(label='measurement1', start_time=0, end_time=1)
# Acquire an analog trace on this channel from t=3s to t=5s
input1.acquire('measurement2', 3, 5)
input1.acquire(label='measurement2', start_time=3, end_time=5)
# Acquire an analog trace on this channel from t=7s to t=9s
input1.acquire('measurement3', 7, 9)
input1.acquire(label='measurement3', start_time=7, end_time=9)

# Set some initial values (t=0) for DDS 1
dds1.setamp(t, 0.5)
dds1.setfreq(t, 0.6)
dds1.setphase(t, 0.7)
dds1.setamp(t=t, value=0.5)
dds1.setfreq(t=t, value=0.6)
dds1.setphase(t=t, value=0.7)

# Set some values for dds2 at t=1s. They will have value '0' before this
# time unless otherwise set
dds2.setamp(t + 1, 0.9)
dds2.setfreq(t + 1, 1.0)
dds2.setphase(t + 1, 1.1)
dds2.setamp(t=t + 1, value=0.9)
dds2.setfreq(t=t + 1, value=1.0)
dds2.setphase(t=t + 1, value=1.1)

# dds5 is a "static" DDS. This means its value can only be set once, and
# will be set just before the experiment begins
dds5.setfreq(90 * MHz)
dds5.setamp(1)
dds5.setphase(0)
dds5.setfreq(value=90 * MHz)
dds5.setamp(value=1)
dds5.setphase(value=0)

# Have the shutters start in the closed state (t=0)
shutter1.close(t)
shutter2.close(t)
shutter1.close(t=t)
shutter2.close(t=t)

# Analog0 is attached to ni_card_1, which is an NI-pci_6733 card (MAX name
# ni_pcie_6733_0) clocked by a pineblaster
Expand All @@ -214,16 +214,16 @@
# the device has actually started.
# To do so, make sure no commands happen on this channel before analog0.t0
# (this variable contains the delay time!)
analog0.constant(analog0.t0, 2)
analog0.constant(t=analog0.t0, value=2)

# Set this channel to a constant value
# As this channel is clocked by the master pseudoclock, you can command
# output from t=0
analog2.constant(t, 3)
analog2.constant(t=t, value=3)

# Again, this must not start until analog1.t0 or later!
analog1.sine(
analog1.t0,
t=analog1.t0,
duration=6,
amplitude=5,
angfreq=2 * np.pi,
Expand All @@ -236,13 +236,13 @@
t += max(1, analog0.t0)

# Open the shutter, enable the DDS, ramp an analog output!
shutter2.open(t)
dds3.enable(t)
analog0.ramp(t, duration=2, initial=2, final=3, samplerate=rate)
shutter2.open(t=t)
dds3.enable(t=t)
analog0.ramp(t=t, duration=2, initial=2, final=3, samplerate=rate)

# Take a picture
andor_ixon_0.expose('exposure_1', t, 'flat')
andor_ixon_0.expose('exposure_1', t + 1, 'atoms')
andor_ixon_0.expose(name='exposure_1', t=t, frametype='flat')
andor_ixon_0.expose(name='exposure_1', t=t + 1, frametype='atoms')

# Do some more things at various times!
# (these are ignoring the t variable)
Expand All @@ -267,7 +267,7 @@ def my_ramp(t, *args, **kwargs):
# The timeout defaults to 5s, unless otherwise specified.
# The timeout specifies how long to wait without seeing the external
# trigger before continuing the experiment
t += wait('my_first_wait', t=t, timeout=2)
t += wait(label='my_first_wait', t=t, timeout=2)

# Waits take very little time as far as labscript is concerned. They only add on the
# retirggering time needed to start devices up and get them all in sync again.
Expand All @@ -278,27 +278,27 @@ def my_ramp(t, *args, **kwargs):

t += 1
# Do something 1s after the wait!
switch.go_high(t)
switch.go_high(t=t)

# Examples programming in different units as specified in the
# unitconversion classes passed as parameters to the channel definition
analog0.constant(t, value=5, units='A')
analog1.constant(t, value=1000, units='mGauss')
dds3.setfreq(t, value=50, units='detuned_MHz')
dds3.setamp(t, value=1.9, units='W')
analog0.constant(t=t, value=5, units='A')
analog1.constant(t=t, value=1000, units='mGauss')
dds3.setfreq(t=t, value=50, units='detuned_MHz')
dds3.setamp(t=t, value=1.9, units='W')

# Hold values for 2 seconds
t += 2

analog0.ramp(t, duration=1, initial=5, final=7, samplerate=rate, units='Gauss')
analog1.constant(t, value=3e6, units='uA')
dds3.setfreq(t, value=60, units='detuned_MHz')
dds3.setamp(t, value=500, units='mW')
analog0.ramp(t=t, duration=1, initial=5, final=7, samplerate=rate, units='Gauss')
analog1.constant(t=t, value=3e6, units='uA')
dds3.setfreq(t=t, value=60, units='detuned_MHz')
dds3.setamp(t=t, value=500, units='mW')

# Hold values for 2 seconds
t += 2

# Stop at t=15 seconds, note that because of the wait timeout, this might
# be as late as 17s (Plus a little bit of retriggering time) in execution
# time
stop(t)
stop(t=t)

0 comments on commit 39c6f0b

Please sign in to comment.