CustomFunction: Difference between revisions
Line 36: | Line 36: | ||
=== Procedure === | === Procedure === | ||
Whenever CustomFunction is part of an | Whenever CustomFunction is part of an iteration in a [[branch]] of the sequencer, the defined function 'main' is called with the given parameters and the defined variables must be returned. SweepMe! measurement values that are requested by using '''a tuple () as argument are automatically handed over as an array''' of the values that have been acquired since the last call CustomFunction. For example to get a single number from this array, one can take the item at the first index, e.g 'val[0]' assuming that 'val' is the list that has been handed over. Please also take about care changing to the correct type beforehand. | ||
=== Applications === | === Applications === |
Revision as of 21:41, 11 February 2020
The CustomFunction module is designed to allow users to load their own python functions and hand over measurement values. The main purpose is to hand over measurement data from multiple modules to a function which takes care about calculating further parameters and about data processing. It can be used for many different purposes and is one basic opportunity to run individual python code.
The position of the CustomFunction module in the Sequencer is essential. It determines the amount of data that is handed over to the CustomFunction function.
A simplified rule is: Whenever a function of the CustomFunction module is called, all values generated since the last call of this function are handed over.
Adding a new function
- Add a CustomFunction module to the sequencer
- Go to the tab of the CustomFunction module
- Press "Add fucntion" and enter the name of the new function, it will be a copy of the example function.
- You can modify your new function using 'Open/Modify'
- Your new function can be found in the public folder '.\DataModules\CustomFunction\Functions'. This folder can be found as wll by using the button "Open folder".
Editing a Function
Inside the python file you have a class 'Main' with a function 'main'. The arguments of the function 'main' automatically define the user interface that is shown to the user inside the CustomFunction module. When modifying a function, the following points are important:
- self.variables: set a list of strings defining the names of your output variables
- self.units: set a list of strings defining the names of the units corresponding to self.variables
- self.variables and self.units have to have the same length as the number of return values of your main-function
- Arguments/Input parameters: Define the names and the types of the input parameters according to the Function 'Example'. Basically, the arguments of the function 'main' automatically define the user interface fields that are shown in the CustomFunction module.
- change the return values according to the definition of self.variables and self.units.
Arguments/Input parameters
- Data from SweepMe!: tuple -> () Please note: data is always handed over as numpy array, so please make sure you process the data correctly before you return it.
- Integer: int -> any integer number which will be the preset value
- Float: float -> any float value which will be the preset value
- String: str -> any string which will be the preset value
- List: list -> any list of strings which will be presented in ComboBox for selection by the user
- Bool: bool -> set to True or False; the user can later select using a CheckBox
- Directory: pathlib.Path(<directory>) -> an empty pathlib.Path object or a non-empty pathlib.Path object with a given directory <directory>. The user will see a QFileDialog to choose a folder.
- File: pathlib.Path(<file>) -> a non-empty pathlib.Path object with a given file <file>. The user will see a QFileDialog to choose a file.
Procedure
Whenever CustomFunction is part of an iteration in a branch of the sequencer, the defined function 'main' is called with the given parameters and the defined variables must be returned. SweepMe! measurement values that are requested by using a tuple () as argument are automatically handed over as an array of the values that have been acquired since the last call CustomFunction. For example to get a single number from this array, one can take the item at the first index, e.g 'val[0]' assuming that 'val' is the list that has been handed over. Please also take about care changing to the correct type beforehand.
Applications
- Data smoothing
- Repetitive curve fitting and extraction of fit parameters
- Parameter extraction
- Specializing a measurement setup to certain needs
- pre-evaluation of the data
- using SweepMe! as a frontend for simulations
Examples
- Characteriztion of field-effect transistors: Transfer characteristics are measured in the linear regime. Current and voltage measurement data is handed over to the Evaluation module where charge carrier mobility and threshold voltage is extracted.
- Characterization of LEDs: Spectra and current-voltage characteristics can be handed over to the Evaluation module to calculate several device efficiency parameters.
- Calculation of peak values, zeroing, derivation, integral, mean, standard deviation, ...