How to Limit Input Data
Data can be limited between a minimum and a maximum value in order to restrict volatile fluctuations in input values. This can be achieved by creating a calculated input V2. Sensors at times can return untrue values which can muck up true effective data. The calculated input V2 will ensure that volatile, false data will be eradicated from the data set. The calculated input V2 works to limit negative values or high spikes in data. The script that is outlined below is only an example, however, it can be copied and used for any inputs as long as the appropriate changes are made to the script.
An Example arose with an ATMOS41 weather station where there was unusually high amounts of rainfall recorded which was nonsense. In this situation with the ATMOS41 weather station rainfall data needed to be limited between 0 and 90 millimetres.
When applying this script to the relevant input, be careful with the limits that are set for the minimum and maximum values. While this filter will exclude invalid data that are outside the specific range, it will also remove valid values if these fall outside the specified range.
Calculated Input V2 script:
'Also enable advanced settings if needed, e.g. sum over one day to get output as the sum of
'the input samples during one day with the sum limited to the min & max values given.
Dim InputData As Input = Inputs.Precipitation #0 mm
Dim CutoffMax As Double = 90
Dim CutoffMin As Double = 0
Dim ResetValue As Double = 0
'Scale inputs as needed
Dim InputDataScaled As Double = InputData.Value * 1
InputDataScaled = if(InputDataScaled > CutoffMax, ResetValue, InputDataScaled)
InputDataScaled = if(InputDataScaled < CutoffMin, ResetValue, InputDataScaled)
Return InputDataScaled