Exemple #1
0
	def SineMod4(self, p0, dt, freq, depth):
		"""Sine wave modulation on channel"""
		if dt <= 0.0:
			return
		else:
			N=int(math.floor(dt/self.ss))
			ramp=[]
			hashbase = '%.8f,%.8f,%.8f,%.8f,%.8f,%.8f,%s,%.3f,%.3f,%.3f,%.3f,%.3f ' % ( b,m1,m2,m3,kink1,kink2, self.name, self.ss, p0, dt, freq, depth)
			ramphash = seqconf.ramps_dir() +'SineMod3_' \
						+ hashlib.md5( hashbase).hexdigest()
			if not os.path.exists(ramphash):
				print '...Making new SineMod4 ramp:  %.2f +/- %.2f' % (p0, 0.5*p0*depth/100.)
				print '... [[ hashbase = %s ]]' % hashbase
				for xi in range(N):
					t = (xi+1)*self.ss
					phys = p0 + (0.5*p0*depth/100.)* math.sin(  t * 2 * math.pi * freq/1000. )
					volt = OdtpowConvert(phys)
					ramp = numpy.append(ramp, [ volt])
				ramp.tofile(ramphash,sep=',',format="%.4f")
			else:
				print '...Recycling previously calculated SineMod3 ramp %.2f +/- %.2f' % (p0, 0.5*p0*depth/100.)
				print '... [[ hashbase = %s ]]' % hashbase
				ramp = numpy.fromfile(ramphash,sep=',')
			
			self.y=numpy.append(self.y,ramp)
		return
Exemple #2
0
	def Evap2(self, p0, p1, t1, tau, beta, offset, t2, tau2, duration):
		"""Evaporation ramp v2"""
		if duration <=0:
			return
		else:
			N=int(round(duration/self.ss))
			print '...Evap nsteps = ' + str(N)
			ramp=[]
			ramphash = seqconf.ramps_dir() + 'Evap2_' \
					   + hashlib.md5(str(self.name)+str(self.ss)+str(duration)+str(p0)+str(p1)+str(t1)+str(tau)+str(beta)\
					                  + str(offset)+str(t2)+str(tau2)).hexdigest()
			if not os.path.exists(ramphash):
				print '...Making new Evap2 ramp'
				for xi in range(N):
					t = (xi+1)*self.ss
					phys = evap.v2(t,p0,p1,t1,tau,beta, offset,t2,tau2)
					volt = cnv(self.name,phys)
					ramp = numpy.append( ramp, [ volt])
				ramp.tofile(ramphash,sep=',',format="%.4f")
			else:
				print '...Recycling previously calculated Evap2 ramp'
				ramp = numpy.fromfile(ramphash,sep=',')

			self.y=numpy.append(self.y,ramp)
		return
Exemple #3
0
	def linear_phys(self,vf,dt):
		"""Adds linear ramp to waveform, starts at current last 
			value and goes to 'vf' in 'dt'"""
		
		if self.lastPhys == None:
			msg = "The last physics value is not available\n for this waveform."
			msg = msg + "\n\nProgram will be stopped."
			errormsg.box('wfm.linear_phys :: ' + self.name, msg)
			exit(1)
		
		print "...linear_phys last physical value is = %f" % self.lastPhys
		
		v0 = self.lastPhys
		
		#One could also obtain v0 via conversion, but it is not recommended		
		#v0=physics.cnv(self.name+"Phys",self.last())
		
		if dt == 0.0:
			self.y[ self.y.size -1] = physics.cnv(self.name,vf)
			return

			
		N = int(math.floor(dt/self.ss))

		hashbase = ''
		hashbase = hashbase + self.name
		hashbase = hashbase + '%.8f' % vf
		hashbase = hashbase + '%.8f' % v0
		hashbase = hashbase + '%.8f' % N
		hashbase = hashbase + '%.8f' % dt
		hashbase = hashbase + rawcalibdat( self.name ) 
		
		ramphash = seqconf.ramps_dir() + 'linearPhys_' \
			           + hashlib.md5( hashbase ).hexdigest()
	
		if not os.path.exists(ramphash) or True:
				print '...Making new linearPhys ramp for ' + self.name
				
				x = numpy.linspace( v0 + (vf-v0)/N , vf , N )
				ramp = physics.cnv( self.name, x )
				
				#yramp= numpy.array([cnv(self.name,v0 + 1.0*(vf-v0)*(i+1)/N) for i in range(N)])
				
				#if ( numpy.absolute( yramp - ramp ) > 0.0001 ).any():
				#	print "NOT EQUAL!"
				#else:
				#	print "EQUAL!"
					
					
				#ramp.tofile(ramphash,sep=',',format="%.4f")
				
				
		else:
				print '...Recycling previously calculated linearPhys ramp for '  + self.name
				ramp =  numpy.fromfile(ramphash,sep=',')	

		self.y=numpy.append(self.y, ramp)
		self.lastPhys = vf
		
		return
