if lbf.imgzc == 1 : 
		bfield.extend( ir1.dt() ) 
		bfield.insertlin_cnv( zc.zcbias, 1.0, -lbf.imgzc_time)
		
	
	# Insert lattice lock
	ir1.insertlin_cnv( lbf.irlockpow, lbf.irlockpowdt, -(lbf.irlockpowdt+lbf.irlocktof))
	ir2.insertlin_cnv( lbf.irlockpow, lbf.irlockpowdt, -(lbf.irlockpowdt+lbf.irlocktof))
	ir3.insertlin_cnv( lbf.irlockpow, lbf.irlockpowdt, -(lbf.irlockpowdt+lbf.irlocktof))
	
	gr1.insertlin_cnv( lbf.grlockpow, lbf.grlockpowdt, -(lbf.grlockpowdt+lbf.grlocktof))
	gr2.insertlin_cnv( lbf.grlockpow, lbf.grlockpowdt, -(lbf.grlockpowdt+lbf.grlocktof))
	gr3.insertlin_cnv( lbf.grlockpow, lbf.grlockpowdt, -(lbf.grlockpowdt+lbf.grlocktof))

	# Ramp down ODT
	odtpow = odt.odt_wave('odtpow', cpowend, ir_ss)
	odtpow.appendhold( imagetime + lbf.odtdelay )
	if lbf.odtzero == 1:
		odtpow.linear( 0.0,  lbf.odtrampdt)

	waveforms = [ir1,ir2,ir3,gr1,gr2,gr3,bfield, odtpow]

	# RF sweep
	if lbf.rf == 1:   
		rfmod  = wfm.wave('rfmod', 0., ir_ss)
		rfmod.appendhold( imagetime + lbf.rftime )
		rfmod.linear( lbf.rfvoltf, lbf.rfpulsedt)
		waveforms = [rfmod,ir1,ir2,ir3,gr1,gr2,gr3,bfield, odtpow]

	endtime = s.analogwfm_add(ir_ss,waveforms)
	print "...Lattice ramp time = " + str(endtime) + " ms"
def go_to_highfield(s):

    #Keep ODT on
    ODT = gen.bstr('ODT', report)
    if ODT == True:
        s.digichg('odtttl', 1)
    s.wait(20.0)

    ss = float(report['SEQ']['analogstepsize'])

    # Cool and Compress MOT
    # ENDCNC is defined as the time up to release from the MOT
    motpow, repdet, trapdet, reppow, trappow, bfield, ENDCNC = cnc.cncRamps()

    # Load UVMOT from CNCMOT
    uvfppiezo, uvpow, motpow, repdet, trapdet, reppow, trappow, bfield, ENDUVMOT = uvred.uvcoolRamps(
        motpow, repdet, trapdet, reppow, trappow, bfield, ENDCNC)

    # Set imaging values
    camera = 'ANDOR'
    motpow, repdet, trapdet, reppow, trappow, maxDT = cnc.imagingRamps_nobfield(
        motpow, repdet, trapdet, reppow, trappow, camera)

    # Switch bfield to FESHBACH
    overlapdt = float(report['ODT']['overlapdt'])
    rampdelay = float(report['FESHBACH']['rampdelay'])
    rampbf = float(report['FESHBACH']['rampbf'])
    bf = float(report['FESHBACH']['bf'])
    feshbachdt = float(report['FESHBACH']['feshbachdt'])
    switchondt = float(report['FESHBACH']['switchondt'])
    switchdelay = float(report['FESHBACH']['switchdelay'])
    bias = float(report['FESHBACH']['bias'])
    biasrampdt = float(report['FESHBACH']['rampdt'])

    bfield.chop(ENDUVMOT - overlapdt)
    bfield.appendhold(rampdelay)
    bfield.linear(bf, rampbf)
    bfield.extend(ENDUVMOT + feshbachdt)
    bfield.linear(0.0, 0.0)
    ENDBFIELD = feshbachdt
    bfield.appendhold(switchondt + switchdelay)
    bfield.linear(bias, biasrampdt)

    #---Ramp up ODT
    odtpow0 = odt.odt_wave('odtpow', f('ODT', 'odtpow0'), ss)
    odtpow0.extend(ENDUVMOT)

    #Add waveforms to sequence
    s.analogwfm_add(ss, [
        motpow, repdet, trapdet, bfield, reppow, trappow, uvfppiezo, uvpow,
        odtpow0
    ])

    #wait normally rounds down using floor, here the duration is changed before so that
    #the wait is rounded up
    ENDUVMOT = ss * math.ceil(ENDUVMOT / ss)

    #insert QUICK pulse  for fast ramping of the field gradient
    s.wait(-10.0)
    quickval = 1 if gen.bstr('CNC', report) == True else 0
    s.digichg('quick', quickval)
    s.wait(10.0)

    #insert UV pulse
    uvtime = float(report['UVRED']['uvtime'])
    s.wait(ENDCNC)
    s.digichg('quick', 0)
    s.wait(uvtime)
    #Shut down the UVAOM's and open the shutter
    s.wait(-50.0)
    s.digichg('uvaom1', 0)
    s.digichg('uvaom2', 0)
    s.digichg('uvshutter', 1)
    s.wait(50.0)
    #Turn on UVAOM
    s.digichg('uvaom1', 1)
    s.wait(-uvtime - ENDCNC)

    #Go to MOT release time and set QUICK back to low
    s.wait(ENDUVMOT)
    s.digichg('quick', 0)

    #CAREFUL: State transfer should be programmed in uvred.py, as it is done un uvmot.py
    s.digichg('uvaom1', 0)

    #RELEASE FROM MOT
    waitshutter = 5.0
    s.wait(waitshutter)
    s.digichg('uvshutter', 0)
    #~ s.wait(20.0)
    #~ s.digichg('uvaom1',0)
    #~ s.digichg('uvaom2',0)
    #~ s.wait(-20.0)
    s.wait(-waitshutter)

    s.digichg('motswitch', 0)
    s.digichg('motshutter', 1)
    s.digichg('field', 0)

    #Insert ODT overlap with UVMOT and switch field to FESHBACH
    overlapdt = float(report['ODT']['overlapdt'])
    servodt = float(report['ODT']['servodt'])
    s.wait(-overlapdt - servodt)
    s.digichg('odt7595', 1)
    s.wait(servodt)
    s.digichg('odtttl', 1)
    #feshbachdt = rampdelay + rampbf + holdbf
    s.wait(overlapdt)
    s.wait(feshbachdt)
    s.digichg('feshbach', 1)
    #s.wait(overlapdt - feshbachdt)
    #s.wait( -feshbachdt)

    #s.wait(offdelay)
    #s.wait(2*switchdt)
    #s.wait(quickdelay)
    s.wait(switchondt)
    do_quick = 1
    s.digichg('field', 1)
    s.digichg('hfquick', do_quick)
    s.digichg('quick', do_quick)
    #Can't leave quick ON for more than quickmax
    quickmax = 100.
    s.wait(quickmax)
    s.digichg('hfquick', 0)
    s.digichg('quick', 0)
    s.wait(-quickmax)
    s.wait(switchdelay + biasrampdt)
    s.digichg('quick', 0)
    s.wait(-biasrampdt)
    #s.wait(-switchdelay-quickdelay-2*switchdt-offdelay)
    s.wait(-switchdelay - switchondt - feshbachdt - ss)

    #At this point the time sequence is at ENDUVMOT

    #This is the time until the end of the bfield ramp
    #toENDBFIELD = biasrampdt + switchdelay + quickdelay + 2*switchdt + offdelay
    toENDBFIELD = biasrampdt + switchdelay + switchondt + feshbachdt

    return s, toENDBFIELD
