本文整理汇总了Python中pyview.lib.datacube.Datacube.loadtxt方法的典型用法代码示例。如果您正苦于以下问题:Python Datacube.loadtxt方法的具体用法?Python Datacube.loadtxt怎么用?Python Datacube.loadtxt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyview.lib.datacube.Datacube
的用法示例。
在下文中一共展示了Datacube.loadtxt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_savetxt
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import loadtxt [as 别名]
def test_savetxt(self):
"""
Test saving a datacube to a text file
"""
for key in self.testCubes.keys():
print "Checking plain text loading of test cube {0!s}".format(key)
cube = self.testCubes[key]
filename = os.path.normpath(self.dataPath+"/test_{0!s}.txt".format(key))
cube.savetxt(filename,overwrite = True)
self.assert_(os.path.exists(filename),"File {0!s} has not been created!".format(filename))
self.assert_(os.path.isfile(filename))
restoredCube = Datacube()
restoredCube.loadtxt(filename)
self.assert_(restoredCube.equal(cube),"Error: Restored datacube does not match original one!")
示例2: Instr
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import loadtxt [as 别名]
#.........这里部分代码省略.........
def analyse(self,nLoops=1,fast=False):
"""
Acquire and analyse the frequencies previously sent and returns (components and probabilities)
"""
maxBit=0
for v in self._frequencies.values():
if v[2]>maxBit and v[1]:
maxBit=v[2]
return self._acqiris.frequenciesAnalyse(frequencies=self._frequencies.values(),nLoops=nLoops,maxBit=maxBit,fast=fast)
def measureBifurcationProbabilities(self):
"""
Acquire, analyse the frequencies, convert it in clicks, and calculate averages values
"""
(av,co,fr)=self.analyse()
r=self._acqiris.multiplexedBifurcationMapAdd(co,fr)
p=self._acqiris.convertToProbabilities(r)
def clear(self):
"""
Clear the list of frequencies to be analysed and the calibration paramaters associated
"""
self._Ilist=[]
self._Qlist=[]
self._philist=[]
self._frequencies=dict()
def calibrateAmplitudeAndOffset(self,f):
"""
Only used when this pulse Analyser has to be used as real analyser, not when using it to see bifurcation
"""
rowData=Datacube()
for phi in arange(0,2*math.pi,math.pi/30):
print "calibration : phi = %f deg" % (phi/math.pi*180)
self._pulseGenerator.clearPulse()
self.clear()
self._pulseGenerator.generatePulse(duration=20000, frequency=f, amplitude=0.6, DelayFromZero=0,useCalibration=True, phase=phi)
self.addFrequency(f=f,useCorrection=False)
self._pulseGenerator.sendPulse()
time.sleep(0.5)
(av, co, fr)= self.analyse()
rowData.set(I=av[0,0], Q=av[1,0],phi=phi)
rowData.commit()
#I0=2/ptp(rowData['I'])
#Q0=2/ptp(rowData['Q'])
(I,Q,phi,dphi)=scipy.optimize.fmin_powell(lambda (I,Q,phi0,dphi): sum((I*rowData['I'] - sin(rowData['phi']+phi0+dphi))**2)+sum((Q*rowData['Q'] - cos(rowData['phi']+phi0))**2),(1,1,0,0))
print (I,Q,phi,dphi)
f_c=self._MWSource.frequency()
df=f-f_c
index=self._calibration.search(f_sb=df,f_c=f_c)
if index!=None:
self._calibration.removeRow(index)
self._calibration.set(I=I,Q=Q,phi=dphi,f_c=f_c,f_sb=df)
self._calibration.commit()
self._calibration.savetxt()
register['%s Cal'% self._name]=self._calibration.filename()
return rowData
def parameters(self):
"""
Returns intrument parameters
"""
return self._params
def initCal(self):
"""
Re-init the calibration when using this instrument as real analyser
"""
self._calibration=Datacube()
self._calibration.setName('analyser IQ mixer Calibration')
self._calibration.savetxt()
register['%s Cal'% self._name]=self._name.filename()
def initialize(self, name, acqiris, acqirisChannels, MWSource,pulse_generator):
"""
Initialize the instrument
"""
instrumentManager=Manager()
self._name=name
self._acqiris=instrumentManager.getInstrument(acqiris)
# self._acqiris("moduleDLL2.setChannels("+str(acqirisChannels[0])+","+str(acqirisChannels[1])+")")
self._acqiris.setChannels(acqirisChannels[0],acqirisChannels[1])
self._MWSource=instrumentManager.getInstrument(MWSource)
self._pulseGenerator=instrumentManager.getInstrument(pulse_generator)
self._params=dict()
self._params["acqiris"]=acqiris
self._params["MWSource"]=MWSource
self._frequencies=dict()
try:
self._calibration=Datacube()
self._calibration.setName('analyser IQ mixer Calibration')
self._calibration.loadtxt(register.parameters()['%s Cal'% self._name])
except:
pass
self._Ilist=[]
self._Qlist=[]
self._philist=[]
示例3: Datacube
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import loadtxt [as 别名]
from pyview.lib.datacube import Datacube
from matplotlib.pyplot import *
from phdthesis.config.params import params
from phdthesis.config.matplotlib.rcparams import *
import sys
titleString = "2 Qubit Anticrossing"
outputFilename = "anticrossing"
dataFile = r"data/Spectroscopy Survey - qubit1-7.txt"
print "Loading data..."
datacube = Datacube()
datacube.loadtxt(dataFile)
##
from numpy import *
from numpy.linalg import *
m1 = zeros((len(datacube.children()[0]),len(datacube)))
m2 = zeros((len(datacube.children()[0]),len(datacube)))
for i,child in enumerate(datacube.children()):
m1[:,i] = child["p1x"]
m2[:,i] = child["px1"]
##Generate a model of the qubit anticrossing
示例4: Instr
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import loadtxt [as 别名]
#.........这里部分代码省略.........
self._frequencies=append(self._frequencies,abs(df))
self._Ilist=append(self._Ilist,I)
self._Qlist=append(self._Qlist,Q)
self._philist=append(self._philist,phi)
return toReturn
def analyse(self):
"""
Acquire and analyse the frequencies previously sent and returns (waveforms, components, and frequencies analysed)
"""
(wa,av,co,fr)=self._acqiris.frequenciesAnalysis(frequencies=self._frequencies, Ilist=self._Ilist, Qlist=self._Qlist, philist=self._philist)
return (av, co, fr)
def measureBifurcationProbabilities(self):
"""
Acquire, analyse the frequencies, convert it in clicks, and calculate averages values
"""
(av,co,fr)=self.analyse()
r=self._acqiris.multiplexedBifurcationMapAdd(co,fr)
p=self._acqiris.convertToProbabilities(r)
def clear(self):
"""
Clear the list of frequencies to be analysed and the calibration paramaters associated
"""
self._Ilist=[]
self._Qlist=[]
self._philist=[]
self._frequencies=[]
def calibrateAmplitudeAndOffset(self,f):
"""
Only used when this pulse Analyser has to be used as real analyser, not when using it to see bifurcation
"""
rowData=Datacube()
for phi in arange(0,2*math.pi,math.pi/30):
print "calibration : phi = %f deg" % (phi/math.pi*180)
self._pulse_generator.clearPulse()
self.clear()
self._pulse_generator.generatePulse(duration=20000, frequency=f, amplitude=0.6, DelayFromZero=0,useCalibration=True, phase=phi)
self.addFrequency(f=f,useCorrection=False)
self._pulse_generator.sendPulse()
time.sleep(0.5)
(av, co, fr)= self.analyse()
rowData.set(I=av[0,0], Q=av[1,0],phi=phi)
rowData.commit()
#I0=2/ptp(rowData['I'])
#Q0=2/ptp(rowData['Q'])
(I,Q,phi,dphi)=scipy.optimize.fmin_powell(lambda (I,Q,phi0,dphi): sum((I*rowData['I'] - sin(rowData['phi']+phi0+dphi))**2)+sum((Q*rowData['Q'] - cos(rowData['phi']+phi0))**2),(1,1,0,0))
print (I,Q,phi,dphi)
f_c=self._MWSource.frequency()
df=f-f_c
index=self._calibration.search(f_sb=df,f_c=f_c)
if index!=None:
self._calibration.removeRow(index)
self._calibration.set(I=I,Q=Q,phi=dphi,f_c=f_c,f_sb=df)
self._calibration.commit()
self._calibration.savetxt()
register['%s Cal'% self._name]=self._calibration.filename()
return rowData
def parameters(self):
"""
Returns intrument parameters
"""
return self._params
def initCal(self):
"""
Re-init the calibration when using this instrument as real analyser
"""
self._calibration=Datacube()
self._calibration.setName('analyser IQ mixer Calibration')
self._calibration.savetxt()
register['%s Cal'% self._name]=self._name.filename()
def initialize(self, name, acqiris, MWSource,pulse_generator):
"""
Initialize the instrument
"""
instrumentManager=Manager()
self._name=name
self._acqiris=instrumentManager.getInstrument(acqiris)
self._MWSource=instrumentManager.getInstrument(MWSource)
self._pulse_generator=instrumentManager.getInstrument(pulse_generator)
self._params=dict()
self._params["acqiris"]=acqiris
self._params["MWSource"]=MWSource
self._frequencies=zeros(0)
try:
self._calibration=Datacube()
self._calibration.setName('analyser IQ mixer Calibration')
self._calibration.loadtxt(register.parameters()['%s Cal'% self._name])
except:
pass
self._Ilist=[]
self._Qlist=[]
self._philist=[]
示例5: range
# 需要导入模块: from pyview.lib.datacube import Datacube [as 别名]
# 或者: from pyview.lib.datacube.Datacube import loadtxt [as 别名]
string+=","
string+="{"
for j in range(0,4):
if j!=0:
string+=","
value = gv.spins.parameters()["densityMatrix"][i][j]
string+=str(real(value))+"+I*"+str(imag(value))
string+="}"
string+="}"
print string
##
from matplotlib.pyplot import *
from numpy import *
from pyview.lib.datacube import Datacube
cube = Datacube()
cube.loadtxt("State Tomography of Swap vs Swap Duration.txt")
##
print cube.structure()
##
def smooth(x,window_len=11,window='hanning'):
"""smooth the data using a window with requested size.
This method is based on the convolution of a scaled window with the signal.
The signal is prepared by introducing reflected copies of the signal
(with the window size) in both ends so that transient parts are minimized
in the begining and end part of the output signal.
input:
x: the input signal
window_len: the dimension of the smoothing window; should be an odd integer