Skip to content

Commit

Permalink
170816-1
Browse files Browse the repository at this point in the history
  • Loading branch information
YulinWu committed Aug 16, 2017
1 parent a7693f2 commit a843893
Show file tree
Hide file tree
Showing 19 changed files with 473 additions and 510 deletions.
21 changes: 11 additions & 10 deletions qos/+data_taking/+public/+scripts/singleQubitBringup.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
% r_fr, the qubit dip frequency, it's exact value changes with qubit state and readout power,
% the value of r_fr is just a reference frequency for automatic
% routines, a close value is sufficient.
setQSettings('r_fr',readoutFreqs(ii),qNames{ii});
setQSettings('r_fr',readoutFreqs(ii),qNames{ii});
% also set r_freq is the frequency of the readout pulse, it is slightly
% different than the qubit dip frequency after optimization, but at the beginning of the
% meausrement, set it to the qubit dip frequency is OK.
Expand Down Expand Up @@ -120,12 +120,12 @@
%%
s21_01('qubit','q2','freq',[],'notes','','gui',true,'save',true);
%%
ramsey('qubit','q9','mode','dp',... % available modes are: df01, dp and dz
'time',[0:50:30e3],'detuning',[2]*1e6,...
'dataTyp','P','notes','','gui',true,'save',true);
ramsey('qubit','q9_1k','mode','dp',... % available modes are: df01, dp and dz
'time',[0:10:2e3],'detuning',[0]*1e6,...
'dataTyp','P','phaseOffset',pi/2,'notes','','gui',true,'save',true);
%%
spin_echo('qubit','q8','mode','dp',... % available modes are: df01, dp and dz
'time',[0:50:30e3],'detuning',[1]*1e6,...
spin_echo('qubit','q9_1','mode','dp',... % available modes are: df01, dp and dz
'time',[0:50:30e3],'detuning',[2]*1e6,...
'notes','','gui',true,'save',true);
%%
T1_1('qubit','q3','biasAmp',[0],'biasDelay',20,'time',[0:100:10e3],...
Expand All @@ -149,10 +149,10 @@
'gui',true,'save',true)
%%
% delayTime = [[0:1:20],[21:2:50],[51:5:100],[101:10:500],[501:50:3000]];
delayTime = [0:20:2e3];
zPulseRipple('qubit','q8',...
delayTime = [-300:10:2e3];
zPulseRipple('qubit','q9_1k',...
'delayTime',delayTime,...
'zAmp',2e4,'gui',true,'save',true);
'zAmp',3e3,'gui',true,'save',true);
%%
state = '|0>-i|1>';
data = singleQStateTomo('qubit','q2','reps',2,'state',state);
Expand Down Expand Up @@ -187,7 +187,8 @@
tuneup.xyGateAmpTuner('qubit',q,'gateTyp','X','AE',true,'gui',true,'save','askMe');
tuneup.iq2prob_01('qubit',q,'numSamples',1e4,'gui',true,'save','askMe');
%% fully auto callibration
qubits = {'q7','q8'};
% qubits = {'q7','q8'};
qubits = {'q9_1k'};
for ii = 1:numel(qubits)
q = qubits{ii};
setQSettings('r_avg',2000,q);
Expand Down
10 changes: 5 additions & 5 deletions qos/+data_taking/+public/+xmon/ramsey.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
% dz: detune by z detune pulse
%
% <_o_> = ramsey('qubit',_c&o_,'mode',m...
% 'time',[_i_],'detuning',<_f_>,...
% 'time',[_i_],'detuning',<_f_>,'phaseOffset',<_f_>,...
% 'notes',<_c_>,'gui',<_b_>,'save',<_b_>)
% _f_: float
% _i_: integer
Expand All @@ -24,19 +24,19 @@

import qes.util.processArgs
import data_taking.public.xmon.*
args = processArgs(varargin,{'mode', 'df01','dataTyp','P',...
args = processArgs(varargin,{'mode', 'df01','dataTyp','P','phaseOffset',0,...
'gui',false,'notes','','detuning',0,'save',true});
switch args.mode
case 'df01'
e = ramsey_df01('qubit',args.qubit,'dataTyp',args.dataTyp,...
e = ramsey_df01('qubit',args.qubit,'dataTyp',args.dataTyp,'phaseOffset',args.phaseOffset,...
'time',args.time,'detuning',args.detuning,...
'notes',args.notes,'gui',args.gui,'save',args.save);
case 'dp'
e = ramsey_dp('qubit',args.qubit,'dataTyp',args.dataTyp,...
e = ramsey_dp('qubit',args.qubit,'dataTyp',args.dataTyp,'phaseOffset',args.phaseOffset,...
'time',args.time,'detuning',args.detuning,...
'notes',args.notes,'gui',args.gui,'save',args.save);
case 'dz'
e = ramsey_dz('qubit',args.qubit,'dataTyp',args.dataTyp,...
e = ramsey_dz('qubit',args.qubit,'dataTyp',args.dataTyp,'phaseOffset',args.phaseOffset,...
'time',args.time,'detuning',args.detuning,...
'notes',args.notes,'gui',args.gui,'save',args.save);
otherwise
Expand Down
8 changes: 5 additions & 3 deletions qos/+data_taking/+public/+xmon/ramsey_df01.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
% ramsey: ramsey oscillation, detune by detuning iq frequency(sideband frequency)
%
% <_o_> = ramsey_df01('qubit',_c&o_,...
% 'time',[_i_],'detuning',<[_f_]>,...
% 'time',[_i_],'detuning',<[_f_]>,'phaseOffset',<_f_>,...
% 'dataTyp',<'_c_'>,... % S21 or P
% 'notes',<_c_>,'gui',<_b_>,'save',<_b_>)
% _f_: float
Expand All @@ -23,7 +23,7 @@
import sqc.*
import sqc.op.physical.*

args = util.processArgs(varargin,{'dataTyp','P','detuning',0,'gui',false,'notes','','save',true});
args = util.processArgs(varargin,{'phaseOffset',0,'dataTyp','P','detuning',0,'gui',false,'notes','','save',true});
q = data_taking.public.util.getQubits(args,{'qubit'});

X2 = gate.X2p(q);
Expand All @@ -41,9 +41,11 @@
throw(MException('QOS_ramsey_df01:unrcognizedDataTyp','unrecognized dataTyp %s, available dataTyp options are P and S21.', args.dataTyp));
end

X2_ = copy(X2);
X2.phase = args.phaseOffset;
function procFactory(delay)
I.ln = delay;
proc = X2*I*X2;
proc = X2_*I*X2;
proc.Run();
R.delay = proc.length;
end
Expand Down
6 changes: 3 additions & 3 deletions qos/+data_taking/+public/+xmon/ramsey_dp.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
% detune by changing the second pi/2 pulse tracking frame
%
% <_o_> = ramsey_dp('qubit',_c&o_,...
% 'time',[_i_],'detuning',<[_f_]>,...
% 'time',[_i_],'detuning',<[_f_]>,'phaseOffset',<_f_>,...
% 'dataTyp',<'_c_'>,... % S21 or P
% 'notes',<_c_>,'gui',<_b_>,'save',<_b_>)
% _f_: float
Expand All @@ -24,7 +24,7 @@
import sqc.*
import sqc.op.physical.*

args = util.processArgs(varargin,{'dataTyp','P','gui',false,'notes','','detuning',0,'save',true});
args = util.processArgs(varargin,{'phaseOffset',0,'dataTyp','P','gui',false,'notes','','detuning',0,'save',true});
q = data_taking.public.util.getQubits(args,{'qubit'});

X2 = op.XY2p(q,0);
Expand All @@ -50,7 +50,7 @@
X2_ = copy(X2);
function procFactory(delay)
I.ln = delay;
X2.phase = -2*pi*detuning.val*delay/daSamplingRate;
X2.phase = -2*pi*detuning.val*delay/daSamplingRate+args.phaseOffset;
proc = X2_*I*X2;
proc.Run();
R.delay = proc.length;
Expand Down
8 changes: 5 additions & 3 deletions qos/+data_taking/+public/+xmon/ramsey_dz.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
% ramsey_dz: ramsey oscillation, detune by z detune pulse
%
% <_o_> = ramsey_dz('qubit',_c&o_,...
% 'time',[_i_],'detuning',<[_f_]>,...
% 'time',[_i_],'detuning',<[_f_]>,'phaseOffset',<_f_>,...
% 'dataTyp',<'_c_'>,... % S21 or P
% 'notes',<_c_>,'gui',<_b_>,'save',<_b_>)
% _f_: float
Expand All @@ -24,7 +24,7 @@
import sqc.*
import sqc.op.physical.*

args = util.processArgs(varargin,{'detuning',0,'dataTyp','P',...
args = util.processArgs(varargin,{'phaseOffset',0,'detuning',0,'dataTyp','P',...
'gui',false,'notes','','detuning',0,'save',true});
q = data_taking.public.util.getQubits(args,{'qubit'});

Expand All @@ -44,9 +44,11 @@
'unrecognized dataTyp %s, available dataTyp options are P and S21.', args.dataTyp));
end

X2_ = copy(X2);
X2.phase = args.phaseOffset;
function procFactory(delay)
I.ln = delay;
proc = X2*I*X2;
proc = X2_*I*X2;
proc.Run();
R.delay = proc.length;
end
Expand Down
20 changes: 15 additions & 5 deletions qos/+data_taking/+public/+xmon/zPulseRipple.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import qes.*
import sqc.*
import sqc.op.physical.*

Z_LENGTH = 10000;

args = util.processArgs(varargin,{'dataTyp','P','gui',false,'notes','','detuning',0,'save',true});
q = data_taking.public.util.getQubits(args,{'qubit'});
Expand All @@ -29,17 +31,25 @@
Y2 = gate.Y2p(q);
I1 = gate.I(q);
I2 = gate.I(q);
Z = op.zRect(q);
Z.ln = 6000;
Z.amp = args.zAmp;
if args.zAmp ~= 0
Z = op.zRect(q);
Z.ln = Z_LENGTH;
Z.amp = args.zAmp;
else
Z = gate.I(q);
Z.ln = Z_LENGTH;
end

R = measure.resonatorReadout_ss(q);
R.state = 2;

maxDelayTime = max(args.delayTime);
function procFactory(delay)
I1.ln = delay;
% I1.ln = delay;
I1.ln = Z_LENGTH+delay;
I2.ln = maxDelayTime - delay;
proc = Z*I1*X2*I2*Y2;
% proc = Z*I1*X2*I2*Y2;
proc = Z.*(I1*X2*I2*Y2); % now minus delay is allowed
proc.Run();
R.delay = proc.length;
end
Expand Down
13 changes: 12 additions & 1 deletion qos/+qes/+hwdriver/+sync/@awg/SendWave.m
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,19 @@ function SendWave(obj,WaveformObj)
% SendWave(...); setChnlOutputDelay(...,200);
% Run(..); % now delay is 100*4 ns, not 200*4 ns,
% 200*4 ns will be the delay amount of next Run.
% this is a da driver bug, might be corrected in a future version.
% this is a da driver bug, might be corrected in a future version.

% persistent ax;
% if isempty(ax)
% h = figure();
% ax = axes('parent',h);
% end

if WaveformObj.iq

% hold(ax,'on');
% plot(ax,WaveformData{1}(1:50));plot(ax,WaveformData{2}(1:50));
%
obj.interfaceobj.setChnlOutputDelay(WaveformObj.awgchnl(1),output_delay_count(1));
obj.interfaceobj.setChnlOutputDelay(WaveformObj.awgchnl(2),output_delay_count(2));
obj.interfaceobj.SendWave(WaveformObj.awgchnl(1),WaveformData{1});
Expand Down
154 changes: 154 additions & 0 deletions qos/+toolbox/+data_tool/+fitting/+scripts/sinDecayFit.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
% data: x, y

LeastOscN = 15;
[A,B,C,D,freq,td,ci] = toolbox.data_tool.fitting.sinDecayFit_auto(x,y);
h = figure('Position',[0,0,1000,500],'Color',[1,1,1]);
plot(x,y,'bo','MarkerSize',10,'MarkerEdgeColor','b','MarkerFaceColor','b');
hold on;
if ischar(A)
disp(A);
xlabel('t','FontSize',28);
ylabel('P','FontSize',28);
set(gcf,'Color',[1,1,1]);
set(gca,'LineWidth',2,'FontSize',24);
title('automatic fitting failed','FontSize',16);
else
home;
disp('Formula: A +B*(exp(-t/td).*(sin(2*pi*freq*t+D)+C))');
fprintf('A = %f B = %f C = %f D = %f freq = %f td = %fnS\n ',A,B,C,D,freq,td);
fprintf('Confidence interval(95%%): A = [%f,%f] B = [%f,%f] C = [%f,%f] D = [%f,%f] freq = [%f,%f] td = [%f,%f]nS\n ',ci(1,1),ci(1,2),ci(2,1),ci(2,2),ci(3,1),ci(3,2),ci(4,1),ci(4,2),ci(5,1),ci(5,2),ci(6,1),ci(6,2));
fprintf('Unit of f: 1/(unit of t); Unit of td: unit of t');
L = length(x);
step = (x(end)-x(1))/L/50; % 50 times sampling density
xf = x(1):step:x(end);
yf = toolbox.data_tool.fitting.SinusoidalDecayTilt([A, B,C,D,freq,td],xf);

plot(xf,yf,'r-','LineWidth',2);
legend('data','fit');
xlabel('t','FontSize',28);
ylabel('P','FontSize',28);
title(['Frequency: ',num2str(freq*1000,'%3.1f'),' 1/(unit of t); td: ',num2str(td,'%4.1f'),' (unit of t)'],'FontSize',16);
set(gcf,'Color',[1,1,1]);
set(gca,'LineWidth',2,'FontSize',24);
end

button = questdlg('If this automatic fitting failed, you may try fitting by helping me to find the proper initial values for the parameters:');
if strcmp(button,'Yes')
close(h);
h = figure('Position',[0,0,1000,500],'Color',[1,1,1]);
plot(x,y,'b-o','MarkerSize',8,'MarkerEdgeColor','b','MarkerFaceColor','b');
title('Waiting... Adjust the figure for good eye sight if needed.','Color','b','FontSize',16);
pause(3);
title('What is the y value of the oscillation after full decay, click to indicate, only Y value is important.','FontSize',16);
[xi,A0] = ginput(1);
title('What is the oscillation amplitude at time zero, click two points to indicate, only Y values are important.','FontSize',16);
[xi,yi] = ginput(2);
B0 = abs(yi(1)-yi(2));
title('What is the oscillation period, click two points to indicate, only X values are important.','FontSize',16);
[xi,yi] = ginput(2);
T = abs(xi(1)-xi(2));
freq0 = 1/T;
title('After what time duration the oscillation decayed to 0.37 of the maximum amplitude, click two points to indicate, only X values are important.','FontSize',16);
[xi,yi] = ginput(2);
T = abs(xi(1)-xi(2));
if T > 0
td0 = T;
else
td0 = [];
end
close(h);
choice = questdlg('Choose fit mode:', ...
'Fit mode', ...
'Varied frequency Exp','Constant frequency Gaussian','Constant frequency Exp','Constant frequency Exp');
% Handle response
switch choice
case 'Constant frequency Exp'
[A, B,C,D,freq,td,ci] = toolbox.data_tool.fitting.sinDecayFitTilt(x,y,...
A0,[0.9*A0,1.1*A0],...
0.5*B0,[0.3*B0,0.7*B0],...
0.5,[0.3,0.7],...
pi/2,[-pi,pi],...
freq0,[0.7*freq0,1.4*freq0],...
td0,[0.7*td0,1.4*td0]);
% [B,C,D,freq,td,ci] = toolbox.data_tool.fitting.sinDecayFit_m(x,y,...
% 0.5*B0,[0.3*B0,0.7*B0],...
% A0/(0.5*B0),sort([0.7*A0/(0.5*B0),1.4*A0/(0.5*B0)]),...
% pi/2,[-pi,pi],...
% freq0,[0.7*freq0,1.4*freq0],...
% td0,[0.7*td0,1.4*td0]);
if ischar(A)
disp(A);
else
home;
disp('Formula: A +B*(exp(-t/td).*(sin(2*pi*freq*t+D)+C))');
fprintf('B = %f C = %f D = %f freq = %f td = %fnS\n ',B,C,D,freq,td);
fprintf('Confidence interval(95%%): B = [%f,%f] C = [%f,%f] D = [%f,%f] freq = [%f,%f] td = [%f,%f]nS\n ',...
ci(1,1),ci(1,2),ci(2,1),ci(2,2),ci(3,1),ci(3,2),ci(4,1),ci(4,2),ci(5,1),ci(5,2));
fprintf('Unit of f: 1/(unit of t); Unit of td: unit of t');
h = figure('Position',[0,0,1000,500],'Color',[1,1,1]);
L = length(x);
step = (x(end)-x(1))/L/50; % 50 times sampling density
xf = x(1):step:x(end);
yf = toolbox.data_tool.fitting.SinusoidalDecayTilt([A,B,C,D,freq,td],xf);
plot(x,y,'bo','MarkerSize',10,'MarkerEdgeColor','b','MarkerFaceColor','b');
hold on;
plot(xf,yf,'r-','LineWidth',2);
legend('data','fit');
xlabel('t','FontSize',28);
ylabel('P','FontSize',28);
title(['Frequency: ',num2str(freq*1000,'%3.1f'),' 1/(unit of t); td: ',num2str(td,'%4.1f'),' (unit of t)'],'FontSize',16);
set(gcf,'Color',[1,1,1]);
set(gca,'LineWidth',2,'FontSize',24);
end
case 'Constant frequency Gaussian'
[A,B,C,D,freq,td,ci] = SinDecayFit_G(x,y,LeastOscN,freq0,td0,A0,B0);
if ischar(A)
disp(A);
else
home;
disp('Formula: A +B*(exp(-t/td).*(sin(2*pi*freq*t+D)+C))');
fprintf('A = %f B = %f C = %f D = %f freq = %f td = %fnS\n ',A,B,C,D,freq,td);
fprintf('Confidence interval(95%%): A = [%f,%f] B = [%f,%f] C = [%f,%f] D = [%f,%f] freq = [%f,%f] td = [%f,%f]nS\n ',ci(1,1),ci(1,2),ci(2,1),ci(2,2),ci(3,1),ci(3,2),ci(4,1),ci(4,2),ci(5,1),ci(5,2),ci(6,1),ci(6,2));
fprintf('Unit of f: 1/(unit of t); Unit of td: unit of t');
h = figure('Position',[0,0,1000,500],'Color',[1,1,1]);
L = length(x);
step = (x(end)-x(1))/L/50; % 50 times sampling density
xf = x(1):step:x(end);
yf = SinusoidalDecay_G([A,B,C,D,freq,td],xf);
plot(x,y,'bo','MarkerSize',10,'MarkerEdgeColor','b','MarkerFaceColor','b');
hold on;
plot(xf,yf,'r-','LineWidth',2);
legend('data','fit');
xlabel('t','FontSize',28);
ylabel('P','FontSize',28);
title(['Frequency: ',num2str(freq*1000,'%3.1f'),' 1/(unit of t); td: ',num2str(td,'%4.1f'),' (unit of t)'],'FontSize',16);
set(gcf,'Color',[1,1,1]);
set(gca,'LineWidth',2,'FontSize',24);
end
case 'Varied frequency'
[A,B,C,D,freq,td,varf,ci] = SinDecayFit_varf(x,y,LeastOscN,freq0,td0,A0,B0);
if ischar(A)
disp(A);
else
home;
disp('Formula: A +B*(exp(-t/td).*(sin(2*pi*(freq+varf*t)*t+D)+C))');
fprintf('A = %f B = %f C = %f D = %f freq = %f varf = %f td = %fnS\n ',A,B,C,D,freq,varf,td);
fprintf('Confidence interval(95%%): A = [%f,%f] B = [%f,%f] C = [%f,%f] D = [%f,%f] freq = [%f,%f] varf = [%f,%f] td = [%f,%f]nS\n ',ci(1,1),ci(1,2),ci(2,1),ci(2,2),ci(3,1),ci(3,2),ci(4,1),ci(4,2),ci(5,1),ci(5,2),ci(7,1),ci(7,2),ci(6,1),ci(6,2));
fprintf('Unit of f: 1/(unit of t); Unit of td: unit of t');
h = figure('Position',[0,0,1000,500],'Color',[1,1,1]);
L = length(x);
step = (x(end)-x(1))/L/50; % 50 times sampling density
xf = x(1):step:x(end);
yf = SinusoidalDecay_varf([A,B,C,D,freq,td,varf],xf,xf(1));
plot(x,y,'bo','MarkerSize',10,'MarkerEdgeColor','b','MarkerFaceColor','b');
hold on;
plot(xf,yf,'r-','LineWidth',2);
legend('data','fit');
xlabel('t','FontSize',28);
ylabel('P','FontSize',28);
title(['Frequency: ',num2str(freq*1000,'%3.1f'),' 1/(unit of t); td: ',num2str(td,'%4.1f'),' (unit of t)'],'FontSize',16);
set(gcf,'Color',[1,1,1]);
set(gca,'LineWidth',2,'FontSize',24);
end
end
end
Loading

0 comments on commit a843893

Please sign in to comment.