def  go_to_highfield(s):

	#---Keep ODT on
	odton = gen.bstr('ODT',report)
	if odton == True:
		s.digichg('odtttl',1)
	s.wait(20.0)

	ss = SEQ.analogstepsize

	#---Cool and Compress MOT
	#---ENDCNC is defined as the time up to release from the MOT
	motpow, repdet, trapdet, reppow, trappow, bfield, ENDCNC = cnc.cncRamps()

	#---Load UVMOT from CNCMOT
	uvpow2, uvpow, motpow, bfield, ENDUVMOT = uvmot.uvRamps(motpow, bfield, ENDCNC)

	repdet.extend(ENDUVMOT)
	trapdet.extend(ENDUVMOT)
	reppow.extend(ENDUVMOT)
	trappow.extend(ENDUVMOT)
	
	#---Make sure everything has the same length before setting imaging values
	#--- Set imaging values
	camera = 'ANDOR'
	motpow, repdet, trapdet, reppow, trappow, maxDT = cnc.imagingRamps_nobfield(motpow, repdet, trapdet, reppow, trappow, camera)


	#---Switch bfield to FESHBACH 
	bfield.appendhold(FB.rampdelay)
	bfield.linear( FB.bf, FB.rampbf)
	bfield.appendhold( FB.feshbachdt)
	bfield.linear(0.0, 0.0)
	bfield.appendhold( FB.switchondt + FB.switchdelay + UV.extradt)
	bfield.linear(FB.bias,FB.rampdt)


	#---Set the starting voltage for the ODT
	odtpow0 = odt.odt_wave('odtpow', ODT.odtpow0, ss)
	odtpow0.extend(ENDUVMOT)
	
	#---Change shunt value from motV to hfV before going to highfield
	shunt = wfm.wave('gradientfield', SHUNT.motV, ss, volt = SHUNT.motV)
	shunt.extend(ENDUVMOT + FB.rampdelay + FB.rampbf + FB.feshbachdt + UV.extradt) 
	#shunt.linear(SHUNT.hfV, 0.0,volt =SHUNT.hfV)	
	shunt.linear(SHUNT.hfV, 0.0,volt =0.0)	
	
	
	wfms = [ motpow, repdet, trapdet, bfield, reppow, trappow, uvpow, uvpow2,odtpow0, shunt]

	
	#---Add waveforms to sequence
	s.analogwfm_add(ss,wfms)
	
		
	#wait normally rounds down using floor, here the duration is changed before so that
	#the wait is rounded up
	ENDUVMOT = ss*math.ceil(ENDUVMOT/ss)
	
	#---Insert QUICK pulse for fast ramping of the field gradient during CNC
	s.wait(-10.0)
	quickval = 1 if gen.bstr('CNC',report) == True else 0
	s.digichg('quick',quickval)	
	s.wait(10.0)
	s.wait(ENDCNC)
	s.digichg('quick',0)
	
	#---Go back in time, shut down the UVAOM's and open the shutter
	#---UVAOM's were on to keep them warm
	s.wait(-50.0)
	s.digichg('uvaom1',0)
	s.digichg('uvaom2',0)
	s.digichg('uvshutter',1)
	s.wait(50.0)
	
	#---Insert ODT overlap 
	s.wait(-ODT.overlapdt-ODT.servodt)
	s.digichg('odt7595',1)
	s.wait(ODT.servodt)
	s.digichg('odtttl',1)
	s.wait(ODT.overlapdt)
	
	#---Turn OFF red light
	s.wait(UV.delay_red)
	s.digichg('motswitch',0) 
	s.digichg('motshutter',1)
	s.wait(-UV.delay_red)
	
	#---Turn ON UVAOM's
	s.wait(UV.delay_uv)
	s.digichg('uvaom1',1)
	s.digichg('uvaom2',1)
	s.wait(-UV.delay_uv)
	

	#---Go to MOT release time
	s.wait(-ENDCNC)
	s.wait(ENDUVMOT)
	

	#---Go to end of field rampdown and set QUICK back to low
	s.wait(FB.rampdelay+FB.rampbf) 
	s.digichg('quick',0)
	

	#---Wait in the UVMOT and then do optical pumping
	s.wait(UV.extradt) 
	s.wait(-UV.pumptime)
	s.digichg('uvaom2',0)
	s.wait(UV.pumptime)
	#---Turn OFF UVAOM
	s.digichg('uvaom1',0)
	#---Close UV shutter
	waitshutter=5.0
	s.wait(waitshutter)
	s.digichg('uvshutter',0)
	s.wait(-waitshutter)

	#---Turn OFF MOT magnetic field and switch it to FESHBACH
	s.digichg('field',0)
	s.wait( FB.feshbachdt )
	s.digichg('feshbach',1)
	s.wait(FB.switchondt)
	do_quick=1
	s.digichg('field',1)
	s.digichg('hfquick',do_quick)
	s.digichg('quick',do_quick)
	#Can't leave quick ON for more than quickmax
	quickmax=100.
	s.wait(quickmax)
	s.digichg('hfquick',0)
	s.digichg('quick',0)
	s.wait(-quickmax)
	#
	s.wait(FB.switchdelay+FB.rampdt)
	s.digichg('quick',0)
	s.wait(-FB.rampdt)
	s.wait(-FB.switchdelay - FB.switchondt - FB.feshbachdt - ss)


	#---At this point the time sequence is at ENDUVMOT
	#---Leave the sequence at the end of the UVMOT, but provide the amount
	#---of time that it needs to wait to go to ENDBFIELD
	toENDBFIELD = FB.rampdt + FB.switchdelay + FB.switchondt + FB.feshbachdt
	
	return s, toENDBFIELD
	if lbf.imgzc == 1 : 
		bfield.extend( ir1.dt() ) 
		bfield.insertlin_cnv( zc.zcbias, 1.0, -lbf.imgzc_time)
		
	
	# Insert lattice lock
	ir1.insertlin_cnv( lbf.irlockpow, lbf.irlockpowdt, -(lbf.irlockpowdt+lbf.irlocktof))
	ir2.insertlin_cnv( lbf.irlockpow, lbf.irlockpowdt, -(lbf.irlockpowdt+lbf.irlocktof))
	ir3.insertlin_cnv( lbf.irlockpow, lbf.irlockpowdt, -(lbf.irlockpowdt+lbf.irlocktof))
	
	gr1.insertlin_cnv( lbf.grlockpow, lbf.grlockpowdt, -(lbf.grlockpowdt+lbf.grlocktof))
	gr2.insertlin_cnv( lbf.grlockpow, lbf.grlockpowdt, -(lbf.grlockpowdt+lbf.grlocktof))
	gr3.insertlin_cnv( lbf.grlockpow, lbf.grlockpowdt, -(lbf.grlockpowdt+lbf.grlocktof))

	# Ramp down ODT
	odtpow = odt.odt_wave('odtpow', cpowend, ir_ss)
	odtpow.appendhold( imagetime + lbf.odtdelay )
	if lbf.odtzero == 1:
		odtpow.linear( 0.0,  lbf.odtrampdt)

	waveforms = [ir1,ir2,ir3,gr1,gr2,gr3,bfield, odtpow]

	# RF sweep
	if lbf.rf == 1:   
		rfmod  = wfm.wave('rfmod', 0., ir_ss)
		rfmod.appendhold( imagetime + lbf.rftime )
		rfmod.linear( lbf.rfvoltf, lbf.rfpulsedt)
		waveforms = [rfmod,ir1,ir2,ir3,gr1,gr2,gr3,bfield, odtpow]

	endtime = s.analogwfm_add(ir_ss,waveforms)
	print "...Lattice ramp time = " + str(endtime) + " ms"
