Code Documentation

start

start.info_dialog()[source]

Info text for presenting on startup

Returns

message box of all of its information

Return type

string

start.test_import()[source]

Verification of all used modues what are used in the Projekt. If the module is able to be imported.

Returns

True = if tested verifications passes, False = if tested verification fails

Return type

bool

start.test_settings()[source]

Space holder for additional requirement verification that want to be thestet at startup

Returns

True = if tested verifications passes, False = if tested verification fails

Return type

bool

start.test_version()[source]

Verification of the installed and use Python syste version

Returns

True = if tested verifications passes, False = if tested verification fails

Return type

bool

Graphical User Interface

GUI.GUI_start()[source]

This will initialise the loggers After all imports it will start the main window

Main Window

class win_main2.window_main(*args, **kwargs)[source]
autosave()[source]

repeatative loop to load and save parameters update the infobox in the main window

debug_logtext(text='test')[source]

Used in the development for showing text on the main window It presents the workflow as an info in the main window

Parameters

text (str, optional) – Any text that want to be pushed to the window logger in the main window, defaults to “test”

get_values()[source]

read all input value form the manin window

Returns

returns parameters form the main window

Return type

dict

load_last_values2()[source]

load setting_last_run.cfg from folder program

load_settings()[source]

Handels the loading from a settings.cfg file into the system

load_settings2()[source]

load setting_last_run.cfg from last saved from GUI

plot_live(s1='', t1='', s2='', t2='')[source]

initialising generating the plot on the main window. Handing over Time and Frequency data for the first generation of the plot. Later all changes will be made with the funktion def: plot_update()

Parameters
  • s1 (str, optional) – plot for timedomain the representative amplitude values , defaults to “”

  • t1 (str, optional) – plot for timedomain the representative interval time values, defaults to “”

  • s2 (str, optional) – plot for frequencydomain the representative amplitude values, defaults to “”

  • t2 (str, optional) – plot for frequencydomain the representative interval time values, defaults to “”

Returns

initital setup of the plot in matplotlib

Return type

figure

plot_update(file_time='program\\scan_data_time.csv', file_freq='program\\scan_data_freq.csv')[source]

update the data what is shown in the plot from a filepath on pull request

Parameters
  • file_time (str, optional) – time data from a *.csv file, defaults to os.path.join(“program”, “scan_data_time.csv”)

  • file_freq (str, optional) – frequency data from a*.csv, defaults to os.path.join(“program”, “scan_data_freq.csv”)

read_tm()[source]

read a tuning and matching file into the system for setting its parameters

save_all()[source]

routine sequence for securing and saving the set situation

save_measurment()[source]

Handels the saving to a settings.cfg file

save_quit_all()[source]

routine sequence for securing and saving the set situation and closing the window.

send_arduino()[source]

send parameters for matching to the microcontroler

set_measur(start=11, stop=22, step=33, average=44)[source]

set the frequency parameters into the GUI specified enterys

Parameters
  • start (int, optional) – start frequency, defaults to 11

  • stop (int, optional) – stop frequency, defaults to 22

  • step (int, optional) – frequency steps, defaults to 33

  • average (int, optional) – number of averages per frequency step, defaults to 44

set_storage(path='test_path', experiment='test_exper', cycle='test_cycle')[source]

initialise storage log information to the main window

Parameters
  • path (str, optional) – name of the ot the path, defaults to “test_path”

  • experiment (str, optional) – name of the experiment, defaults to “test_exper”

  • cycle (str, optional) – name of the cycle, defaults to “test_cycle”

set_tm(tune=5, match=100, tm_step=100, lut=50)[source]

read from the main window tuning and matching parameters and set them in the system variabels for processing

Parameters
  • tune (int, optional) – maximum voltage for the tuning circuit to tune up to, defaults to 5

  • match (int, optional) – maximum voltage for the matching circuit to tune up to, defaults to 100

  • tm_step (int, optional) – number of steps samples generated, defaults to 100

  • lut (int, optional) – recoreded samples for interpolation, defaults to 50

time_autosave = 5000

Gernerates the main window to call and handel all variabels and processes from a central position.

File handling

win_load_file.save_file(path, experiment='test_experiment_1', data='test_data_11')[source]

chech if folderstrukture for saving exist otherwise generate filestrukture

Parameters
  • path (str) – main storage path

  • experiment (str, optional) – sub folder path, defaults to “test_experiment_1”

  • data (str, optional) – subsubfolder path, defaults to “test_data_11”

Returns

check if sucsessfull

Return type

str