Exemple #4
0
	def analogwfm_add(self,step,wfms):
		""" analogwfm_add adds a waveform output ot the sequence.
			aouts is an array of waveforms (instances of the wfm class)
			The device is determined from the names of the wfm's 
			and a pulse is added to the DIGITAL_OUT that triggers
			the device.  This function makes sure that the added
			waveform does not conflict with any waveform outputs
			already in the sequence.
			"""
		aouts = []
		
		#print("...start adding waveforms.")
		ss0=0
		for n,elem in enumerate(wfms):
			if n == 0: ss0= elem.ss
			if elem.ss != ss0:
				print "Step Size doesn't match in Waveform."
				for el in wfms:
					print "Channel=",el.name,"\tStep Size=",el.ss
				exit(1)
			ss0 = elem.ss
			
		for elem in wfms:
			dict = {}
			dict["name"] = elem.name
			filename = seqconf.ramps_dir()+elem.name+ '_'+ elem.wfm_id() +'.txt'
			elem.fileoutput(filename)
			#print ("filename = %s" % filename)
			dict["path"] = filename
			aouts.append(dict)
			
		#print("...end adding waveforms.")
		
		status = self.analogwfm(step,aouts)
		return status
Exemple #5
0
    def Evap3(self, p0, p1, t1, tau, beta, offset, t2, tau2, duration):
        """Evaporation ramp v2"""
        if duration <= 0:
            return
        else:
            N = int(round(duration / self.ss))
            print '...Evap nsteps = ' + str(N)
            ramp = []
            hashbase = '%.8f,%.8f,%.8f,%.8f,%s,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f ' \
                       % ( b,m1,m2,kink, self.name, self.ss, duration, p0, p1, t1, tau, beta, offset, t2, tau2)

            ramphash = seqconf.ramps_dir() +'Evap3_' \
               + hashlib.md5( hashbase).hexdigest()
            if not os.path.exists(ramphash):
                print '...Making new Evap3 ramp'
                for xi in range(N):
                    t = (xi + 1) * self.ss
                    phys = evap.v2(t, p0, p1, t1, tau, beta, offset, t2, tau2)
                    volt = OdtpowConvert(phys)
                    ramp = numpy.append(ramp, [volt])
                ramp.tofile(ramphash, sep=',', format="%.4f")
            else:
                print '...Recycling previously calculated Evap3 ramp'
                ramp = numpy.fromfile(ramphash, sep=',')

            self.y = numpy.append(self.y, ramp)

        #This returns the last value of the ramp
        return evap.v2(N * self.ss, p0, p1, t1, tau, beta, offset, t2, tau2)
Exemple #6
0
	def Evap3(self, p0, p1, t1, tau, beta, offset, t2, tau2, duration):
		"""Evaporation ramp v2"""
		if duration <=0:
			return
		else:
			N=int(round(duration/self.ss))
			print '...Evap nsteps = ' + str(N)
			ramp=[]
			hashbase = '%.8f,%.8f,%.8f,%.8f,%s,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f ' \
			           % ( b,m1,m2,kink, self.name, self.ss, duration, p0, p1, t1, tau, beta, offset, t2, tau2)
			
			ramphash = seqconf.ramps_dir() +'Evap3_' \
						+ hashlib.md5( hashbase).hexdigest()
			if not os.path.exists(ramphash):
				print '...Making new Evap3 ramp'
				for xi in range(N):
					t = (xi+1)*self.ss
					phys = evap.v2(t,p0,p1,t1,tau,beta, offset,t2,tau2)                    
					volt = OdtpowConvert(phys)
					ramp = numpy.append( ramp, [ volt])
				ramp.tofile(ramphash,sep=',',format="%.4f")
			else:
				print '...Recycling previously calculated Evap3 ramp'
				ramp = numpy.fromfile(ramphash,sep=',')

			self.y=numpy.append(self.y,ramp)

		#This returns the last value of the ramp
		return evap.v2(N*self.ss,p0,p1,t1,tau,beta,offset,t2,tau2)