Example #5
0
#PARAMETERS
stepsize = float(report['SEQ']['stepsize'])
tof = float(report['BASLER']['tof'])
preexp = float(report['BASLER']['preexp'])
texp = float(report['BASLER']['exp'])
postexp = float(report['BASLER']['postexp'])

#SEQUENCE
s = seq.sequence(stepsize)

s = gen.initial(s)
if UVSEC.odt == 1:
    s.digichg('odtttl', 1)
    odtss = 0.1
    from odt import odt_wave, ipg_wave
    odtpow = odt_wave('odtpow', None, odtss, volt=10.0)
    ipganalog = ipg_wave('ipganalog', 10., odtss)
    odtpow.appendhold(5.0)
    ipganalog.appendhold(10.0)
    s.analogwfm_add(odtss, [odtpow, ipganalog])

s.wait(20.0)
s, duration = uvmot.run(s, 'BASLER')

#RELEASE FROM MOT
s.digichg('motswitch', 0)
s.digichg('uvshutter', 0)
s.digichg('field', 0)

s.wait(tof)
def  go_to_highfield(s):

	#---Keep ODT on
	ODT = gen.bstr('ODT',report)
	if ODT == True:
		s.digichg('odtttl',1)
	s.wait(20.0)

	ss = float(report['SEQ']['analogstepsize'])

	#---Cool and Compress MOT
	#---ENDCNC is defined as the time up to release from the MOT
	motpow, repdet, trapdet, reppow, trappow, bfield, ENDCNC = cnc.cncRamps()

	#---Load UVMOT from CNCMOT
	uvfppiezo, uvpow2, uvpow, motpow, bfield, ENDUVMOT = uvmot.uvRamps(motpow, bfield, ENDCNC)

	repdet.extend(ENDUVMOT)
	trapdet.extend(ENDUVMOT)
	reppow.extend(ENDUVMOT)
	trappow.extend(ENDUVMOT)
	
	#---Make sure everything has the same length before setting imaging values
	#print motpow.dt(), repdet.dt(), trapdet.dt(), bfield.dt(), reppow.dt(), trappow.dt(), uvfppiezo.dt()
	#print motpow.N(), repdet.N(), trapdet.N(), bfield.N(), reppow.N(), trappow.N(), uvfppiezo.N()
	#--- Set imaging values
	camera = 'ANDOR'
	motpow, repdet, trapdet, reppow, trappow, maxDT = cnc.imagingRamps_nobfield(motpow, repdet, trapdet, reppow, trappow, camera)

	#---Switch bfield to FESHBACH 
	overlapdt    = float(report['ODT']['overlapdt'])
	rampdelay    = float(report['FESHBACH']['rampdelay'])
	rampbf       = float(report['FESHBACH']['rampbf'])
	bf           = float(report['FESHBACH']['bf'])
	feshbachdt   = float(report['FESHBACH']['feshbachdt'])
	switchondt  = float(report['FESHBACH']['switchondt'])
	switchdelay  = float(report['FESHBACH']['switchdelay'])
	bias         = float(report['FESHBACH']['bias'])
	biasrampdt   = float(report['FESHBACH']['rampdt'])
	
	bfield.chop(ENDUVMOT-overlapdt,1)
	bfield.appendhold(rampdelay)
	bfield.linear( bf, rampbf)
	bfield.extend(ENDUVMOT+feshbachdt)
	bfield.linear(0.0, 0.0)
	ENDBFIELD = feshbachdt
	bfield.appendhold( switchondt + switchdelay)
	bfield.linear(bias,biasrampdt)
	
	
	#---Ramp up ODT
	odtpow0 = odt.odt_wave('odtpow', f('ODT','odtpow0'), ss)
	odtpow0.extend(ENDUVMOT)
	
	#---Add waveforms to sequence
	s.analogwfm_add(ss,[ motpow, repdet, trapdet, bfield, reppow, trappow, uvfppiezo, uvpow, uvpow2,odtpow0])
	
	#wait normally rounds down using floor, here the duration is changed before so that
	#the wait is rounded up
	ENDUVMOT = ss*math.ceil(ENDUVMOT/ss)
	
	#---Insert QUICK pulse for fast ramping of the field gradient during CNC
	s.wait(-10.0)
	quickval = 1 if gen.bstr('CNC',report) == True else 0
	s.digichg('quick',quickval)	
	s.wait(10.0)
	s.wait(ENDCNC)
	s.digichg('quick',0)

	#---Go back in time, shut down the UVAOM's and open the shutter
	s.wait(-50.0)
	s.digichg('uvaom1',0)
	s.digichg('uvaom2',0)
	s.digichg('uvshutter',1)
	s.wait(50.0)
	
	#---Turn OFF red light
	delay_red = float(report['UV']['delay_red'])
	s.wait(delay_red)
	s.digichg('motswitch',0) 
	s.digichg('motshutter',1)
	s.wait(-delay_red)
	
	#---Turn ON UVAOM's
	delay_uv = float(report['UV']['delay_uv'])
	s.wait(delay_uv)
	s.digichg('uvaom1',1)
	s.digichg('uvaom2',1)
	s.wait(-delay_uv)
	
	s.wait(-ENDCNC)
	
	#---Go to MOT release time and set QUICK back to low
	s.wait(ENDUVMOT)
	s.digichg('quick',0)

	#---Turn OFF UVAOM2 for optical pumping
	pumptime = float(report['UV']['pumptime'])
	s.wait(-pumptime)
	s.digichg('uvaom2',0)
	s.wait(pumptime)
	#---Turn OFF UVAOM
	s.digichg('uvaom1',0)
	#---Close UV shutter
	waitshutter=5.0
	s.wait(waitshutter)
	s.digichg('uvshutter',0)
	s.wait(-waitshutter)
	
	#---Turn OFF MOT magnetic field
	s.digichg('field',0)

	#---Insert ODT overlap with UVMOT and switch field to FESHBACH
	overlapdt = float(report['ODT']['overlapdt'])
	servodt = float(report['ODT']['servodt'])
	#
	s.wait(-overlapdt-servodt)
	s.digichg('odt7595',1)
	s.wait(servodt)
	s.digichg('odtttl',1)
	s.wait(overlapdt)
	s.wait( feshbachdt )
	s.digichg('feshbach',1)
	s.wait(switchondt)
	do_quick=1
	s.digichg('field',1)
	s.digichg('hfquick',do_quick)
	s.digichg('quick',do_quick)
	#Can't leave quick ON for more than quickmax
	quickmax=100.
	s.wait(quickmax)
	s.digichg('hfquick',0)
	s.digichg('quick',0)
	s.wait(-quickmax)
	#
	s.wait(switchdelay+biasrampdt)
	s.digichg('quick',0)
	s.wait(-biasrampdt)
	s.wait(-switchdelay - switchondt - feshbachdt - ss)

	#---At this point the time sequence is at ENDUVMOT
	
	#This is the time until the end of the bfield ramp
	toENDBFIELD = biasrampdt + switchdelay + switchondt + feshbachdt
	
	return s, toENDBFIELD