win_load_file.save_values(path='test_data', experiment='test_experiment', data='test_data')[source]

save files to folderstructure

Parameters
  • path (str, optional) – main folder to save to, defaults to “test_data”

  • experiment (str, optional) – subfolder to save to, defaults to “test_experiment”

  • data (str, optional) – subsub folder to save to, defaults to “test_data”

class win_load_file.win_load_file(path='test_sample', experiment='test_experiment', data='test_data', *args, **kwargs)[source]

generate Window for Filehandeling

Parameters

tk (tkinter) – import tkinter module

Sequence handling

class win_sequenz.Window_seq[source]

will launch the main window to enter the Variable. In the init, values will be pre-set.

Returns:

all values aquiriert will be saved to files as specified by the user.

load_seq()[source]

acquire saved data from storea and load into the file handler and visualise the data in the GUI

Returns

dictonray of all loaded parameters

Return type

dict

read2cfg(file_path='C:\\Users\\Malin\\AppData\\Local\\Programs\\Python\\Python39\\Scripts', file='program/setting_sequence.cfg')[source]

take the .cfg file and format it into a dictonray

Parameters
  • file_path (os.path, optional) – path of the program., defaults to os.path.dirname(sys.argv[0])

  • file (str, optional) – path of the file to be loaded., defaults to “program/setting_sequence.cfg”

Returns

hand over all parameters to be processed for loading into the system

Return type

dict

save2cfg(file='program/setting_sequence.cfg', file_path='C:\\Users\\Malin\\AppData\\Local\\Programs\\Python\\Python39\\Scripts')[source]

save all parameters to the file set.

Parameters
  • file (str, optional) – path where to save the *.cfg file to, defaults to “program/setting_sequence.cfg”

  • file_path (os.path, optional) – abolute system file path, defaults to os.path.dirname(sys.argv[0])

Returns

return all saved parameters

Return type

dict

static save_seq(self)[source]

get input parameter and save to class variables

Returns

a dictionary of all variables of the sequence

Return type

dic

window_sequenz(seq_type='0', value_settings='1', puls_cylce='1', value_set='none')[source]

initial setting the sequenc parameters

Parameters
  • seq_type (str, optional) – sequence type that was selected, defaults to “0”

  • value_settings (str, optional) – initial setting parameters of parameters, defaults to “1”

  • puls_cylce (str, optional) – number of pulses, defaults to “1”

  • value_set (str, optional) – variabel handeling settings, defaults to “none”

Returns

_description_

Return type

_type_

win_sequenz.load_file(path='data', experiment='test_experiment', cycle='test_cycle')[source]

load Parameters from storage to handed over to the sytem

Parameters
  • path (str, optional) – mainfolder to save acquire measurment data, defaults to “data”

  • experiment (str, optional) – subfolder to save acquire measurment data, defaults to “test_experiment”

  • cycle (str, optional) – subsubfolder to save acquire measurment data, defaults to “test_cycle”

Returns

“True” if files could be loaed, “False” if files could not be loaed

Return type

_type_

win_sequenz.save_file(path, experiment='test_experiment_1', cycle='test_cycle_11')[source]

check if the storage strukture exist, othersise generate the correspondingly needed folders

Parameters
  • path (str) – location of where to save the file

  • experiment (str, optional) – subfolder for storage. Defaults to “test_experiment_1”, defaults to “test_experiment_1”

  • cycle (str, optional) – subsubfolder for declaing the storage, defaults to “test_cycle_11”

Returns

True if folders could be found or were generated, False if not possible

Return type

bool

win_sequenz.save_values(path='test_data', experiment='test_experiment', cycle='test_cycle')[source]

collect Parameters and save to handed over structure

Parameters
  • path (str, optional) – mainfolder to save acquire measurment data, defaults to “test_data”

  • experiment (str, optional) – subfolder to save acquire measurment data, defaults to “test_experiment”

  • cycle (str, optional) – subsubfolder to save acquire measurment data, defaults to “test_cycle”

win_sequenz.string2array(value)[source]

covert a long string format into a list

Parameters

value (str) – a string that can be split by “,”

Returns

the array of flaoting numbers from a sring

Return type

[float,float,….]

win_sequenz.windows_file(path='test_data', experiment='test_experiment', cycle='test_cycle')[source]

Window of setting the set Puls sequence from a funktion. Basic setupfor minimal settings. Update from thins Funktion is the class Window_seq

Parameters
  • path (str, optional) – ain folder, defaults to “test_data”

  • experiment (str, optional) – subfolder, defaults to “test_experiment”

  • cycle (str, optional) – subsubfolder for saving the experiment Data, defaults to “test_cycle”