Exemple #7
0
	def analogwfm_add(self,step,wfms):
		""" analogwfm_add adds a waveform output ot the sequence.
			aouts is an array of waveforms (instances of the wfm class)
			The device is determined from the names of the wfm's 
			and a pulse is added to the DIGITAL_OUT that triggers
			the device.  This function makes sure that the added
			waveform does not conflict with any waveform outputs
			already in the sequence.
			"""
		aouts = []
		
		#print("...start adding waveforms.")
		for elem in wfms:
			dict = {}
			dict["name"] = elem.name
			filename = seqconf.ramps_dir()+elem.name+ '_'+ elem.wfm_id() +'.txt'
			elem.fileoutput(filename)
			#print ("filename = %s" % filename)
			dict["path"] = filename
			aouts.append(dict)
			
		#print("...end adding waveforms.")
		
		status = self.analogwfm(step,aouts)
		return status
Exemple #8
0
    def Evap2(self, p0, p1, t1, tau, beta, offset, t2, tau2, duration):
        """Evaporation ramp v2"""
        if duration <= 0:
            return
        else:
            N = int(round(duration / self.ss))
            print '...Evap nsteps = ' + str(N)
            ramp = []
            ramphash = seqconf.ramps_dir() + 'Evap2_' \
                 + hashlib.md5(str(self.name)+str(self.ss)+str(duration)+str(p0)+str(p1)+str(t1)+str(tau)+str(beta)\
                                + str(offset)+str(t2)+str(tau2)).hexdigest()
            if not os.path.exists(ramphash):
                print '...Making new Evap2 ramp'
                for xi in range(N):
                    t = (xi + 1) * self.ss
                    phys = evap.v2(t, p0, p1, t1, tau, beta, offset, t2, tau2)
                    volt = cnv(self.name, phys)
                    ramp = numpy.append(ramp, [volt])
                ramp.tofile(ramphash, sep=',', format="%.4f")
            else:
                print '...Recycling previously calculated Evap2 ramp'
                ramp = numpy.fromfile(ramphash, sep=',')

            self.y = numpy.append(self.y, ramp)
        return
Exemple #9
0
    def SineMod4(self, p0, dt, freq, depth):
        """Sine wave modulation on channel"""
        if dt <= 0.0:
            return
        else:
            N = int(math.floor(dt / self.ss))
            ramp = []
            hashbase = '%.8f,%.8f,%.8f,%.8f,%.8f,%.8f,%s,%.3f,%.3f,%.3f,%.3f,%.3f ' % (
                b, m1, m2, m3, kink1, kink2, self.name, self.ss, p0, dt, freq,
                depth)
            ramphash = seqconf.ramps_dir() +'SineMod3_' \
               + hashlib.md5( hashbase).hexdigest()
            if not os.path.exists(ramphash):
                print '...Making new SineMod4 ramp:  %.2f +/- %.2f' % (
                    p0, 0.5 * p0 * depth / 100.)
                print '... [[ hashbase = %s ]]' % hashbase
                for xi in range(N):
                    t = (xi + 1) * self.ss
                    phys = p0 + (0.5 * p0 * depth / 100.) * math.sin(
                        t * 2 * math.pi * freq / 1000.)
                    volt = OdtpowConvert(phys)
                    ramp = numpy.append(ramp, [volt])
                ramp.tofile(ramphash, sep=',', format="%.4f")
            else:
                print '...Recycling previously calculated SineMod3 ramp %.2f +/- %.2f' % (
                    p0, 0.5 * p0 * depth / 100.)
                print '... [[ hashbase = %s ]]' % hashbase
                ramp = numpy.fromfile(ramphash, sep=',')

            self.y = numpy.append(self.y, ramp)
        return
