Call()

From SweepMe! Wiki
Jump to navigation Jump to search

call() must be used to return any measured or other value to SweepMe!. It must return a tuple or a list with one value for each variable defined in self.variables (and self.units) of the driver. If only one variable is defined, the value can also be returned directly without a list. In order to improve the speed of measurements, the concept of unblocking parallelization can be used.

Driver programming

The use of call can be omitted in a driver if no variables and units have been defined in a driver. In this case, call() can also return None.

If the number of returned values does not match the number of variables, the run is stopped with the error message "Mismatch between variables and values".

If your only variable holds a list of values, return it inside a list, e.g. return [values]. Otherwise, each element of the list is interpreted as the value of a separate variable.

Data types

To make sure that your returned data can be handled, please make sure that it is converted into python data types such as 'str', 'int', 'float', 'list' or a numpy array.

  • Plotting: data must be of type 'int', 'float', list of floats, numpy array
  • Saving data: Data that is 0-dimensional (0D), e.g. int, str, float is saved to the main data file. Data from lists, or arrays is saved to a file which contains 1-dimensional (1D) data. For each iteration of the sequencer, a new file for 1D data is created.