Skip to content

Commit

Permalink
Merge branch 'master' into issues/348_documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lumip committed Aug 30, 2018
2 parents c834048 + e817eb7 commit 61ae8a5
Show file tree
Hide file tree
Showing 31 changed files with 802 additions and 249 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ doc/build/*
build/*
dist/*
doc/source/examples/.ipynb_checkpoints/*
**.asv
**.asv
*.orig
21 changes: 21 additions & 0 deletions MATLAB/+qc/AWGwatch.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function AWGwatch()
% starts a matlab (vers 2018a) app to DISPLAY SEQUENCER TABLES AND
% WAFEFORMS in qctoolkit and on the Tabor AWG simulatar
% -------------------------------------------------------------------------
% - to edit the app open awgdisp_app.mlapp in the Matlab app designer
% - user preferences can be edited in the app private properties directly
% at the top in awgdisp_app.mlapp
% -------------------------------------------------------------------------
% App written by Marcel Meyer 08|2018 marcel.meyer1@rwth-aachen.de

disp('AWGwatch - app is started');

% the app is not on path +qc because matlab then one has problems debugging it
pathOfApp = which('qc.AWGwatch');
pathOfApp = pathOfApp(1:end-10);
pathOfApp = [pathOfApp 'AWGwatch'];
addpath(pathOfApp);

awgdisp_app();

end
Binary file added MATLAB/+qc/AWGwatch/awgdisp_app.mlapp
Binary file not shown.
23 changes: 12 additions & 11 deletions MATLAB/+qc/awg_program.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
bool = false;

default_args = struct(...
'program_name', 'default_program', ...
'pulse_template', 'default_pulse', ...
'parameters_and_dicts', {plsdata.awg.defaultParametersAndDicts}, ...
'channel_mapping', plsdata.awg.defaultChannelMapping, ...
'window_mapping', plsdata.awg.defaultWindowMapping, ...
'add_marker', {plsdata.awg.defaultAddMarker}, ...
'force_update', false, ...
'verbosity', 10 ...
'program_name', 'default_program', ...
'pulse_template', 'default_pulse', ...
'parameters_and_dicts', {plsdata.awg.defaultParametersAndDicts}, ...
'channel_mapping', plsdata.awg.defaultChannelMapping, ...
'window_mapping', plsdata.awg.defaultWindowMapping, ...
'global_transformation', plsdata.awg.globalTransformation, ...
'add_marker', {plsdata.awg.defaultAddMarker}, ...
'force_update', false, ...
'verbosity', 10 ...
);
a = util.parse_varargin(varargin, default_args);

Expand All @@ -35,14 +36,14 @@
a.pulse_template = pulse_to_python(a.pulse_template);
[a.pulse_template, a.channel_mapping] = add_marker_if_not_empty(a.pulse_template, a.add_marker, a.channel_mapping);

program = qc.program_to_struct(a.program_name, a.pulse_template, a.parameters_and_dicts, a.channel_mapping, a.window_mapping);
program = qc.program_to_struct(a.program_name, a.pulse_template, a.parameters_and_dicts, a.channel_mapping, a.window_mapping, a.global_transformation);
plsdata.awg.registeredPrograms.(a.program_name) = program;

if a.verbosity > 9
fprintf('Program ''%s'' is now being instantiated...', a.program_name);
tic;
end
instantiated_pulse = qc.instantiate_pulse(a.pulse_template, 'parameters', qc.join_params_and_dicts(program.parameters_and_dicts), 'channel_mapping', program.channel_mapping, 'window_mapping', program.window_mapping);
instantiated_pulse = qc.instantiate_pulse(a.pulse_template, 'parameters', qc.join_params_and_dicts(program.parameters_and_dicts), 'channel_mapping', program.channel_mapping, 'window_mapping', program.window_mapping, 'global_transformation', program.global_transformation);

if a.verbosity > 9
fprintf('took %.0fs\n', toc);
Expand Down Expand Up @@ -189,7 +190,7 @@
a.pulse_template = pulse_to_python(a.pulse_template);
[a.pulse_template, a.channel_mapping] = add_marker_if_not_empty(a.pulse_template, a.add_marker, a.channel_mapping);

newProgram = qc.program_to_struct(a.program_name, a.pulse_template, a.parameters_and_dicts, a.channel_mapping, a.window_mapping);
newProgram = qc.program_to_struct(a.program_name, a.pulse_template, a.parameters_and_dicts, a.channel_mapping, a.window_mapping, a.global_transformation);
newProgram = qc.get_minimal_program(newProgram);
% pulse_duration is just a helper field, can recognize whether
% program has changed without it. Removing it for the equality check
Expand Down
20 changes: 20 additions & 0 deletions MATLAB/+qc/awgdisp.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function awgdisp(source)

if nargin < 1
source = 'qctk';
end

% get AWG objects
switch source
case 'qctk'
disp('source = qctoolkit')
case 'sim'
disp('simulaotr')
otherwise
disp('no input')
end


% get sequence tables

% create app
168 changes: 93 additions & 75 deletions MATLAB/+qc/disp_awg_seq_table.m
Original file line number Diff line number Diff line change
@@ -1,77 +1,95 @@
% function to display the sequence table hold by qctoolkit Tabor instance
% or given in the varargins
% -------------------------------------------------------------------------
% Notes:
% - if varargin.seq_table is empty the sequence table saved in the qctoolkit
% Tabor object is plotted -> function uses qc.get_sequence_table internaly
% -------------------------------------------------------------------------
% written by Marcel Meyer 08|2018


function disp_awg_seq_table(varargin)

global plsdata

defaultArgs = struct(...
'programName', plsdata.awg.currentProgam, ...
'advancedSeqTableFlag', false ...
);
args = util.parse_varargin(varargin, defaultArgs);



seq_table = qc.get_sequence_table(args.programName, args.advancedSeqTableFlag);

disp(' ');
disp('[i] Table 1 is for channel pair AB and table 2 for channel pair CD.');
disp(' ');

for k = 1:2
if ~args.advancedSeqTableFlag

disp(sprintf('--- table %d -----------------', k));
for n = 1:length(seq_table{k})
disp(sprintf(' -- sub table %d ---------', n));

counter_disp_flag = false;
tmpEntry = seq_table{k}{n}{1};
disp(tmpEntry);
counter = 0;
for i=1:length(seq_table{k}{n})
if isequal(tmpEntry, seq_table{k}{n}{i})
counter = counter+1;
else
disp(sprintf(' rep = %d', counter));
tmpEntry = seq_table{k}{n}{i};
disp(tmpEntry);
counter = 0;
counter_disp_flag = true;
end
end
if counter_disp_flag == false
disp(sprintf(' rep = %d', counter));
end
disp('-----------------------------')
end



else

disp(sprintf('--- table %d -----------------', k));

counter_disp_flag = false;
tmpEntry = seq_table{k}{1};
disp(tmpEntry);
counter = 0;
for i=1:length(seq_table{k})
if isequal(tmpEntry, seq_table{k}{i})
counter = counter+1;
else
disp(sprintf(' rep = %d', counter));
tmpEntry = seq_table{k}{i};
disp(tmpEntry);
counter = 0;
counter_disp_flag = true;
end
end
if counter_disp_flag == false
disp(sprintf(' rep = %d', counter));
end
disp('-----------------------------')
end


end


global plsdata

defaultArgs = struct(...
'seq_table', {{}}, ...
'programName', plsdata.awg.currentProgam, ...
'advancedSeqTableFlag', false ...
);
args = util.parse_varargin(varargin, defaultArgs);


if isempty(args.seq_table)
seq_table = qc.get_sequence_table(args.programName, args.advancedSeqTableFlag);
else
assert(iscell(args.seq_table), 'wrong format sequence table')
seq_table = args.seq_table;
end

disp(' ');
disp('[i] Table 1 is for channel pair AB and table 2 for channel pair CD.');
disp(' ');

counter = 0;
tmpEntry = '';

for k = 1:2
if isempty(seq_table{k})
warning('-- empty sequence table at channel nr %i -- \n', k);
else
if ~args.advancedSeqTableFlag

fprintf('--- table %d -----------------\n', k);
for n = 1:length(seq_table{k})
fprintf(' -- sub table %d ---------\n', n);

tmpEntry = seq_table{k}{n}{1};
counter = 0;
for i=1:length(seq_table{k}{n})
if isequal(tmpEntry, seq_table{k}{n}{i})
counter = counter+1;
else

fprintf(' rep = %d', counter);
disp(tmpEntry);

tmpEntry = seq_table{k}{n}{i};
counter = 1;
end
end
fprintf(' rep = %d', counter);
disp(tmpEntry);
disp('-----------------------------')
end




else

fprintf('--- table %d -----------------\n', k);

tmpEntry = seq_table{k}{1};
counter = 0;
for i=1:length(seq_table{k})
if isequal(tmpEntry, seq_table{k}{i})
counter = counter+1;
else
fprintf(' rep = %d', counter);
disp(tmpEntry);

tmpEntry = seq_table{k}{i};
counter = 0;
end
end
fprintf(' rep = %d', counter);
disp(tmpEntry);
disp('-----------------------------')

end


end
end
end
44 changes: 44 additions & 0 deletions MATLAB/+qc/get_awg_memory.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
% function to get waveforms and sequence tables from the AWG
% -------------------------------------------------------------------------
% Notes:
% - the function only works with the Tabor AWG Simulator not on the real
% Tabor AWG
% - the function arms the program that is inspected
% -------------------------------------------------------------------------
% written by Marcel Meyer 08|2018

function awg_memory_struct = get_awg_memory(program_name, awg_channel_pair_identifier)

global plsdata

assert(ischar(program_name), 'first argument of get_awg_memory must be string');

if nargin < 2 || isempty(awg_channel_pair_identifier)
awg_channel_pair_identifier = 'AB';
else
assert(ischar(awg_channel_pair_identifier), 'second argument of get_awg_memory must be string');
end

% get AWG channelpair python object
hws = plsdata.awg.hardwareSetup;
known_awgs = util.py.py2mat(hws.known_awgs);
sort_indices = cellfun(@(x)(~isempty(strfind(char(x.identifier), awg_channel_pair_identifier))), known_awgs);
channelpair = known_awgs(find(sort_indices));
channelpair = channelpair{1};

% arm program at AWG
try
channelpair.arm(program_name);
catch err
warning('program seems not to be on AWG, upload it first, returning without returning memory');
warning(err.message);
return
end

% get a plottable program object -> qctoolkit Tabor driver gets sequence
% tables and waveforms from the simulator
plottableProgram = channelpair.read_complete_program();

awg_memory_struct = util.py.py2mat(plottableProgram.to_builtin());

end
13 changes: 13 additions & 0 deletions MATLAB/+qc/get_awg_seq_table.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function seq_table = get_awg_seq_table(varargin)

global plsdata

defaultArgs = struct(...
'programName', plsdata.awg.currentProgam, ...
'advancedSeqTableFlag', false ...
);
args = util.parse_varargin(varargin, defaultArgs);

seq_table = qc.get_sequence_table(args.programName, args.advancedSeqTableFlag);

end
53 changes: 53 additions & 0 deletions MATLAB/+qc/get_segment_waveform.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
function [wf1, wf2] = get_segment_waveform(program_name, channel_pair_index, memory_index, awg_channel_pair_identifiers)
% Get Wafeform of Sequencer Table Element
% PLEASE NOTE: works only for the Tabor AWG SIMULATOR
% PLEASE NOTE: program gets armed by calling this function
%
% --- Outputs -------------------------------------------------------------
% wf1 : first channel y-values of AWG channelpair
% wf2 : second channel y-values of AWG channelpair
%
% --- Inputs --------------------------------------------------------------
% program_name : Program name for which wafeform is
% returned
% channel_pair_index : 1 for channelpair AB and 2 for channelpair
% CD. Also see awg_channel_pair_identifier
% input
% memory_index : identifier number of element at the Tabor
% AWG (corresponds to second column in
% Sequencer Table
% awg_channel_pair_identifiers : Some substring in the channel pair
% identifiers to be matched. Sequence tables
% are sorted in the same order as channel
% pair identifiers substrings passed in this
% variable. Default is {'AB', 'CD'}.
%
% -------------------------------------------------------------------------
% 2018/08 Marcel Meyer
% (marcel.meyer1@rwth-aachen.de)

global plsdata
hws = plsdata.awg.hardwareSetup;

if nargin < 4 || isempty(awg_channel_pair_identifiers)
awg_channel_pair_identifiers = {'AB', 'CD'};
end

known_awgs = util.py.py2mat(hws.known_awgs);
sort_indices = cellfun(@(x)(find( cellfun(@(y)(~isempty(strfind(char(x.identifier), y))), awg_channel_pair_identifiers) )), known_awgs);
known_awgs = known_awgs(sort_indices);

%one has to arm the program to access the plottableProgram object of the
%program
known_awgs{channel_pair_index}.arm(program_name);

plottableProgram = known_awgs{channel_pair_index}.read_complete_program();

wf1 = plottableProgram.get_segment_waveform(uint8(0), uint8(memory_index));
wf2 = plottableProgram.get_segment_waveform(uint8(1), uint8(memory_index));

wf1 = util.py.py2mat(wf1);
wf2 = util.py.py2mat(wf2);

wf1 = cell2mat(wf1);
wf2 = cell2mat(wf2);

0 comments on commit 61ae8a5

Please sign in to comment.