Calc: Difference between revisions
Jump to navigation
Jump to search
(description added) |
(added further information) |
||
Line 1: | Line 1: | ||
Calc is a simple calculator that helps you to do simple math based on the latest measurement values. | Calc is a simple calculator that helps you to do simple math based on the latest measurement values. | ||
[[File:Calc.PNG| | [[File:Calc.PNG|frame|right|Screenshot of the Calc module. Based on the current of the module SMU1, the variable 'Current density' is calculated in units of 'mA/cm^2' assuming an active area of 0.04 cm^2.]] | ||
Line 18: | Line 18: | ||
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. | 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 | * '''Always:''' Use 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 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. | * '''At the end:''' Can be used, if you like to post-process the latest measurement data. | ||
Line 24: | Line 24: | ||
== Further information == | == 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 | * 'x0' is the last return value of the Calc module. It might be of interest to do some iterative recalculation and refinement. Please choose the correct execution, e.g. "At the beginning" or "At the end". Otherwise, the result will be modified twice per measurement point. | ||
* 'x0' is always initialized as float('nan') (i.e. not a number of type float). You can test whether is x0 is such a 'nan' using isnan(x0) | |||
* Several Calc modules can be used and combined to create more complex calculations. | |||
* Calc only provides the data of the last measurement point, which can be 0-dimensional, e.g. in case of voltage, a time etc. or 1-dimensional, e.g. in case of a spectrum or a transient of an oscilloscope. | |||
* If you need to access all points, that have been measured so far, the module 'CustomFunction' is recommended that allows you to write your own python scrips and load additional libraries. | |||
== Examples == | == Examples == | ||
* Current density in mA/cm²: | * Current density in mA/cm²: '''1000 * x1 / 0.04''' where x1 is the current of an SMU module in A. | ||
* Normalize spectrum by max: ''' | * Normalize spectrum by max: '''x1/max(x1)''' where x1 is a spectrum of a Spectrometer module. | ||
* Calibrate temperatures: ''' | * 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. | ||
* | * Sum up a value: '''x1 if isnan(x0) else x0 + x1''' where x1 is the value to be summed up and x0 is the return value. Use Execution = "At the end". In the first step, y is set to x1, so that in subsequent steps x0 (which is the last y) is initialized to a start value. | ||
* Create a message: '''"Ok" if x1 < 50 else "Warning"''' where x1 is a process parameter that is checked whether it would be ok 50 or not. | |||
* Indexing: '''x1[62]''' where x1 is a variable with 1-dimensional data, e.g. a spectrum. Here, the value at index 62 is returned. Please note that indices start from 0. | |||
== Supported Functions == | == Supported Functions == |
Revision as of 14:52, 10 March 2019
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 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 choose the correct execution, e.g. "At the beginning" or "At the end". Otherwise, the result will be modified twice per measurement point.
- 'x0' is always initialized as float('nan') (i.e. not a number of type float). You can test whether is x0 is such a 'nan' using isnan(x0)
- Several Calc modules can be used and combined to create more complex calculations.
- Calc only provides the data of the last measurement point, which can be 0-dimensional, e.g. in case of voltage, a time etc. or 1-dimensional, e.g. in case of a spectrum or a transient of an oscilloscope.
- If you need to access all points, that have been measured so far, the module 'CustomFunction' is recommended that allows you to write your own python scrips and load additional libraries.
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.
- Sum up a value: x1 if isnan(x0) else x0 + x1 where x1 is the value to be summed up and x0 is the return value. Use Execution = "At the end". In the first step, y is set to x1, so that in subsequent steps x0 (which is the last y) is initialized to a start value.
- Create a message: "Ok" if x1 < 50 else "Warning" where x1 is a process parameter that is checked whether it would be ok 50 or not.
- Indexing: x1[62] where x1 is a variable with 1-dimensional data, e.g. a spectrum. Here, the value at index 62 is returned. Please note that indices start from 0.
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