Returns

none

Return type

none

Variables handling

class variables.File_Settings(value_set)[source]

main file handeler

static generate_folder(self, sample='pre_sample', experiment='pre_experiment', data='pre_data')[source]

generate filestructure if not existing

Parameters
  • sample (str, optional) – main folder name, defaults to “pre_sample”

  • experiment (str, optional) – usb folder name, defaults to “pre_experiment”

  • data (str, optional) – subsub folder name, defaults to “pre_data”

Returns

storage path

Return type

os.path

static load_folder(self)[source]

get folder struktures form user input

static save_close(self)[source]

sequenc of when closing the window

property save_experiment

Window for Set Experiment Structure

Returns

logging to the commandwindow that the window is closed

Return type

print()

static update_set_Parameters(self)[source]

repedative update Parameters at a timed intervall

class variables.Pulse_Settings[source]

arbituary pulse generator !!!! more implementations is needet

static parameter2Vektor(start, stop, shape='squaer', number=100)[source]

arbituary puls shape generator

Parameters
  • start (int) – position of start pulse shape

  • stop (int) – stop position of pulse shape

  • shape (str, optional) – name of pulsshape, defaults to “squaer”

  • number (int, optional) – sampelpoints resolution, defaults to 100

Run external hardware

run_external.broad_seq_fid(value_main, value_sequenz)[source]

multi frequency Free Induction Decay (FID) sequence measurment

Parameters
  • value_main (dict) – all parameterst from the main window

  • value_sequenz (dict) – all parameters dependent on the sequence

Raises

Exception – Exception: if not possible to send to the hardware

Returns

steps time domain, amplitude time domain,steps frequency domain, amplitude frequency domain

Return type

[list, list, list, list]

Example

>>> [x_time, y_time, x_freq, y_freq] = broad_seq_fid(value_main, value_sequenz)
run_external.send_sdr(value_main, value_sequenz)[source]

Execution of the sequence from the main window. It will hand over the parameters to the sequence what will send all parameterst to the sdr and will control the execution of the sequence. It handels the returened data from the sequence and will save it to set filestrukture

Parameters
  • value_main (dict) – all parameterst structured from the main window

  • value_sequenz (dict) – all parameters structured dependent on the sequence

Example

>>> run_external.send_sdr(self.get_values(), self.value_sequenz)     
value_main =
 {'freq': {'freq_start': '80', 'freq_end': '100', 'freq_step': '100', 'freq_repetitions': '10'},
 'tunematch': {'tune': '3.3', 'match': '5', 'step': '10', 'lut': '10'},
 'load': {'sample': '_test_Sample', 'experiment': '_test_Experiment', 'data': '_test_Data'}
 'sequenz': {'sequenz': 'fid'}} # fid, spin, comp, spin_phase,own
sequenz_select = {'start': {'datum created:': '2022-01-19 23:26:53.497312', 'user created:': 'User: laborPC', 'experiment:': "['Experiment initialise']", 'experiment parameter:': '[1.2]'},
 'setting': {'sequenz_type': 'fid', 'target_freq': '83.62', 'band_freq': '1.2', 'lo_freq': '82420000.0'},
 'SDR setting': {'correction_tx_i_dc': '-45', 'correction_tx_q_dc': '0', 'correction_tx_i_gain': '2047', 'correction_tx_q_gain': '2039', 'correction_tx_pahse': '3',    'correction_rx_i_dc': '0', 'correction_rx_q_dc': '0', 'correction_rx_i_gain': '2047', 'correction_rx_q_gain': '2047', 'correction_rx_phase': '0', 'low_pass_rx': '3000000.0', 'low_pass_tx': '130000000.0', 'gain_rx': '55.0', 'gain_tx': '40.0'},
 'Puls': {'puls_freq': '[1.2]', 'puls_duration': '[3e-06]', 'puls_amplitude': '[1]', 'puls_arangement': '[300]', 'puls_count': '1'},
 'Phase': {'phase_number': '[4, 1]', 'phase_level': '[0, 1]', 'phase_puls': '[0, 0.7853981633974483]', 'number_phase_level': '1'},
 'Readout': {'repetition_time': '5', 'acquisition_time': '82', 'gate_signal': '[1, 0, 50, 10]'}}
run_external.send_tune_match(tune, match, tm_step, tm_lut)[source]

provisions for development of a new tuning and matching system

Parameters
  • tune (float) – max voltage range of tunig capacitor

  • match (float) – max voltage range of matching capacitor

  • tm_step (int) – step size of measured data

  • tm_lut (int) – resolution of saved measured data