Example #7
0
def  go_to_highfield(s):

	#---Keep ODT on
	odton = gen.bstr('ODT',report)
	if odton == True:
		s.digichg('odtttl',1)
	s.wait(20.0)

	ss = SEQ.analogstepsize

	#---Cool and Compress MOT
	#---ENDCNC is defined as the time up to release from the MOT
	motpow, repdet, trapdet, reppow, trappow, bfield, ENDCNC = cnc.cncRamps()

	#---Load UVMOT from CNCMOT
	uvpow2, uvpow, motpow, bfield, ENDUVMOT = uvmot.uvRamps(motpow, bfield, ENDCNC)

	repdet.extend(ENDUVMOT)
	trapdet.extend(ENDUVMOT)
	reppow.extend(ENDUVMOT)
	trappow.extend(ENDUVMOT)
	
	#---Make sure everything has the same length before setting imaging values
	#--- Set imaging values
	camera = 'ANDOR'
	motpow, repdet, trapdet, reppow, trappow, maxDT = cnc.imagingRamps_nobfield(motpow, repdet, trapdet, reppow, trappow, camera)


	#---Switch bfield to FESHBACH 
	bfield.appendhold(FB.rampdelay)
	bfield.linear( FB.bf, FB.rampbf)
	bfield.appendhold( FB.feshbachdt)
	bfield.linear(0.0, 0.0)
	bfield.appendhold( FB.switchondt + FB.switchdelay + UV.extradt)
	bfield.linear(FB.bias,FB.rampdt)


	#---Set the starting voltage for the ODT
	odtpow0 = odt.odt_wave('odtpow', ODT.odtpow0, ss)
	odtpow0.extend(ENDUVMOT)
	
	#---Change shunt value from motV to hfV before going to highfield
	shunt = wfm.wave('gradientfield', SHUNT.motV, ss, volt = SHUNT.motV)
	shunt.extend(ENDUVMOT + FB.rampdelay + FB.rampbf + FB.feshbachdt + UV.extradt) 
	#shunt.linear(SHUNT.hfV, 0.0,volt =SHUNT.hfV)	
	shunt.linear(SHUNT.hfV, 0.0,volt =0.0)	
	
	
	wfms = [ motpow, repdet, trapdet, bfield, reppow, trappow, uvpow, uvpow2,odtpow0, shunt]

	
	#---Add waveforms to sequence
	s.analogwfm_add(ss,wfms)
	
		
	#wait normally rounds down using floor, here the duration is changed before so that
	#the wait is rounded up
	ENDUVMOT = ss*math.ceil(ENDUVMOT/ss)
	
	#---Insert QUICK pulse for fast ramping of the field gradient during CNC
	s.wait(-10.0)
	quickval = 1 if gen.bstr('CNC',report) == True else 0
	s.digichg('quick',quickval)	
	s.wait(10.0)
	s.wait(ENDCNC)
	s.digichg('quick',0)
	
	#---Go back in time, shut down the UVAOM's 
	#---UVAOM's were on to keep them warm
	s.wait(UV.clearaoms)
	s.digichg('uvaom1',0)
	s.digichg('uvaom2',0)
	s.wait(-UV.clearaoms)
	
	#---Insert ODT overlap 
	s.wait(-ODT.overlapdt-ODT.servodt)
	s.digichg('odt7595',1)
	s.wait(ODT.servodt)
	s.digichg('odtttl',1)
	s.wait(ODT.overlapdt)
	
	#---Turn OFF red light
	s.wait(UV.delay_red)
	s.digichg('motswitch',0) 
	s.digichg('motshutter',1)
	s.wait(-UV.delay_red)
	
	#---Turn ON UVAOM's
	s.wait(UV.delay_uv)
        #---make sure to open the shutter:
        s.wait(UV.openshutter)
	s.digichg('uvshutter',1)
        s.wait(-UV.openshutter)

	s.digichg('uvaom1',1)
	s.digichg('uvaom2',1)
	s.wait(-UV.delay_uv)
	

	#---Go to MOT release time
	s.wait(-ENDCNC)
	s.wait(ENDUVMOT)
	

	#---Go to end of field rampdown and set QUICK back to low
	s.wait(FB.rampdelay+FB.rampbf) 
	s.digichg('quick',0)
	

	#---Wait in the UVMOT and then do optical pumping
	s.wait(UV.extradt) 
	s.wait(-UV.pumptime)
	s.digichg('uvaom2',0)
	s.wait(UV.pumptime)
	#---Turn OFF UVAOM
	s.digichg('uvaom1',0)
	#---Close UV shutter
	waitshutter=UV.closeshutter
	s.wait(waitshutter)
	s.digichg('uvshutter',0)
	s.wait(-waitshutter)

	#---Turn OFF MOT magnetic field and switch it to FESHBACH
	s.digichg('field',0)
	s.wait( FB.feshbachdt )
	s.digichg('feshbach',1)
	s.wait(FB.switchondt)
	do_quick=1
	s.digichg('field',1)
	s.digichg('hfquick',do_quick)
	s.digichg('quick',do_quick)
	#Can't leave quick ON for more than quickmax
	quickmax=100.
	s.wait(quickmax)
	s.digichg('hfquick',0)
	s.digichg('quick',0)
	s.wait(-quickmax)
	#
	s.wait(FB.switchdelay+FB.rampdt)
	s.digichg('quick',0)
	s.wait(-FB.rampdt)
	s.wait(-FB.switchdelay - FB.switchondt - FB.feshbachdt - ss)


	#---At this point the time sequence is at ENDUVMOT
	#---Leave the sequence at the end of the UVMOT, but provide the amount
	#---of time that it needs to wait to go to ENDBFIELD
	toENDBFIELD = FB.rampdt + FB.switchdelay + FB.switchondt + FB.feshbachdt
	
	return s, toENDBFIELD