Exemple #10
0
    def linear_phys(self, vf, dt):
        """Adds linear ramp to waveform, starts at current last 
			value and goes to 'vf' in 'dt'"""

        if self.lastPhys == None:
            msg = "The last physics value is not available\n for this waveform."
            msg = msg + "\n\nProgram will be stopped."
            errormsg.box('wfm.linear_phys :: ' + self.name, msg)
            exit(1)

        print "...linear_phys last physical value is = %f" % self.lastPhys

        v0 = self.lastPhys

        #One could also obtain v0 via conversion, but it is not recommended
        #v0=physics.cnv(self.name+"Phys",self.last())

        if dt == 0.0:
            self.y[self.y.size - 1] = physics.cnv(self.name, vf)
            return

        N = int(math.floor(dt / self.ss))

        hashbase = ''
        hashbase = hashbase + self.name
        hashbase = hashbase + '%.8f' % vf
        hashbase = hashbase + '%.8f' % v0
        hashbase = hashbase + '%.8f' % N
        hashbase = hashbase + '%.8f' % dt
        hashbase = hashbase + rawcalibdat(self.name)

        ramphash = seqconf.ramps_dir() + 'linearPhys_' \
                    + hashlib.md5( hashbase ).hexdigest()

        if not os.path.exists(ramphash) or True:
            print '...Making new linearPhys ramp for ' + self.name

            x = numpy.linspace(v0 + (vf - v0) / N, vf, N)
            ramp = physics.cnv(self.name, x)

            #yramp= numpy.array([cnv(self.name,v0 + 1.0*(vf-v0)*(i+1)/N) for i in range(N)])

            #if ( numpy.absolute( yramp - ramp ) > 0.0001 ).any():
            #	print "NOT EQUAL!"
            #else:
            #	print "EQUAL!"

            #ramp.tofile(ramphash,sep=',',format="%.4f")

        else:
            print '...Recycling previously calculated linearPhys ramp for ' + self.name
            ramp = numpy.fromfile(ramphash, sep=',')

        self.y = numpy.append(self.y, ramp)
        self.lastPhys = vf

        return
Exemple #11
0
    def sinhRise(self, vf, dt, tau):
        """Inserts a hyperbolic-sine-like ramp to the waveform.  
			tau is the ramp scale, it is understood in units of dt
			
			if tau is equal or greater to dt the ramp approaches a
			linear ramp
		
			as tau gets smaller than dt the ramp starts to deviate from 
			linear
			
			a real difference starts to be seen wheh tau = dt/3
			
			from tau=dt/20 it doesn't make a difference to keep making
			tau smaller
			
			good values to vary it are tau=dt/20, dt/5, dt/3, dt/2, dt"""
        ### WARNING: in general the conversion should be done for every point
        ### i.e. inside of the for loop below.
        ### This one just does it on the endpoints.  It is ok because it is used
        ### for the magnetic field which has a mostly linear relationship between
        ### set voltage and current in the coils.  But don't use this as an example
        ### for other things.
        self.lastPhys = vf
        vf = physics.cnv(self.name, vf)

        v0 = self.last()
        if dt == 0.0:
            self.y[self.y.size - 1] = vf
            return
        else:
            N = int(math.floor(dt / self.ss))

            hashbase = ''
            hashbase = hashbase + self.name
            hashbase = hashbase + '%.8f' % vf
            hashbase = hashbase + '%.8f' % v0
            hashbase = hashbase + '%.8f' % N
            hashbase = hashbase + '%.8f' % dt
            hashbase = hashbase + '%.8f' % tau
            ramphash = seqconf.ramps_dir() + 'sinhRise_' + hashlib.md5(
                hashbase).hexdigest()

            if not os.path.exists(ramphash) or True:
                print '...Making new sinhRise ramp'

                x = numpy.linspace(dt / N, dt, N)
                ramp = v0 + (vf - v0) * (x / tau + (x / tau)**3.0 / 6.0) / (
                    dt / tau + (dt / tau)**3.0 / 6.0)

                #ramp.tofile(ramphash,sep=',',format="%.4f")

            else:
                print '...Recycling previously calculated sinhRise ramp'
                ramp = numpy.fromfile(ramphash, sep=',')

            self.y = numpy.append(self.y, ramp)
        return
Exemple #12
0
	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)
Exemple #13
0
	def sinhRise(self,vf,dt,tau):
		"""Inserts a hyperbolic-sine-like ramp to the waveform.  
			tau is the ramp scale, it is understood in units of dt
			
			if tau is equal or greater to dt the ramp approaches a
			linear ramp
		
			as tau gets smaller than dt the ramp starts to deviate from 
			linear
			
			a real difference starts to be seen wheh tau = dt/3
			
			from tau=dt/20 it doesn't make a difference to keep making
			tau smaller
			
			good values to vary it are tau=dt/20, dt/5, dt/3, dt/2, dt"""
		### WARNING: in general the conversion should be done for every point
		### i.e. inside of the for loop below.
		### This one just does it on the endpoints.  It is ok because it is used
		### for the magnetic field which has a mostly linear relationship between
		### set voltage and current in the coils.  But don't use this as an example
		### for other things.   
		self.lastPhys = vf
		vf=physics.cnv(self.name,vf)
		
		v0=self.last()
		if dt == 0.0:
			self.y[ self.y.size -1] = vf
			return
		else:
			N = int(math.floor(dt/self.ss))
			
			hashbase = ''
			hashbase = hashbase + self.name
			hashbase = hashbase + '%.8f' % vf
			hashbase = hashbase + '%.8f' % v0
			hashbase = hashbase + '%.8f' % N
			hashbase = hashbase + '%.8f' % dt
			hashbase = hashbase + '%.8f' % tau
			ramphash = seqconf.ramps_dir() + 'sinhRise_' + hashlib.md5(hashbase).hexdigest()
			
			if not os.path.exists(ramphash) or True:
				print '...Making new sinhRise ramp'
				
				x = numpy.linspace( dt/N, dt, N)
				ramp = v0 + (vf-v0)*(x/tau+(x/tau)**3.0/6.0)/(dt/tau+(dt/tau)**3.0/6.0)
				
				#ramp.tofile(ramphash,sep=',',format="%.4f")
				
				
			else:
				print '...Recycling previously calculated sinhRise ramp'
				ramp =  numpy.fromfile(ramphash,sep=',')
			
			self.y=numpy.append(self.y, ramp)
		return
