Temperature (and humidity) measurement: Difference between revisions

m
Line 82: Line 82:


==Cumulus Calculated Parameters==
==Cumulus Calculated Parameters==
See external Wiki or other sections of this Wiki for specific information on the values that Cumulus calculates:
See external Wiki or other sections of this Wiki for specific information on the values that Cumulus calculates:


Line 89: Line 90:


*The dew point calculation for Cumulus 1 uses a third party library which uses the Davis dew point calculation '''dewpoint := tempinC + ((0.13 * tempinC) + 13.6) * Ln(humidity / 100)'''  
*The dew point calculation for Cumulus 1 uses a third party library which uses the Davis dew point calculation '''dewpoint := tempinC + ((0.13 * tempinC) + 13.6) * Ln(humidity / 100)'''  
* The dew point calculation for MX follows the standard [https://en.wikipedia.org/wiki/Dew_point calculation in wikipedia].
* The dew point calculation for MX follows the standard [https://en.wikipedia.org/wiki/Dew_point calculation in wikipedia]  
<pre>public static double DewPoint(double tempC, double humidity)
        {
            //return tempC + ((0.13*tempC) + 13.6)*Math.Log(humidity/100.0);
            // Davis algorithm
            double lnVapor = Math.Log(ActualVapourPressure(tempC, (int) humidity));
            return ((243.12 * lnVapor) - 440.1) / (19.43 - lnVapor);
        }</pre>


Note this means that Cumulus 1 and MX log files have a continuity break when you migrate from one flavour to another.
Note this means that Cumulus 1 and MX log files have a continuity break when you migrate from one flavour to another.
<pre>
/* =================================================================================================
DEW POINT TEMPERATURE
The dew point calculation in Cumulus 1 uses a third party library which uses the Davis dew point calculation '''dewpoint := tempinC + ((0.13 * tempinC) + 13.6) * Ln(humidity / 100)'''
============================================================================== */
function calcDewPoint(tempDegC, tempLetter, RHumidity)
{
var dp = tempDegC + ((0.13 * tempDegC) +13.6) * Math.log(RHumidity / 100);
return  calcTempR(dp, tempLetter);  // return as string in right units for user
}
/* =================================================================================================
DEW POINT TEMPERATURE
The following is a formula from  https://github.com/nicolasgrancher/weather-js/blob/master/js/weather.js
This matches the formula that MX uses.
It has only been edited to add the middle input parameter and to output using a call to CalcTempR
============================================================================== */
/**
* Dew point calculation.
* @see https://en.wikipedia.org/wiki/Dew_point
*
* @param Tc temperature in celsius
* @param R relative humidity
* @returns {number}
*/
function dewPoint(Tc, tempLetter,  R)
{  // parameters: tempDegC, tempLetter, (RHumidity /100)  // added middle parameter, should be accessible anyway, but playing safe
    if (Tc < 0 || Tc > 60)
{
        return  calcTempR(Tc, tempLetter);  // return as string in right units for user
    }
    if (R < 0.01 || R > 1) {
        return  calcTempR(Tc, tempLetter);  // return as string in right units for user
    }
    var a = 17.27;
    var b = 237.7;
    var alphaTR = ((a * Tc) / (b + Tc)) + Math.log(R);
    var Tr = (b * alphaTR) / (a - alphaTR);
    if (Tr < 0 || Tr > 50) {
        return  calcTempR(Tc, tempLetter);  // return as string in right units for user
    }
        return  calcTempR(Tr, tempLetter);  // return as string in right units for user
}
</pre>




5,838

edits