Commit f47c8402 authored by Christian Schneider's avatar Christian Schneider
Browse files

Adapted other modules to data_table structure

parent 90126cde
......@@ -159,7 +159,7 @@ class data_complex(data_table):
return self.get_phase()
def get_phase(self, unit='deg', unwrap=True):
"""This function returns a data_line module with the selected data of
"""This function returns a data_table module with the selected data of
this data module converted in amplitude (dB). Data Module parameters
are copied as well.
......
......@@ -173,7 +173,7 @@ class data_grid(data_module_base):
Returns
--------
DataModule
data_line module
data_table module
"""
x, y = self.df.dims[:2]
ex = self.df.sel(x=x0, method='nearest')
......@@ -209,7 +209,7 @@ class data_grid(data_module_base):
Returns
--------
DataModule
data_line module
data_table module
"""
x, y = self.df.dims[:2]
ex = self.df.sel(y=y0, method='nearest')
......@@ -410,7 +410,7 @@ class data_grid(data_module_base):
Returns
--------
DataModule
A `data_line` DataModule. Values depend on argument keyword (see
A `data_table` DataModule. Values depend on argument keyword (see
above)
"""
if nnB == 1:
......@@ -465,7 +465,7 @@ class data_grid(data_module_base):
Returns
--------
DataModule
A `data_line` DataModule. Values depend on argument keyword (see
A `data_table` DataModule. Values depend on argument keyword (see
above)
"""
if nnB == 1:
......@@ -522,7 +522,7 @@ class data_grid(data_module_base):
Returns
--------
DataModule
A `data_line` DataModule. Values depend on argument keyword (see
A `data_table` DataModule. Values depend on argument keyword (see
above)
"""
tmp = np.zeros_like(self.y)
......@@ -598,7 +598,7 @@ class data_grid(data_module_base):
Returns
--------
DataModule
A `data_line` DataModule. Values depend on argument keyword (see
A `data_table` DataModule. Values depend on argument keyword (see
above)
"""
tmp = np.zeros_like(self.y)
......
......@@ -176,7 +176,7 @@ class data_table(data_module_base):
self.df[order_names[i]][df_idx] = data_arrays[i][idx]
else:
self.df = self.df.append({key: value[idx] for key, value
in zip(order_names, data_arrays)},
in zip(order_names, data_arrays)},
ignore_index=True)
pass
......@@ -341,23 +341,28 @@ class data_table(data_module_base):
legend = ""
# Plot Data
for kw in style:
if kw == '-':
fig.line(x * xscale, y * yscale, line_color=c,
line_width=linewidth, legend=legend, **kwargs)
elif kw == 'o':
fig.circle(x, y, fill_color=c, line_color=c,
size=markersize, legend=legend, **kwargs)
if ("{} Errors".format(self.name_y) in self.df.keys() and
plot_errors):
err_xs = []
err_ys = []
errs = self.df[self.name_y + ' Errors'][
self.idx_min:self.idx_max]
for xs, ys, yerr in zip(x, y, errs):
err_xs.append((xs, xs))
err_ys.append((ys - yerr, ys+ yerr))
fig.multi_line(err_xs, err_ys, color=c)
if ("{} Errors".format(self.name_y) in self.df.keys() and
plot_errors):
# Just plot dots if error bars given
fig.circle(x, y, fill_color=c, line_color=c,
size=markersize, legend=legend, **kwargs)
err_xs = []
err_ys = []
errs = self.df[self.name_y + ' Errors'][
self.idx_min:self.idx_max]
for xs, ys, yerr in zip(x, y, errs):
err_xs.append((xs, xs))
err_ys.append((ys - yerr, ys + yerr))
fig.multi_line(err_xs, err_ys, color=c)
else:
for kw in style:
if kw == '-':
fig.line(x * xscale, y * yscale, line_color=c,
line_width=linewidth, legend=legend, **kwargs)
elif kw == 'o':
fig.circle(x, y, fill_color=c, line_color=c,
size=markersize, legend=legend, **kwargs)
# Plot Fit
if plot_fit and self._fit_executed:
......@@ -367,7 +372,7 @@ class data_table(data_module_base):
else:
fc = fitcolor
# Plot fit
fig.line(x*xscale, fitfunc(x, *self._fit_parameters)*yscale,
fig.line(x * xscale, fitfunc(x, *self._fit_parameters) * yscale,
line_color=fc, line_width=fit_linewidth)
# Format nicer HoverTool
......@@ -521,8 +526,9 @@ class data_table(data_module_base):
self._fit_parameters = fit_p_fit
self._fit_par_errors = np.sqrt(np.diag(err))
# Chi squared
self._fit_data_error = (np.sum((fitfunc(xsel, *fit_p_fit) - ysel) ** 2) /
(len(xsel) - 2))
self._fit_data_error = (
np.sum((fitfunc(xsel, *fit_p_fit) - ysel) ** 2) /
(len(xsel) - 2))
self._fit_labels = labels
if plot_params:
......
......@@ -998,7 +998,7 @@ class IQCalAM(object):
# Completing the measurement
x, y = self._SpecAna.Read()
tmp = dm.data_line(x/1e9, y)
tmp = dm.data_table([x/1e9, y], ['Frequency (GHz)', 'PSD (dB)'])
# Obtain the data for the LSB, carrier and RSB
tmp.select([LSB - peaks_span, LSB + peaks_span])
......
......@@ -975,7 +975,7 @@ class IQCalAM(object):
# Completing the measurement
x, y = self._SpecAna.Read()
tmp = dm.data_line(x/1e9, y)
tmp = dm.data_table([x/1e9, y], ['Frequency (GHz)', 'PSD (dB)'])
# Obtain the data for the LSB, carrier and RSB
tmp.select([LSB - peaks_span, LSB + peaks_span])
......
......@@ -88,7 +88,7 @@ class SA(object):
def meas(self, f1, f2, filename, avgs=1, bw_res='auto',
points=32001, center=False, sweep_time='auto',
**dm_parameters):
"""Take a spectrum and save it as a data_line datamodule
"""Take a spectrum and save it as a data_table datamodule
Parameters
-----------
......
......@@ -80,7 +80,7 @@ class VNA(object):
# parameters={}, power_port2=False):
# """VNA Measurement
#
# Automatically save as data_line datamodule if not specified
# Automatically save as data_table datamodule if not specified
# otherwise (autoSave=False).
#
# Parameters
......
%% Cell type:code id: tags:
``` python
from DIGSIGD import Digsigd
from AWGSIGD import Awgsigd
from SIGGEN import Siggen
from IPLIST import IPList
from IQCALIBRATION import *
from PULSE import Pulse
import numpy as np
import matplotlib.pyplot as plt
from QUBEXP import Qubexp
from UtilitiesLib import check_shared_gen,initialize_shared_gen
import DataModule as dm
%matplotlib inline
```
%% Output
UtilitiesLib v1.2.4
DataModule v2.3.6
SIGGEN v1.5.2
Pulse library v2.0.1
Sensor reader v2.0.0
%% Cell type:markdown id: tags:
# initialize some parameters/instruments
%% Cell type:code id: tags:
``` python
exp = Qubexp('Freezer')
exp.dig = Digsigd(8)
exp.awg = Awgsigd(7)
exp.sgLO = IPList['Fanta4']
exp.sgLOch = 1
exp.sgro = IPList['MXG']
exp.sgIQLO = IPList['EXG3']
```
%% Cell type:markdown id: tags:
# Load HVI
%% Cell type:code id: tags:
``` python
HVI = exp.dig.sigd.SD_HVI()
tmp= HVI.open('/home/oscar/personal-repo/HVIs/awg+dig-chassis2.HVI')
if tmp<0:
print('ERROR in opening the HVI: {}\n'.format(tmp))
raise Exception('HVIERR')
```
%% Cell type:markdown id: tags:
# readout setup
%% Cell type:code id: tags:
``` python
500.0/16
```
%% Output
31.25
%% Cell type:code id: tags:
``` python
exp.readout_setup(HVI,1,channel_amplitude=0.3,LOpwr=12,delay_fix=150,down_freq=31.25)
```
%% Cell type:markdown id: tags:
# peak scan
%% Cell type:code id: tags:
``` python
ro_pulse = Pulse(8.802,Duration=1e3,Delay=0) #Note: AWG pulse seems slow, 300 ns are needed for sync
ro_pulse.par['sigpow'] = -5
ro_pulse.par['instdelay'] = 180
exp.averages= 1
sweep = np.arange(8.804,8.81,0.05e-3)
len(sweep)
```
%% Output
121
%% Cell type:code id: tags:
``` python
exp.awg.clear_waves()
exp.awg.set_channel()
exp.generate_readout_pulse(ro_pulse)
initialize_shared_gen(exp.sgIQLO,output=0)
```
%% Cell type:code id: tags:
``` python
def IQ_to_amplitude_and_phase(I,Q):
c = (np.sum(I,0)/len(I) + 1j*np.sum(Q,0)/len(Q) )
return np.abs(c),np.angle(c)
```
%% Cell type:code id: tags:
``` python
ro = ro_pulse.copy()
measurement_amp = np.ndarray(len(sweep))
measurement_ph = np.ndarray(len(sweep))
ave=10
for i,f in enumerate( sweep):
ro.frequency(np.round(f,12))
exp.generate_readout_pulse(ro)
time.sleep(0.01)
I,Q = exp.readout_IQ(ro_pulse)
for count in range(ave-1):
tmp1,tmp2 = exp.readout_IQ(ro_pulse)
I += tmp1
Q += tmp2
I /= ave
Q /=ave
measurement_amp[i],measurement_ph[i] = IQ_to_amplitude_and_phase(I,Q)
progressive_plot_2d(sweep[:i],measurement_amp[:i],'-o')
```
%% Output
%% Cell type:code id: tags:
``` python
plt.plot(sweep,measurement_ph,'-o')
```
%% Cell type:code id: tags:
``` python
ro_pulse.frequency(8.809)
```
%% Cell type:code id: tags:
``` python
data_e = dm.data_line(sweep[:-1],measurement_ph[:-1])
data_e = dm.data_table([sweep[:-1],measurement_ph[:-1]])
```
%% Cell type:code id: tags:
``` python
data_g.plot(engine='p')
data_e.plot(engine='p',color='r')
```
%% Output
%% Cell type:code id: tags:
``` python
np.abs(data_e.y-data_g.y)
```
%% Output
array([ 0.05867681, 0.13100047, 0.47434809, 0.25884587, 0.3349008 ,
0.37331859, 0.05068808, 0.2078128 , 0.18652742, 0.06579955,
0.23108727, 0.36655149, 0.21678218, 0.05120841, 0.26849868,
0.38783263, 0.23891928, 0.32523668, 0.2094726 , 0.20757055,
0.35692857, 0.14165355, 0.42854291, 0.19061517, 0.71388717,
0.38383214, 0.42072403, 0.52528852, 0.45831899, 0.09106379,
0.1321099 , 0.28909524, 0.21388836, 0.18888819, 0.1489761 ,
0.21225261, 0.43873524, 0.06674079, 0.53673795, 0.25097401,
0.47037214, 0.80254856, 0.18971179, 0.62827167, 0.16029798,
0.99436373, 0.0294345 , 0.00375602, 0.77213866, 0.37836664,
0.10981937, 0.36287821, 0.3429589 , 0.27497099, 1.71589279,
0.59922602, 0.59774947, 0.41716981, 0.51165314, 0.16681705,
0.62687455, 1.56919644, 0.55274685, 0.85816204, 0.05988168,
0.82472902, 0.1209473 , 1.47670707, 1.17451923, 0.51940272,
1.28972072, 1.6010486 , 0.85264411, 0.50594145, 0.13867164,
0.5119408 , 0.33623679, 0.69735639, 0.02611529, 0.95895958,
0.65109784, 0.4435927 , 0.88283573, 0.9419947 , 0.93186209,
0.3408138 , 0.67041377, 0.86858798, 1.07964665, 0.4610227 ,
1.11052212, 0.20911585, 1.03248826, 0.35389907, 1.21060766,
0.44429101, 1.5061231 , 1.00081053, 0.86498239, 1.22160131,
0.56512484, 1.39600071, 1.32034757, 1.0441579 , 1.48468858,
1.25302228, 1.39717278, 1.17124093, 0.8485038 , 0.9374302 ,
0.04065379, 0.85593347, 2.72962914, 1.06300745, 1.5685232 ,
0.11009581, 2.10423512, 0.11092194, 1.50547721, 1.52161184])
%% Cell type:markdown id: tags:
# qubit-spec
%% Cell type:code id: tags:
``` python
for i in range(2):
exp.awg.amplitude(i,1) #1V to "open" the mixer
exp.awg.mode(i,'DC')
exp.awg.set_channel('a')
```
%% Cell type:code id: tags:
``` python
exp.awg.get_channel_parameters(2)
```
%% Output
Frequency: 0 MHz
Amplitude: 0 V
Offset: 0 V
Phase: 0 deg
Mode: OFF
Amplitude Modulation: False
Queue elements: 0
%% Cell type:code id: tags:
``` python
ex_pulse = Pulse(8.,Duration=100e3)
ex_pulse.par['sigpow'] = -50
sweep = np.arange(6.44,6.46,0.4e-3)
#filename = 'test'
```
%% Cell type:code id: tags:
``` python
measurement_amp = np.ndarray(len(sweep))
measurement_ph = np.ndarray(len(sweep))
ave=100
for i,f in enumerate( sweep):
ex_pulse.frequency(np.round(f,12))
exp.generate_readout_pulse(ro_pulse)
exp.generate_excitation_pulse(ex_pulse)
time.sleep(0.01)
I,Q = exp.readout_IQ(ro_pulse)
for count in range(ave-1):
tmp1,tmp2 = exp.readout_IQ(ro_pulse)
I += tmp1
Q += tmp2
I /= ave
Q /=ave
measurement_amp[i],measurement_ph[i] = IQ_to_amplitude_and_phase(I,Q)
progressive_plot_2d(sweep[:i],measurement_amp[:i],'-o')
```
%% Output
%% Cell type:code id: tags:
``` python
plt.plot(sweep,measurement_ph,'-o')
```
%% Output
[<matplotlib.lines.Line2D at 0x7efc49e33be0>]
%% Cell type:markdown id: tags:
# Calibration
%% Cell type:code id: tags:
``` python
awg_pulse = Pulse(6.433845,Duration=200,Shape='g')
awg_pulse.par['upmix']=True
awg_pulse.par['AM']=True
awg_pulse.par
```
%% Cell type:markdown id: tags:
## On the go
%% Cell type:code id: tags:
``` python
calib = IQCalAM(exp.awg,exp.sgIQLO,1,'RS',0.6)
```
%% Cell type:code id: tags:
``` python
calib.set_awg(awg_pulse.par['awg_freq'],awg_pulse.par['awg_chan1'],awg_pulse.par['awg_chan2'])
calib.set_frequency(awg_pulse.frequency(),'R')
calib.set_LO()
calib.apply_corr()
calib.measure_SB(True)
```
%% Cell type:code id: tags:
``` python
calib.calibrate_offset(0.2,max_num_steps=2)
calib.calibrate_offset(0.002)
calib.calibrate_amp_ratio_and_phase(0,0.2,2,max_num_steps=2)
calib.calibrate_amp_ratio_and_phase(0,0.002,0.05)
```
%% Cell type:code id: tags:
``` python
cal_file ='test-{}MHz-freq-{}GHz'.format(calib.calibration.awg_parameters()[0],calib.calibration.frequency()[0])
calib.save_calibration(cal_file)
```
%% Cell type:markdown id: tags:
## Or load stored calibration
%% Cell type:code id: tags:
``` python
cal_file ='test-200.0MHz-freq-6.433845GHz.cal'
```
%% Cell type:code id: tags:
``` python
#the following is used for testing, it will also apply the correction to the AWG channels
calib = IQCalAM(exp.awg,exp.sgIQLO,1,'RS',0.6,cal_file)
calib.apply_corr()
calib.set_LO()
calib.measure_SB(True)
```
%% Cell type:code id: tags:
``` python
awg_pulse.par['calibration'] = cal_file
```
%% Cell type:code id: tags:
``` python
from SCOPE import Scope
sc=Scope()
```
%% Cell type:markdown id: tags:
# Rabi
%% Cell type:code id: tags:
``` python
ro_pulse.par['sigpow']=-5
#ro_pulse.par['instdelay']= 180
```
%% Cell type:code id: tags:
``` python
#exp.averages = 400
amplitude_sweep = [0.6]#np.arange(0,1.1,0.05)
```
%% Cell type:code id: tags:
``` python
sc.clear(),sc.run(1)
data_rabi = exp.Rabi(amplitude_sweep,ro_pulse,awg_pulse,fit_attempt=False,clear_mem=True)
```
%% Cell type:code id: tags:
``` python
check_shared_gen(exp.sgro)
```
%% Cell type:code id: tags:
``` python
a = sc.read('ch2')
a.select([500,1000])
a.plot(engine='p')
```
%% Cell type:markdown id: tags:
## Pi-pulse set
%% Cell type:code id: tags:
``` python
pi_pulse = awg_pulse.copy()
pi_pulse.par['sigpow']=0.4
```
%% Cell type:markdown id: tags:
# T1
%% Cell type:code id: tags:
``` python
delay_sweep = [200]#np.arange(0,10e3,100)
```
%% Cell type:code id: tags:
``` python
sc.clear(),sc.run(1)
data_t1 = exp.T1(delay_sweep,ro_pulse,pi_pulse,clear_mem=True)
```
%% Cell type:code id: tags:
``` python
a = sc.read('ch2')
a.select([710,960])
a.plot(engine='p')
```
%% Cell type:markdown id: tags:
# T2
%% Cell type:code id: tags:
``` python
osc_period = 0
delay_sweep = [400]#np.arange(0,10e3,20)
```
%% Cell type:code id: tags:
``` python
hpi_pulse = pi_pulse.copy()
hpi_pulse.par['sigpow'] = pi_pulse.par['sigpow']/2
```
%% Cell type:code id: tags:
``` python
sc.clear(),sc.run(1)
data = exp.T2(delay_sweep,ro_pulse,hpi_pulse,osc_period,clear_mem=True)
```
%% Cell type:code id: tags:
``` python
a = sc.read('ch2')
#a.select([0,2000])
a.plot(engine='p')
```
%% Cell type:markdown id: tags:
# TEcho
%% Cell type:code id: tags:
``` python
osc_period = 0
delay_sweep = [400]
amp_ratio = hpi_pulse.par['sigpow']/pi_pulse.par['sigpow']
amp_ratio
```
%% Cell type:code id: tags:
``` python
sc.clear(),sc.run(1)
data = exp.TEcho(delay_sweep,ro_pulse,pi_pulse,amp_ratio,osc_period,clear_mem=True)
```
%% Cell type:code id: tags:
``` python
a = sc.read('ch2')
a.plot(engine='p')
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
......
......@@ -1883,7 +1883,7 @@ class Qubexp(object):
#----------------------------------------------------------------------------------------------- q07 Utilities functions
def create_dm_before(self,Temp_reading=True):
data = dm.data_line()
data = dm.data_table()
if Temp_reading is True:
sr = SensorReader(self.CryoID)
......@@ -1897,7 +1897,7 @@ class Qubexp(object):
def create_dm_after(self,data,x,y,Temp_reading=True):
if data is None:
data = dm.data_line()
data = dm.data_table()
if Temp_reading is True:
sr = SensorReader(self.CryoID)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment