Skip to content

Commit

Permalink
intermediate state
Browse files Browse the repository at this point in the history
  • Loading branch information
terrorfisch authored and M-superposition committed Aug 13, 2018
1 parent 0642364 commit 422f71f
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 4 deletions.
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
5 changes: 4 additions & 1 deletion MATLAB/+qc/qcToolkitTestSetupUploadProgram.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
% upload_pulse = 's_pumping_AB_4chan';
% upload_pulse = 'pumping_s_stp';
% upload_pulse = 'pumping_s';
upload_scan = 'dnp_decay_dbz_fid_4chan';
% upload_scan = 'dnp_decay_dbz_fid_4chan';
upload_scan = 'line';
% upload_scan = 'lead';
% upload_scan = 'tl';



Expand Down
4 changes: 4 additions & 0 deletions qctoolkit/hardware/awgs/tabor.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,10 @@ def get_waveforms(self, channel: int) -> List[np.ndarray]:
return [ch_getter(self._segments[segment_no - 1])
for _, segment_no, _ in self._iter_segment_table_entry()]

def get_segment_waveform(self, channel: int, segment_no: int) -> np.ndarray:
ch_getter = (operator.attrgetter('ch_a'), operator.attrgetter('ch_b'))[channel]
return [ch_getter(self._segments[segment_no - 1])]

def get_repetitions(self) -> np.ndarray:
return np.fromiter((segment_repeat
for segment_repeat, *_ in self._iter_segment_table_entry()), dtype=np.uint32)
Expand Down

0 comments on commit 422f71f

Please sign in to comment.