def  go_to_highfield(s):

	#Keep ODT on
	ODT = gen.bstr('ODT',report)
	if ODT == True:
		s.digichg('odtttl',1)
	s.wait(20.0)

	ss = float(report['SEQ']['analogstepsize'])

	# Cool and Compress MOT
	# ENDCNC is defined as the time up to release from the MOT
	motpow, repdet, trapdet, reppow, trappow, bfield, ENDCNC = cnc.cncRamps()

	# Load UVMOT from CNCMOT
	uvfppiezo, uvpow, motpow, repdet, trapdet, reppow, trappow, bfield, ENDUVMOT = uvred.uvcoolRamps(motpow, repdet, trapdet, reppow, trappow, bfield, ENDCNC)

	# Set imaging values
	camera = 'ANDOR'
	motpow, repdet, trapdet, reppow, trappow, maxDT = cnc.imagingRamps_nobfield(motpow, repdet, trapdet, reppow, trappow, camera)

	# Switch bfield to FESHBACH
	overlapdt    = float(report['ODT']['overlapdt'])
	rampdelay    = float(report['FESHBACH']['rampdelay'])
	rampbf       = float(report['FESHBACH']['rampbf'])
	bf           = float(report['FESHBACH']['bf'])
	feshbachdt   = float(report['FESHBACH']['feshbachdt'])
	switchondt  = float(report['FESHBACH']['switchondt'])
	switchdelay  = float(report['FESHBACH']['switchdelay'])
	bias         = float(report['FESHBACH']['bias'])
	biasrampdt   = float(report['FESHBACH']['rampdt'])

	bfield.chop(ENDUVMOT-overlapdt)
	bfield.appendhold(rampdelay)
	bfield.linear( bf, rampbf)
	bfield.extend(ENDUVMOT+feshbachdt)
	bfield.linear(0.0, 0.0)
	ENDBFIELD = feshbachdt
	bfield.appendhold( switchondt + switchdelay)
	bfield.linear(bias,biasrampdt)

	#---Ramp up ODT
	odtpow0 = odt.odt_wave('odtpow', f('ODT','odtpow0'), ss)
	odtpow0.extend(ENDUVMOT)



	#Add waveforms to sequence
	s.analogwfm_add(ss,[ motpow, repdet, trapdet, bfield, reppow, trappow, uvfppiezo, uvpow, odtpow0])
	
	#wait normally rounds down using floor, here the duration is changed before so that
	#the wait is rounded up
	ENDUVMOT = ss*math.ceil(ENDUVMOT/ss)
	
	#insert QUICK pulse  for fast ramping of the field gradient
	s.wait(-10.0)
	quickval = 1 if gen.bstr('CNC',report) == True else 0
	s.digichg('quick',quickval)	
	s.wait(10.0)

	#insert UV pulse
	uvtime  = float(report['UVRED']['uvtime'])
	s.wait(ENDCNC)
	s.digichg('quick',0)
	s.wait(uvtime)
	#Shut down the UVAOM's and open the shutter
	s.wait(-50.0)
	s.digichg('uvaom1',0)
	s.digichg('uvaom2',0)
	s.digichg('uvshutter',1)
	s.wait(50.0)
	#Turn on UVAOM
	s.digichg('uvaom1',1)
	s.wait(-uvtime - ENDCNC)
	
	#Go to MOT release time and set QUICK back to low
	s.wait(ENDUVMOT)
	s.digichg('quick',0)

	#CAREFUL: State transfer should be programmed in uvred.py, as it is done un uvmot.py
	s.digichg('uvaom1',0)


	#RELEASE FROM MOT
	waitshutter=5.0
	s.wait(waitshutter)
	s.digichg('uvshutter',0)
	#~ s.wait(20.0)
	#~ s.digichg('uvaom1',0)
	#~ s.digichg('uvaom2',0)
	#~ s.wait(-20.0)
	s.wait(-waitshutter)

	s.digichg('motswitch',0) 
	s.digichg('motshutter',1)
	s.digichg('field',0)

	#Insert ODT overlap with UVMOT and switch field to FESHBACH
	overlapdt = float(report['ODT']['overlapdt'])
	servodt = float(report['ODT']['servodt'])
	s.wait(-overlapdt-servodt)
	s.digichg('odt7595',1)
	s.wait(servodt)
	s.digichg('odtttl',1)
	#feshbachdt = rampdelay + rampbf + holdbf
	s.wait(overlapdt)
	s.wait( feshbachdt )
	s.digichg('feshbach',1)
	#s.wait(overlapdt - feshbachdt)
	#s.wait( -feshbachdt)
	

	#s.wait(offdelay)
	#s.wait(2*switchdt)
	#s.wait(quickdelay)
	s.wait(switchondt)
	do_quick=1
	s.digichg('field',1)
	s.digichg('hfquick',do_quick)
	s.digichg('quick',do_quick)
	#Can't leave quick ON for more than quickmax
	quickmax=100.
	s.wait(quickmax)
	s.digichg('hfquick',0)
	s.digichg('quick',0)
	s.wait(-quickmax)
	s.wait(switchdelay+biasrampdt)
	s.digichg('quick',0)
	s.wait(-biasrampdt)
	#s.wait(-switchdelay-quickdelay-2*switchdt-offdelay)
	s.wait(-switchdelay - switchondt - feshbachdt - ss)

	#At this point the time sequence is at ENDUVMOT
	
	#This is the time until the end of the bfield ramp
	#toENDBFIELD = biasrampdt + switchdelay + quickdelay + 2*switchdt + offdelay
	toENDBFIELD = biasrampdt + switchdelay + switchondt + feshbachdt
	
	return s, toENDBFIELD 
