CustomFunction

From SweepMe! Wiki
Jump to navigation Jump to search

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 tis function are handed over.

Adding a new function

  1. Add a CustomFunction module to the sequencer
  2. Go to the tab of the CustomFunction module
  3. Press "Add fucntion" and enter the name of the new function, it will be a copy of the example function.
  4. You can modify your new function using 'Open/Modify'
  5. 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 -> () data is always handed over as list or 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
  • Path: pathlib.Path() -> an empty or non-empty pathlib.Path object. The user will see a QFileDialog to choose a file.

Procedure

Whenever CustomFunction is part of an interation 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 a list of the latest values since the last call of CustomFunction. For example to get a single number from this list, 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 changing to the correct type.

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, ...