def odt_evap_patch(): odtpow = odt_wave('odtpow', p0, evap_ss) ### SELECT EVAP TRAJECTORY HERE### finalcpow = odtpow.Evap6(\ EVAP.patch_cuttime, \ EVAP.patch_m, \ EVAP.patch_y, \ EVAP.patch_t0, \ EVAP.patch_kink1, \ EVAP.patch_kink2, \ EVAP.patch_m_t0, \ EVAP.patch_m_t0_2, \ EVAP.image) #Here, go ahead and save the finalcpow to the report gen.save_to_report('EVAP','finalcpow', finalcpow) #---Setup ipganalog ramp ipganalog = ipg_wave('ipganalog', 10., EVAP.evapss) if ODT.use_servo == 0: ipganalog.extend( odtpow.dt() ) elif ODT.use_servo == 1: ipganalog.follow( odtpow ) maxDT = odtpow.dt() return odtpow, maxDT, finalcpow, ipganalog
def odt_evap(scale=1.0): odtpow = odt_wave('odtpow', ODT.p0, ODT.evapss) ### SELECT EVAP TRAJECTORY HERE### finalcpow = odtpow.Evap8(\ ODT.odtpow, \ EVAP.p1, \ EVAP.t1, EVAP.tau, \ EVAP.beta, \ EVAP.offset, \ EVAP.t2, \ EVAP.tau2, \ EVAP.smoothdt, \ EVAP.image, \ EVAP.scale \ ) #---Here, go ahead and save the finalcpow to the report gen.save_to_report('EVAP','finalcpow', finalcpow) #---Setup ipganalog ramp ipganalog = ipg_wave('ipganalog', 10., evap_ss) if ODT.use_servo == 0: ipganalog.extend( odtpow.dt() ) elif ODT.use_servo == 1: ipganalog.follow( odtpow ) maxDT = odtpow.dt() return odtpow, maxDT, finalcpow, ipganalog
def Evap8(self, p0, p1, t1, tau, beta, offset, t2, tau2, smoothdt, duration,scale = 1.0): """Evaporation ramp v8 same as v7 with scale""" if True: print "" print "----- EVAPORATION RAMP Version 8-----" if duration <=0: return else: N=int(round(duration*scale/self.ss)) print '\t...Evap nsteps = ' + str(N) ramp_phys=numpy.array([]) ramp=numpy.array([]) hashbase = '' hashbase = hashbase + '%.s' % self.name hashbase = hashbase + '%.8f' % self.ss hashbase = hashbase + '%.8f' % duration hashbase = hashbase + '%.8f' % p0 hashbase = hashbase + '%.8f' % p1 hashbase = hashbase + '%.8f' % t1 hashbase = hashbase + '%.8f' % tau hashbase = hashbase + '%.8f' % beta hashbase = hashbase + '%.8f' % offset hashbase = hashbase + '%.8f' % t2 hashbase = hashbase + '%.8f' % tau2 hashbase = hashbase + '%.8f' % smoothdt hashbase = hashbase + '%.8f' % scale ramphash = seqconf.ramps_dir() +'Evap8_' \ + hashlib.md5( hashbase).hexdigest() #Here, go ahead and save the trajectory path to the report gen.save_to_report('EVAP','ramp', ramphash+'_phys') if not os.path.exists(ramphash) or True: print '\t...Making new Evap8 ramp' for xi in range(N): t = (xi+1)*self.ss/scale phys = evap.v6(t,p0,p1,t1,tau,beta, offset,t2,tau2,smoothdt) volt = physics.cnv( 'odtpow', phys) ramp_phys = numpy.append( ramp_phys, [ phys]) ramp = numpy.append( ramp, numpy.around([ volt],decimals=4)) ramp_phys.tofile(ramphash+'_phys',sep='\n',format="%.4f") #ramp.tofile(ramphash,sep=',',format="%.4f") else: print '\t...Recycling previously calculated Evap8 ramp' ramp = numpy.fromfile(ramphash,sep=',') self.y=numpy.append(self.y,ramp) #This returns the last value of the ramp print "" return evap.v6(N*self.ss/scale,p0,p1,t1,tau,beta,offset,t2,tau2,smoothdt)
def odt_evap_field_free(toENDBFIELD, scale =1.0): odtfree = EVAP.free - EVAP.buffer - toENDBFIELD #---Setup ODT ramp odtpow = odt_wave('odtpow', ODT.odtpow, EVAP.evapss) odtpow.appendhold( odtfree ) #image = DIMPLE.image if DIMPLE.image <= EVAP.image else EVAP.image image = DIMPLE.image ### SELECT EVAP TRAJECTORY HERE### finalcpow = odtpow.Evap8(\ ODT.odtpow, \ EVAP.p1, \ EVAP.t1, EVAP.tau, \ EVAP.beta, \ EVAP.offset, \ EVAP.t2, \ EVAP.tau2, \ EVAP.smoothdt, \ image, \ EVAP.scale \ ) #Here, go ahead and save the finalcpow to the report gen.save_to_report('EVAP','finalcpow', finalcpow) #---Setup field ramp and shunt ramp field_ramp_time = EVAP.fieldrampt0*scale field_ramp_dt = EVAP.fieldrampdt*scale print '\t...Making new Evap_field' bfield = wfm.wave('bfield', FB.bias, EVAP.evapss) bfield.extend(field_ramp_time + odtfree) bfield.linear(EVAP.fieldrampfinal,field_ramp_dt) if((field_ramp_time+field_ramp_dt)<image*scale): bfield.extend(image*scale) else: bfield.chop(image*scale) #---Setup ipganalog ramp ipganalog = ipg_wave('ipganalog', 10., EVAP.evapss) if ODT.use_servo == 0: ipganalog.extend( odtpow.dt() ) elif ODT.use_servo == 1: if ODT.ipgfollow == 1: ipganalog.follow( odtpow ,ODT.ipgmin) else: ipganalog.extend( odtpow.dt() ) maxDT = odtpow.dt() return bfield, odtpow, maxDT, finalcpow, ipganalog
def Evap7(self, p0, p1, t1, tau, beta, offset, t2, tau2, smoothdt, duration): """Evaporation ramp v7 same as v4 except with smooth kink""" if True: print "" print "----- EVAPORATION RAMP Version 7-----" print "\tp0 = %.4f" % p0 print "\tp1 = %.4f" % p1 print "\tt1 = %.4f" % t1 print "\ttau = %.4f" % tau print "\tbeta = %.4f" % beta print "\toffset = %.4f" % offset print "\tt2 = %.4f" % t2 print "\ttau2 = %.4f" % tau2 print "\tduration = %.4f" % duration if duration <= 0: return else: N = int(round(duration / self.ss)) print '\t...Evap nsteps = ' + str(N) ramp_phys = [] ramp = [] hashbase = '%.8f,%.8f,%.8f,%.8f,%.8f,%.8f,%s,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f ' \ % ( b,m1,m2,m3,kink1,kink2, self.name, self.ss, duration, p0, p1, t1, tau, beta, offset, t2, tau2,smoothdt) ramphash = seqconf.ramps_dir() +'Evap7_' \ + hashlib.md5( hashbase).hexdigest() #Here, go ahead and save the trajectory path to the report gen.save_to_report('EVAP', 'ramp', ramphash + '_phys') if not os.path.exists(ramphash): print '\t...Making new Evap7 ramp' for xi in range(N): t = (xi + 1) * self.ss phys = evap.v6(t, p0, p1, t1, tau, beta, offset, t2, tau2, smoothdt) volt = OdtpowConvert(phys) ramp_phys = numpy.append(ramp_phys, [phys]) ramp = numpy.append(ramp, [volt]) ramp_phys.tofile(ramphash + '_phys', sep='\n', format="%.4f") ramp.tofile(ramphash, sep=',', format="%.4f") else: print '\t...Recycling previously calculated Evap7 ramp' ramp = numpy.fromfile(ramphash, sep=',') self.y = numpy.append(self.y, ramp) #This returns the last value of the ramp print "" return evap.v6(N * self.ss, p0, p1, t1, tau, beta, offset, t2, tau2, smoothdt)
def Evap7(self, p0, p1, t1, tau, beta, offset, t2, tau2, smoothdt, duration): """Evaporation ramp v7 same as v4 except with smooth kink""" if True: print "" print "----- EVAPORATION RAMP Version 7-----" print "\tp0 = %.4f" % p0 print "\tp1 = %.4f" % p1 print "\tt1 = %.4f" % t1 print "\ttau = %.4f" % tau print "\tbeta = %.4f" % beta print "\toffset = %.4f" % offset print "\tt2 = %.4f" % t2 print "\ttau2 = %.4f" % tau2 print "\tduration = %.4f" % duration if duration <=0: return else: N=int(round(duration/self.ss)) print '\t...Evap nsteps = ' + str(N) ramp_phys=[] ramp=[] hashbase = '%.8f,%.8f,%.8f,%.8f,%.8f,%.8f,%s,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f ' \ % ( b,m1,m2,m3,kink1,kink2, self.name, self.ss, duration, p0, p1, t1, tau, beta, offset, t2, tau2,smoothdt) ramphash = seqconf.ramps_dir() +'Evap7_' \ + hashlib.md5( hashbase).hexdigest() #Here, go ahead and save the trajectory path to the report gen.save_to_report('EVAP','ramp', ramphash+'_phys') if not os.path.exists(ramphash): print '\t...Making new Evap7 ramp' for xi in range(N): t = (xi+1)*self.ss phys = evap.v6(t,p0,p1,t1,tau,beta, offset,t2,tau2,smoothdt) volt = OdtpowConvert(phys) ramp_phys = numpy.append( ramp_phys, [ phys]) ramp = numpy.append( ramp, [ volt]) ramp_phys.tofile(ramphash+'_phys',sep='\n',format="%.4f") ramp.tofile(ramphash,sep=',',format="%.4f") else: print '\t...Recycling previously calculated Evap7 ramp' ramp = numpy.fromfile(ramphash,sep=',') self.y=numpy.append(self.y,ramp) #This returns the last value of the ramp print "" return evap.v6(N*self.ss,p0,p1,t1,tau,beta,offset,t2,tau2,smoothdt)
def Evap6(self, cut_time, m, y, t0, kink1, kink2, m_t0_1, m_t0_2, duration): """Evaporation ramp v6""" if True: print "" print "----- EVAPORATION RAMP Version 6-----" print "\tm = %.4f" % m print "\ty = %.4f" % y print "\tt0 = %.4f" % t0 if duration <= 0: return else: N = int(round(duration / self.ss)) print '\t...Evap nsteps = ' + str(N) ramp_phys = [] ramp = [] hashbase = '%.8f,%.8f,%.8f,%.8f,%.8f,%.8f,%s,%.3f,%.3f,%.3f,%.3f,%.3f ' \ % ( b,m1,m2,m3,kink1,kink2, self.name, self.ss, duration, m,y,t0) ramphash = seqconf.ramps_dir() +'Evap6_1560' \ + hashlib.md5( hashbase).hexdigest() #Here, go ahead and save the trajectory path to the report gen.save_to_report('EVAP', 'ramp', ramphash + '_phys') #if not os.path.exists(ramphash): if True: print '\t...Making new Evap6 ramp' for xi in range(N): t = (xi + 1) * self.ss phys = evap.v5(cut_time, m, y, t0, kink1, kink2, m_t0_1, m_t0_2, t) volt = OdtpowConvert(phys) ramp_phys = numpy.append(ramp_phys, [phys]) ramp = numpy.append(ramp, [volt]) ramp_phys.tofile(ramphash + '_phys', sep='\n', format="%.4f") ramp.tofile(ramphash, sep=',', format="%.4f") else: print '\t...Recycling previously calculated Evap6 ramp' ramp = numpy.fromfile(ramphash, sep=',') self.y = numpy.append(self.y, ramp) #This returns the last value of the ramp print "" return evap.v5(cut_time, m, y, t0, kink1, kink2, m_t0_1, m_t0_2, N * self.ss)
def Evap6(self,cut_time,m,y,t0,kink1,kink2,m_t0_1,m_t0_2,duration): """Evaporation ramp v6""" if True: print "" print "----- EVAPORATION RAMP Version 6-----" print "\tm = %.4f" % m print "\ty = %.4f" % y print "\tt0 = %.4f" % t0 if duration <=0: return else: N=int(round(duration/self.ss)) print '\t...Evap nsteps = ' + str(N) ramp_phys=[] ramp=[] hashbase = '%.8f,%.8f,%.8f,%.8f,%.8f,%.8f,%s,%.3f,%.3f,%.3f,%.3f,%.3f ' \ % ( b,m1,m2,m3,kink1,kink2, self.name, self.ss, duration, m,y,t0) ramphash = seqconf.ramps_dir() +'Evap6_1560' \ + hashlib.md5( hashbase).hexdigest() #Here, go ahead and save the trajectory path to the report gen.save_to_report('EVAP','ramp', ramphash+'_phys') #if not os.path.exists(ramphash): if True: print '\t...Making new Evap6 ramp' for xi in range(N): t = (xi+1)*self.ss phys = evap.v5(cut_time,m,y,t0,kink1,kink2,m_t0_1,m_t0_2,t) volt = OdtpowConvert(phys) ramp_phys = numpy.append( ramp_phys, [ phys]) ramp = numpy.append( ramp, [ volt]) ramp_phys.tofile(ramphash+'_phys',sep='\n',format="%.4f") ramp.tofile(ramphash,sep=',',format="%.4f") else: print '\t...Recycling previously calculated Evap6 ramp' ramp = numpy.fromfile(ramphash,sep=',') self.y=numpy.append(self.y,ramp) #This returns the last value of the ramp print "" return evap.v5(cut_time,m,y,t0,kink1,kink2,m_t0_1,m_t0_2,N*self.ss)
def odt_evap(image, scale=1.0): evap_ss = f('EVAP', 'evapss') p0 = f('ODT', 'odtpow') p1 = f('EVAP', 'p1') t1 = f('EVAP', 't1') tau = f('EVAP', 'tau') beta = f('EVAP', 'beta') offset = f('EVAP', 'offset') t2 = f('EVAP', 't2') tau2 = f('EVAP', 'tau2') smoothdt = f('EVAP', 'smoothdt') odtpow = odt_wave('odtpow', p0, evap_ss) #odtpow.Evap(p0, p1, t1, tau, beta, image) #odtpow.Evap2(p0, p1, t1, tau, beta, offset, t2, tau2, image) #odtpow.Evap3(p0, p1, t1, tau, beta, offset, t2, tau2, image) ### SELECT EVAP TRAJECTORY HERE### finalcpow = odtpow.Evap8(p0, p1, t1, tau, beta, offset, t2, tau2, smoothdt, image, scale) #Here, go ahead and save the finalcpow to the report gen.save_to_report('EVAP', 'finalcpow', finalcpow) #ipganalog starts out at full power ipganalog = ipg_wave('ipganalog', 10., evap_ss) if f('ODT', 'use_servo') == 0: ipganalog.extend(odtpow.dt()) elif f('ODT', 'use_servo') == 1: ipganalog.follow(odtpow) #~ ipganalog.follow( odtpow ) #~ odtpow.Exponential(pow0,powf,evap_dt,tau) #~ odtpow.linear( powf, evap_ss) #~ odtpow.appendhold( evap_dt) maxDT = odtpow.dt() return odtpow, maxDT, finalcpow, ipganalog
def odt_evap(image,scale=1.0): evap_ss = f('EVAP','evapss') p0 = f('ODT','odtpow') p1 = f('EVAP','p1') t1 = f('EVAP','t1') tau = f('EVAP','tau') beta = f('EVAP','beta') offset = f('EVAP','offset') t2 = f('EVAP','t2') tau2 = f('EVAP','tau2') smoothdt = f('EVAP','smoothdt') odtpow = odt_wave('odtpow', p0, evap_ss) #odtpow.Evap(p0, p1, t1, tau, beta, image) #odtpow.Evap2(p0, p1, t1, tau, beta, offset, t2, tau2, image) #odtpow.Evap3(p0, p1, t1, tau, beta, offset, t2, tau2, image) ### SELECT EVAP TRAJECTORY HERE### finalcpow = odtpow.Evap8(p0, p1, t1, tau, beta, offset, t2, tau2,smoothdt,image,scale) #Here, go ahead and save the finalcpow to the report gen.save_to_report('EVAP','finalcpow', finalcpow) #ipganalog starts out at full power ipganalog = ipg_wave('ipganalog', 10., evap_ss) if f('ODT','use_servo') == 0: ipganalog.extend( odtpow.dt() ) elif f('ODT','use_servo') == 1: ipganalog.follow( odtpow ) #~ ipganalog.follow( odtpow ) #~ odtpow.Exponential(pow0,powf,evap_dt,tau) #~ odtpow.linear( powf, evap_ss) #~ odtpow.appendhold( evap_dt) maxDT = odtpow.dt() return odtpow, maxDT, finalcpow, ipganalog
def odt_evap_patch(image): evap_ss = f('EVAP', 'evapss') p0 = f('ODT', 'odtpow') m = f('EVAP', 'patch_m') y1 = f('EVAP', 'patch_y') t0 = f('EVAP', 'patch_t0') cut_time = f('EVAP', 'patch_cuttime') m_t0 = f('EVAP', 'patch_m_t0') kink1 = f('EVAP', 'patch_kink1') m_t0_1 = f('EVAP', 'patch_m_t0') kink2 = f('EVAP', 'patch_kink2') m_t0_2 = f('EVAP', 'patch_m_t0_2') odtpow = odt_wave('odtpow', p0, evap_ss) #odtpow.Evap(p0, p1, t1, tau, beta, image) #odtpow.Evap2(p0, p1, t1, tau, beta, offset, t2, tau2, image) #odtpow.Evap3(p0, p1, t1, tau, beta, offset, t2, tau2, image) ### SELECT EVAP TRAJECTORY HERE### finalcpow = odtpow.Evap6(cut_time, m, y1, t0, kink1, kink2, m_t0_1, m_t0_2, image) #Here, go ahead and save the finalcpow to the report gen.save_to_report('EVAP', 'finalcpow', finalcpow) #ipganalog starts out at full power ipganalog = ipg_wave('ipganalog', 10., evap_ss) if f('ODT', 'use_servo') == 0: ipganalog.extend(odtpow.dt()) elif f('ODT', 'use_servo') == 1: ipganalog.follow(odtpow) #~ ipganalog.follow( odtpow ) #~ odtpow.Exponential(pow0,powf,evap_dt,tau) #~ odtpow.linear( powf, evap_ss) #~ odtpow.appendhold( evap_dt) maxDT = odtpow.dt() return odtpow, maxDT, finalcpow, ipganalog
def odt_evap_patch(image): evap_ss = f('EVAP','evapss') p0 = f('ODT','odtpow') m = f('EVAP','patch_m') y1 = f('EVAP','patch_y') t0 = f('EVAP','patch_t0') cut_time = f('EVAP','patch_cuttime') m_t0 = f('EVAP','patch_m_t0') kink1= f('EVAP','patch_kink1') m_t0_1 = f('EVAP','patch_m_t0') kink2= f('EVAP','patch_kink2') m_t0_2 = f('EVAP','patch_m_t0_2') odtpow = odt_wave('odtpow', p0, evap_ss) #odtpow.Evap(p0, p1, t1, tau, beta, image) #odtpow.Evap2(p0, p1, t1, tau, beta, offset, t2, tau2, image) #odtpow.Evap3(p0, p1, t1, tau, beta, offset, t2, tau2, image) ### SELECT EVAP TRAJECTORY HERE### finalcpow = odtpow.Evap6(cut_time,m,y1,t0,kink1,kink2,m_t0_1,m_t0_2,image) #Here, go ahead and save the finalcpow to the report gen.save_to_report('EVAP','finalcpow', finalcpow) #ipganalog starts out at full power ipganalog = ipg_wave('ipganalog', 10., evap_ss) if f('ODT','use_servo') == 0: ipganalog.extend( odtpow.dt() ) elif f('ODT','use_servo') == 1: ipganalog.follow( odtpow ) #~ ipganalog.follow( odtpow ) #~ odtpow.Exponential(pow0,powf,evap_dt,tau) #~ odtpow.linear( powf, evap_ss) #~ odtpow.appendhold( evap_dt) maxDT = odtpow.dt() return odtpow, maxDT, finalcpow, ipganalog
DIMPLE = gen.getsection('DIMPLE') EVAP = gen.getsection('EVAP') FB = gen.getsection('FESHBACH') ZC = gen.getsection('ZEROCROSS') ANDOR = gen.getsection('ANDOR') DL = gen.getsection('DIMPLELATTICE') MANTA = gen.getsection('MANTA') LATTICEMOD = gen.getsection('LatticeMod') print "\n...SEQ:camera will be modified in report" print "\tNEW SEQ:camera = %s\n" % ( DL.camera ) # When only use one camera the reading of DL.camera will be a string instead of a list of string. As a consequence we need to check the type. gen.save_to_report('SEQ','camera', DL.camera if type(DL.camera) == type("string") else ",".join(DL.camera)) #SEQUENCE stepsize = float(report['SEQ']['stepsize']) s=seq.sequence(stepsize) s=gen.initial(s) s.digichg('hfimg',1) s.digichg('odt7595',0) #Get hfimg ready s.digichg('hfimg',1) #If using analoghfimg get it ready if ANDOR.analoghfimg == 1:
def odt_evap_field(scale =1.0): field_ramp_time = EVAP.fieldrampt0*scale field_ramp_dt = EVAP.fieldrampdt*scale ramp=[] hashbase = '' hashbase = hashbase + '%.8f' % EVAP.image hashbase = hashbase + '%.8f' % EVAP.evapss hashbase = hashbase + '%.8f' % field_ramp_time hashbase = hashbase + '%.8f' % field_ramp_dt hashbase = hashbase + '%.8f' % FB.bias hashbase = hashbase + '%.8f' % EVAP.fieldrampfinal hashbase = hashbase + '%.8f' % scale hashbase = hashbase + wfm.rawcalibdat( 'bfield' ) #---Here, go ahead and save the trajectory path to the report ramphash = seqconf.ramps_dir() +'Evap_field_withscale'+ hashlib.md5( hashbase).hexdigest() gen.save_to_report('EVAP','ramp_field', ramphash) #---Setup field ramp bfield = wfm.wave('bfield', FB.bias, EVAP.evapss) if not os.path.exists(ramphash) or True: print '\t...Making new Evap_field' bfield.extend(field_ramp_time) bfield.linear(EVAP.fieldrampfinal,field_ramp_dt) if((field_ramp_time+field_ramp_dt)<EVAP.image*scale): bfield.extend(EVAP.image*scale) else: bfield.chop(EVAP.image*scale) ramp = bfield.y #ramp.tofile(ramphash,sep=',',format="%.4f") else: print '\t...Recycling previously calculated Evap_field' ramp = numpy.fromfile(ramphash,sep=',') bfield.y=ramp #---Setup ODT ramp odtpow = odt_wave('odtpow', ODT.odtpow, EVAP.evapss) ### SELECT EVAP TRAJECTORY HERE### finalcpow = odtpow.Evap8(\ ODT.odtpow, \ EVAP.p1, \ EVAP.t1, EVAP.tau, \ EVAP.beta, \ EVAP.offset, \ EVAP.t2, \ EVAP.tau2, \ EVAP.smoothdt, \ EVAP.image, \ EVAP.scale \ ) #Here, go ahead and save the finalcpow to the report gen.save_to_report('EVAP','finalcpow', finalcpow) #---Setup ipganalog ramp ipganalog = ipg_wave('ipganalog', 10., EVAP.evapss) if ODT.use_servo == 0: ipganalog.extend( odtpow.dt() ) elif ODT.use_servo == 1: ipganalog.follow( odtpow ) maxDT = odtpow.dt() return bfield, odtpow, maxDT, finalcpow, ipganalog
report=gen.getreport() #GET SECTION CONTENTS SEQ = gen.getsection('SEQ') EVAP = gen.getsection('EVAP') ANDOR = gen.getsection('ANDOR') ODT = gen.getsection('ODT') FESHBACH = gen.getsection('FESHBACH') ZEROCROSS = gen.getsection('ZEROCROSS') RF = gen.getsection('RF') if EVAP.andor2 == 1: print "\n...SEQ:camera will be modified in report" print "\tNEW SEQ:camera = andor,andor2\n" gen.save_to_report('SEQ','camera', 'andor,andor2') #SEQUENCE s=seq.sequence(SEQ.stepsize) s=gen.initial(s) s.wait(0.0) #Get hfimg ready s.digichg('hfimg',1) #If using analoghfimg get it ready if ANDOR.analoghfimg == 1: s.digichg('analogimgttl',1)
def dimple_to_lattice(s, cpowend): print "----- LATTICE LOADING RAMPS -----" # Find out which is the longest of the ramps we are dealing with: maxX =max( [xdomain(DL.latticeV0)[1] ,\ xdomain(DL.irpow)[1],\ xdomain(DL.grpow1)[1],\ xdomain(DL.grpow2)[1],\ xdomain(DL.grpow3)[1],\ xdomain(DL.a_s)[1]] ) print "Largest x value = %.3f ms\n" % maxX # We define the times for which all functions will be evaluated # MIN TIME TO DO DIGITAL EXTENSION DIGEXTENSION = 2050. if DL.image >= DIGEXTENSION: Xendtime = DIGEXTENSION else: Xendtime = DL.image Nnew = int(math.floor(Xendtime / DL.ss)) Xnew = numpy.arange(Xendtime / Nnew, DL.image, Xendtime / Nnew) print "X array defined from dt:" print "DL.ss =", DL.ss print "x0 = ", Xnew[0] print "xf = ", Xnew[-1] print "xdt = ", Xnew[1] - Xnew[0] print "%d samples" % Nnew print 'x shape = ', Xnew.shape # Define how we want to ramp up the lattice depth v0_ramp, xy_v0, v0set = interpolate_ramp(DL.latticeV0) v0 = v0_ramp(Xnew) ########################################### #### 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]) allax = [ax0, ax1, ax2, ax3, ax4, ax5, ax6] for ax in allax: ax.axvline(DL.image, linewidth=1., color='black', alpha=0.6) lw = 1.5 labelx = -0.12 legsz = 8. xymew = 0.5 xyms = 9 ax0.plot(Xnew, 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 if DIMPLE.allirpow > 0.: ir_offset = DIMPLE.allirpow else: ir_offset = DIMPLE.ir1pow2 ir_ramp, xy_ir, ir = interpolate_ramp(DL.irpow, yoffset=ir_offset) 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_ramp(Xnew) 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) alpha_clip_range = 0.1 if (v0 > y_ir + alpha_clip_range).any(): msg = "IRPOW ERROR: not enough power to get desired lattice depth" print msg bad = numpy.where(v0 > y_ir + alpha_clip_range) timefail = int(bad[0][0]) * float(DL.ss) msg = msg + "\nFirst bad sample = %d out of %d" % (bad[0][0], v0.size) msg = msg + "\n t = %f " % timefail 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(Xnew, y_ir, lw=lw, color='darkorange', label='irpow') # Define how we want to ramp up the GR power grwfms = {} splmrkr = ['x', '+', 'd'] ptsmrkr = ['^', 's', 'p'] for i, grramp in enumerate([(DL.grpow1, DIMPLE.gr1pow2), (DL.grpow2, DIMPLE.gr2pow2), (DL.grpow3, DIMPLE.gr3pow2)]): ramppts = grramp[0] ramp0 = grramp[1] print 'gr' + '%d' % i + ' offset = %f' % ramp0 gr_ramp, xy_gr, gr = interpolate_ramp(ramppts, yoffset=ramp0) 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(Xnew) if DL.signal == 0: y_gr = y_gr / 2.0 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) grwfms['greenpow' + '%1d' % (i + 1)] = y_gr ax0.plot(xy_gr[:, 0], xy_gr[:, 1], marker=splmrkr[i], mec='green', mfc='None', ms=3.) ax0.plot(gr[:, 0], gr[:, 1], marker=ptsmrkr[i], mew=xymew, ms=xyms / 2., mfc='None', mec='green') #, label='grpow dat') ax0.plot(Xnew, y_gr, lw=lw, color='green', label='grpow') for grch in grwfms.keys(): print grch, " = ", grwfms[grch].shape 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(Xnew) 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(Xnew, 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 = alpha.clip(0., 1.) 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]]) #alpha = alpha.clip(0., 1.) ax2.plot(Xnew, alpha, lw=lw, color='saddlebrown', label='alpha adv') ax2.plot(Xnew, 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(Xnew, 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) print print "The last value of the scattering length ramp is:" print 'a_s =', y_a_s[-1] print 'B =', bfieldG[-1] print U_over_t = y_a_s * bohrRadius / lattice_spacing * wannierF / tunneling_Er ax4.plot(Xnew, 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(Xnew, 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(Xnew, (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((Xnew, v0, y_ir, grwfms['greenpow1'], 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') shutil.copyfile( datfile, seqconf.savedir() + 'expseq' + seqconf.runnumber() + '_latticeRamp.dat') #plt.savefig( seqconf.savedir() + 'expseq' + seqconf.runnumber() + '_latticeRamp.png', dpi=120) ################################# #### APPEND RAMPS TO SEQUENCE ### ################################# wfms = [] if DL.signal == 0: print " LOCK VALUE FOR SIGNAL / NOSIGNAL " print " before = ", DL.lock_Er DL.lock_Er = DL.lock_Er / 1.8 print " after = \n", DL.lock_Er 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) if DL.lock: endval = w.y[-1] w.insertlin_cnv(DL.lock_Er, DL.lock_dtUP, DL.lock_t0) elif DL.lightassist_lock: endval = w.y[-1] w.linear(DL.lightassist_lockpowIR, DL.lightassist_lockdtUP) w.appendhold(DL.lightassist_t0 + DL.lightassistdt) if DL.endvalIR >= 0.: w.linear(DL.endvalIR, DL.lightassist_lockdtDOWN) else: w.linear(None, DL.lightassist_lockdtDOWN, volt=endval) 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 correction = DIMPLE.__dict__['gr' + n + 'correct'] w.y = physics.cnv(ch, correction * grwfms[ch]) if DL.lightassist_lock: endval = w.y[-1] w.linear(DL.lightassist_lockpowGR, DL.lightassist_lockdtUP) w.appendhold(DL.lightassist_t0 + DL.lightassistdt) if DL.endvalGR >= 0.: w.linear(DL.endvalGR, DL.lightassist_lockdtDOWN) else: w.linear(None, DL.lightassist_lockdtDOWN, volt=endval) 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 force = DL.__dict__['force_' + ch] if force >= 0 and force <= 1: print "...Forcing LCR%s = %f during lattice ramp" % (n, force) w.y = physics.cnv(ch, numpy.array(alpha.size * [force])) elif DL.signal == 0: print "...Forcing LCR%s = 0. so that it does NOT rotate to LATTICE" % n w.y = physics.cnv(ch, numpy.array(alpha.size * [0.0])) else: 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) print "The last value of the bfield voltage is =", bfield.y[-1] print wfms.append(bfield) ##ADD gradient field gradient = gradient_wave('gradientfield', 0.0, DL.ss, volt=0.0) gradient.follow(bfield) wfms.append(gradient) buffer = 40. 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) if DL.round_trip == 1: bindex = 0 # Calculate detunings using starting field else: bindex = -1 # Calculate detunings using field at the end of ramps bfieldG = physics.inv('bfield', bfield.y[bindex]) * 6.8 hfimg0 = -1. * (100.0 + 163.7 - 1.414 * bfieldG) # Find bindex for braggkill time bindex_BK = math.floor(-DL.braggkilltime / bfield.ss) bfieldG_BK = physics.inv('bfield', bfield.y[-1 - bindex_BK]) * 6.8 hfimg0_BK = -1. * (100.0 + 163.7 - 1.414 * bfieldG_BK) DL.braggkill_hfimg = hfimg0_BK - DL.braggkill_hfimg print "\n...Braggkill hfimg modification:\n" print "\tNEW braggkill_hfimg = %.2f MHz" % DL.braggkill_hfimg # Find bindex for bragg2kill time bindex_B2K = math.floor(-DL.bragg2killtime / bfield.ss) bfieldG_B2K = physics.inv('bfield', bfield.y[-1 - bindex_B2K]) * 6.8 hfimg0_B2K = -1. * (100.0 + 163.7 - 1.414 * bfieldG_B2K) DL.bragg2kill_hfimg1 = hfimg0_B2K - DL.bragg2kill_hfimg1 DL.bragg2kill_hfimg2 = hfimg0_B2K - DL.bragg2kill_hfimg2 print "\n...Bragg2kill hfimg modification:\n" print "\tNEW brag2gkill_hfimg1 = %.2f MHz" % DL.bragg2kill_hfimg1 print "\tNEW brag2gkill_hfimg2 = %.2f MHz" % DL.bragg2kill_hfimg2 print "\n...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) newANDORhfimg = hfimg0 - DL.imgdet # THIS DEFINES THE TIME IT TAKES THE OFFSET LOCK TO SWITCH TO # A NEW SETPOINT hfimgdelay = 50. #ms # Kill hfimg if DL.probekill == 1 or DL.braggkill == 1 or DL.bragg2kill == 1 or DL.lightassist or DL.lightassist_lock: analogimg = wfm.wave('analogimg', newANDORhfimg, 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: print "Setting up analogimg for braggkill" if (-DL.braggkilltime + 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) elif DL.bragg2kill == 1: print "Setting up analogimg for bragg2kill" if (-DL.bragg2killtime + hfimgdelay) < DL.image: # This sets up the detuning for the first pulse analogimg.appendhold(bfield.dt() + DL.bragg2killtime - hfimgdelay) analogimg.linear(DL.bragg2kill_hfimg1, 0.0) analogimg.appendhold(hfimgdelay + DL.bragg2killdt + 3 * DL.ss) # Then set up the detuning for the second pulse analogimg.linear(DL.bragg2kill_hfimg2, 0.0) analogimg.appendhold(hfimgdelay + DL.bragg2killdt + 3 * DL.ss) elif DL.lightassist == 1 or DL.lightassist_lock: analogimg.appendhold(bfield.dt() - hfimgdelay) analogimg.linear(DL.lightassist_hfimg, 0.0) duration = DL.lightassist_lockdtUP + DL.lightassist_t0 + DL.lightassistdt + DL.lightassist_lockdtDOWN analogimg.appendhold(hfimgdelay + duration + 3 * DL.ss) analogimg.linear(newANDORhfimg, 0.) analogimg.extend(10) wfms.append(analogimg) #analogimg = bfieldwfm.hfimg_wave('analogimg', ANDOR.hfimg, DL.ss) #andorhfimg0 = analogimg.follow(bfield, DL.imgdet) #wfms.append(analogimg) # If we are doing round trip END, then mirror all the ramps # before adding them to the sequence if DL.round_trip == 1: if DL.round_trip_type == 1: maxdt = 0. maxi = -1 for i, w in enumerate(wfms): if w.dt() > maxdt: maxdt = w.dt() maxi = i maxdt = maxdt + DL.wait_at_top / 2. for w in wfms: w.extend(maxdt) if 'lcr' in w.name: yvals = w.y #Get the reverse of the alpha desired array alpha_mirror = numpy.copy(alpha_desired[::-1]) #Add the wait at top part so that it has same length as yvals if alpha_mirror.size > yvals.size: print "Error making mirror ramp for LCR." print "Program will exit." exit(1) alpha_mirror = numpy.append( (yvals.size - alpha_mirror.size) * [alpha_mirror[0]], alpha_mirror) #This is how much the mirror ramp will be advanced N_adv = int(math.floor(DL.lcr_mirror_advance / DL.ss)) if N_adv < alpha_mirror.size: alpha_mirror = alpha_mirror[N_adv:] alpha_mirror = numpy.append( alpha_mirror, (yvals.size - alpha_mirror.size) * [alpha_mirror[-1]]) else: alpha_mirror = numpy.array(yvals.size * [alpha_mirror[-1]]) w.y = numpy.concatenate( (yvals, physics.cnv(w.name, alpha_mirror))) else: w.mirror() w.appendhold(DL.wait_at_end) N_adv = int(math.floor(alpha_advance / DL.ss)) alpha_desired = numpy.copy(alpha) for wavefm in wfms: print "%s dt = %f" % (wavefm.name, wavefm.dt()) duration = s.analogwfm_add(DL.ss, wfms) if DL.image < DIGEXTENSION: s.wait(duration) else: print "...DL.image = %f >= %.2f Digital seq extension will be used." % ( DL.image, DIGEXTENSION) s.wait(DL.image) ### Prepare the parts of the ramps that are going to be used to mock ### the conditions for the noatoms shot ### 1. get dt = [noatoms] ms from the end of the lattice ramps. if 'manta' in DL.camera: noatomsdt = MANTA.noatoms else: noatomsdt = ANDOR.noatoms noatomswfms = [] for wavefm in wfms: cp = copy.deepcopy(wavefm) cp.idnum = time.time() * 100 cp.retain_last(DL.bgRetainDT) noatomswfms.append(cp) ### 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) ######################################### ## OTHER TTL EVENTS: probekill, braggkill, rf, quick2 ######################################### # Braggkill if DL.braggkill == 1: print "Using Bragg Kill" s.wait(DL.braggkilltime) s = manta.OpenShutterBragg(s, DL.shutterdelay) s.digichg('bragg', 1) s.wait(DL.braggkilldt) s.digichg('brshutter', 1) # to close shutter s.digichg('bragg', 0) s.wait(-DL.braggkilldt) s.wait(-DL.braggkilltime) if DL.bragg2kill == 1: print "Using Bragg 2 Kill" tcur = s.tcur s.wait(DL.bragg2killtime) s = manta.OpenShutterBragg(s, DL.shutterdelay) s.digichg('bragg', 1) s.wait(DL.bragg2killdt) s.digichg('brshutter', 1) # to close shutter s.digichg('bragg', 0) s.wait(hfimgdelay + 3 * DL.ss) s = manta.OpenShutterBragg(s, DL.shutterdelay) s.digichg('bragg', 1) s.wait(DL.bragg2killdt) s.digichg('brshutter', 1) # to close shutter s.digichg('bragg', 0) # Revert to current time after pulses have been added in the past s.tcur = tcur # Probe Kill if DL.probekill == 1: s.wait(DL.probekilltime) s.wait(-10) s.digichg('prshutter', 0) s.wait(10) s.digichg('probe', 1) s.wait(DL.probekilldt) s.digichg('probe', 0) s.digichg('prshutter', 1) s.wait(-DL.probekilltime) # Pulse RF if DL.rf == 1: s.wait(DL.rftime) s.digichg('rfttl', 1) s.wait(DL.rfpulsedt) s.digichg('rfttl', 0) s.wait(-DL.rfpulsedt) s.wait(-DL.rftime) # QUICK2 if DL.quick2 == 1: s.wait(DL.quick2time) s.digichg('quick2', 1) s.wait(-DL.quick2time) # Light-assisted collisions if DL.lightassist == 1 or DL.lightassist_lock: s.wait(-DL.lightassist_lockdtUP - DL.lightassist_t0 - DL.lightassistdt - DL.lightassist_lockdtDOWN - 3 * DL.ss) s.wait(DL.lightassist_lockdtUP + DL.lightassist_t0) s.wait(-10) s.digichg('prshutter', 0) s.wait(10) s.digichg('probe', DL.lightassist) s.wait(DL.lightassistdt) s.digichg('probe', 0) s.digichg('prshutter', 1) s.wait(DL.lightassist_lockdtDOWN) s.wait(3 * DL.ss) # After the collisions happen we still need to wait some time # for the probe frequency to come back to the desired value s.wait(hfimgdelay) ######################################### ## GO BACK IN TIME IF DOING ROUND-TRIP START ######################################### if DL.round_trip == 1: if DL.round_trip_type == 0: s.wait(-DL.image) s.stop_analog() ######################################### ## TURN GREEN OFF BEFORE PICTURES ######################################### if DL.greenoff == 1: s.wait(DL.greenoff_t0) s.digichg('greenttl1', 0) s.digichg('greenttl2', 0) s.digichg('greenttl3', 0) s.wait(-DL.greenoff_t0) ######################################### ## LATTICE LOCK WITH POSSIBILITY OF RF ######################################### bufferdt = 5.0 lastIR = y_ir[-1] lockwfms = [] if DL.locksmooth == 1 and DL.lock == 0: s.wait(bufferdt) for ch in ['ir1pow', 'ir2pow', 'ir3pow']: n = filter(str.isdigit, ch)[0] w = wfm.wave(ch, lastIR, DL.lockss) #Start value will be overrriden w.tanhRise(DL.lock_Er, DL.lock_dtUP, 0.4, 0.2) lockwfms.append(w) print "...LOCKING LATTICE TO %f Er" % DL.lock_Er print "...lastIR = %.4f" % lastIR duration = s.analogwfm_add(DL.lockss, lockwfms) print "...duration = %.2f" % duration s.wait(duration) #~ if DL.lockrf: #~ s.digichg('rfttl',1) #~ s.wait(DL.rfpulsedt) #~ s.digichg('rfttl',0) #~ s.wait(0.036) #else: # s.wait(bufferdt) lockwfmscopy = [] for wavefm in lockwfms: cp = copy.deepcopy(wavefm) cp.idnum = time.time() * 100 + 1e3 * numpy.random.randint(0, 1e8) lockwfmscopy.append(cp) ######################################### ## IMAGING AT LOW FIELD ######################################### if DL.lowfieldimg == 1: s.wait(DL.lowfieldimg_t0) s.digichg('field', 0) s.wait(-DL.lowfieldimg_t0) ######################################### ## TTL RELEASE FROM ODT and LATTICE ######################################### #INDICATE WHICH CHANNELS ARE TO BE CONSIDERED FOR THE BACKGROUND bg = [ 'odtttl', 'irttl1', 'irttl2', 'irttl3', 'greenttl1', 'greenttl2', 'greenttl3' ] bgdictPRETOF = {} for ch in bg: bgdictPRETOF[ch] = s.digistatus(ch) bgdictPRETOF['tof'] = DL.tof print "\nChannel status for pictures: PRE-TOF" print bgdictPRETOF print #RELEASE FROM LATTICE if DL.tof <= 0.: s.wait(1.0 + ANDOR.exp) s.digichg('greenttl1', 0) s.digichg('greenttl2', 0) s.digichg('greenttl3', 0) s.digichg('irttl1', 0) s.digichg('irttl2', 0) s.digichg('irttl3', 0) #RELEASE FROM IR TRAP s.digichg('odtttl', 0) if DL.tof <= 0.: s.wait(-1.0 + ANDOR.exp) print "TIME WHEN RELEASED FROM LATTICE = ", s.tcur s.wait(DL.tof) return s, noatomswfms, lockwfmscopy, bgdictPRETOF
def do_roundtrip( s, wfms ): """ creates roundtrips to characterize cooling in lattice. wfms are the lattice wfms, they can be mirrored here if a mirror ramp is desired. """ s.wait( RT.wait_at_top) # This case is for mirrored ramps if RT.mirror == 1 : alpha_desired = wfms[1] wfms = wfms[0] mirrorwfms = [] for wavefm in wfms: cp = copy.deepcopy( wavefm ) cp.idnum = time.time()*100 mirrorwfms.append( cp ) for w in mirrorwfms: if 'lcr' in w.name: yvals = w.y # Get the reverse of the alpha desired array alpha_mirror = numpy.copy(alpha_desired[::-1]) makeplot( [w, alpha_mirror], name=w.name ) # It needs to have the same length as yvals, so append # constant samples at the beginning if needed if alpha_mirror.size > yvals.size: print "Error making mirror ramp for LCR." print "Program will exit." exit(1) alpha_mirror = numpy.append( (yvals.size - alpha_mirror.size)*[ alpha_mirror[0] ], alpha_mirror ) # This is how much the mirror ramp will be advanced N_adv = int(math.floor( RT.lcr_mirror_advance / DL.ss)) if N_adv < alpha_mirror.size: alpha_mirror = alpha_mirror[N_adv:] alpha_mirror = numpy.append(alpha_mirror, (yvals.size-alpha_mirror.size)*[alpha_mirror[-1]]) else: alpha_mirror = numpy.array( yvals.size*[alpha_mirror[-1]] ) if RT.lcr_snap == 1: alpha_mirror[ alpha_mirror > 0.01 ] = 1. w.y = physics.cnv( w.name, alpha_mirror) else: w.y = w.y[::-1] w.appendhold( RT.wait_at_end) wfms = mirrorwfms # This case is for custom ramps else: # There need to be 10 waveforms # 3IR, 3LCR, 3GR, BFIELD # This follows the procedure done for the lattice ramps Xendtime = float( RT.image ) Nnew = int(math.floor( Xendtime / DL.ss) ) Xnew = numpy.arange( Xendtime/Nnew, RT.image, Xendtime/Nnew ) ir_ramp, xy_ir, ir = lattice.interpolate_ramp( RT.irpow, yoffset=0.) y_ir = ir_ramp(Xnew) grwfms = {} for i,grramp in enumerate([RT.grpow1, RT.grpow2, RT.grpow3]): gr_ramp, xy_gr, gr = lattice.interpolate_ramp( grramp, yoffset=0.) y_gr = gr_ramp(Xnew) grwfms[ 'greenpow' + '%1d' % (i+1) ] = y_gr alpha_ramp, xy_alpha, alpha = lattice.interpolate_ramp( RT.alpha, yoffset=0. ) y_alpha = alpha_ramp(Xnew) 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 correction = DIMPLE.__dict__['gr'+n+'correct'] w.y = physics.cnv( ch, correction * grwfms[ch] ) 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 print "Obtaining LCR waveform for ROUNDTRIP..." print y_alpha w.y = physics.cnv( ch, y_alpha ) wfms.append(w) ##ADD field bfieldG = physics.cnv('as_to_B', DL.knob05) bfieldA = bfieldG/6.8 bfield = wfm.wave('bfield', bfieldA, DL.ss) bfield.extend( wfms[-1].dt() ) wfms.append(bfield) # Include ramp to zerocrossing, valid for mirror and custom cases # Final field can be given in amps (default) or in a0 if RT.enable_zc == 1 : if isinstance(RT.zc_bias, str): if 'a0' in RT.zc_bias: print "Using scattering length units for final field" scattlen = float(re.sub('a0','', RT.zc_bias)) bfieldG = physics.cnv('as_to_B', scattlen) bfieldA = bfieldG/6.8 elif 'knob05' in RT.zc_bias: print "Using knob05 as the final scattering length, amounts to no change" bfieldG = physics.cnv('as_to_B', DL.knob05) bfieldA = bfieldG/6.8 else: bfieldA = RT.zc_bias bfieldG = bfieldA*6.8 else: print "Using knob05 as the final scattering length, amounts to no change" bfieldG = physics.cnv('as_to_B', DL.knob05) bfieldA = bfieldG/6.8 # Set hfimg value for the given final field hfimg0 = -1.*(100.0 + 163.7 - 1.414*bfieldG) print "\n...ANDOR:hfimg and hfimg0 will be modified in report\n" print "\tNEW ANDOR:hfimg = %.2f MHz" % ( hfimg0 - RT.imgdet) print "\tNEW ANDOR:hfimg0 = %.2f MHz\n" % hfimg0 gen.save_to_report('ANDOR','hfimg', hfimg0 - RT.imgdet) gen.save_to_report('ANDOR','hfimg0', hfimg0) newANDORhfimg = hfimg0 - RT.imgdet for w in wfms: if 'bfield' in w.name: bfieldw = w if RT.enable_zc == 1 : if RT.zc_mirror_t0 < 0.: dt = w.dt() w.chop( w.dt() + RT.zc_mirror_t0 ) if RT.zc_mirror_t0 > 0.: w.appendhold( RT.zc_mirror_t0 ) w.linear( bfieldA, RT.zc_mirror_rampdt) w.appendhold( RT.zc_mirror_holddt ) for i,w in enumerate(wfms): if 'gradientfield' in w.name: gradientfield_i = i print "REMOVING GRADIENT FIELD" print len(wfms) wfms = [ w for w in wfms if w.name != 'gradientfield' ] print len(wfms) #Add gradientfield ramp to have levitation all the time from bfieldwfm import gradient_wave gradient = gradient_wave('gradientfield', 0.0, bfieldw.ss,volt = 0.0) gradient.follow( bfieldw) wfms.append(gradient) duration = s.analogwfm_add(DL.ss,wfms) s.wait(duration) ### Prepare the parts of the ramps that are going to be used to mock ### the conditions for the noatoms shot ### 1. get dt = [noatoms] ms from the end of the lattice ramps. if 'manta' in DL.camera: noatomsdt = MANTA.noatoms else: noatomsdt = ANDOR.noatoms noatomswfms = [] for wavefm in wfms: cp = copy.deepcopy( wavefm ) cp.idnum = time.time()*100 cp.retain_last( DL.bgRetainDT ) noatomswfms.append( cp ) #INDICATE WHICH CHANNELS ARE TO BE CONSIDERED FOR THE BACKGROUND bg = ['odtttl','irttl1','irttl2','irttl3','greenttl1','greenttl2','greenttl3'] bgdictPRETOF={} for ch in bg: bgdictPRETOF[ch] = s.digistatus(ch) bgdictPRETOF['tof'] = RT.tof print "\nChannel status for pictures: PRE-TOF" print bgdictPRETOF print #RELEASE FROM LATTICE if RT.tof <= 0.: s.wait(1.0+ANDOR.exp) s.digichg('greenttl1',0) s.digichg('greenttl2',0) s.digichg('greenttl3',0) s.digichg('irttl1',0) s.digichg('irttl2',0) s.digichg('irttl3',0) #RELEASE FROM IR TRAP s.digichg('odtttl',0) if RT.tof <= 0.: s.wait(-1.0+ANDOR.exp) print "TIME WHEN RELEASED FROM LATTICE = ",s.tcur s.wait(RT.tof) return s, noatomswfms, bgdictPRETOF
s.wait(tof) #Use MOT beams for fluorescence imaging light = 'motswitch' noatoms = 67.0 cameras = UVSEC.camera imagetime = s.tcur if 'andor' in cameras: new_seqcam = 'andor' else: new_seqcam = 'none' print "\n...SEQ:camera will be modified in report" print "\tNEW SEQ:camera = %s\n" % new_seqcam # SEQ:camera needs to be a list of strings. gen.save_to_report('SEQ', 'camera', new_seqcam) print "Current time before BASLER = ", s.tcur #Take fluorescence imaging shot with the MOT beams. #PICTURE OF ATOMS s.tcur = imagetime s = basler.BaslerPicture(s, preexp, texp, postexp, light) #PICTURE OF BACKGROUND s.wait(noatoms) s.wait(noatoms) s.wait(noatoms) s = basler.BaslerPicture(s, preexp, texp, postexp, light) print "Current time after BASLER = ", s.tcur if 'andor' in cameras: s.tcur = imagetime
report = gen.getreport() #GET SECTION CONTENTS DIMPLE = gen.getsection('DIMPLE') EVAP = gen.getsection('EVAP') FB = gen.getsection('FESHBACH') ZC = gen.getsection('ZEROCROSS') ANDOR = gen.getsection('ANDOR') DL = gen.getsection('DIMPLELATTICE') MANTA = gen.getsection('MANTA') print "\n...SEQ:camera will be modified in report" print "\tNEW SEQ:camera = %s\n" % (DL.camera) # When only use one camera the reading of DL.camera will be a string instead of a list of string. As a consequence we need to check the type. gen.save_to_report( 'SEQ', 'camera', DL.camera if type(DL.camera) == type("string") else ",".join(DL.camera)) #SEQUENCE stepsize = float(report['SEQ']['stepsize']) s = seq.sequence(stepsize) s = gen.initial(s) s.digichg('hfimg', 1) s.digichg('odt7595', 0) #Get hfimg ready s.digichg('hfimg', 1) #If using analoghfimg get it ready if ANDOR.analoghfimg == 1: s.digichg('analogimgttl', 1)
def do_roundtrip(s, wfms): """ creates roundtrips to characterize cooling in lattice. wfms are the lattice wfms, they can be mirrored here if a mirror ramp is desired. """ s.wait(RT.wait_at_top) # This case is for mirrored ramps if RT.mirror == 1: alpha_desired = wfms[1] wfms = wfms[0] mirrorwfms = [] for wavefm in wfms: cp = copy.deepcopy(wavefm) cp.idnum = time.time() * 100 mirrorwfms.append(cp) for w in mirrorwfms: if 'lcr' in w.name: yvals = w.y # Get the reverse of the alpha desired array alpha_mirror = numpy.copy(alpha_desired[::-1]) makeplot([w, alpha_mirror], name=w.name) # It needs to have the same length as yvals, so append # constant samples at the beginning if needed if alpha_mirror.size > yvals.size: print "Error making mirror ramp for LCR." print "Program will exit." exit(1) alpha_mirror = numpy.append( (yvals.size - alpha_mirror.size) * [alpha_mirror[0]], alpha_mirror) # This is how much the mirror ramp will be advanced N_adv = int(math.floor(RT.lcr_mirror_advance / DL.ss)) if N_adv < alpha_mirror.size: alpha_mirror = alpha_mirror[N_adv:] alpha_mirror = numpy.append( alpha_mirror, (yvals.size - alpha_mirror.size) * [alpha_mirror[-1]]) else: alpha_mirror = numpy.array(yvals.size * [alpha_mirror[-1]]) if RT.lcr_snap == 1: alpha_mirror[alpha_mirror > 0.01] = 1. w.y = physics.cnv(w.name, alpha_mirror) else: w.y = w.y[::-1] w.appendhold(RT.wait_at_end) wfms = mirrorwfms # This case is for custom ramps else: # There need to be 10 waveforms # 3IR, 3LCR, 3GR, BFIELD # This follows the procedure done for the lattice ramps Xendtime = float(RT.image) Nnew = int(math.floor(Xendtime / DL.ss)) Xnew = numpy.arange(Xendtime / Nnew, RT.image, Xendtime / Nnew) ir_ramp, xy_ir, ir = lattice.interpolate_ramp(RT.irpow, yoffset=0.) y_ir = ir_ramp(Xnew) grwfms = {} for i, grramp in enumerate([RT.grpow1, RT.grpow2, RT.grpow3]): gr_ramp, xy_gr, gr = lattice.interpolate_ramp(grramp, yoffset=0.) y_gr = gr_ramp(Xnew) grwfms['greenpow' + '%1d' % (i + 1)] = y_gr alpha_ramp, xy_alpha, alpha = lattice.interpolate_ramp(RT.alpha, yoffset=0.) y_alpha = alpha_ramp(Xnew) 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 correction = DIMPLE.__dict__['gr' + n + 'correct'] w.y = physics.cnv(ch, correction * grwfms[ch]) 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 #print "Obtaining LCR waveform for ROUNDTRIP..." w.y = physics.cnv(ch, y_alpha) wfms.append(w) ##ADD field bfieldG = physics.cnv('as_to_B', DL.knob05) bfieldA = bfieldG / 6.8 bfield = wfm.wave('bfield', bfieldA, DL.ss) bfield.extend(wfms[-1].dt()) wfms.append(bfield) # Include ramp to zerocrossing, valid for mirror and custom cases # Final field can be given in amps (default) or in a0 if RT.enable_zc == 1: if isinstance(RT.zc_bias, str): if 'a0' in RT.zc_bias: print "Using scattering length units for final field" scattlen = float(re.sub('a0', '', RT.zc_bias)) bfieldG = physics.cnv('as_to_B', scattlen) bfieldA = bfieldG / 6.8 elif 'knob05' in RT.zc_bias: print "Using knob05 as the final scattering length, amounts to no change" bfieldG = physics.cnv('as_to_B', DL.knob05) bfieldA = bfieldG / 6.8 else: bfieldA = RT.zc_bias bfieldG = bfieldA * 6.8 else: print "Using knob05 as the final scattering length, amounts to no change" bfieldG = physics.cnv('as_to_B', DL.knob05) bfieldA = bfieldG / 6.8 # Set hfimg value for the given final field hfimg0 = -1. * (100.0 + 163.7 - 1.414 * bfieldG) print "\n...ANDOR:hfimg and hfimg0 will be modified in report\n" print "\tNEW ANDOR:hfimg = %.2f MHz" % (hfimg0 - RT.imgdet) print "\tNEW ANDOR:hfimg0 = %.2f MHz\n" % hfimg0 gen.save_to_report('ANDOR', 'hfimg', hfimg0 - RT.imgdet) gen.save_to_report('ANDOR', 'hfimg0', hfimg0) newANDORhfimg = hfimg0 - RT.imgdet for w in wfms: if 'bfield' in w.name: bfieldw = w if RT.enable_zc == 1: if RT.zc_mirror_t0 < 0.: dt = w.dt() w.chop(w.dt() + RT.zc_mirror_t0) if RT.zc_mirror_t0 > 0.: w.appendhold(RT.zc_mirror_t0) w.linear(bfieldA, RT.zc_mirror_rampdt) w.appendhold(RT.zc_mirror_holddt) for i, w in enumerate(wfms): if 'gradientfield' in w.name: gradientfield_i = i print "REMOVING GRADIENT FIELD" print len(wfms) wfms = [w for w in wfms if w.name != 'gradientfield'] print len(wfms) #Add gradientfield ramp to have levitation all the time from bfieldwfm import gradient_wave gradient = gradient_wave('gradientfield', 0.0, bfieldw.ss, volt=0.0) gradient.follow(bfieldw) wfms.append(gradient) duration = s.analogwfm_add(DL.ss, wfms) s.wait(duration) ### Prepare the parts of the ramps that are going to be used to mock ### the conditions for the noatoms shot ### 1. get dt = [noatoms] ms from the end of the lattice ramps. if 'manta' in DL.camera: noatomsdt = MANTA.noatoms else: noatomsdt = ANDOR.noatoms noatomswfms = [] for wavefm in wfms: cp = copy.deepcopy(wavefm) cp.idnum = time.time() * 100 cp.retain_last(DL.bgRetainDT) noatomswfms.append(cp) #INDICATE WHICH CHANNELS ARE TO BE CONSIDERED FOR THE BACKGROUND bg = [ 'odtttl', 'irttl1', 'irttl2', 'irttl3', 'greenttl1', 'greenttl2', 'greenttl3' ] bgdictPRETOF = {} for ch in bg: bgdictPRETOF[ch] = s.digistatus(ch) bgdictPRETOF['tof'] = RT.tof print "\nChannel status for pictures: PRE-TOF" print bgdictPRETOF print #RELEASE FROM LATTICE if RT.tof <= 0.: s.wait(1.0 + ANDOR.exp) s.digichg('greenttl1', 0) s.digichg('greenttl2', 0) s.digichg('greenttl3', 0) s.digichg('irttl1', 0) s.digichg('irttl2', 0) s.digichg('irttl3', 0) #RELEASE FROM IR TRAP s.digichg('odtttl', 0) if RT.tof <= 0.: s.wait(-1.0 + ANDOR.exp) print "TIME WHEN RELEASED FROM LATTICE = ", s.tcur s.wait(RT.tof) return s, noatomswfms, bgdictPRETOF
if int(report['EVAP']['use_odt_lock']) == 1: odtlockpow = float(report['EVAP']['odtlockpow']) odtlockpowdt = float(report['EVAP']['odtlockpowdt']) if odtlockpow == -1: odtpow.appendhold(odtlockpowdt) bfield.extend(odtpow.dt()) ipganalog.extend(bfield.dt()) else: odtpow.linear( odtlockpow, odtlockpowdt) bfield.extend(odtpow.dt()) ipganalog.extend(bfield.dt()) #Here, go ahead and save the finalcpow to the report gen.save_to_report('EVAP','finalcpow', odtlockpow) waveforms = [odtpow,bfield,ipganalog]#,odtpow_test,odtpow_test2] #ADD rf ramp if int(report['RF']['rf']) == 1: rfmod = wfm.wave('rfmod', 0., evap_ss) rfmod.extend(bfield.dt()) rfdelay_probe = 0 if int(report['RF']['probekill']) == 1: rfdelay_probe = rfdelay_probe + float(report['RF']['probekilldt'])+float(report['RF']['probewait'])
def odt_evap_field(image,scale =1.0): evap_ss = f('EVAP','evapss') p0 = f('ODT','odtpow') p1 = f('EVAP','p1') t1 = f('EVAP','t1') tau = f('EVAP','tau') beta = f('EVAP','beta') offset = f('EVAP','offset') t2 = f('EVAP','t2') tau2 = f('EVAP','tau2') smoothdt = f('EVAP','smoothdt') field_ramp_time = f('EVAP','fieldrampt0')*scale field_ramp_dt = f('EVAP','fieldrampdt')*scale field_ramp_start = f('FESHBACH','bias') field_ramp_final = f('EVAP','fieldrampfinal') ramp=[] hashbase = '' hashbase = hashbase + '%.8f' % image hashbase = hashbase + '%.8f' % evap_ss hashbase = hashbase + '%.8f' % field_ramp_time hashbase = hashbase + '%.8f' % field_ramp_dt hashbase = hashbase + '%.8f' % field_ramp_start hashbase = hashbase + '%.8f' % field_ramp_final hashbase = hashbase + '%.8f' % scale ramphash = seqconf.ramps_dir() +'Evap_field_withscale'+ hashlib.md5( hashbase).hexdigest() #Here, go ahead and save the trajectory path to the report gen.save_to_report('EVAP','ramp_field', ramphash) bfield = wfm.wave('bfield',field_ramp_start,evap_ss) if not os.path.exists(ramphash) or True: bfield.extend(field_ramp_time) bfield.linear(field_ramp_final,field_ramp_dt) if((field_ramp_time+field_ramp_dt)<image*scale): bfield.extend(image*scale) else: bfield.chop(image*scale) ramp = bfield.y ramp.tofile(ramphash,sep=',',format="%.4f") else: print '\t...Recycling previously calculated Evap_field' ramp = numpy.fromfile(ramphash,sep=',') bfield.y=numpy.append(bfield.y,ramp) odtpow = odt_wave('odtpow', p0, evap_ss) #~ odtpow_test = odt_wave('NC0', p0, evap_ss) #~ odtpow_test2 = odt_wave('NC1', p0, evap_ss) #odtpow.Evap(p0, p1, t1, tau, beta, image) #odtpow.Evap2(p0, p1, t1, tau, beta, offset, t2, tau2, image) #odtpow.Evap3(p0, p1, t1, tau, beta, offset, t2, tau2, image) ### SELECT EVAP TRAJECTORY HERE### finalcpow = odtpow.Evap8(p0, p1, t1, tau, beta, offset, t2, tau2,smoothdt,image,scale) #~ finalcpow2 = odtpow_test.Evap7(p0, p1, t1, tau, beta, offset, t2, tau2,smoothdt,image) #~ finalcpow3 = odtpow_test2.Evap7(p0, p1, t1, tau, beta, offset, t2, tau2,smoothdt,image) #Here, go ahead and save the finalcpow to the report gen.save_to_report('EVAP','finalcpow', finalcpow) #ipganalog starts out at full power ipganalog = ipg_wave('ipganalog', 10., evap_ss) if f('ODT','use_servo') == 0: ipganalog.extend( odtpow.dt() ) elif f('ODT','use_servo') == 1: ipganalog.follow( odtpow ) #~ ipganalog.follow( odtpow ) #~ odtpow.Exponential(pow0,powf,evap_dt,tau) #~ odtpow.linear( powf, evap_ss) #~ odtpow.appendhold( evap_dt) maxDT = odtpow.dt() return bfield, odtpow, maxDT, finalcpow, ipganalog#,odtpow_test,odtpow_test2
#GET SECTION CONTENTS DIMPLE = gen.getsection('DIMPLE') EVAP = gen.getsection('EVAP') FB = gen.getsection('FESHBACH') ZC = gen.getsection('ZEROCROSS') ANDOR = gen.getsection('ANDOR') DL = gen.getsection('DIMPLELATTICE') MANTA = gen.getsection('MANTA') print "\n...SEQ:camera will be modified in report" print "\tNEW SEQ:camera = %s\n" % ( DL.camera ) gen.save_to_report('SEQ','camera', DL.camera) #SEQUENCE stepsize = float(report['SEQ']['stepsize']) s=seq.sequence(stepsize) s=gen.initial(s) s.digichg('hfimg',1) s.digichg('odt7595',0) #Get hfimg ready s.digichg('hfimg',1) #If using analoghfimg get it ready if ANDOR.analoghfimg == 1:
def dimple_to_lattice(s, cpowend): print "----- LATTICE LOADING RAMPS -----" dt = DL.dt N0 = 0 N = int(math.floor(dt / DL.ss)) x = numpy.arange(dt / N, dt, dt / N) print "%d samples" % N print x.shape # Define how we want to ramp up the lattice depth v0_ramp, xy_v0, v0set = interpolate_ramp(DL.latticeV0) v0 = v0_ramp(x) 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 and DL.image < 2500.: 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 if DIMPLE.allirpow > 0.: ir_offset = DIMPLE.allirpow else: ir_offset = DIMPLE.ir1pow2 ir_ramp, xy_ir, ir = interpolate_ramp(DL.irpow, yoffset=ir_offset) 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) alpha_clip_range = 0.1 if (v0 > y_ir + alpha_clip_range).any(): msg = "IRPOW ERROR: not enough power to get desired lattice depth" print msg bad = numpy.where(v0 > y_ir + alpha_clip_range) timefail = int(bad[0][0]) * float(DL.ss) msg = msg + "\nFirst bad sample = %d out of %d" % (bad[0][0], v0.size) msg = msg + "\n t = %f " % timefail 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 grwfms = {} splmrkr = ['x', '+', 'd'] ptsmrkr = ['^', 's', 'p'] for i, grramp in enumerate([(DL.grpow1, DIMPLE.gr1pow2), (DL.grpow2, DIMPLE.gr2pow2), (DL.grpow3, DIMPLE.gr3pow2)]): ramppts = grramp[0] ramp0 = grramp[1] print 'gr' + '%d' % i + ' offset = %f' % ramp0 gr_ramp, xy_gr, gr = interpolate_ramp(ramppts, yoffset=ramp0) 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) grwfms['greenpow' + '%1d' % (i + 1)] = y_gr ax0.plot(xy_gr[:, 0], xy_gr[:, 1], marker=splmrkr[i], mec='green', mfc='None', ms=3.) ax0.plot(gr[:, 0], gr[:, 1], marker=ptsmrkr[i], mew=xymew, ms=xyms / 2., mfc='None', mec='green') #, label='grpow dat') ax0.plot(x_v0, y_gr, lw=lw, color='green', label='grpow') for grch in grwfms.keys(): print grch, " = ", grwfms[grch].shape 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 = alpha.clip(0., 1.) 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]]) #alpha = alpha.clip(0., 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, grwfms['greenpow1'], 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') shutil.copyfile( datfile, seqconf.savedir() + 'expseq' + seqconf.runnumber() + '_latticeRamp.dat') #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 correction = DIMPLE.__dict__['gr' + n + 'correct'] w.y = physics.cnv(ch, correction * grwfms[ch]) 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 force = DL.__dict__['force_' + ch] if force >= 0 and force <= 1: print "...Forcing LCR%s = %f during lattice ramp" % (n, force) w.y = physics.cnv(ch, numpy.array(alpha.size * [force])) else: 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) # 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) #Take care of imaging frequencies, including various kill experiments bfieldG = physics.inv('bfield', bfield.y[-1]) * 6.8 hfimg0 = -1. * (100.0 + 163.7 - 1.414 * bfieldG) 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) newANDORhfimg = hfimg0 - DL.imgdet # Kill hfimg if DL.probekill == 1 or DL.braggkill == 1 or DL.lightassist or DL.lightassist_lock: hfimgdelay = 50. #ms analogimg = wfm.wave('analogimg', newANDORhfimg, 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.braggkilltime + 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) #elif DL.lightassist == 1 or DL.lightassist_lock: # analogimg.appendhold( bfield.dt() - hfimgdelay) # analogimg.linear( DL.lightassist_hfimg , 0.0) # duration = DL.lightassist_lockdtUP + DL.lightassist_t0 + DL.lightassistdt + DL.lightassist_lockdtDOWN # analogimg.appendhold( hfimgdelay + duration + 3*DL.ss) analogimg.linear(newANDORhfimg, 0.) analogimg.extend(10) wfms.append(analogimg) #analogimg = bfieldwfm.hfimg_wave('analogimg', ANDOR.hfimg, DL.ss) #andorhfimg0 = analogimg.follow(bfield, DL.imgdet) #wfms.append(analogimg) # If we are doing round trip END, then mirror all the ramps # before adding them to the sequence if DL.round_trip == 1: if DL.round_trip_type == 1: maxdt = 0. maxi = -1 for i, w in enumerate(wfms): if w.dt() > maxdt: maxdt = w.dt() maxi = i maxdt = maxdt + DL.wait_at_top / 2. for w in wfms: w.extend(maxdt) if 'lcr' in w.name: yvals = w.y #Get the reverse of the alpha desired array alpha_mirror = numpy.copy(alpha_desired[::-1]) #Add the wait at top part so that it has same length as yvals if alpha_mirror.size > yvals.size: print "Error making mirror ramp for LCR." print "Program will exit." exit(1) alpha_mirror = numpy.append( (yvals.size - alpha_mirror.size) * [alpha_mirror[0]], alpha_mirror) #This is how much the mirror ramp will be advanced N_adv = int(math.floor(DL.lcr_mirror_advance / DL.ss)) if N_adv < alpha_mirror.size: alpha_mirror = alpha_mirror[N_adv:] alpha_mirror = numpy.append( alpha_mirror, (yvals.size - alpha_mirror.size) * [alpha_mirror[-1]]) else: alpha_mirror = numpy.array(yvals.size * [alpha_mirror[-1]]) w.y = numpy.concatenate( (yvals, physics.cnv(w.name, alpha_mirror))) else: w.mirror() w.appendhold(DL.wait_at_end) N_adv = int(math.floor(alpha_advance / DL.ss)) alpha_desired = numpy.copy(alpha) for wavefm in wfms: print "%s dt = %f" % (wavefm.name, wavefm.dt()) #Wait the buffer for the lattice loading ramps before adding them bufferdt = 20. s.wait(bufferdt) #Add lattice wfms duration = s.analogwfm_add(DL.ss, wfms) if DL.image < 2500.: s.wait(duration) else: print "...DL.image = %f >= 2500. Digital seq extension will be used." % DL.image s.wait(DL.image) #Here give some buffer time to do lock, RF etc. #It has to be minimum 5.0 ms ### 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, y_ir[-1]
s = seq.sequence(stepsize) s = gen.initial(s) s.digichg('hfimg', 1) s.digichg('odt7595', 0) #Get hfimg ready s.digichg('hfimg', 1) #If using analoghfimg get it ready if ANDOR.analoghfimg == 1: s.digichg('analogimgttl', 1) if EVAP.andor2 == 1: print "\n...SEQ:camera will be modified in report" print "\tNEW SEQ:camera = andor,andor2\n" gen.save_to_report('SEQ', 'camera', 'andor,andor2') # Do CNC, UVMOT, and field ramps s, toENDBFIELD = highfield_uvmot.go_to_highfield(s) # Evaporate into the dimple s, cpowend = odt.crossbeam_dimple_evap(s, toENDBFIELD) zcbuffer = 40. s.wait(zcbuffer) # Go to scattering length zero-crossing if DIMPLE.Bramp == 1: fieldF = DIMPLE.B else: fieldF = EVAP.fieldrampfinal if DIMPLE.image > EVAP.fieldrampt0 else FB.bias
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 ) if DL.lock: endval = w.y[-1] w.insertlin_cnv(DL.lock_Er, DL.lock_dtUP, DL.lock_t0 ) if DL.camera == 'manta' or DL.camera == 'both': w.appendhold( MANTA.exp + 1.0 ) w.insertlin( endval, 0., 0.) w.appendhold( MANTA.noatoms - MANTA.exp - 1.0) w.insertlin_cnv(DL.lock_Er, DL.lock_dtUP, DL.lock_t0 ) elif DL.lightassist_lock: endval = w.y[-1] w.linear(DL.lightassist_lockpowIR, DL.lightassist_lockdtUP) w.appendhold( DL.lightassist_t0 + DL.lightassistdt ) if DL.endvalIR >= 0.: w.linear( DL.endvalIR, DL.lightassist_lockdtDOWN) else: w.linear( None, DL.lightassist_lockdtDOWN, volt=endval) 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 ) if DL.lightassist_lock: endval = w.y[-1] w.linear(DL.lightassist_lockpowGR, DL.lightassist_lockdtUP) w.appendhold( DL.lightassist_t0 + DL.lightassistdt ) if DL.endvalGR >= 0.: w.linear( DL.endvalGR, DL.lightassist_lockdtDOWN) else: w.linear( None, DL.lightassist_lockdtDOWN, volt=endval) 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 force = DL.__dict__['force_'+ch] if force >= 0 and force <=1: print "...Forcing LCR%s = %f during lattice ramp" % (n,force) w.y = physics.cnv( ch, numpy.array( alpha.size*[force] ) ) else: 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) bfieldG = physics.inv( 'bfield', bfield.y[-1]) * 6.8 hfimg0 = -1.*(100.0 + 163.7 - 1.414*bfieldG) 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) newANDORhfimg = hfimg0 - DL.imgdet # Kill hfimg if DL.probekill ==1 or DL.braggkill ==1 or DL.lightassist or DL.lightassist_lock: hfimgdelay = 50. #ms analogimg = wfm.wave('analogimg', newANDORhfimg, 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.braggkilltime+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) elif DL.lightassist == 1 or DL.lightassist_lock: analogimg.appendhold( bfield.dt() - hfimgdelay) analogimg.linear( DL.lightassist_hfimg , 0.0) duration = DL.lightassist_lockdtUP + DL.lightassist_t0 + DL.lightassistdt + DL.lightassist_lockdtDOWN analogimg.appendhold( hfimgdelay + duration + 3*DL.ss) analogimg.linear( newANDORhfimg, 0.) analogimg.extend(10) wfms.append(analogimg) #analogimg = bfieldwfm.hfimg_wave('analogimg', ANDOR.hfimg, DL.ss) #andorhfimg0 = analogimg.follow(bfield, DL.imgdet) #wfms.append(analogimg) # If we are doing round trip END, then mirror all the ramps # before adding them to the sequence if DL.round_trip == 1: if DL.round_trip_type == 1: maxdt = 0. maxi = -1 for i,w in enumerate(wfms): if w.dt() > maxdt: maxdt = w.dt() maxi = i maxdt = maxdt + DL.wait_at_top for w in wfms: w.extend(maxdt) if 'lcr' in w.name: yvals = w.y alpha_mirror = numpy.copy(alpha_desired[::-1]) N_adv = int(math.floor( DL.lcr_mirror_advance / DL.ss)) if N_adv < v0.size: alpha_mirror = alpha_mirror[N_adv:] alpha_mirror = numpy.append(alpha_mirror, (yvals.size-alpha_mirror.size)*[alpha_mirror[-1]]) else: alpha_mirror = numpy.array( yvals.size*[alpha_mirror[-1]] ) w.y = numpy.concatenate((yvals,physics.cnv( w.name, alpha_mirror ))) else: w.mirror() w.appendhold( DL.wait_at_end) N_adv = int(math.floor( alpha_advance / DL.ss)) alpha_desired = numpy.copy(alpha) duration = s.analogwfm_add(DL.ss,wfms) s.wait( duration ) if DL.lock: if DL.camera == 'manta' or DL.camera == 'both': s.wait( - MANTA.noatoms) ### 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
def Evap8(self, p0, p1, t1, tau, beta, offset, t2, tau2, smoothdt, duration, scale=1.0): """Evaporation ramp v8 same as v7 with scale""" if True: print "" print "----- EVAPORATION RAMP Version 7-----" print "\tp0 = %.4f" % p0 print "\tp1 = %.4f" % p1 print "\tt1 = %.4f" % t1 print "\ttau = %.4f" % tau print "\tbeta = %.4f" % beta print "\toffset = %.4f" % offset print "\tt2 = %.4f" % t2 print "\ttau2 = %.4f" % tau2 print "\tduration = %.4f" % duration if duration <= 0: return else: N = int(round(duration * scale / self.ss)) print '\t...Evap nsteps = ' + str(N) ramp_phys = numpy.array([]) ramp = numpy.array([]) hashbase = '' hashbase = hashbase + '%.8f' % b hashbase = hashbase + '%.8f' % m1 hashbase = hashbase + '%.8f' % m2 hashbase = hashbase + '%.8f' % m3 hashbase = hashbase + '%.8f' % kink1 hashbase = hashbase + '%.8f' % kink2 hashbase = hashbase + '%.s' % self.name hashbase = hashbase + '%.8f' % self.ss hashbase = hashbase + '%.8f' % duration hashbase = hashbase + '%.8f' % p0 hashbase = hashbase + '%.8f' % p1 hashbase = hashbase + '%.8f' % t1 hashbase = hashbase + '%.8f' % tau hashbase = hashbase + '%.8f' % beta hashbase = hashbase + '%.8f' % offset hashbase = hashbase + '%.8f' % t2 hashbase = hashbase + '%.8f' % tau2 hashbase = hashbase + '%.8f' % smoothdt hashbase = hashbase + '%.8f' % scale ramphash = seqconf.ramps_dir() +'Evap8_' \ + hashlib.md5( hashbase).hexdigest() #Here, go ahead and save the trajectory path to the report gen.save_to_report('EVAP', 'ramp', ramphash + '_phys') if not os.path.exists(ramphash) or True: print '\t...Making new Evap7 ramp' for xi in range(N): t = (xi + 1) * self.ss / scale phys = evap.v6(t, p0, p1, t1, tau, beta, offset, t2, tau2, smoothdt) volt = OdtpowConvert(phys) ramp_phys = numpy.append(ramp_phys, [phys]) ramp = numpy.append(ramp, numpy.around([volt], decimals=4)) ramp_phys.tofile(ramphash + '_phys', sep='\n', format="%.4f") ramp.tofile(ramphash, sep=',', format="%.4f") else: print '\t...Recycling previously calculated Evap7 ramp' ramp = numpy.fromfile(ramphash, sep=',') self.y = numpy.append(self.y, ramp) #This returns the last value of the ramp print "" return evap.v6(N * self.ss / scale, p0, p1, t1, tau, beta, offset, t2, tau2, smoothdt)
def odt_evap_field(image, scale=1.0): evap_ss = f('EVAP', 'evapss') p0 = f('ODT', 'odtpow') p1 = f('EVAP', 'p1') t1 = f('EVAP', 't1') tau = f('EVAP', 'tau') beta = f('EVAP', 'beta') offset = f('EVAP', 'offset') t2 = f('EVAP', 't2') tau2 = f('EVAP', 'tau2') smoothdt = f('EVAP', 'smoothdt') field_ramp_time = f('EVAP', 'fieldrampt0') * scale field_ramp_dt = f('EVAP', 'fieldrampdt') * scale field_ramp_start = f('FESHBACH', 'bias') field_ramp_final = f('EVAP', 'fieldrampfinal') ramp = [] hashbase = '' hashbase = hashbase + '%.8f' % image hashbase = hashbase + '%.8f' % evap_ss hashbase = hashbase + '%.8f' % field_ramp_time hashbase = hashbase + '%.8f' % field_ramp_dt hashbase = hashbase + '%.8f' % field_ramp_start hashbase = hashbase + '%.8f' % field_ramp_final hashbase = hashbase + '%.8f' % scale ramphash = seqconf.ramps_dir() + 'Evap_field_withscale' + hashlib.md5( hashbase).hexdigest() #Here, go ahead and save the trajectory path to the report gen.save_to_report('EVAP', 'ramp_field', ramphash) bfield = wfm.wave('bfield', field_ramp_start, evap_ss) if not os.path.exists(ramphash) or True: bfield.extend(field_ramp_time) bfield.linear(field_ramp_final, field_ramp_dt) if ((field_ramp_time + field_ramp_dt) < image * scale): bfield.extend(image * scale) else: bfield.chop(image * scale) ramp = bfield.y ramp.tofile(ramphash, sep=',', format="%.4f") else: print '\t...Recycling previously calculated Evap_field' ramp = numpy.fromfile(ramphash, sep=',') bfield.y = numpy.append(bfield.y, ramp) odtpow = odt_wave('odtpow', p0, evap_ss) #~ odtpow_test = odt_wave('NC0', p0, evap_ss) #~ odtpow_test2 = odt_wave('NC1', p0, evap_ss) #odtpow.Evap(p0, p1, t1, tau, beta, image) #odtpow.Evap2(p0, p1, t1, tau, beta, offset, t2, tau2, image) #odtpow.Evap3(p0, p1, t1, tau, beta, offset, t2, tau2, image) ### SELECT EVAP TRAJECTORY HERE### finalcpow = odtpow.Evap8(p0, p1, t1, tau, beta, offset, t2, tau2, smoothdt, image, scale) #~ finalcpow2 = odtpow_test.Evap7(p0, p1, t1, tau, beta, offset, t2, tau2,smoothdt,image) #~ finalcpow3 = odtpow_test2.Evap7(p0, p1, t1, tau, beta, offset, t2, tau2,smoothdt,image) #Here, go ahead and save the finalcpow to the report gen.save_to_report('EVAP', 'finalcpow', finalcpow) #ipganalog starts out at full power ipganalog = ipg_wave('ipganalog', 10., evap_ss) if f('ODT', 'use_servo') == 0: ipganalog.extend(odtpow.dt()) elif f('ODT', 'use_servo') == 1: ipganalog.follow(odtpow) #~ ipganalog.follow( odtpow ) #~ odtpow.Exponential(pow0,powf,evap_dt,tau) #~ odtpow.linear( powf, evap_ss) #~ odtpow.appendhold( evap_dt) maxDT = odtpow.dt() return bfield, odtpow, maxDT, finalcpow, ipganalog #,odtpow_test,odtpow_test2
report = gen.getreport() # GET SECTION CONTENTS DIMPLE = gen.getsection("DIMPLE") EVAP = gen.getsection("EVAP") FB = gen.getsection("FESHBACH") ZC = gen.getsection("ZEROCROSS") ANDOR = gen.getsection("ANDOR") DL = gen.getsection("DIMPLELATTICE") MANTA = gen.getsection("MANTA") print "\n...SEQ:camera will be modified in report" print "\tNEW SEQ:camera = %s\n" % (DL.camera) # When only use one camera the reading of DL.camera will be a string instead of a list of string. As a consequence we need to check the type. gen.save_to_report("SEQ", "camera", DL.camera if type(DL.camera) == type("string") else ",".join(DL.camera)) # SEQUENCE stepsize = float(report["SEQ"]["stepsize"]) s = seq.sequence(stepsize) s = gen.initial(s) s.digichg("hfimg", 1) s.digichg("odt7595", 0) # Get hfimg ready s.digichg("hfimg", 1) # If using analoghfimg get it ready if ANDOR.analoghfimg == 1: s.digichg("analogimgttl", 1)
report = gen.getreport() # GET SECTION CONTENTS SEQ = gen.getsection("SEQ") EVAP = gen.getsection("EVAP") ANDOR = gen.getsection("ANDOR") ODT = gen.getsection("ODT") FESHBACH = gen.getsection("FESHBACH") ZEROCROSS = gen.getsection("ZEROCROSS") RF = gen.getsection("RF") if EVAP.andor2 == 1: print "\n...SEQ:camera will be modified in report" print "\tNEW SEQ:camera = andor,andor2\n" gen.save_to_report("SEQ", "camera", "andor,andor2") # SEQUENCE s = seq.sequence(SEQ.stepsize) s = gen.initial(s) s.wait(0.0) # Get hfimg ready s.digichg("hfimg", 1) # If using analoghfimg get it ready if ANDOR.analoghfimg == 1: s.digichg("analogimgttl", 1)
s=seq.sequence(stepsize) s=gen.initial(s) s.digichg('hfimg',1) s.digichg('odt7595',0) #Get hfimg ready s.digichg('hfimg',1) #If using analoghfimg get it ready if ANDOR.analoghfimg == 1: s.digichg('analogimgttl',1) if EVAP.andor2 == 1: print "\n...SEQ:camera will be modified in report" print "\tNEW SEQ:camera = andor,andor2\n" gen.save_to_report('SEQ','camera', 'andor,andor2') # Do CNC, UVMOT, and field ramps s, toENDBFIELD = highfield_uvmot.go_to_highfield(s) # Evaporate into the dimple s, cpowend = odt.crossbeam_dimple_evap(s, toENDBFIELD) buffer = 20. s.wait(buffer)
def dimple_to_lattice(s,cpowend): print "----- LATTICE LOADING RAMPS -----" dt = DL.dt N0 = 0 N = int(math.floor( dt/ DL.ss)) x = numpy.arange(dt/N, dt, dt/N) print "%d samples" % N print x.shape # Define how we want to ramp up the lattice depth v0_ramp, xy_v0, v0set = interpolate_ramp( DL.latticeV0) v0 = v0_ramp(x) 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 and DL.image < 2500.: 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 if DIMPLE.allirpow > 0.: ir_offset = DIMPLE.allirpow else: ir_offset = DIMPLE.ir1pow2 ir_ramp, xy_ir, ir = interpolate_ramp( DL.irpow, yoffset=ir_offset) 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) alpha_clip_range = 0.1 if (v0 > y_ir+ alpha_clip_range).any(): msg = "IRPOW ERROR: not enough power to get desired lattice depth" print msg bad = numpy.where( v0 > y_ir + alpha_clip_range) timefail = int(bad[0][0])*float(DL.ss) msg = msg + "\nFirst bad sample = %d out of %d" % (bad[0][0], v0.size) msg = msg + "\n t = %f " % timefail 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 grwfms = {} splmrkr = ['x','+','d'] ptsmrkr = ['^','s','p'] for i,grramp in enumerate([(DL.grpow1,DIMPLE.gr1pow2), (DL.grpow2,DIMPLE.gr2pow2), (DL.grpow3,DIMPLE.gr3pow2)]): ramppts = grramp[0] ramp0 = grramp[1] print 'gr'+'%d'%i +' offset = %f' % ramp0 gr_ramp, xy_gr, gr = interpolate_ramp( ramppts, yoffset=ramp0) 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) grwfms[ 'greenpow' + '%1d' % (i+1) ] = y_gr ax0.plot(xy_gr[:,0],xy_gr[:,1], marker= splmrkr[i] ,mec='green', mfc='None', ms=3.) ax0.plot(gr[:,0],gr[:,1], marker=ptsmrkr[i], mew=xymew, ms=xyms/2., mfc='None', mec='green')#, label='grpow dat') ax0.plot(x_v0, y_gr, lw=lw, color='green', label='grpow') for grch in grwfms.keys(): print grch, " = ", grwfms[grch].shape 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 = alpha.clip(0.,1.) 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]] ) #alpha = alpha.clip(0., 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, grwfms['greenpow1'], 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') shutil.copyfile( datfile, seqconf.savedir() + 'expseq' + seqconf.runnumber() + '_latticeRamp.dat') #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 correction = DIMPLE.__dict__['gr'+n+'correct'] w.y = physics.cnv( ch, correction * grwfms[ch] ) 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 force = DL.__dict__['force_'+ch] if force >= 0 and force <=1: print "...Forcing LCR%s = %f during lattice ramp" % (n,force) w.y = physics.cnv( ch, numpy.array( alpha.size*[force] ) ) else: 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) # 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) #Take care of imaging frequencies, including various kill experiments bfieldG = physics.inv( 'bfield', bfield.y[-1]) * 6.8 hfimg0 = -1.*(100.0 + 163.7 - 1.414*bfieldG) 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) newANDORhfimg = hfimg0 - DL.imgdet # Kill hfimg if DL.probekill ==1 or DL.braggkill ==1 or DL.lightassist or DL.lightassist_lock: hfimgdelay = 50. #ms analogimg = wfm.wave('analogimg', newANDORhfimg, 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.braggkilltime+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) #elif DL.lightassist == 1 or DL.lightassist_lock: # analogimg.appendhold( bfield.dt() - hfimgdelay) # analogimg.linear( DL.lightassist_hfimg , 0.0) # duration = DL.lightassist_lockdtUP + DL.lightassist_t0 + DL.lightassistdt + DL.lightassist_lockdtDOWN # analogimg.appendhold( hfimgdelay + duration + 3*DL.ss) analogimg.linear( newANDORhfimg, 0.) analogimg.extend(10) wfms.append(analogimg) #analogimg = bfieldwfm.hfimg_wave('analogimg', ANDOR.hfimg, DL.ss) #andorhfimg0 = analogimg.follow(bfield, DL.imgdet) #wfms.append(analogimg) # If we are doing round trip END, then mirror all the ramps # before adding them to the sequence if DL.round_trip == 1: if DL.round_trip_type == 1: maxdt = 0. maxi = -1 for i,w in enumerate(wfms): if w.dt() > maxdt: maxdt = w.dt() maxi = i maxdt = maxdt + DL.wait_at_top / 2. for w in wfms: w.extend(maxdt) if 'lcr' in w.name: yvals = w.y #Get the reverse of the alpha desired array alpha_mirror = numpy.copy(alpha_desired[::-1]) #Add the wait at top part so that it has same length as yvals if alpha_mirror.size > yvals.size: print "Error making mirror ramp for LCR." print "Program will exit." exit(1) alpha_mirror = numpy.append( (yvals.size - alpha_mirror.size)*[ alpha_mirror[0] ], alpha_mirror ) #This is how much the mirror ramp will be advanced N_adv = int(math.floor( DL.lcr_mirror_advance / DL.ss)) if N_adv < alpha_mirror.size: alpha_mirror = alpha_mirror[N_adv:] alpha_mirror = numpy.append(alpha_mirror, (yvals.size-alpha_mirror.size)*[alpha_mirror[-1]]) else: alpha_mirror = numpy.array( yvals.size*[alpha_mirror[-1]] ) w.y = numpy.concatenate((yvals,physics.cnv( w.name, alpha_mirror ))) else: w.mirror() w.appendhold( DL.wait_at_end) N_adv = int(math.floor( alpha_advance / DL.ss)) alpha_desired = numpy.copy(alpha) for wavefm in wfms: print "%s dt = %f" % (wavefm.name, wavefm.dt()) #Wait the buffer for the lattice loading ramps before adding them bufferdt = 20. s.wait(bufferdt) #Add lattice wfms duration = s.analogwfm_add(DL.ss,wfms) if DL.image < 2500.: s.wait(duration) else: print "...DL.image = %f >= 2500. Digital seq extension will be used." % DL.image s.wait( DL.image ) #Here give some buffer time to do lock, RF etc. #It has to be minimum 5.0 ms ### 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, y_ir[-1]
def dimple_to_lattice(s,cpowend): print "----- LATTICE LOADING RAMPS -----" # Find out which is the longest of the ramps we are dealing with: maxX =max( [xdomain(DL.latticeV0)[1] ,\ xdomain(DL.irpow)[1],\ xdomain(DL.grpow1)[1],\ xdomain(DL.grpow2)[1],\ xdomain(DL.grpow3)[1],\ xdomain(DL.a_s)[1]] ) print "Largest x value = %.3f ms\n" % maxX # We define the times for which all functions will be evaluated # MIN TIME TO DO DIGITAL EXTENSION DIGEXTENSION = 2050. if DL.image >= DIGEXTENSION: Xendtime = DIGEXTENSION else: Xendtime = DL.image Nnew = int(math.floor( Xendtime / DL.ss) ) Xnew = numpy.arange( Xendtime/Nnew, DL.image, Xendtime/Nnew ) print "X array defined from dt:" print "DL.ss =", DL.ss print "x0 = ",Xnew[0] print "xf = ",Xnew[-1] print "xdt = ",Xnew[1]-Xnew[0] print "%d samples" % Nnew print 'x shape = ', Xnew.shape # Define how we want to ramp up the lattice depth v0_ramp, xy_v0, v0set = interpolate_ramp( DL.latticeV0) v0 = v0_ramp(Xnew) ########################################### #### 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]) allax = [ax0, ax1, ax2, ax3, ax4, ax5, ax6] for ax in allax: ax.axvline( DL.image, linewidth = 1., color='black', alpha=0.6) lw=1.5 labelx=-0.12 legsz =8. xymew=0.5 xyms=9 ax0.plot( Xnew, 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 if DIMPLE.allirpow > 0.: ir_offset = DIMPLE.allirpow else: ir_offset = DIMPLE.ir1pow2 ir_ramp, xy_ir, ir = interpolate_ramp( DL.irpow, yoffset=ir_offset) 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_ramp(Xnew) 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) alpha_clip_range = 0.1 if (v0 > y_ir+ alpha_clip_range).any(): msg = "IRPOW ERROR: not enough power to get desired lattice depth" print msg bad = numpy.where( v0 > y_ir + alpha_clip_range) timefail = int(bad[0][0])*float(DL.ss) msg = msg + "\nFirst bad sample = %d out of %d" % (bad[0][0], v0.size) msg = msg + "\n t = %f " % timefail 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(Xnew, y_ir, lw=lw, color='darkorange',label='irpow') # Define how we want to ramp up the GR power grwfms = {} splmrkr = ['x','+','d'] ptsmrkr = ['^','s','p'] for i,grramp in enumerate([(DL.grpow1,DIMPLE.gr1pow2), (DL.grpow2,DIMPLE.gr2pow2), (DL.grpow3,DIMPLE.gr3pow2)]): ramppts = grramp[0] ramp0 = grramp[1] print 'gr'+'%d'%i +' offset = %f' % ramp0 gr_ramp, xy_gr, gr = interpolate_ramp( ramppts, yoffset=ramp0) 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(Xnew) if DL.signal == 0: y_gr = y_gr / 2.0 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) grwfms[ 'greenpow' + '%1d' % (i+1) ] = y_gr ax0.plot(xy_gr[:,0],xy_gr[:,1], marker= splmrkr[i] ,mec='green', mfc='None', ms=3.) ax0.plot(gr[:,0],gr[:,1], marker=ptsmrkr[i], mew=xymew, ms=xyms/2., mfc='None', mec='green')#, label='grpow dat') ax0.plot(Xnew, y_gr, lw=lw, color='green', label='grpow') for grch in grwfms.keys(): print grch, " = ", grwfms[grch].shape 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(Xnew) 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(Xnew, 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 = alpha.clip(0.,1.) 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]] ) #alpha = alpha.clip(0., 1.) ax2.plot( Xnew, alpha, lw=lw, color='saddlebrown', label='alpha adv') ax2.plot( Xnew, 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( Xnew, 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) print print "The last value of the scattering length ramp is:" print 'a_s =', y_a_s[-1] print 'B =', bfieldG[-1] print U_over_t = y_a_s * bohrRadius / lattice_spacing * wannierF / tunneling_Er ax4.plot( Xnew, 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( Xnew, 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( Xnew, (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((Xnew, v0, y_ir, grwfms['greenpow1'], 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') shutil.copyfile( datfile, seqconf.savedir() + 'expseq' + seqconf.runnumber() + '_latticeRamp.dat') #plt.savefig( seqconf.savedir() + 'expseq' + seqconf.runnumber() + '_latticeRamp.png', dpi=120) ################################# #### APPEND RAMPS TO SEQUENCE ### ################################# wfms=[] if DL.signal == 0: print " LOCK VALUE FOR SIGNAL / NOSIGNAL " print " before = ", DL.lock_Er DL.lock_Er = DL.lock_Er / 1.8 print " after = \n", DL.lock_Er 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 ) if DL.lock: endval = w.y[-1] w.insertlin_cnv(DL.lock_Er, DL.lock_dtUP, DL.lock_t0 ) elif DL.lightassist_lock: endval = w.y[-1] w.linear(DL.lightassist_lockpowIR, DL.lightassist_lockdtUP) w.appendhold( DL.lightassist_t0 + DL.lightassistdt ) if DL.endvalIR >= 0.: w.linear( DL.endvalIR, DL.lightassist_lockdtDOWN) else: w.linear( None, DL.lightassist_lockdtDOWN, volt=endval) 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 correction = DIMPLE.__dict__['gr'+n+'correct'] w.y = physics.cnv( ch, correction * grwfms[ch] ) if DL.lightassist_lock: endval = w.y[-1] w.linear(DL.lightassist_lockpowGR, DL.lightassist_lockdtUP) w.appendhold( DL.lightassist_t0 + DL.lightassistdt ) if DL.endvalGR >= 0.: w.linear( DL.endvalGR, DL.lightassist_lockdtDOWN) else: w.linear( None, DL.lightassist_lockdtDOWN, volt=endval) 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 force = DL.__dict__['force_'+ch] if force >= 0 and force <=1: print "...Forcing LCR%s = %f during lattice ramp" % (n,force) w.y = physics.cnv( ch, numpy.array( alpha.size*[force] ) ) elif DL.signal == 0: print "...Forcing LCR%s = 0. so that it does NOT rotate to LATTICE" % n w.y = physics.cnv( ch, numpy.array( alpha.size*[0.0] ) ) else: 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) print "The last value of the bfield voltage is =", bfield.y[-1] print wfms.append(bfield) ##ADD gradient field gradient = gradient_wave('gradientfield', 0.0, DL.ss,volt = 0.0) gradient.follow(bfield) wfms.append(gradient) buffer = 40. 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) if DL.round_trip == 1: bindex = 0 # Calculate detunings using starting field else: bindex = -1 # Calculate detunings using field at the end of ramps bfieldG = physics.inv( 'bfield', bfield.y[bindex]) * 6.8 hfimg0 = -1.*(100.0 + 163.7 - 1.414*bfieldG) # Find bindex for braggkill time bindex_BK = math.floor(-DL.braggkilltime / bfield.ss) bfieldG_BK = physics.inv( 'bfield', bfield.y[-1-bindex_BK]) * 6.8 hfimg0_BK = -1.*(100.0 + 163.7 - 1.414*bfieldG_BK) DL.braggkill_hfimg = hfimg0_BK - DL.braggkill_hfimg print "\n...Braggkill hfimg modification:\n" print "\tNEW braggkill_hfimg = %.2f MHz" % DL.braggkill_hfimg # Find bindex for bragg2kill time bindex_B2K = math.floor(-DL.bragg2killtime / bfield.ss) bfieldG_B2K = physics.inv( 'bfield', bfield.y[-1-bindex_B2K]) * 6.8 hfimg0_B2K = -1.*(100.0 + 163.7 - 1.414*bfieldG_B2K) DL.bragg2kill_hfimg1 = hfimg0_B2K - DL.bragg2kill_hfimg1 DL.bragg2kill_hfimg2 = hfimg0_B2K - DL.bragg2kill_hfimg2 print "\n...Bragg2kill hfimg modification:\n" print "\tNEW brag2gkill_hfimg1 = %.2f MHz" % DL.bragg2kill_hfimg1 print "\tNEW brag2gkill_hfimg2 = %.2f MHz" % DL.bragg2kill_hfimg2 print "\n...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) newANDORhfimg = hfimg0 - DL.imgdet # THIS DEFINES THE TIME IT TAKES THE OFFSET LOCK TO SWITCH TO # A NEW SETPOINT hfimgdelay = 50. #ms # Kill hfimg if DL.probekill ==1 or DL.braggkill ==1 or DL.bragg2kill==1 or DL.lightassist or DL.lightassist_lock: analogimg = wfm.wave('analogimg', newANDORhfimg, 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: print "Setting up analogimg for braggkill" if (-DL.braggkilltime+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) elif DL.bragg2kill == 1: print "Setting up analogimg for bragg2kill" if (-DL.bragg2killtime+hfimgdelay) < DL.image: # This sets up the detuning for the first pulse analogimg.appendhold( bfield.dt() + DL.bragg2killtime - hfimgdelay) analogimg.linear( DL.bragg2kill_hfimg1 , 0.0) analogimg.appendhold( hfimgdelay + DL.bragg2killdt + 3*DL.ss) # Then set up the detuning for the second pulse analogimg.linear( DL.bragg2kill_hfimg2 , 0.0) analogimg.appendhold( hfimgdelay + DL.bragg2killdt + 3*DL.ss) elif DL.lightassist == 1 or DL.lightassist_lock: analogimg.appendhold( bfield.dt() - hfimgdelay) analogimg.linear( DL.lightassist_hfimg , 0.0) duration = DL.lightassist_lockdtUP + DL.lightassist_t0 + DL.lightassistdt + DL.lightassist_lockdtDOWN analogimg.appendhold( hfimgdelay + duration + 3*DL.ss) analogimg.linear( newANDORhfimg, 0.) analogimg.extend(10) wfms.append(analogimg) #analogimg = bfieldwfm.hfimg_wave('analogimg', ANDOR.hfimg, DL.ss) #andorhfimg0 = analogimg.follow(bfield, DL.imgdet) #wfms.append(analogimg) # If we are doing round trip END, then mirror all the ramps # before adding them to the sequence if DL.round_trip == 1: if DL.round_trip_type == 1: maxdt = 0. maxi = -1 for i,w in enumerate(wfms): if w.dt() > maxdt: maxdt = w.dt() maxi = i maxdt = maxdt + DL.wait_at_top / 2. for w in wfms: w.extend(maxdt) if 'lcr' in w.name: yvals = w.y #Get the reverse of the alpha desired array alpha_mirror = numpy.copy(alpha_desired[::-1]) #Add the wait at top part so that it has same length as yvals if alpha_mirror.size > yvals.size: print "Error making mirror ramp for LCR." print "Program will exit." exit(1) alpha_mirror = numpy.append( (yvals.size - alpha_mirror.size)*[ alpha_mirror[0] ], alpha_mirror ) #This is how much the mirror ramp will be advanced N_adv = int(math.floor( DL.lcr_mirror_advance / DL.ss)) if N_adv < alpha_mirror.size: alpha_mirror = alpha_mirror[N_adv:] alpha_mirror = numpy.append(alpha_mirror, (yvals.size-alpha_mirror.size)*[alpha_mirror[-1]]) else: alpha_mirror = numpy.array( yvals.size*[alpha_mirror[-1]] ) w.y = numpy.concatenate((yvals,physics.cnv( w.name, alpha_mirror ))) else: w.mirror() w.appendhold( DL.wait_at_end) N_adv = int(math.floor( alpha_advance / DL.ss)) alpha_desired = numpy.copy(alpha) for wavefm in wfms: print "%s dt = %f" % (wavefm.name, wavefm.dt()) duration = s.analogwfm_add(DL.ss,wfms) if DL.image < DIGEXTENSION: s.wait(duration) else: print "...DL.image = %f >= %.2f Digital seq extension will be used." % (DL.image, DIGEXTENSION) s.wait( DL.image ) ### Prepare the parts of the ramps that are going to be used to mock ### the conditions for the noatoms shot ### 1. get dt = [noatoms] ms from the end of the lattice ramps. if 'manta' in DL.camera: noatomsdt = MANTA.noatoms else: noatomsdt = ANDOR.noatoms noatomswfms = [] for wavefm in wfms: cp = copy.deepcopy( wavefm ) cp.idnum = time.time()*100 cp.retain_last( DL.bgRetainDT ) noatomswfms.append( cp ) ### 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) ######################################### ## OTHER TTL EVENTS: probekill, braggkill, rf, quick2 ######################################### # Braggkill if DL.braggkill == 1: print "Using Bragg Kill" s.wait( DL.braggkilltime) s = manta.OpenShutterBragg(s,DL.shutterdelay) s.digichg('bragg',1) s.wait( DL.braggkilldt) s.digichg('brshutter',1) # to close shutter s.digichg('bragg',0) s.wait( -DL.braggkilldt) s.wait( -DL.braggkilltime ) if DL.bragg2kill == 1: print "Using Bragg 2 Kill" tcur = s.tcur s.wait( DL.bragg2killtime ) s = manta.OpenShutterBragg(s,DL.shutterdelay) s.digichg('bragg',1) s.wait( DL.bragg2killdt) s.digichg('brshutter',1) # to close shutter s.digichg('bragg',0) s.wait( hfimgdelay + 3*DL.ss ) s = manta.OpenShutterBragg(s,DL.shutterdelay) s.digichg('bragg',1) s.wait( DL.bragg2killdt) s.digichg('brshutter',1) # to close shutter s.digichg('bragg',0) # Revert to current time after pulses have been added in the past s.tcur = tcur # Probe Kill if DL.probekill == 1: s.wait(DL.probekilltime) s.wait(-10) s.digichg('prshutter',0) s.wait(10) s.digichg('probe',1) s.wait(DL.probekilldt) s.digichg('probe',0) s.digichg('prshutter',1) s.wait(-DL.probekilltime) # Pulse RF if DL.rf == 1: s.wait(DL.rftime) s.digichg('rfttl',1) s.wait(DL.rfpulsedt) s.digichg('rfttl',0) s.wait(-DL.rfpulsedt) s.wait(-DL.rftime) # QUICK2 if DL.quick2 == 1: s.wait( DL.quick2time) s.digichg('quick2',1) s.wait(-DL.quick2time) # Light-assisted collisions if DL.lightassist == 1 or DL.lightassist_lock: s.wait( -DL.lightassist_lockdtUP -DL.lightassist_t0 -DL.lightassistdt -DL.lightassist_lockdtDOWN - 3*DL.ss) s.wait(DL.lightassist_lockdtUP + DL.lightassist_t0) s.wait(-10) s.digichg('prshutter',0) s.wait(10) s.digichg('probe', DL.lightassist) s.wait(DL.lightassistdt) s.digichg('probe',0) s.digichg('prshutter',1) s.wait(DL.lightassist_lockdtDOWN) s.wait(3*DL.ss) # After the collisions happen we still need to wait some time # for the probe frequency to come back to the desired value s.wait(hfimgdelay) ######################################### ## GO BACK IN TIME IF DOING ROUND-TRIP START ######################################### if DL.round_trip == 1: if DL.round_trip_type == 0: s.wait( -DL.image ) s.stop_analog() ######################################### ## TURN GREEN OFF BEFORE PICTURES ######################################### if DL.greenoff == 1: s.wait( DL.greenoff_t0 ) s.digichg('greenttl1', 0) s.digichg('greenttl2', 0) s.digichg('greenttl3', 0) s.wait(-DL.greenoff_t0 ) ######################################### ## LATTICE LOCK WITH POSSIBILITY OF RF ######################################### bufferdt = 5.0 lastIR = y_ir[-1] lockwfms=[] if DL.locksmooth == 1 and DL.lock == 0: s.wait(bufferdt) for ch in ['ir1pow','ir2pow','ir3pow']: n = filter( str.isdigit, ch)[0] w = wfm.wave(ch, lastIR, DL.lockss) #Start value will be overrriden w.tanhRise( DL.lock_Er, DL.lock_dtUP, 0.4,0.2) lockwfms.append(w) print "...LOCKING LATTICE TO %f Er" % DL.lock_Er print "...lastIR = %.4f" % lastIR duration = s.analogwfm_add(DL.lockss,lockwfms) print "...duration = %.2f" % duration s.wait(duration) #~ if DL.lockrf: #~ s.digichg('rfttl',1) #~ s.wait(DL.rfpulsedt) #~ s.digichg('rfttl',0) #~ s.wait(0.036) #else: # s.wait(bufferdt) lockwfmscopy = [] for wavefm in lockwfms: cp = copy.deepcopy( wavefm ) cp.idnum = time.time()*100 + 1e3*numpy.random.randint(0,1e8) lockwfmscopy.append( cp ) ######################################### ## IMAGING AT LOW FIELD ######################################### if DL.lowfieldimg == 1: s.wait(DL.lowfieldimg_t0) s.digichg('field',0) s.wait(-DL.lowfieldimg_t0) ######################################### ## TTL RELEASE FROM ODT and LATTICE ######################################### #INDICATE WHICH CHANNELS ARE TO BE CONSIDERED FOR THE BACKGROUND bg = ['odtttl','irttl1','irttl2','irttl3','greenttl1','greenttl2','greenttl3'] bgdictPRETOF={} for ch in bg: bgdictPRETOF[ch] = s.digistatus(ch) bgdictPRETOF['tof'] = DL.tof print "\nChannel status for pictures: PRE-TOF" print bgdictPRETOF print #RELEASE FROM LATTICE if DL.tof <= 0.: s.wait(1.0+ANDOR.exp) s.digichg('greenttl1',0) s.digichg('greenttl2',0) s.digichg('greenttl3',0) s.digichg('irttl1',0) s.digichg('irttl2',0) s.digichg('irttl3',0) #RELEASE FROM IR TRAP s.digichg('odtttl',0) if DL.tof <= 0.: s.wait(-1.0+ANDOR.exp) print "TIME WHEN RELEASED FROM LATTICE = ",s.tcur s.wait(DL.tof) return s, noatomswfms, lockwfmscopy, bgdictPRETOF
s.wait(tof) #Use MOT beams for fluorescence imaging light = 'motswitch' noatoms = 67.0 cameras = UVSEC.camera imagetime = s.tcur if 'andor' in cameras: new_seqcam = 'andor' else: new_seqcam = 'none' print "\n...SEQ:camera will be modified in report" print "\tNEW SEQ:camera = %s\n" % new_seqcam # SEQ:camera needs to be a list of strings. gen.save_to_report('SEQ','camera', new_seqcam) print "Current time before BASLER = ", s.tcur #Take fluorescence imaging shot with the MOT beams. #PICTURE OF ATOMS s.tcur = imagetime s=basler.BaslerPicture(s,preexp,texp,postexp,light) #PICTURE OF BACKGROUND s.wait(noatoms) s.wait(noatoms) s.wait(noatoms) s=basler.BaslerPicture(s,preexp,texp,postexp,light) print "Current time after BASLER = ", s.tcur if 'andor' in cameras: s.tcur = imagetime