Documents & Examples

In Getting started the general idea behind the structure of the code is provided. In this section three examples are provided, for three different scenarios.
  1. Example 1: can be applied when it is not required to interface the PI instrument with the Zurich lock-in, i.e, only a single line scan is needed. In this case the only two necessary modules are InputValidator and Scanner.

  2. Example 2: can be applied when it is not required to execute the line scan (data were previously acquired), i.e, only post processing of the data is needed. In this case the three necessary modules are InputValidator, InputProcessor and Outputprocessor.

  3. Example 3: can be applied in the most general scenario, i.e, the data need both to be acquired with the Zurich lock-in (and thus a scan must be executed) and post processed. In this case all the modules must be used.

Example 1: Scan execution

Let’s suppose that we only need to perform a line scan, without the need for setting up the DAQ of the Zurich lock-in and processing output data. In case, the role of the user is to:
  1. Compile the input_dicts with the appropriate scan parameters

  2. Create a script file in the package folder (“pizurscan/pizurscan”) with the Code 1.

 1 from Scanner import Scanner
 2 from InputValidator import input_validator
 3
 4 # extract and validate input data
 5 inpars = input_validator()
 6 scan_pars = inpars["scan_pars"]
 7 # instantiate the Scanner object
 8 with Scanner(inpars) as scanner:
 9     try:
10         if scan_pars["type"] == "continuous":
11             scanner.execute_continuous_scan()
12         else:
13             scanner.execute_discrete_scan()
14     except KeyboardInterrupt:
15         scanner.stepper.close_connection()
16         print("Scan execution interrupted: closing program ...")

Example 2: Data processing

Let’s suppose that we only need to process data acquired by the DAQ of the Zurich lock-in and processing output data. In case, the role of the user is to:

#. Compile the input_dicts with the appropriate scan parameters. Indeed, even though the scan will not be executed, the scan parameters are still necessary for the InputProcessor class. #. Create a script file in the package folder (“pziruscan/pziruscan”) with the Code 2.

 1 from InputValidator import input_validator
 2 from InputProcessor import evaluate_daq_pars
 3 from OutputProcessor import save_processed_data
 4
 5 # extract and validate input data
 6 inpars = input_validator()
 7
 8 # process scan_pars to find the daq_pars
 9 daq_pars = evaluate_daq_pars(inpars["scan_pars"])
10
11 # process data that are outputted by Zurich-lock in and saved into the output folder
12 save_processed_data(filename = "dev4910_demods_0_sample_r_avg_00000.csv",
13                     scan_pars = inpars["scan_pars"],
14                     daq_pars = daq_pars)

Example 3: Scan execution and data processing

  1. Compile the input_dicts with the appropriate input parameters

  2. Create a script file in the package folder (“pizurscan/pizurscan”) with the Code 3.

 1 from InputValidator import input_validator
 2 from Scanner import Scanner
 3 from InputProcessor import evaluate_daq_pars
 4 from OutputProcessor import save_processed_data
 5 import json
 6 import sys
 7 import keyboard
 8 from colorama import Fore, Back, Style, init
 9
10 def press_any_key_to_continue():
11     """
12     Pauses the program execution until the user presses any key.
13     If the ESC key is pressed, the program terminates.
14     """
15     print(Back.RED +"Program is pausing: when you're done working on the Zurich lock-in, press any key to continue, or ESC to exit.")
16     print("Waiting for user input...")
17     while True:
18         pressed_key = keyboard.read_event()
19         try:
20             if pressed_key.name == 'esc':
21                 print("\nYou pressed ESC, so exiting...")
22                 print(Style.RESET_ALL)
23                 sys.exit(0)
24             else:
25                 print("Continuing program...")
26                 print(Style.RESET_ALL)
27                 break
28         except:
29             break
30
31 init()
32 # extract and validate input data
33 inpars = input_validator()
34 scan_pars = inpars["scan_pars"]
35 # process scan_pars to find the daq_pars
36 daq_pars = evaluate_daq_pars(scan_pars)
37 print(Fore.GREEN +  "Here're the parameters that you should insert into the DAQ panel of the Zurich:")
38 for k, v in daq_pars.items():
39     print(Back.WHITE + Fore.BLUE+k+": ", v)
40 print(Style.RESET_ALL)
41
42 press_any_key_to_continue()
43
44 # instantiate the Scanner object
45 with Scanner(inpars) as scanner:
46     try:
47         if scan_pars["type"] == "continuous":
48             scanner.execute_continuous_scan()
49         else:
50             scanner.execute_discrete_scan()
51     except KeyboardInterrupt:
52         scanner.stepper.close_connection()
53         print("Scan execution interrupted: closing program ...")
54
55 press_any_key_to_continue()
56
57 # process data that are outputted by Zurich-lock in and saved into the output folder
58 save_processed_data(filename = "dev4910_demods_0_sample_r_avg_00000.csv",
59                         scan_pars = scan_pars,
60                         daq_pars = daq_pars)
61
62 print("Scan data are saved to 'output/cleaned_1D_data.txt'. Closing the program ...")