Example #9
0
def dimple_to_lattice(s,cpowend):
    
    print "----- LATTICE LOADING RAMPS -----"
    
    dt = DL.dt
    tau = DL.tau
    shift = DL.shift
    
    N0 = 0
    
    N = int(math.floor( dt/ DL.ss))
    x = numpy.arange(dt/N, dt, dt/N)
    tau = tau*dt
    shift = dt/2. + shift*dt/2.
    
    # Define how we want to ramp up the lattice depth
    v0_ramp, xy_v0, v0set =  interpolate_ramp( DL.latticeV0)
    
    
    v0  = v0_ramp(x)
    
    #v0 = 0. + DL.latticeV0 * ( (1+numpy.tanh((x-shift)/tau)) - (1+numpy.tanh((-shift)/tau)) )\
    #                    / ( (1+numpy.tanh((dt-shift)/tau)) - (1+numpy.tanh((-shift)/tau)) )
                        
    NH = int(math.floor( DL.dthold/ DL.ss))
    
    v0 = numpy.concatenate(( numpy.zeros(N0), v0, numpy.array(NH*[v0[-1]])  ))
    
    x_v0 = numpy.arange( v0.size )
    x_v0 = x_v0*DL.ss
    
    # Number of samples to keep
    NS = int(math.floor( DL.image / DL.ss))
    if NS > v0.size:
        x_v0 = numpy.append(x_v0, (NS-v0.size)*[x_v0[-1]])
        v0 = numpy.append(v0, (NS-v0.size)*[v0[-1]])
        
    else:
        x_v0 = x_v0[:NS]
        v0 = v0[:NS]
    
    ###########################################
    #### AXIS DEFINITIONS FOR PLOTS ###
    ###########################################    
    
    fig = plt.figure( figsize=(4.5*1.05,8.*1.1))
    ax0 = fig.add_axes( [0.18,0.76,0.76,0.20]) 
    ax2 = fig.add_axes( [0.18,0.645,0.76,0.11])
    ax3 = fig.add_axes( [0.18,0.53,0.76,0.11])
    ax1 = fig.add_axes( [0.18,0.415,0.76,0.11])
    ax5 = fig.add_axes( [0.18,0.30,0.76,0.11])
    ax4 = fig.add_axes( [0.18,0.185,0.76,0.11])
    ax6 = fig.add_axes( [0.18,0.07,0.76,0.11])
    
    lw=1.5
    labelx=-0.12
    legsz =8.
    
    xymew=0.5
    xyms=9

    ax0.plot( x_v0, v0, 'b', lw=2.5, label='Lattice depth')
    ax0.plot(xy_v0[:,0],xy_v0[:,1], 'x', color='blue', ms=5.)
    ax0.plot(v0set[:,0],v0set[:,1], '.', mew=xymew, ms=xyms, color='blue')
    
    
    ###########################################
    #### USER DEFINED RAMPS: IR, GR, and U ###
    ###########################################      
    
    # Define how we want to ramp up the IR power
    ir_ramp, xy_ir, ir =  interpolate_ramp( DL.irpow, yoffset=DIMPLE.ir1pow)
    
    dt_ir = numpy.amax( ir[:,0]) - numpy.amin( ir[:,0])
    N_ir = int(math.floor( dt_ir / DL.ss ))
    x_ir = numpy.arange( dt_ir/N_ir, dt_ir, dt_ir/N_ir)
    
    #y_ir = ir_spline(x_ir) 
    y_ir = ir_ramp(x_ir)
    
    if v0.size > y_ir.size:
        y_ir = numpy.append(y_ir, (v0.size-y_ir.size)*[y_ir[-1]])
    elif v0.size < y_ir.size:
        y_ir = y_ir[0:v0.size]
        
    if v0.size != y_ir.size:
        msg = "IRPOW ERROR: number of samples in IR ramp and V0 ramp does not match!"
        errormsg.box('LATTICE LOADING ERROR',msg)
        exit(1)
        
    
    if (v0 > y_ir).any():
        msg = "IRPOW ERROR:  not enough power to get desired lattice depth"
        print msg
        bad = numpy.where( v0 > y_ir)
        msg = msg + "\nFirst bad sample = %d out of %d" % (bad[0][0], v0.size)
        msg = msg + "\n v0 = %f " %   v0[ bad[0][0] ]
        msg = msg + "\n ir = %f " % y_ir[ bad[0][0] ]
        print v0[bad[0][0]]
        print y_ir[bad[0][0]]
        errormsg.box('LATTICE LOADING ERROR',msg)
        exit(1)
    
    ax0.plot(xy_ir[:,0],xy_ir[:,1], 'x', color='darkorange', ms=5.)
    ax0.plot(ir[:,0],ir[:,1], '.', mew=xymew, ms=xyms, color='darkorange')
    ax0.plot(x_v0, y_ir, lw=lw, color='darkorange',label='irpow')
    
    
    # Define how we want to ramp up the GR power
    gr_ramp, xy_gr, gr =  interpolate_ramp( DL.grpow, yoffset=DIMPLE.gr1pow)
    
    dt_gr = numpy.amax( gr[:,0]) - numpy.amin( gr[:,0])
    N_gr = int(math.floor( dt_gr / DL.ss ))
    x_gr = numpy.arange( dt_gr/N_gr, dt_gr, dt_gr/N_gr)
    
    y_gr = gr_ramp(x_gr) 
    
    if v0.size > y_gr.size:
        y_gr = numpy.append(y_gr, (v0.size-y_gr.size)*[y_gr[-1]])
    elif v0.size < y_gr.size:
        y_gr = y_gr[0:v0.size]
        
    if v0.size != y_gr.size:
        msg = "GRPOW ERROR: number of samples in GR ramp and V0 ramp does not match!"
        errormsg.box('LATTICE LOADING ERROR',msg)
        exit(1)


    ax0.plot(xy_gr[:,0],xy_gr[:,1], 'x', color='green', ms=5.)
    ax0.plot(gr[:,0],gr[:,1],'.', mew=xymew, ms=xyms, color='green')#, label='grpow dat')
    ax0.plot(x_v0, y_gr, lw=lw, color='green', label='grpow')
    
    ax0.set_xlim(left=-10., right= ax0.get_xlim()[1]*1.1)   
    plt.setp( ax0.get_xticklabels(), visible=False)
    ylim = ax0.get_ylim()
    extra = (ylim[1]-ylim[0])*0.1
    ax0.set_ylim( ylim[0]-extra, ylim[1]+extra )
    ax0.grid(True)
    ax0.set_ylabel('$E_{r}$',size=16, labelpad=0)
    ax0.yaxis.set_label_coords(labelx, 0.5)
    ax0.set_title('Lattice Loading')
    ax0.legend(loc='best',numpoints=1,prop={'size':legsz*0.8})
    
    
    # Define how we want to ramp up the scattering length (control our losses)
    a_s_ramp, xy_a_s, a_s =  interpolate_ramp( DL.a_s)
    
    
    dt_a_s = numpy.amax( a_s[:,0]) - numpy.amin( a_s[:,0])
    N_a_s = int(math.floor( dt_a_s / DL.ss ))
    x_a_s = numpy.arange( dt_a_s/N_a_s, dt_a_s, dt_a_s/N_a_s)
    y_a_s = a_s_ramp(x_a_s)
    
    if v0.size > y_a_s.size:
        y_a_s = numpy.append(y_a_s, (v0.size-y_a_s.size)*[y_a_s[-1]])
    elif v0.size < y_a_s.size:
        y_a_s = y_a_s[0:v0.size]
        
    if v0.size != y_a_s.size:
        msg = "a_s ERROR: number of samples in a_s ramp and V0 ramp does not match!"
        errormsg.box('LATTICE LOADING ERROR',msg)
        exit(1)
    
    
    
    ax1.plot(xy_a_s[:,0],xy_a_s[:,1]/100., 'x', color='#C10087', ms=5.)
    ax1.plot(a_s[:,0],a_s[:,1]/100., '.', mew=xymew, ms=xyms, color='#C10087')
    ax1.plot(x_v0, y_a_s/100., lw=lw, color='#C10087', label=r'$a_s\mathrm{(100 a_{0})}$')
    ax1.set_ylabel(r'$a_s\mathrm{(100 a_{0})}$',size=16, labelpad=0)
    ax1.yaxis.set_label_coords(labelx, 0.5)

    
    ax1.set_xlim( ax0.get_xlim()) 
    ylim = ax1.get_ylim()
    extra = (ylim[1]-ylim[0])*0.1
    ax1.set_ylim( ylim[0]-extra, ylim[1]+extra )
    plt.setp( ax1.get_xticklabels(), visible=False)
    ax1.grid(True)
    ax1.legend(loc='best',numpoints=1,prop={'size':legsz})
    

    #######################################################################
    #### CALCULATED RAMPS:  ALPHA, TUNNELING, SCATTERING LENGTH, BFIELD ###
    #######################################################################
    
    alpha = (v0/y_ir)**2.
    
    alpha_advance = 100.
    N_adv = int(math.floor( alpha_advance / DL.ss))
    
    alpha_desired = numpy.copy(alpha)
    
    if N_adv < v0.size:
        alpha = alpha[N_adv:]
        alpha = numpy.append(alpha, (v0.size-alpha.size)*[alpha[-1]])
    else:
        alpha = numpy.array( v0.size*[alpha[-1]] )
    
    
    
    ax2.plot( x_v0, alpha, lw=lw, color='saddlebrown', label='alpha adv')
    ax2.plot( x_v0, alpha_desired,':', lw=lw, color='saddlebrown', label='alpha')
    
    ax2.set_xlim( ax0.get_xlim()) 
    ax2.set_ylim(-0.05,1.05)
    plt.setp( ax2.get_xticklabels(), visible=False)
    ax2.grid()
    ax2.set_ylabel('$\\alpha$',size=16, labelpad=0)
    ax2.yaxis.set_label_coords(labelx, 0.5)
    
    ax2.legend(loc='best',numpoints=1,prop={'size':legsz})
    
    
    tunneling_Er  = physics.inv('t_to_V0', v0)
    tunneling_kHz = tunneling_Er * 29.2
    
    ax3.plot( x_v0, tunneling_kHz, lw=lw, color='red', label='$t$ (kHz)')
    
    ax3.set_xlim( ax0.get_xlim()) 
    ylim = ax3.get_ylim()
    extra = (ylim[1]-ylim[0])*0.1
    ax3.set_ylim( ylim[0]-extra, ylim[1]+extra )
    plt.setp( ax3.get_xticklabels(), visible=False)
    ax3.grid(True)
    ax3.set_ylabel(r'$t\,\mathrm{(kHz)}$',size=16, labelpad=0)
    ax3.yaxis.set_label_coords(labelx, 0.5)
    ax3.legend(loc='best',numpoints=1,prop={'size':legsz})

    
    wannierF = physics.inv('wF_to_V0', v0)
     
    bohrRadius = 5.29e-11 #meters
    lattice_spacing = 1.064e-6 / 2. #meters
    
    bfieldG = physics.cnv('as_to_B', y_a_s)
    
    U_over_t = y_a_s * bohrRadius / lattice_spacing * wannierF / tunneling_Er
    
    
    
    
    ax4.plot( x_v0, U_over_t, lw=lw, color='k', label=r'$U/t$')
    
    ax4.set_xlim( ax0.get_xlim()) 
    ylim = ax4.get_ylim()
    extra = (ylim[1]-ylim[0])*0.1
    ax4.set_ylim( ylim[0]-extra, ylim[1]+extra )
    plt.setp( ax4.get_xticklabels(), visible=False)
    ax4.grid(True)
    ax4.set_ylabel(r'$U/t$',size=16, labelpad=0)
    ax4.yaxis.set_label_coords(labelx, 0.5)
    
    ax4.legend(loc='best',numpoints=1,prop={'size':legsz})
    
    
    ax5.plot( x_v0, bfieldG, lw=lw, color='purple', label='$B$ (G)')
    
    ax5.set_xlim( ax0.get_xlim()) 
    ylim = ax5.get_ylim()
    extra = (ylim[1]-ylim[0])*0.1
    ax5.set_ylim( ylim[0]-extra, ylim[1]+extra )
    ax5.grid(True)
    plt.setp( ax5.get_xticklabels(), visible=False)
    ax5.set_ylabel(r'$B\,\mathrm{(G)}$',size=16, labelpad=0)
    ax5.yaxis.set_label_coords(labelx, 0.5)
    
    
    ax5.legend(loc='best',numpoints=1,prop={'size':legsz})
    
    
    ax6.plot( x_v0, (tunneling_Er / U_over_t), lw=lw, color='#25D500', label=r'$t^{2}/U\,(E_{r)}$')
    #ax6.set_yscale('log')
    
    ax6.set_xlim( ax0.get_xlim()) 
    ylim = ax6.get_ylim()
    extra = (ylim[1]-ylim[0])*0.1
    ax6.set_ylim( ylim[0]*0.5, ylim[1] )
    ax6.grid(True)
    ax6.set_ylabel(r'$t^{2}/U\,(E_{r)}$',size=16, labelpad=0)
    ax6.yaxis.set_label_coords(labelx, 0.5)
    
    
    ax6.legend(loc='best',numpoints=1,prop={'size':legsz})
    
    ax6.set_xlabel('time (ms)')

    figfile = seqconf.seqtxtout().split('.')[0]+'_latticeRamp.png'    
    plt.savefig(figfile , dpi=120 )
    
    #Save all ramps to a txt file for later plotting. 
    datfile = seqconf.seqtxtout().split('.')[0]+'_latticeRamp.dat'
    allRamps = numpy.transpose(numpy.vstack((x_v0, v0, y_ir, y_gr, y_a_s, alpha, alpha_desired, \
                                    tunneling_kHz, U_over_t, bfieldG)))
    header = '# Column index'
    header = header + '\n#\t0\t' + 'time(ms)'
    header = header + '\n#\t1\t' + 'Lattice Depth (Er)'
    header = header + '\n#\t2\t' + 'Ir power (Er)'
    header = header + '\n#\t3\t' + 'GR power (Er)'
    header = header + '\n#\t4\t' + 'a_s (a0)'
    header = header + '\n#\t5\t' + 'alpha - advance'
    header = header + '\n#\t6\t' + 'alpha - desired'
    header = header + '\n#\t7\t' + 'tunneling (kHz)'
    header = header + '\n#\t8\t' + 'U/t'
    header = header + '\n#\t9\t' + 'bfield (Gauss)'
    header = header + '\n'
    
    #numpy.savetxt( datfile, allRamps)
    
    with open(datfile, 'w') as f:
        X = numpy.asarray( allRamps )
        f.write(bytes(header))
        
        format = '%.6e'
        ncol = X.shape[1]
        format = [format ,] *ncol
        format = ' '.join(format)
        
        newline = '\n'
        for row in X:
            f.write(numpy.compat.asbytes(format % tuple(row) + newline))

    
    shutil.copyfile( figfile,  seqconf.savedir() + 'expseq' + seqconf.runnumber() + '_latticeRamp.png')
    #plt.savefig( seqconf.savedir() + 'expseq' + seqconf.runnumber() + '_latticeRamp.png', dpi=120)
    
    
    #################################
    #### APPEND RAMPS TO SEQUENCE ###
    #################################
    
    wfms=[]
    
    for ch in ['ir1pow','ir2pow','ir3pow']:
        n = filter( str.isdigit, ch)[0] 
        w = wfm.wave(ch, 0.0, DL.ss)  #Start value will be overrriden
        w.y = physics.cnv( ch, y_ir )
        wfms.append(w)
        
    for ch in ['greenpow1','greenpow2','greenpow3']:
        n = filter( str.isdigit, ch)[0] 
        w = wfm.wave(ch, 0.0, DL.ss)  #Start value will be overrriden
        w.y = physics.cnv( ch, y_gr )
        wfms.append(w)
        
    for ch in ['lcr1','lcr2','lcr3']:
        n = filter( str.isdigit, ch)[0] 
        w = wfm.wave(ch, 0.0, DL.ss)  #Start value will be overrriden
        w.y = physics.cnv( ch, alpha )
        wfms.append(w)
    

    
    bfieldA = bfieldG/6.8
    
    ##ADD field
    bfield = wfm.wave('bfield', 0.0, DL.ss)
    bfield.y = physics.cnv( 'bfield', bfieldA)
    wfms.append(bfield)
    
    
    ##ADD gradient field
    gradient = gradient_wave('gradientfield', 0.0, DL.ss,volt = 0.0)
    gradient.follow(bfield)
    wfms.append(gradient)
    
    
    buffer = 20.
    s.wait(buffer)
    
    
    odtpow = odt.odt_wave('odtpow', cpowend, DL.ss)
    if DIMPLE.odt_t0 > buffer :
        odtpow.appendhold( DIMPLE.odt_t0 - buffer)
    if DIMPLE.odt_pow < 0.:
        odtpow.appendhold( DIMPLE.odt_dt)
    else:
        odtpow.tanhRise( DIMPLE.odt_pow, DIMPLE.odt_dt, DIMPLE.odt_tau, DIMPLE.odt_shift)    
        
    if numpy.absolute(DIMPLE.odt_pow) < 0.0001:
        s.wait( odtpow.dt() )
        s.digichg('odtttl',0)
        s.wait(-odtpow.dt() )
    
    wfms.append(odtpow)
        
    
    # RF sweep
    if DL.rf == 1:   
        rfmod  = wfm.wave('rfmod', 0., DL.ss)
        rfmod.appendhold( bfield.dt() + DL.rftime )
        rfmod.linear( DL.rfvoltf, DL.rfpulsedt)
        wfms.append(rfmod)
        
        
    # Kill hfimg
    if DL.probekill ==1 or DL.braggkill ==1:
        hfimgdelay = 40. #ms
        analogimg = wfm.wave('analogimg', ANDOR.hfimg, DL.ss)
        
        if DL.probekill == 1:
            if (-DL.probekilltime+hfimgdelay) < DL.image:
                analogimg.appendhold( bfield.dt() + DL.probekilltime - hfimgdelay)
                analogimg.linear( DL.probekill_hfimg , 0.0)
                analogimg.appendhold( hfimgdelay + DL.probekilldt + 3*DL.ss)
        
        elif DL.braggkill == 1:
            if (-DL.probekilltime+hfimgdelay) < DL.image:
                analogimg.appendhold( bfield.dt() + DL.braggkilltime - hfimgdelay)
                analogimg.linear( DL.braggkill_hfimg , 0.0)
                analogimg.appendhold( hfimgdelay + DL.braggkilldt + 3*DL.ss)
            
        analogimg.linear( ANDOR.hfimg, 0.)
        print "USING EXTEND BFIELD"
        analogimg.extend(bfield.dt())
        wfms.append(analogimg)
    
        
    bfieldG = physics.inv( 'bfield', bfield.y[-1]) * 6.8
    hfimg0 = -1.*(100.0 + 163.7 - 1.414*bfieldG)
    
    
    #analogimg = bfieldwfm.hfimg_wave('analogimg', ANDOR.hfimg, DL.ss)
    #andorhfimg0 = analogimg.follow(bfield, DL.imgdet)
    #wfms.append(analogimg)
    
    print "...ANDOR:hfimg and hfimg0 will be modified  in report\n"
    print "\tNEW  ANDOR:hfimg  = %.2f MHz" % ( hfimg0 - DL.imgdet)
    print "\tNEW  ANDOR:hfimg0 = %.2f MHz\n" %  hfimg0
    gen.save_to_report('ANDOR','hfimg', hfimg0 - DL.imgdet)
    gen.save_to_report('ANDOR','hfimg0', hfimg0)
            
    
    duration = s.analogwfm_add(DL.ss,wfms)
    
        
    s.wait( duration )
    
    
    ### Figure out when to turn interlock back on, using alpha information
    #~ if duration > DL.t0 + DL.dt:
        #~ s.wait(-DL.lattice_interlock_time)
        #~ if DL.use_lattice_interlock == 1:
            #~ s.digichg('latticeinterlockbypass',0)
        #~ else:
            #~ s.digichg('latticeinterlockbypass',1)
        #~ s.wait( DL.lattice_interlock_time)
    
    
    return s 
                        

    
    
stepsize    =float(report['SEQ']['stepsize'])
tof         =float(report['BASLER']['tof'])
preexp      =float(report['BASLER']['preexp'])
texp        =float(report['BASLER']['exp'])
postexp     =float(report['BASLER']['postexp'])


#SEQUENCE
s=seq.sequence(stepsize)

s=gen.initial(s)
if UVSEC.odt == 1:
    s.digichg('odtttl', 1)
    odtss = 0.1
    from odt import odt_wave, ipg_wave 
    odtpow  = odt_wave('odtpow',  None, odtss, volt=10.0)
    ipganalog = ipg_wave('ipganalog', 10., odtss)
    odtpow.appendhold(5.0) 
    ipganalog.appendhold(10.0)
    s.analogwfm_add( odtss, [odtpow,ipganalog])

s.wait(20.0)
s, duration = uvmot.run(s,'BASLER')

#RELEASE FROM MOT
s.digichg('motswitch',0) 
s.digichg('uvshutter',0)
s.digichg('field',0)

s.wait(tof)