CDL - EVAL

From Cumulus Wiki
Revision as of 16:33, 21 February 2023 by HansR (talk | contribs) (→‎Functions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Introduction

The Equations are kind of in continuous BETA, by the nature of all possible combinations and the recursive parsing not all possible equations have been tested (haha)

The EVAL functions gives the possibility to modify a measurement and plot the result as a separate line. So theoretically one could plot the Dewpoint as a calculated derivative of the Temperature. Also the Growth Degree Days can be simply calculated. The effect of EVAL is that it is not required to transfer data if it can be derived from measurement. Only the measurement needs to be transferred.

To be able to accomplish the calculations, one needs certain additional functions such as SUM, LN and EXP. The functions which are available to the user are described below. The list will grow as the functions become available.

Equation

Each equation is formulated between square brackets and is meant to modify a weather variable. Available to the user are functions, the weather variables and the mathematical operators +, -, * and /. EVAL Equations are more or less formally described as:

 EVAL '[' Equation ']'
 Equation := Term [ '+'|'-'|'*'|'/'  Term ]
 Term := '(' Equation ')' | Function '(' Equation ')' | Plotvariable | Number
 Function := 'SUM' | 'LN' | 'EXP'
 Number := <Integer>[.[<Integer>]]

NOTE: The plotvariable MUST be from the range as defined for the PLOT i.e. ALL | DAILY | RECENT.

Functions

SUM

The SUM function produces the sum of the Plotvariable from the first of january to the 31 of december after which it resets to zero. So it is a cyclic function! When applied to the temperature this leads to the Growing Degree Days, when applied to rain it leads to the yearly rainfall until the current day. For other variables it may have meaning or it may have not.

At the moment there can be only one sum function per chart.

The following example shows the daily average temperature modified to the Growing Degree Days with an offset of 5 °C:

 CHART GrowingDgreeDays TITLE TempSum with offset 5
   PLOT ALL AverageTemp colour CornflowerBlue as column
   PLOT ALL AverageTemp EVAL [ SUM(AverageTemp-5) ] colour green Axis DegreeDays
 EndChart

LN

The LN function provides the Natural Logarithm (the logarithm on the basis of the Euler number e). It is implemented as the JavaScript function Math.log.

EXP

The EXP function provides the power function for the base of the Euler number e. It is implemented as the JavaScript Math.exp.