Exemple #14
0
    def TwoChsAdiabaticOn(self):
        """ An example that shows how to use the analogwfm method.
			"""
        #A waveform to turn on adiabatically nc-00 and nc-01 is added.
        #The step size is 0.001ms and the values are in the indicated path.
        path00 = seqconf.ramps_dir() + 'adiabatic_tanh_On.txt'
        self.analogwfm(0.001,[{'name':'nc-00',\
                'path':path00},\
               {'name':'nc-01',\
                'path':path00}])
Exemple #15
0
	def TwoChsAdiabaticOn(self):
		""" An example that shows how to use the analogwfm method.
			"""
		#A waveform to turn on adiabatically nc-00 and nc-01 is added.
		#The step size is 0.001ms and the values are in the indicated path.
		path00 = seqconf.ramps_dir()+'adiabatic_tanh_On.txt'
		self.analogwfm(0.001,[{'name':'nc-00',\
							   'path':path00},\
							  {'name':'nc-01',\
							   'path':path00}])
Exemple #16
0
    def TwoChsAdiabaticOff(self):
        """ An example that shows how to use the analogwfm method.
			The paths don't have to be hardcoded, they can be arguments
			defined somewehere else for ease of use.
			"""
        #A waveform to turn off adiabatically nc-00 and nc-01 is added.
        #The step size is 0.001ms and the values are in the indicated path.
        path00 = seqconf.ramps_dir() + 'adiabatic_tanh_Off.txt'
        self.analogwfm(0.001,[{'name':'nc-00',\
                'path':path00},\
               {'name':'nc-01',\
                'path':path00}])
Exemple #17
0
	def TwoChsAdiabaticOff(self):
		""" An example that shows how to use the analogwfm method.
			The paths don't have to be hardcoded, they can be arguments
			defined somewehere else for ease of use.
			"""
		#A waveform to turn off adiabatically nc-00 and nc-01 is added.
		#The step size is 0.001ms and the values are in the indicated path.
		path00 = seqconf.ramps_dir()+'adiabatic_tanh_Off.txt'
		self.analogwfm(0.001,[{'name':'nc-00',\
							   'path':path00},\
							  {'name':'nc-01',\
							   'path':path00}])
Exemple #18
0
    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)
Exemple #19
0
	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)
Exemple #20
0
    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)
Exemple #21
0
	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) 
Exemple #22
0
    def analogwfm_add(self, step, wfms):
        """ analogwfm_add adds a waveform output ot the sequence.
			aouts is an array of waveforms (instances of the wfm class)
			The device is determined from the names of the wfm's 
			and a pulse is added to the DIGITAL_OUT that triggers
			the device.  This function makes sure that the added
			waveform does not conflict with any waveform outputs
			already in the sequence.
			"""
        aouts = []

        #print("...start adding waveforms.")
        ss0 = 0
        for n, elem in enumerate(wfms):
            if n == 0: ss0 = elem.ss
            if elem.ss != ss0:
                print "Step Size doesn't match in Waveform."
                for el in wfms:
                    print "Channel=", el.name, "\tStep Size=", el.ss
                exit(1)
            ss0 = elem.ss

        for elem in wfms:
            dict = {}
            dict["name"] = elem.name
            filename = seqconf.ramps_dir() + elem.name + '_' + elem.wfm_id(
            ) + '.txt'
            elem.fileoutput(filename)
            #print ("filename = %s" % filename)
            dict["path"] = filename
            aouts.append(dict)

        #print("...end adding waveforms.")

        status = self.analogwfm(step, aouts)
        return status
Exemple #23
0
    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)
Exemple #24
0
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
Exemple #25
0
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
Exemple #26
0
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