本文整理汇总了Python中pyview.lib.datacube.Datacube.createColumn方法的典型用法代码示例。如果您正苦于以下问题:Python Datacube.createColumn方法的具体用法?Python Datacube.createColumn怎么用?Python Datacube.createColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyview.lib.datacube.Datacube
的用法示例。
在下文中一共展示了Datacube.createColumn方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clicks
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import createColumn [as 别名]
def clicks(self):
"""
Returns a datacube that contains the individual detector clicks for all measured samples in binary form.
"""
clicks = Datacube("detector clicks",dtype = uint8)
angles = self.bifurcationMapRotation()
clicks1 = self.trends()[0]*cos(angles[0])+self.trends()[1]*sin(angles[0]) > 0
clicks2 = self.trends()[2]*cos(angles[1])+self.trends()[3]*sin(angles[1]) > 0
def mapper(t):
(x1,x2) = t
if x1 and x2:
return 3
elif x1 and not x2:
return 1
elif x2 and not x1:
return 2
else:
return 0
clicks.createColumn("clicks",map(mapper,zip(clicks1,clicks2)))
return clicks
示例2: measureRabi
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import createColumn [as 别名]
def measureRabi(self,durations,data=None,rabiParameters=None, dataParameters=None):
"""
Measure a rabi, will use what is in dictionnary if power/frequency/useCalibration/nLoops are not set
Fit and save the period in the Qubit dictionnary under piRabiTime
Return the datacube and rabiPeriod
"""
if dataParameters==None:
dataParameters=dict()
dataParameters['addToDataManager']=True
dataParameters['save']=True
if rabiParameters==None:
if self._params.has_key('rabiParameters'):
rabiParameters=self._params['rabiParameters']
else: raise Exception("Unable to find rabi parameters... Exiting... ")
useCalibration=rabiParameters['useCalibration']
frequency=rabiParameters['frequency']
if frequency=="f01":frequency=self.frequency01()
power=rabiParameters['power']
nLoops=rabiParameters['nLoops']
if rabiParameters.has_key('remember'):
if rabiParameters['remember']: self._params['rabiParameters']=rabiParameters
if self._params.has_key('offsetDelay'):
offsetDelay=self._params['offsetDelay']
else: offsetDelay=20
if data==None:
data=Datacube("Rabi %s dBm"%power)
if dataParameters['addToDataManager']:data.toDataManager()
if power !="stay":self._pulseGenerator._MWSource.setPower(power)
self._pulseGenerator._MWSource.turnOn()
for duration in durations:
self.clearPulses()
self.generateRabiPulse(duration=duration, frequency=frequency, offsetDelay=offsetDelay,useCalibration=rabiParameters['useCalibration'])
result=self._jba.measure(nLoops=nLoops,fast=True)[0]
data.set(**result)
data.set(duration=duration)
data.commit()
#Fit
try:
columnName="b%i"%self._jba.bit
period= estimatePeriod(data['duration'],data[columnName])
[y0,dy,piRabi,t10],yfit=fitRabi(data['duration'],data[columnName],period=period)
data.createColumn("%sfit"%columnName,yfit)
except:
print 'fit error'
piRabi=0
if dataParameters['save']:data.savetxt()
self._params['piRabiTime']=piRabi
return data,piRabi
示例3: caracteriseIQvsFvsP
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import createColumn [as 别名]
def caracteriseIQvsFvsP(self,frequencies,voltages,data=None):
if data==None:
data=Datacube("JBA mapping")
dataManager.addDatacube(data)
try:
previousShape=self.shape
self.shape=zeros((20000),dtype = numpy.complex128)
self.shape[10000:10010]=linspace(0,1,10)
self.shape[10010:12100]=1
self.shape[12100:12110]=linspace(1,0,10)
# return self.shape
import scipy
pvsv=Datacube("power")
data.addChild(pvsv)
for v in voltages:
self.setAmplitude(amplitude=v)
p=self.measureJBAPower(f='autodetect')
pvsv.set(v=v,bluePower=p)
pvsv.commit()
pv=scipy.interpolate.interp1d(pvsv.column("v"),pvsv.column("bluePower"))
data.savetxt()
for f in frequencies:
child=Datacube("f=%f"%f)
data.addChild(child)
self.setFrequency(f)
for v in voltages:
self.setAmplitude(amplitude=v)
time.sleep(0.5)
co=self.getThisMeasure()[1]
var=cov(co[0])+cov(co[1])
if var>0.01:
cod=Datacube("components at p=%f" %pv(v))
cod.createColumn('I',co[0])
cod.createColumn('Q',co[1])
cod.createColumn('bluePower',[pv(v)]*len(co[0]))
child.addChild(cod)
else:
####### ECRIRE QUELQUE CHOSE ICI
[I,Q]=[mean(co[0]),mean(co[1])]
child.set(f=f,v=v,I=I,Q=Q,sigma=var,bluePower=pv(v))
child.set(M=sqrt(I**2+Q**2))
child.set(phi=math.atan2(I,Q))
child.commit()
data.set(f=f,v=v,I=I,Q=Q,sigma=var,bluePower=pv(v))
data.set(M=sqrt(I**2+Q**2))
data.set(phi=math.atan2(I,Q))
data.commit()
data.savetxt()
except:
raise
finally:
data.savetxt()
self.shape=previousShape
示例4: getTrace
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import createColumn [as 别名]
def getTrace(self,correctPhase = False,waitFullSweep = False,timeOut = 200):
print "Getting trace..."
trace = Datacube()
if DEBUG:
print "Getting trace..."
handle = self.getHandle()
handle.timeout = timeOut
if waitFullSweep:
# freqs = self.ask_for_values("HLD;TRS;WFS;fma;msb;OFV;") 2011/12 VS
self.write("TRS;WFS;")
freqs = self.ask_for_values("fma;msb;OFV;")
data = self.ask_for_values("fma;msb;OFD;")
freqs.pop(0)
data.pop(0)
mag = []
phase = []
#If y length is twice the x length, we got phase and magnitude.
if len(data) == 2*len(freqs):
for i in range(0,len(data)):
if i%2 == 0:
mag.append(data[i])
else:
phase.append(data[i])
else:
mag = data
trace.createColumn("freq",freqs)
trace.createColumn("mag",mag)
attenuation = float(self.ask("SA1?"))
power = float(self.ask("PWR?"))
trace.column("mag")[:]+= attenuation
params = dict()
params["attenuation"] = attenuation
params["power"] = power
trace.setParameters(params)
if len(phase) > 0:
correctedPhase = []
if correctPhase:
correctedPhase.append(phase[0])
oldPhi = phase[0]
for phi in phase[1:]:
if fabs(phi+360.0-oldPhi) < fabs(phi-oldPhi):
newPhi = phi+360.0
elif fabs(phi-360.0-oldPhi) < fabs(phi-oldPhi):
newPhi = phi-360.0
else:
newPhi = phi
correctedPhase.append(newPhi)
oldPhi = newPhi
else:
correctedPhase = phase
trace.createColumn("phase",correctedPhase)
print "returning trace."
return trace
示例5: sCurves
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import createColumn [as 别名]
def sCurves(qubit,jba,variable = "p1x",data = None,ntimes = 20,optimize = "v20"):
"""
Measures the s curves of the JBA. Assumes that the qubit is alread preset to a pi-pulse.
"""
def getVoltageBounds(v0,jba,variable,ntimes):
v = v0
jba.setVoltage(v)
acqiris.bifurcationMap(ntimes = ntimes)
p = acqiris.Psw()[variable]
while p > 0.03 and v < v0*2.0:
v*=1.05
jba.setVoltage(v)
acqiris.bifurcationMap()
p = acqiris.Psw()[variable]
vmax = v
v = v0
jba.setVoltage(v)
acqiris.bifurcationMap(ntimes = ntimes)
p = acqiris.Psw()[variable]
while p < 0.98 and v > v0/2.0:
v/=1.05
jba.setVoltage(v)
acqiris.bifurcationMap()
p = acqiris.Psw()[variable]
vmin = v
return (vmin*0.95,vmax*1.2)
try:
v0 = jba.voltage()
if data == None:
sData = Datacube()
else:
sData = data
sData.setName("S curves - %s" % qubit.name())
sData.setParameters(instrumentManager.parameters())
s0 = Datacube("S0")
s1 = Datacube("S1")
s2 = Datacube("S2")
sData.addChild(s0)
sData.addChild(s1)
sData.addChild(s2)
qubit.turnOffDrive()
(vmin,vmax) = getVoltageBounds(v0,jba,variable,ntimes)
measureSingleS(voltages = arange(vmin,vmax,0.005),data = s0,jba = jba,ntimes = ntimes)
qubit.turnOnDrive()
loadPi01Pulse(qubit)
measureSingleS(voltages = arange(vmin,vmax,0.005),data = s1,jba = jba,ntimes = ntimes)
failed12 = False
try:
loadPi012Pulse(qubit)
measureSingleS(voltages = arange(vmin,vmax,0.005),data = s2,jba = jba,ntimes = ntimes)
s1.createColumn("contrast20",s2.column(variable)-s0.column(variable))
s1.createColumn("contrast21",s2.column(variable)-s1.column(variable))
qubit.parameters()["readout.v20"] = s1.column("v")[argmax(s1.column("contrast20"))]
qubit.parameters()["readout.v21"] = s1.column("v")[argmax(s1.column("contrast21"))]
except:
failed12 = True
raise
s1.createColumn("contrast10",s1.column(variable)-s0.column(variable))
qubit.parameters()["readout.v10"] = s1.column("v")[argmax(s1.column("contrast10"))]
if optimize == "v20" and not failed12:
imax = argmax(s1.column("contrast20"))
qubit.parameters()["readout.p11"] = s2.column(variable)[imax]
v0 = s1.column("v")[imax]
elif optimize == "v21" and not failed12:
imax = argmax(s1.column("contrast21"))
v0 = s1.column("v")[imax]
else:
imax = argmax(s1.column("contrast10"))
qubit.parameters()["readout.p11"] = s1.column(variable)[imax]
v0 = s1.column("v")[imax]
#To do: Add dialog to ask to which voltage (v10,v20,v21) in
qubit.parameters()["readout.p00"] = 1.0-s0.column(variable)[imax]
return (sData,v0)
finally:
jba.setVoltage(v0)
data.savetxt()
示例6: measureSCurves
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import createColumn [as 别名]
def measureSCurves(qubit,jba,variable = "p1x",data = None,ntimes = 20):
"""
Measures the s curves of the JBA. Assumes that the qubit is alread preset to a pi-pulse.
"""
def getVoltageBounds(v0,jba,variable,ntimes):
v = v0
jba.setVoltage(v)
acqiris.bifurcationMap(ntimes = ntimes)
p = acqiris.Psw()[variable]
while p > 0.03 and v < v0*2.0:
v*=1.05
jba.setVoltage(v)
acqiris.bifurcationMap()
p = acqiris.Psw()[variable]
vmax = v
v = v0
jba.setVoltage(v)
acqiris.bifurcationMap(ntimes = ntimes)
p = acqiris.Psw()[variable]
while p < 0.98 and v > v0/2.0:
v/=1.05
jba.setVoltage(v)
acqiris.bifurcationMap()
p = acqiris.Psw()[variable]
vmin = v
return (vmin*0.9,vmax*1.1)
try:
v0 = jba.voltage()
if data == None:
sData = Datacube()
else:
sData = data
sData.setName("S curves - %s" % qubit.name())
sData.setParameters(instrumentManager.parameters())
sOff = Datacube("SOFF")
sOn = Datacube("SON")
sData.addChild(sOff)
sData.addChild(sOn)
qubit.turnOffDrive()
(vmin,vmax) = getVoltageBounds(v0,jba,variable,ntimes)
for v in arange(vmin,vmax,0.005):
jba.setVoltage(v)
acqiris.bifurcationMap(ntimes = ntimes)
sOff.set(**(acqiris.Psw()))
sOff.set(v = v)
sOff.commit()
qubit.turnOnDrive()
for v in arange(vmin,vmax,0.005):
jba.setVoltage(v)
acqiris.bifurcationMap(ntimes = ntimes)
sOn.set(**acqiris.Psw())
sOn.set(v = v)
sOn.commit()
sOn.createColumn("contrast",sOn.column(variable)-sOff.column(variable))
v0 = sOn.column("v")[argmax(sOn.column("contrast"))]
maxContrast = max(sOn.column("contrast"))
return (sData,maxContrast,v0)
finally:
jba.setVoltage(v0)
示例7: sCurves
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import createColumn [as 别名]
def sCurves(jba,qubit = None,variable = "p1x",data = None,ntimes = 20,s2=False,optimize = "v10",step = 0.01,measureErrors = False,saveData = True,voltageBounds = None,**kwargs):
"""
Measures the s curves of the JBA. Assumes that the qubit is alread preset to a pi-pulse.
"""
def getVoltageBounds(v0,jba,variable,ntimes):
v = v0
jba.setVoltage(v)
acqiris.bifurcationMap(ntimes = ntimes)
p = acqiris.Psw()[variable]
while p > 0.03 and v < v0*2.0:
v*=1.1
jba.setVoltage(v)
acqiris.bifurcationMap()
p = acqiris.Psw()[variable]
vmax = v
v = v0
jba.setVoltage(v)
acqiris.bifurcationMap(ntimes = ntimes)
p = acqiris.Psw()[variable]
while p < 0.98 and v > v0/2.0:
v/=1.1
jba.setVoltage(v)
acqiris.bifurcationMap()
p = acqiris.Psw()[variable]
vmin = v
return (vmin*0.95,vmax*1.1)
hasFinished = False
try:
data.setParameters(instrumentManager.parameters())
v0 = jba.voltage()
if data == None:
sData = Datacube()
else:
sData = data
if sData.name() == "datacube":
if not qubit == None:
sData.setName("S curves - %s" % qubit.name())
s0 = Datacube("S0")
s1 = Datacube("S1")
sData.addChild(s0)
sData.addChild(s1)
s0.parameters()["defaultPlot"]=[["v",variable]]
s1.parameters()["defaultPlot"]=[["v",variable]]
s1.parameters()["defaultPlot"].append(["v","contrast10"])
else:
sData.setName("S curve - %s" % jba.name())
sData.parameters()["defaultPlot"]=[["v",variable]]
error=False
if not qubit == None:
qubit.turnOnDrive()
qubit.loadRabiPulse(length = 0)
if voltageBounds == None:
(vmin,vmax) = getVoltageBounds(v0,jba,variable,ntimes)
else:
(vmin,vmax) = voltageBound
print vmin,vmax
if qubit == None:
measureSingleS(voltages = arange(vmin,vmax,step),data = sData,jba = jba,ntimes = ntimes)
return
else:
measureSingleS(voltages = arange(vmin,vmax,step),data = s0,jba = jba,ntimes = ntimes)
qubit.loadRabiPulse(phase = math.pi,**kwargs)
measureSingleS(voltages = arange(vmin,vmax,step),data = s1,jba = jba,ntimes = ntimes)
failed12 = False
if s2:
try:
s2 = Datacube("S2")
s2.parameters()["defaultPlot"]=[["v",variable]]
sData.addChild(s2)
loadPi012Pulse(qubit)
measureSingleS(voltages = arange(vmin,vmax,step),data = s2,jba = jba,ntimes = ntimes)
s1.createColumn("contrast20",s2.column(variable)-s0.column(variable))
s1.createColumn("contrast21",s2.column(variable)-s1.column(variable))
s1.parameters()["defaultPlot"].extend([["v","contrast20"],["v","contrast21"]])
qubit.parameters()["readout.v20"] = float(s1.column("v")[argmax(s1.column("contrast20"))])
qubit.parameters()["readout.v21"] = float(s1.column("v")[argmax(s1.column("contrast21"))])
qubit.parameters()["readout.contrast20"] = float(s1.column("contrast20")[argmax(s1.column("contrast20"))])
qubit.parameters()["readout.contrast21"] = float(s1.column("contrast21")[argmax(s1.column("contrast21"))])
data.setName(data.name()+" - v20 = %g" % qubit.parameters()["readout.contrast20"])
data.setName(data.name()+" - v21 = %g" % qubit.parameters()["readout.contrast21"])
except:
failed12 = True
raise
else:
failed12=True
s1.createColumn("contrast10",s1.column(variable)-s0.column(variable))
#.........这里部分代码省略.........
示例8: measureT1
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import createColumn [as 别名]
def measureT1(self,delays,data=None,t1Parameters=None, dataParameters=None):
"""
Measure a T1, will use what is in dictionnary if power/frequency/useCalibration/nLoops are not set
Fit and save the period in the Qubit dictionnary under T1
Return data and T1
"""
if dataParameters==None:
dataParameters=dict()
dataParameters['addToDataManager']=True
dataParameters['save']=True
print t1Parameters
if t1Parameters==None:
if self._params.has_key('t1Parameters'):
t1Parameters=self._params['t1Parameters']
else: raise Exception("Unable to find rabi parameters... Exiting... ")
useCalibration=t1Parameters['useCalibration']
frequency=t1Parameters['frequency']
if frequency=="f01":frequency=self.frequency01()
print frequency
power=t1Parameters['power']
nLoops=t1Parameters['nLoops']
duration=t1Parameters['duration']
if duration=="rabi":duration=self._params['piRabiTime']
if t1Parameters.has_key('remember'):
if t1Parameters['remember']: self._params['t1Parameters']=t1Parameters
if self._params.has_key('offsetDelay'):
offsetDelay=self._params['offsetDelay']
else: offsetDelay=20
if data==None:
data=Datacube("T1 Measurement")
if dataParameters['addToDataManager']:data.toDataManager()
if power !="stay":self._pulseGenerator._MWSource.setPower(power)
if power !="stay":self._pulseGenerator._MWSource.setPower(power)
for delay in delays:
self._pulseGenerator.clearPulse()
self._pulseGenerator.generatePulse(duration=duration, frequency=frequency, DelayFromZero=10000-delay-duration-offsetDelay,useCalibration=False)
self._pulseGenerator.sendPulse()
result=self._jba.measure(nLoops=nLoops,fast=True)[0]
data.set(**result)
data.set(delay=delay)
data.commit()
columnName="b%i"%self._jba.bit
[y0,dy,T1],yfit=fitT1(data['delay'],data[columnName])
data.createColumn("fit",yfit)
self._params['T1']=T1
return data,T1
示例9: measureSpectroscopy
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import createColumn [as 别名]
def measureSpectroscopy(self,frequencies, data=None, spectroscopyParameters=None,dataParameters=None):
"""
Measure a spectroscopy
Fit
Return the datacube and centerFrequency
"""
if spectroscopyParameters==None:
if self._params.has_key(spectroscopyParameters):
spectroscopyParameters=self._params['spectroscopyParameters']
else:
raise Exception("No spectroscopy parameters found... Exiting...")
if dataParameters==None:
dataParameters=dict()
dataParameters['addToDataManager']=True
dataParameters['save']=True
if spectroscopyParameters.has_key('remember'):self._params['spectroscopyParameters']=spectroscopyParameters
useCalibration=spectroscopyParameters['useCalibration']
nLoops=spectroscopyParameters['nLoops']
duration=spectroscopyParameters['duration']
if spectroscopyParameters.has_key('power'): self._pulseGenerator._MWSource.setPower(spectroscopyParameters['power'])
amplitude = spectroscopyParameters['amplitude'] if spectroscopyParameters.has_key('amplitude') else 0
if data==None:
data=Datacube("Spectroscopy measurement")
if dataParameters['addToDataManager']:data.toDataManager()
if self._params.has_key('offsetDelay'):
offsetDelay=self._params['offsetDelay']
else: offsetDelay=20
first=True
for frequency in frequencies:
self._pulseGenerator._MWSource.setFrequency(frequency)
if first: # i.e. generate a rabi pulse on the AWG only the first time (no need to re-generate an AWG pulse every time)
self._pulseGenerator.pulseList=()
self.generateRabiPulse(duration=duration,amplitude=amplitude,offsetDelay=offsetDelay,useCalibration=useCalibration,frequency=frequency)
first=False
time.sleep(0.2)
data.set(frequency=frequency)
data.set(**self._jba.measure(nLoops=nLoops,fast=True)[0])
data.commit()
try:
columnName="b%i"%self._jba.bit
[dy,f0,df,y0],yfit=fitLorentzian(data['frequency'],data[columnName],1)
data.createColumn(columnName+"fit",yfit)
except:
print "fitting error"
[dy,f0,df,y0]=[0]*4
if dataParameters['save']:data.savetxt()
d0.setParameters(Manager().saveState('currentState'))
return data, f0
示例10: plot
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import createColumn [as 别名]
#plot(xOn,refCurve(xOn-shift_on),'--')
plot(xOn,contrast)
axvline(xOn[argmax(fittedContrast)],ls = '-.')
if fitS02:
plot(xOn2,contrast2)
axvline(xOn2[argmax(fittedContrast2)],ls = '-.')
ylim(0,1)
from pyview.lib.datacube import Datacube
sDataFit = Datacube("s curve analysis")
sDataFit.createColumn("x",xOn)
sDataFit.createColumn("yOff",yOff)
sDataFit.createColumn("yOn",yOn)
sDataFit.createColumn("contrast10",contrast)
sDataFit.createColumn("yOnFit",yOnFit(xOn))
sDataFit.createColumn("contrastFit",yOnFit(xOn)-yOff)
sDataFit.createColumn("xRef",xRef)
sDataFit.createColumn("yRef",yRef)
if fitS02:
sDataFit.createColumn("x2",xOn2)
sDataFit.createColumn("yOn2",yOn2)
sDataFit.createColumn("contrast2",contrast2)
sDataFit.createColumn("yOn2Fit",yOn2Fit(xOn2))
sDataFit.createColumn("contrast2Fit",yOn2Fit(xOn2)-yOff2)
示例11: measureSCurve
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import createColumn [as 别名]
def measureSCurve(self,voltages = None,ntimes = 10,microwaveOff = True,data=None,fspPower=False,corelations=False,**extraInDatacube):
self.notify("status","Measuring S curve...")
def getVoltageBounds(v0,jba,variable,ntimes):
return (0.5,5)
v = v0
jba.setVoltage(v)
jba._acqiris.bifurcationMap(ntimes = ntimes)
p = jba._acqiris.Psw()[variable]
while p > 0.03 and v < v0*2.0:
v*=1.05
jba.setVoltage(v)
jba._acqiris.bifurcationMap(ntimes = ntimes)
p = jba._acqiris.Psw()[variable]
vmax = v
v = v0
jba.setVoltage(v)
jba._acqiris.bifurcationMap(ntimes = ntimes)
p = jba._acqiris.Psw()[variable]
while p < 0.98 and v > v0/2.0:
v/=1.05
jba.setVoltage(v)
jba._acqiris.bifurcationMap(ntimes = ntimes)
p = jba._acqiris.Psw()[variable]
vmin = v
return (vmin*0.95,vmax*1.2)
if fspPower:
self._pulseGenerator._mixer._fsp.setFrequency(self._frequency)
if data==None:
data = Datacube("%s S Curve - f=%f" %(self.name(),self._frequency))
dataManager = DataManager()
dataManager.addDatacube(data)
else:
data.setName("%s S Curve - f=%f" %(self.name(),self._frequency))
if voltages==None:
bounds=[self._vMaxAmplitude-2*max(self._vMaxAmplitude/5,abs(self._sCurveParams[0])),self._vMaxAmplitude+2*max(self._vMaxAmplitude/5,abs(self._sCurveParams[0]))]
voltages=linspace(bounds[0],bounds[1],200)
try:
for v in voltages:
self.setAmplitude(v)
data.set(v = v)
d=self.measure(nLoops=ntimes)
#d=self.getThisMeasure()
data.set(**d[1])
if corelations:
data.set(**d[4])
data.set(**extraInDatacube)
if fspPower:
time.sleep(1)
data.set(fspPower=self._pulseGenerator._mixer._fsp.getValueAtMarker())
#self.notify("histograms",d[2][self.bit][0])
#self.notify("iqdata",(d[2][self.bit][0],d[2][self.bit][1]))
##self.notify("iqP",(d[0][:,0],d[0][:,1],((0,0,0))))
data.commit()
#self.notify("sCurve",(data.column("v"),data.column("b%i"%self.bit)))
data.createColumn("p-0.5",abs(data["b%i"%self.bit]-0.5))
data.sortBy("p-0.5")
self._p50fromS=data['v'][0]
data.sortBy('v')
#data.sortBy("b%i"%self.bit)
#p=data["b%i"%self.bit]
#v=data['v']
#p=p[p>0]
#v=v[p>0]
##p=p[p<1]
#v=v[p<1]
#self.sInterpolateVP=scipy.interpolate.interp1d(p,v)
#data.sortBy('v')
except:
raise
finally:
data.savetxt()
self.notify("status","S curve complete.")
self.setAmplitude(self._vMaxAmplitude)
return data
示例12: _findAmplitude
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import createColumn [as 别名]
def _findAmplitude(self,frequency=None,shape=None,magnitudeButton=None,center=None,color=0,bounds=None,dataValues=None):
"""
Only used by function calibrate.
Measure and find the amplitude where the JBA is bi-evaluated, go to this point, and store this amplitude
"""
def fitLorentzian(fs,p1,f0=None):
fitfunc = lambda p, x: p[2]+p[0]/(1.0+pow((x-fs[argmax(p1)])/p[1],2.0))
errfunc = lambda p, x, y,ff: pow(numpy.linalg.norm(ff(p,x)-y),2.0)
ps = [(max(p1)-min(p1)),0.005,min(p1)]
if f0!=None:
if max(fs)>f0 and min(fs)<f0:ps[1]=f0
print "Initial guess:",ps
import numpy.linalg
import scipy
import scipy.optimize
p1s = scipy.optimize.fmin(errfunc, ps,args=(fs,p1,fitfunc))
rsquare = 1.0-numpy.cov(p1-fitfunc(p1s,fs))/numpy.cov(p1)
print p1s
return p1s.tolist()
if frequency==None:frequency=self._frequency
if shape==None:shape=self.shape
if magnitudeButton==None:magnitudeButton=self._magnitudeButton
self.setFrequency(frequency=frequency,shape=shape)
self.sendWaveform()
if magnitudeButton=='formAmplitude':
"""
values = voltage amplitude
"""
if center==None:
values=arange(0,0.8,0.01)
else:
values=arange(center-0.025,center+0.025,0.001)
elif magnitudeButton=='variableAttenuator':
"""
values = attenuator voltage
"""
if center==None:
values=arange(0,5,0.1)
else:
values=arange(center-0.2,center+0.2,0.01)
elif magnitudeButton=='microwaveSource':
"""
values = microwave Output power in dB
"""
self.setFrequency(frequency=frequency,shape=shape)
self.sendWaveform()
if center==None:
values=arange(0,20,0.20)
else:
values=arange(center-1,center+1,0.05)
else:
print "Error in the value of magnitudeButton"
if bounds!=None:
if center==None:
values=linspace(bounds[0],bounds[1],bounds[2])
else:
print ''
self.notify('iqP',0)
ps = []
maxcov = 0
maxVoltage = 0
self.variances = zeros((len(values),2))
self.variances[:,0] = values
self.data.clear()
try:
self.setAmplitude(magnitudeButton=magnitudeButton, amplitude=values[0])
time.sleep(0.5)
for i in range(0,len(values)):
if self.stopped():
self._stopped = False
raise Exception("Got stopped!")
v = values[i]
v=self.setAmplitude(magnitudeButton=magnitudeButton, amplitude=v)
trends=self.getComponents()
varsum =cov(trends[0])+cov(trends[1])
if not dataValues==None:
ch=Datacube()
dataValues.addChild(ch)
ch.createColumn('I',trends[0])
ch.createColumn('Q',trends[0])
dataValues.set(v=v,varsum=varsum)
dataValues.commit()
self.data.set(v = v)
self.data.set(varsum=varsum)
self.data.commit()
self.notify("variance",(self.data.column("v"),self.data.column("varsum"),((color,0,0))))
x=1.*i/len(values)
self.notify("iqP",(trends[0],trends[1],((x,0,1-x))))
#.........这里部分代码省略.........
示例13: _findAmplitude
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import createColumn [as 别名]
#.........这里部分代码省略.........
time.sleep(0.5)
for i in range(0,len(values)):
if self.stopped():
self._stopped = False
raise Exception("Got stopped!")
v = values[i]
v=self.setAmplitude(magnitudeButton=magnitudeButton, amplitude=v)
trends=self.getComponents(nLoops=nLoops)
varsum =cov(trends[0])+cov(trends[1])
x=1.*i/len(values)
self.notify("iqP",(trends[0],trends[1],((x,0,1-x))))
if fitModel:
try:
fitResults=self.multiGaussianClusters(trends.transpose())
except:
raise
sep=self.separatrixBimodal(fitResults)
separatrixList.append(sep)
self.separatrixList=separatrixList
s=[sep[0]]
sepCenters=array([[p[0],p[1]] for p in s]).transpose()
c=sep[3]
centers=[[c[0][0],c[1][0]],[c[0][1],c[1][1]]]
self.notify("centersIQ",[sepCenters, centers])
if not dataValues==None:
ch=Datacube()
dataValues.addChild(ch)
ch.createColumn('I',trends[0])
ch.createColumn('Q',trends[1])
dataValues.set(v=v,varsum=varsum)
dataValues.commit()
self.data.set(v = v)
self.data.set(varsum=varsum)
self.data.commit()
self.notify("variance",(self.data.column("v"),self.data.column("varsum"),((color,0,0))))
self.notify("status","Variance at %g V: %g" % (v,varsum))
if DEBUG: print "Variance at v = %f : %f" % (v,varsum)
self.variances[i,1] = varsum
ps.append(varsum)
if varsum > maxcov:
maxcov = varsum
maxVoltage = values[i]
self.setAmplitude(magnitudeButton=magnitudeButton,amplitude=maxVoltage)
self._vMaxAmplitude=maxVoltage
except:
raise
finally:
# calculate separatrix
print "fitModel: ",fitModel
if fitModel:
self.separatrixList=separatrixList
sepCenters=[s[0] for s in self.separatrixList]
centers=[s[3] for s in self.separatrixList]
self.notify("centersIQ",[sepCenters, centers])