Пример #1
0
int get_local_windchill( double temperature, double humidity, double windpower )
{
    double tmptemp = temperature;
    double tmpwind = windpower;
    double windchill = 0;

    if( tmptemp < 50 ) {
        /// Model 1, cold wind chill (only valid for temps below 50F)
        /// Is also used as a standard in North America.

        // Temperature is removed at the end, because get_local_windchill is meant to calculate the difference.
        // Source : http://en.wikipedia.org/wiki/Wind_chill#North_American_and_United_Kingdom_wind_chill_index
        windchill = 35.74 + 0.6215 * tmptemp - 35.75 * ( pow( tmpwind,
                    0.16 ) ) + 0.4275 * tmptemp * ( pow( tmpwind, 0.16 ) ) - tmptemp;
        if( tmpwind < 4 ) {
            windchill = 0;    // This model fails when there is 0 wind.
        }
    } else {
        /// Model 2, warm wind chill

        // Source : http://en.wikipedia.org/wiki/Wind_chill#Australian_Apparent_Temperature
        tmpwind = tmpwind * 0.44704; // Convert to meters per second.
        tmptemp = temp_to_celsius( tmptemp );

        windchill = ( 0.33 * ( ( humidity / 100.00 ) * 6.105 * exp( ( 17.27 * tmptemp ) /
                               ( 237.70 + tmptemp ) ) ) - 0.70 * tmpwind - 4.00 );
        // Convert to Fahrenheit, but omit the '+ 32' because we are only dealing with a piece of the felt air temperature equation.
        windchill = windchill * 9 / 5;
    }

    return windchill;
}
Пример #2
0
/**
 * Print temperature (and convert to celsius if celsius display is enabled.)
 */
std::string print_temperature( double fahrenheit, int decimals )
{
    std::ostringstream ret;
    ret.precision( decimals );
    ret << std::fixed;

    if(get_option<std::string>( "USE_CELSIUS" ) == "celsius") {
        ret << temp_to_celsius( fahrenheit );
        return string_format( pgettext( "temperatur in Celsius", "%sC" ), ret.str().c_str() );
    } else {
        ret << fahrenheit;
        return string_format( pgettext( "temperatur in Fahrenheit", "%sF" ), ret.str().c_str() );
    }
}
Пример #3
0
/**
 * Print temperature (and convert to celsius if celsius display is enabled.)
 */
std::string print_temperature( double fahrenheit, int decimals )
{
    std::ostringstream ret;
    ret.precision( decimals );
    ret << std::fixed;

    if(OPTIONS["USE_CELSIUS"] == "celsius") {
        ret << temp_to_celsius( fahrenheit );
        return rmp_format( _( "<Celsius>%sC" ), ret.str().c_str() );
    } else {
        ret << fahrenheit;
        return rmp_format( _( "<Fahrenheit>%sF" ), ret.str().c_str() );
    }

}
Пример #4
0
double temp_to_kelvin( double fahrenheit )
{
    return temp_to_celsius( fahrenheit ) + 273.15;
}