run_external.seq_comp(value_main, value_sequenz)[source]

composite pulse sequence with pulses that change their phase in time

Parameters
  • value_main (dict) – all parameterst from the main window

  • value_sequenz (dict) – all parameters dependent on the sequence

Raises

Exception – Exception: if not possible to send to the hardware

Returns

steps time domain, amplitude time domain,steps frequency domain, amplitude frequency domain

Return type

[list, list, list, list]

Example

>>> [x_time, y_time, x_freq, y_freq] = seq_comp (value_main, value_sequenz)
run_external.seq_fid(value_main, value_sequenz)[source]

singel frequency Free Induction Decay (FID) sequence measurment

Parameters
  • value_main (dict) – all parameterst from the main window

  • value_sequenz (dict) – all parameters dependent on the sequence

Raises

Exception – Exception: if not possible to send to the hardware

Returns

steps time domain, amplitude time domain,steps frequency domain, amplitude frequency domain

Return type

[list, list, list, list]

Example

>>> [x_time, y_time, x_freq, y_freq] = seq_fid(value_main, value_sequenz)
run_external.seq_own(value_main, value_sequenz)[source]

own sequence can be used to desine a arbitrary sequence used with up to 10 pulses und all its dependet phases

Parameters
  • value_main (dict) – all parameterst from the main window

  • value_sequenz (dict) – all parameters dependent on the sequence

Raises

Exception – Exception: if not possible to send to the hardware

Returns

steps time domain, amplitude time domain,steps frequency domain, amplitude frequency domain

Return type

[list, list, list, list]

Example

>>> [x_time, y_time, x_freq, y_freq] = seq_own(value_main, value_sequenz)
run_external.seq_spin(value_main, value_sequenz)[source]

Spin-Echo sequence

Parameters
  • value_main (dict) – all parameterst from the main window

  • value_sequenz (dict) – all parameters dependent on the sequence

Raises

Exception – Exception: if not possible to send to the hardware

Returns

steps time domain, amplitude time domain,steps frequency domain, amplitude frequency domain

Return type

[list, list, list, list]

Example

>>> [x_time, y_time, x_freq, y_freq] = seq_spin(value_main, value_sequenz)
run_external.seq_spin_phase(value_main, value_sequenz)[source]

spin-echo with phase-cycling sequence

Parameters
  • value_main (dict) – all parameterst from the main window

  • value_sequenz (dict) – all parameters dependent on the sequence

Raises

Exception – Exception: if not possible to send to the hardware

Returns

steps time domain, amplitude time domain,steps frequency domain, amplitude frequency domain

Return type

[list, list, list, list]

Example

>>> [x_time, y_time, x_freq, y_freq] = seq_spin_phase(value_main, value_sequenz)
run_external.string2array(value)[source]

Format string to a array which is seperated by a “,”

Parameters

value (str) – a long string to be split

Returns

array of split of handed over sring

Return type

array

Example

>>> [1.2 ,1.3 ,1.4 ,1.5 ,1.6 ,1.7  ] = string2array("[1.2,1.3,1.4,1.5,1.6,1.7]")

Data ploting

data2plot.plot(filename)[source]
Generates a figer from a file which has a predefined format.

The use is, to call saved files and generates plots for reevaluation in the GUI window

Parameters

filename (str) – *.h5 file path with data to plot data

Returns

figure of a type matplotlib which can be ploted

Return type

figure

Helper funktions

function.error_type_window(input_var, type_should=<class 'str'>, variable_name='', message_example='none')[source]

rais a window for presenting an error message to the user with additional option

Parameters
  • input_var (str) – what parameter we are talking about

  • type_should (type , optional) – expected type for the varialbe, defaults to str

  • variable_name (str, optional) – additonal description of the variable , defaults to “”

  • message_example (str, optional) – a message for a example for solving type colission , defaults to “none”

function.error_window(text='TEST')[source]

rais a window for presenting an info or error message to the user

Parameters

text (str, optional) – Error message , defaults to “TEST”

function.load_setting(path='/home/pi/Bach_arbeit/program', file='setting_last_run.cfg')[source]

load the settings file with all its variables for the experiment into a dictonary

Parameters
  • path (str, optional) – abolute path of the file with the settings *.cfg, defaults to “/home/pi/Bach_arbeit/program”

  • file (str, optional) – file with the saved settings, defaults to “setting_last_run.cfg”

Returns

Values from loaded fils settings

Return type

dict

Indices and tables