Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/triton_200/master' into triton_2…
Browse files Browse the repository at this point in the history
…00/marcel_dev/check_pulse_params_fun
  • Loading branch information
M-superposition committed Aug 24, 2018
2 parents 85756f9 + b95a9ea commit 813a955
Show file tree
Hide file tree
Showing 80 changed files with 8,047 additions and 2,564 deletions.
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
21 changes: 18 additions & 3 deletions MATLAB/+qc/disp_awg_seq_table.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
% 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(...
'seq_table', {{}}, ...
'programName', plsdata.awg.currentProgam, ...
'advancedSeqTableFlag', false ...
);
args = util.parse_varargin(varargin, defaultArgs);



seq_table = qc.get_sequence_table(args.programName, args.advancedSeqTableFlag);
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.');
Expand All @@ -21,7 +36,7 @@ function disp_awg_seq_table(varargin)

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

Expand Down
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);
40 changes: 24 additions & 16 deletions MATLAB/+qc/get_sequence_table.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function seq_table = get_sequence_table(program_name, advanced_seq_table_flag, awg_channel_pair_identifiers, verbosity)
function seq_table = get_sequence_table(program_name, advanced_seq_table_flag, awg_channel_pair_identifiers, verbosity, return_python_list)
% GET_SEQUENCE_TABLE Get sequence table of program on Tabor AWG
% (not actually from AWG but from the qctoolkit Tabor Driver instance)
%
% --- Outputs -------------------------------------------------------------
% seq_table : Cell of sequence tables for each Tabor
Expand All @@ -17,9 +18,14 @@
% variable. Default is {'AB', 'CD'}.
% verbosity : Print sequence table to command line.
% Default is 0.
% return_python_list : Returns a python list object instead of a
% matlab cell. This makes the function
% faster as the conversion is slow.
% Dafault is false.
%
% -------------------------------------------------------------------------
% (c) 2018/06 Pascal Cerfontaine (cerfontaine@physik.rwth-aachen.de)
% (c) 2018/06 Pascal Cerfontaine and Marcel Meyer
% (cerfontaine@physik.rwth-aachen.de)

global plsdata
hws = plsdata.awg.hardwareSetup;
Expand All @@ -33,6 +39,9 @@
if nargin < 4 || isempty(verbosity)
verbosity = 0;
end
if nargin < 5 || isempty(return_python_list)
return_python_list = false;
end
if advanced_seq_table_flag
seq_txt = 'A';
else
Expand All @@ -53,20 +62,19 @@
if isfield(known_programs{k}, program_name)
tabor_program{k} = known_programs{k}.(program_name){2};

if advanced_seq_table_flag
seq_table{k} = py.getattr(tabor_program{k}, '_advanced_sequencer_table');
else
seq_table{k} = py.getattr(tabor_program{k}, '_sequencer_tables');
end

if verbosity > 0
disp(seq_table{k});
end

% if ~advanced_seq_table_flag
% seq_table{k} = seq_table{k}{1}; % Since it is a list inside a list -> one should pass all elements, list of list is used if advanced seq table is not trivial
% end
seq_table{k} = util.py.py2mat(seq_table{k});
if advanced_seq_table_flag
seq_table{k} = py.getattr(tabor_program{k}, '_advanced_sequencer_table');
else
seq_table{k} = py.getattr(tabor_program{k}, '_sequencer_tables');
end

if verbosity > 0
disp(seq_table{k});
end

if ~return_python_list
seq_table{k} = util.py.py2mat(seq_table{k});
end
else
tabor_program{k} = {};
seq_table{k} = {};
Expand Down
Loading

0 comments on commit 813a955

Please sign in to comment.