CDL - EVAL: Difference between revisions

m
 
(9 intermediate revisions by the same user not shown)
== Introduction ==
{|align=right
'''The Equations are in BETA, by the nature of all possible combinations and the recursive parsing not all possible equations have been tested (haha)'''
|__TOC__
|}
'''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.
PLOT ALL AverageTemp EVAL [ SUM(AverageTemp-5) ] colour green Axis DegreeDays
EndChart
 
 
[[Category:CumulusUtils]]
 
=== LN ===
=== EXP ===
The EXP function provides the power function for the base of the Euler number e.
It is implemented as the JavaScript function ''Math.exp''.
 
== Trouble in Paradise ==
Equations may seem like functions, and there is a resemblance, but they are not. If you are using an equation in another you must be aware that the plotparameters in the first equation remain the same during substitution. I will explain this through an example of the ''Wet Bulb Temperature calculation'' (WBT).
 
The WBT is calculated in CMX as:
<pre>
public static double CalculateWetBulbC(double tempC, double dewPointC, double pressureMb)
{
double svpDP = SaturationVapourPressure1980(dewPointC);
return (((0.00066 * pressureMb) * tempC) + ((4098 * svpDP) / (Sqr(dewPointC + 237.7)) * dewPointC)) / ((0.00066 * pressureMb) + (4098 * svpDP) / (Sqr(dewPointC + 237.7)));
}
 
(Sqr(a) being a*a)
</pre>
To put this in CDL the first attempt was:
<pre>
Psat1980 EVAL [ 6.112 * EXP(17.67*Temperature/(243.5+Temperature)) ]
WetBulbTemp Eval [ (0.00066 * Pressure * Temperature + 4098 * Psat1980 / Pow( (Dewpoint + 237.7), 2) * Dewpoint) /
(0.00066 * Pressure + 4098 * Psat1980 / Pow((Dewpoint + 237.7),2)) ]
</pre>
''Psat1980'' will be substituted into the ''WetBulbTemp'' equation when needed so it will calculate with Temperature but it required to be the ''Dewpoint'' calculation as you can see from ''CMX svpDP'' function. To account for this issue a Psat1980 equation specifically for the dewPoint needs to be created. So, to calculate the WetBulbTemp correctly, we have to do:
 
<pre>
; Specifically for the Wet Bulb Calculation: Psat at Dewpoint
dewpointPsat1980 EVAL [ 6.112 * EXP(17.67*Dewpoint/(243.5+Dewpoint)) ]
WetBulbTemp Eval [ (0.00066 * Pressure * Temperature + 4098 * dewpointPsat1980 / Pow( (Dewpoint + 237.7), 2) * Dewpoint) /
(0.00066 * Pressure + 4098 * dewpointPsat1980 / Pow((Dewpoint + 237.7),2)) ]
</pre>
 
The CUtils compiler then takes the rest and creates the correct javascript function required for Highcharts.
 
This took 5 years before the problem was discovered and when it finally showed it took some considerable time before it was understood. See [https://cumulus.hosiene.co.uk/viewtopic.php?t=24257 this topic on the forum].
 
[[Category:CumulusUtils]]