Calc
Jump to navigation
Jump to search
Calc is a simple calculator that helps you to do simple math based on the latest measurement values.
Usage
The typical way to use Calc involved the following steps:
- Create a Calc module in the sequencer and change to the corresponding tab
- Change the label of the module if desired
- Enter a name of the calculated variable and its unit
- Define whether the variable can be plotted and whether it should be saved
- In section 'Values' create as many fields you need using 'Add value field'
- Select the SweepMe! internal variables and relate them to 'x1', 'x2', and so on.
- Type in your formula in section 'Formula' using 'x1', 'x2', etc. as placeholders for
Execution
Calc can calculate the actual value at different positions during the measurement procedure, e.g. before a new measurement point is set and measured or after all variables of a meaurement point have been taken.
- Always: Use it this default value if you do not matter and just want to have actual values all the time.
- At the beginning: Needed if you like to modify a SweepValue of a certain module that has to be handed over to another Module as a SweepValue before the next measurement point is run through.
- At the end: Can be used, if you like to post-process the latest measurement data.
Further information
- 'x0' is the last return value of the Calc module. It might be of interest to do some iterative recalculation and refinement. Please coose the correct execution. Otherwise, the result will be modified twice per measurement point.
Examples
- Current density in mA/cm²: '1000 * x1 / 0.04' where x1 is the current of an SMU module in A
- Normalize spectrum by max: "x1/max(x1)" where x1 is a spectrum of a Spectrometer module
- Calibrate temperatures: "a * x1 + b" where x1 is a measured temperature of the Temperature module and a,b are the coefficients of a linear calibration function
Supported Functions
There is a limited number of functions that can be used inside the Calc module. The following list gives the string that can be used and the corresponding function that will be loaded. If there are further functions needed, please let us know (support@sweep-me.net)
python built-in functions
- 'abs' = abs
- 'len' = len
- 'max' = max
- 'min' = min
- 'int' = int
- 'float' = float
- 'round' = round
- 'str' = str
math functions
- 'ceil' = math.ceil
- 'degrees' = math.degrees
- 'fabs' = math.fabs
- 'floor' = math.floor
- 'fmod' = math.fmod
- 'frexp' = math.frexp
- 'hypot' = math.hypot
- 'ldexp' = math.ldexp
- 'modf' = math.modf
- 'pi' = math.pi
- 'pow' = math.pow
- 'radians' = math.radians
random functions
- 'random' = random.random
- 'random' = random.randint
numpy functions
- 'sqrt' = np.sqrt
- 'sin' = np.sin
- 'sinh' = np.sinh
- 'asin' = np.arcsin
- 'arcsin' = np.arcsin
- 'cos' = np.cos
- 'cosh' = np.cosh
- 'acos' = np.arccos
- 'arccos' = np.arccos
- 'tan' = np.tan
- 'tanh' = np.tanh
- 'arctan' = np.arctan
- 'atan' = np.arctan
- 'arctan2' = np.arctan2
- 'atan2' = np.arctan2
- 'exp' = np.exp
- 'ln' = np.log
- 'log' = np.log
- 'log10' = np.log10
- 'average' = np.average
- 'mean' = np.mean
- 'arange' = np.arange
- 'linspace' = np.linspace
- 'logspace' = np.logspace
- 'divide' = np.divide
- 'sum' = np.sum
- 'trapz' = np.trapz
- 'sign' = np.sign
- 'isnan' = np.isnan