Add a climate section under the /environment properties. Add relative humidity, mean temperature and dewpoint for sea level and set the snow level based on the mean temperatures. Fix some issues for high-altitude airports (SLLP).
This commit is contained in:
parent
0982b2827a
commit
658aa4a764
2 changed files with 125 additions and 98 deletions
|
@ -59,6 +59,28 @@ FGClimate::FGClimate(const SGGeod& position)
|
||||||
_epsilon = 360.0/_image_width;
|
_epsilon = 360.0/_image_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ground_elev_node = fgGetNode("/position/ground-elev-ft", true );
|
||||||
|
|
||||||
|
_tiedProperties.setRoot( fgGetNode("/environment/climate", true) );
|
||||||
|
|
||||||
|
// environment properties
|
||||||
|
_tiedProperties.Tie( "environment-update", &_environment_adjust );
|
||||||
|
|
||||||
|
// weather properties
|
||||||
|
_tiedProperties.Tie( "weather-update", &_weather_update);
|
||||||
|
_tiedProperties.Tie( "relative-humidity", &_relative_humidity_gl);
|
||||||
|
_tiedProperties.Tie( "relative-humidity-sea-level", &_relative_humidity_sl);
|
||||||
|
_tiedProperties.Tie( "dewpoint-degc", &_dewpoint_gl);
|
||||||
|
_tiedProperties.Tie( "dewpoint-sea-level-degc", &_dewpoint_sl);
|
||||||
|
_tiedProperties.Tie( "temperature-degc", &_temperature_gl);
|
||||||
|
_tiedProperties.Tie( "temperature-sea-level-degc", &_temperature_sl);
|
||||||
|
_tiedProperties.Tie( "temperature-mean-degc", &_temperature_mean_gl);
|
||||||
|
_tiedProperties.Tie( "temperature-mean-sea-level-degc", &_temperature_mean_sl);
|
||||||
|
_tiedProperties.Tie( "precipitation-month-mm", &_precipitation);
|
||||||
|
_tiedProperties.Tie( "precipitation-annual-mm", & _precipitation_annual);
|
||||||
|
_tiedProperties.Tie( "snow-level-m", &_snow_level);
|
||||||
|
_tiedProperties.Tie( "wind-kmph", &_wind);
|
||||||
|
|
||||||
update(position);
|
update(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,16 +145,21 @@ void FGClimate::update(const SGGeod& position)
|
||||||
else if (_classicfication < 32) set_polar();
|
else if (_classicfication < 32) set_polar();
|
||||||
else set_ocean();
|
else set_ocean();
|
||||||
|
|
||||||
// Relative humidity decreases linearly with an increase in altitude at
|
double alt_km;
|
||||||
// an average of 4% per kilometer
|
alt_km = _ground_elev_node->getDoubleValue()*SG_FEET_TO_METER/1000.0;
|
||||||
double alt_km = pos.getElevationM()/1000.0;
|
|
||||||
_relative_humidity -= 0.04*alt_km;
|
// Relative humidity decreases with an average of 4% per kilometer
|
||||||
|
_relative_humidity_sl = std::min(_relative_humidity_gl + 4.0*alt_km, 100.0);
|
||||||
|
|
||||||
|
// The temperature decreases by about 9.8°C per kilometer
|
||||||
|
_temperature_sl = _temperature_gl + 9.8*alt_km;
|
||||||
|
_temperature_mean_sl = _temperature_mean_gl + 9.8*alt_km;
|
||||||
|
|
||||||
|
_snow_level = 1000.0 * _temperature_mean_sl / 9.8;
|
||||||
|
|
||||||
// Mark G. Lawrence:
|
// Mark G. Lawrence:
|
||||||
_dew_point = _temperature_gl - ((100.0 - 100.0*_relative_humidity)/5.0);
|
_dewpoint_sl = _temperature_sl - ((100.0 - _relative_humidity_sl)/5.0);
|
||||||
|
_dewpoint_gl = _temperature_gl - ((100.0 - _relative_humidity_gl)/5.0);
|
||||||
// The temperature decreases by about 5.3°C per kilometer
|
|
||||||
_temperature_sl = _temperature_gl + 5.3*alt_km;
|
|
||||||
|
|
||||||
set_environment();
|
set_environment();
|
||||||
|
|
||||||
|
@ -168,8 +195,6 @@ void FGClimate::update_season_factor()
|
||||||
|
|
||||||
void FGClimate::set_ocean()
|
void FGClimate::set_ocean()
|
||||||
{
|
{
|
||||||
_total_annual_precipitation = 990.0; // use the global value, for now.
|
|
||||||
|
|
||||||
double day = _day_noon;
|
double day = _day_noon;
|
||||||
double summer = _season_summer;
|
double summer = _season_summer;
|
||||||
|
|
||||||
|
@ -188,10 +213,10 @@ void FGClimate::set_ocean()
|
||||||
_temperature_gl = season_even(ifact_lat, temp_pole, temp_equator);
|
_temperature_gl = season_even(ifact_lat, temp_pole, temp_equator);
|
||||||
|
|
||||||
double temp_mean_equator = 0.5*(temp_equator_day + temp_equator_night);
|
double temp_mean_equator = 0.5*(temp_equator_day + temp_equator_night);
|
||||||
_temperature_mean = season_even(ifact_lat, temp_pole, temp_mean_equator);
|
_temperature_mean_gl = season_even(ifact_lat, temp_pole, temp_mean_equator);
|
||||||
|
|
||||||
// relative humidity based on latitude
|
// relative humidity based on latitude
|
||||||
_relative_humidity = triangular(fabs(fact_lat-0.5), 0.70, 0.87);
|
_relative_humidity_gl = triangular(fabs(fact_lat-0.5), 70.0, 87.0);
|
||||||
|
|
||||||
// steady winds
|
// steady winds
|
||||||
_wind = 3.0;
|
_wind = 3.0;
|
||||||
|
@ -200,8 +225,8 @@ void FGClimate::set_ocean()
|
||||||
_has_autumn = false;
|
_has_autumn = false;
|
||||||
|
|
||||||
// average precipitation
|
// average precipitation
|
||||||
_total_annual_precipitation = 990.0; // global
|
_precipitation_annual = 990.0; // global average
|
||||||
double avg_precipitation = 100.0 - (_total_annual_precipitation/25.0);
|
double avg_precipitation = 100.0 - (_precipitation_annual/25.0);
|
||||||
_precipitation = avg_precipitation;
|
_precipitation = avg_precipitation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +235,7 @@ void FGClimate::set_ocean()
|
||||||
void FGClimate::set_tropical()
|
void FGClimate::set_tropical()
|
||||||
{
|
{
|
||||||
// weather
|
// weather
|
||||||
_total_annual_precipitation = 3000.0;
|
_precipitation_annual = 3000.0;
|
||||||
|
|
||||||
double day = _day_noon;
|
double day = _day_noon;
|
||||||
|
|
||||||
|
@ -224,37 +249,37 @@ void FGClimate::set_tropical()
|
||||||
double fact_lat = std::max(abs(latitude_deg), 15.0)/15.0;
|
double fact_lat = std::max(abs(latitude_deg), 15.0)/15.0;
|
||||||
double wind = 3.0*fact_lat*fact_lat;
|
double wind = 3.0*fact_lat*fact_lat;
|
||||||
|
|
||||||
double temp_night = _temperature_gl;
|
double temp_night = _temperature_sl;
|
||||||
double temp_day = _temperature_gl;
|
double temp_day = _temperature_sl;
|
||||||
double precipitation = _precipitation;
|
double precipitation = _precipitation;
|
||||||
double relative_humidity = _relative_humidity;
|
double relative_humidity = _relative_humidity_gl;
|
||||||
switch(_classicfication)
|
switch(_classicfication)
|
||||||
{
|
{
|
||||||
case 1: // Af: equatorial, fully humid
|
case 1: // Af: equatorial, fully humid
|
||||||
temp_night = triangular(summer, 20.0, 22.5);
|
temp_night = triangular(summer, 20.0, 22.5);
|
||||||
temp_day = triangular(summer, 29.5, 32.5);
|
temp_day = triangular(summer, 29.5, 32.5);
|
||||||
precipitation = season_even(winter, 150.0, 280.0);
|
precipitation = season_even(winter, 150.0, 280.0);
|
||||||
relative_humidity = triangular(humidity_fact, 0.75, 0.85);
|
relative_humidity = triangular(humidity_fact, 75.0, 85.0);
|
||||||
break;
|
break;
|
||||||
case 2: // Am: equatorial, monsoonal
|
case 2: // Am: equatorial, monsoonal
|
||||||
temp_night = triangular(summer, 17.5, 22.5);
|
temp_night = triangular(summer, 17.5, 22.5);
|
||||||
temp_day = triangular(summer, 27.5, 32.5);
|
temp_day = triangular(summer, 27.5, 32.5);
|
||||||
precipitation = season_even(summer, 75.0, 320.0);
|
precipitation = season_even(summer, 75.0, 320.0);
|
||||||
relative_humidity = triangular(humidity_fact, 0.75, 0.85);
|
relative_humidity = triangular(humidity_fact, 75.0, 85.0);
|
||||||
wind *= 2.0*_precipitation/320.0;
|
wind *= 2.0*_precipitation/320.0;
|
||||||
break;
|
break;
|
||||||
case 3: // As: equatorial, summer dry
|
case 3: // As: equatorial, summer dry
|
||||||
temp_night = season_long_high(summer, 15.0, 22.5);
|
temp_night = season_long_high(summer, 15.0, 22.5);
|
||||||
temp_day = triangular(summer, 27.5, 35.0);
|
temp_day = triangular(summer, 27.5, 35.0);
|
||||||
precipitation = season_even(summer , 35.0, 150.0);
|
precipitation = season_even(summer , 35.0, 150.0);
|
||||||
relative_humidity = triangular(humidity_fact, 0.60, 0.80);
|
relative_humidity = triangular(humidity_fact, 60.0, 80.0);
|
||||||
wind *= 2.0*_precipitation/350.0;
|
wind *= 2.0*_precipitation/350.0;
|
||||||
break;
|
break;
|
||||||
case 4: // Aw: equatorial, winter dry
|
case 4: // Aw: equatorial, winter dry
|
||||||
temp_night = season_long_high(summer, 15.0, 22.5);
|
temp_night = season_long_high(summer, 15.0, 22.5);
|
||||||
temp_day = triangular(summer, 27.5, 35.0);
|
temp_day = triangular(summer, 27.5, 35.0);
|
||||||
precipitation = season_even(summer, 10.0, 230.0);
|
precipitation = season_even(summer, 10.0, 230.0);
|
||||||
relative_humidity = triangular(humidity_fact, 0.60, 0.80);
|
relative_humidity = triangular(humidity_fact, 60.0, 80.0);
|
||||||
wind *= 2.0*_precipitation/230.0;
|
wind *= 2.0*_precipitation/230.0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -262,9 +287,9 @@ void FGClimate::set_tropical()
|
||||||
}
|
}
|
||||||
|
|
||||||
_temperature_gl = season_even(day, temp_night, temp_day);
|
_temperature_gl = season_even(day, temp_night, temp_day);
|
||||||
_temperature_mean = 0.5*(temp_night + temp_day);
|
_temperature_mean_gl = 0.5*(temp_night + temp_day);
|
||||||
|
|
||||||
_relative_humidity = relative_humidity;
|
_relative_humidity_gl = relative_humidity;
|
||||||
_precipitation = precipitation;
|
_precipitation = precipitation;
|
||||||
_has_autumn = false;
|
_has_autumn = false;
|
||||||
_wind = wind;
|
_wind = wind;
|
||||||
|
@ -281,49 +306,49 @@ void FGClimate::set_dry()
|
||||||
|
|
||||||
double humidity_fact = season_even(winter, 0.5, 1.0-0.5*day);
|
double humidity_fact = season_even(winter, 0.5, 1.0-0.5*day);
|
||||||
|
|
||||||
_total_annual_precipitation = 100.0;
|
_precipitation_annual = 100.0;
|
||||||
if (_classicfication == 5 || _classicfication == 6) { // steppe
|
if (_classicfication == 5 || _classicfication == 6) { // steppe
|
||||||
_total_annual_precipitation *= 2.0;
|
_precipitation_annual *= 2.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double temp_night = _temperature_gl;
|
double temp_night = _temperature_sl;
|
||||||
double temp_day = _temperature_gl;
|
double temp_day = _temperature_sl;
|
||||||
double precipitation = _precipitation;
|
double precipitation = _precipitation;
|
||||||
double relative_humidity = _relative_humidity;
|
double relative_humidity = _relative_humidity_gl;
|
||||||
switch(_classicfication)
|
switch(_classicfication)
|
||||||
{
|
{
|
||||||
case 5: // BSh: arid, steppe, hot arid
|
case 5: // BSh: arid, steppe, hot arid
|
||||||
temp_night = season_long_high(summer, 10.0, 22.0);
|
temp_night = season_long_high(summer, 10.0, 22.0);
|
||||||
temp_day = triangular(summer, 27.5, 35.0);
|
temp_day = triangular(summer, 27.5, 35.0);
|
||||||
precipitation = season_long_low(summer, 8.0, 117.0);
|
precipitation = season_long_low(summer, 8.0, 117.0);
|
||||||
relative_humidity = triangular(humidity_fact, 0.20, 0.30);
|
relative_humidity = triangular(humidity_fact, 20.0, 30.0);
|
||||||
break;
|
break;
|
||||||
case 6: // BSk: arid, steppe, cold arid
|
case 6: // BSk: arid, steppe, cold arid
|
||||||
temp_night = season_even(summer, -14.0, 12.0);
|
temp_night = season_even(summer, -14.0, 12.0);
|
||||||
temp_day = season_even(summer, 0.0, 30.0);
|
temp_day = season_even(summer, 0.0, 30.0);
|
||||||
precipitation = season_even(summer, 15.0, 34.0);
|
precipitation = season_even(summer, 15.0, 34.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.48, 0.67);
|
relative_humidity = season_even(humidity_fact, 48.0, 67.0);
|
||||||
break;
|
break;
|
||||||
case 7: // BWh: arid, desert, hot arid
|
case 7: // BWh: arid, desert, hot arid
|
||||||
temp_night = season_even(summer, 7.5, 22.0);
|
temp_night = season_even(summer, 7.5, 22.0);
|
||||||
temp_day = season_even(summer, 22.5, 37.5);
|
temp_day = season_even(summer, 22.5, 37.5);
|
||||||
precipitation = monsoonal(summer, 3.0, 18.0);
|
precipitation = monsoonal(summer, 3.0, 18.0);
|
||||||
relative_humidity = monsoonal(humidity_fact, 0.25, 0.55);
|
relative_humidity = monsoonal(humidity_fact, 25.0, 55.0);
|
||||||
break;
|
break;
|
||||||
case 8: // BWk: arid, desert, cold arid
|
case 8: // BWk: arid, desert, cold arid
|
||||||
temp_night = season_even(summer, -15.0, 15.0);
|
temp_night = season_even(summer, -15.0, 15.0);
|
||||||
temp_day = season_even(summer, -2.0, 30.0);
|
temp_day = season_even(summer, -2.0, 30.0);
|
||||||
precipitation = linear(summer, 4.0, 14.0);
|
precipitation = linear(summer, 4.0, 14.0);
|
||||||
relative_humidity = linear(humidity_fact, 0.45, 0.61);
|
relative_humidity = linear(humidity_fact, 45.0, 61.0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_temperature_gl = season_even(day, temp_night, temp_day);
|
_temperature_gl = season_even(day, temp_night, temp_day);
|
||||||
_temperature_mean = 0.5*(temp_night + temp_day);
|
_temperature_mean_gl = 0.5*(temp_night + temp_day);
|
||||||
|
|
||||||
_relative_humidity = relative_humidity;
|
_relative_humidity_gl = relative_humidity;
|
||||||
_precipitation = precipitation;
|
_precipitation = precipitation;
|
||||||
_has_autumn = false;
|
_has_autumn = false;
|
||||||
_wind = 3.0;
|
_wind = 3.0;
|
||||||
|
@ -339,74 +364,74 @@ void FGClimate::set_temperate()
|
||||||
|
|
||||||
double humidity_fact = season_even(winter, 0.5, 1.0-0.5*day);
|
double humidity_fact = season_even(winter, 0.5, 1.0-0.5*day);
|
||||||
|
|
||||||
double temp_night = _temperature_gl;
|
double temp_night = _temperature_sl;
|
||||||
double temp_day = _temperature_gl;
|
double temp_day = _temperature_sl;
|
||||||
double precipitation = _precipitation;
|
double precipitation = _precipitation;
|
||||||
double relative_humidity = _relative_humidity;
|
double relative_humidity = _relative_humidity_gl;
|
||||||
switch(_classicfication)
|
switch(_classicfication)
|
||||||
{
|
{
|
||||||
case 9: // Cfa: warm temperature, fully humid hot summer
|
case 9: // Cfa: warm temperature, fully humid hot summer
|
||||||
temp_night = season_even(summer, -3.0, 20.0);
|
temp_night = season_even(summer, -3.0, 20.0);
|
||||||
temp_day = season_even(summer, 10.0, 33.0);
|
temp_day = season_even(summer, 10.0, 33.0);
|
||||||
precipitation = season_even(summer, 60.0, 123.0);
|
precipitation = season_even(summer, 60.0, 123.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.65, 0.80);
|
relative_humidity = season_even(humidity_fact, 65.0, 80.0);
|
||||||
break;
|
break;
|
||||||
case 10: // Cfb: warm temperature, fully humid, warm summer
|
case 10: // Cfb: warm temperature, fully humid, warm summer
|
||||||
temp_night = season_even(summer, -3.0, 10.0);
|
temp_night = season_even(summer, -3.0, 10.0);
|
||||||
temp_day = season_even(summer, 5.0, 25.0);
|
temp_day = season_even(summer, 5.0, 25.0);
|
||||||
precipitation = linear(0.5*(summer+_season_transistional), 44.0, 88.0);
|
precipitation = linear(0.5*(summer+_season_transistional), 44.0, 88.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.68, 0.87);
|
relative_humidity = season_even(humidity_fact, 68.0, 87.0);
|
||||||
break;
|
break;
|
||||||
case 11: // Cfc: warm temperature, fully humid, cool summer
|
case 11: // Cfc: warm temperature, fully humid, cool summer
|
||||||
temp_night = season_long_low(summer, -3.0, 8.0);
|
temp_night = season_long_low(summer, -3.0, 8.0);
|
||||||
temp_day = season_long_low(summer, 2.0, 14.0);
|
temp_day = season_long_low(summer, 2.0, 14.0);
|
||||||
precipitation = season_even(winter, 44.0, 88.0);
|
precipitation = season_even(winter, 44.0, 88.0);
|
||||||
relative_humidity = season_long_low(humidity_fact, 0.70, 0.85);
|
relative_humidity = season_long_low(humidity_fact, 70.0, 85.0);
|
||||||
break;
|
break;
|
||||||
case 12: // Csa: warm temperature, summer dry, hot summer
|
case 12: // Csa: warm temperature, summer dry, hot summer
|
||||||
temp_night = season_even(summer, 2.0, 16.0);
|
temp_night = season_even(summer, 2.0, 16.0);
|
||||||
temp_day = season_even(summer, 12.0, 33.0);
|
temp_day = season_even(summer, 12.0, 33.0);
|
||||||
precipitation = season_long_low(winter, 25.0, 70.0);
|
precipitation = season_long_low(winter, 25.0, 70.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.58, 0.72);
|
relative_humidity = season_even(humidity_fact, 58.0, 72.0);
|
||||||
break;
|
break;
|
||||||
case 13: // Csb: warm temperature, summer dry, warm summer
|
case 13: // Csb: warm temperature, summer dry, warm summer
|
||||||
temp_night = linear(summer, -4.0, 10.0);
|
temp_night = linear(summer, -4.0, 10.0);
|
||||||
temp_day = linear(summer, 6.0, 27.0);
|
temp_day = linear(summer, 6.0, 27.0);
|
||||||
precipitation = season_short(winter, 25.0, 120.0);
|
precipitation = season_short(winter, 25.0, 120.0);
|
||||||
relative_humidity = linear(humidity_fact, 0.50, 0.72);
|
relative_humidity = linear(humidity_fact, 50.0, 72.0);
|
||||||
break;
|
break;
|
||||||
case 14: // Csc: warm temperature, summer dry, cool summer
|
case 14: // Csc: warm temperature, summer dry, cool summer
|
||||||
temp_night = season_even(summer, -4.0, 5.0);
|
temp_night = season_even(summer, -4.0, 5.0);
|
||||||
temp_day = season_even(summer, 5.0, 16.0);
|
temp_day = season_even(summer, 5.0, 16.0);
|
||||||
precipitation = season_even(winter, 60.0, 95.0);
|
precipitation = season_even(winter, 60.0, 95.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.55, 0.75);
|
relative_humidity = season_even(humidity_fact, 55.0, 75.0);
|
||||||
break;
|
break;
|
||||||
case 15: // Cwa: warm temperature, winter dry, hot summer
|
case 15: // Cwa: warm temperature, winter dry, hot summer
|
||||||
temp_night = season_even(summer, 4.0, 20.0);
|
temp_night = season_even(summer, 4.0, 20.0);
|
||||||
temp_day = season_long_low(summer, 15.0, 30.0);
|
temp_day = season_long_low(summer, 15.0, 30.0);
|
||||||
precipitation = season_long_low(summer, 10.0, 320.0);
|
precipitation = season_long_low(summer, 10.0, 320.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.60, 0.79);
|
relative_humidity = season_even(humidity_fact, 60.0, 79.0);
|
||||||
break;
|
break;
|
||||||
case 16: // Cwb: warm temperature, winter dry, warm summer
|
case 16: // Cwb: warm temperature, winter dry, warm summer
|
||||||
temp_night = season_even(summer, 1.0, 13.0);
|
temp_night = season_even(summer, 1.0, 13.0);
|
||||||
temp_day = season_long_low(summer, 15.0, 27.0);
|
temp_day = season_long_low(summer, 15.0, 27.0);
|
||||||
precipitation = season_long_low(summer, 10.0, 250.0);
|
precipitation = season_long_low(summer, 10.0, 250.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.58, 0.72);
|
relative_humidity = season_even(humidity_fact, 58.0, 72.0);
|
||||||
break;
|
break;
|
||||||
case 17: // Cwc: warm temperature, winter dry, cool summer
|
case 17: // Cwc: warm temperature, winter dry, cool summer
|
||||||
temp_night = season_long_high(summer, -9.0, 6.0);
|
temp_night = season_long_high(summer, -9.0, 6.0);
|
||||||
temp_day = season_long_high(summer, 6.0, 17.0);
|
temp_day = season_long_high(summer, 6.0, 17.0);
|
||||||
precipitation = season_long_low(summer, 10.0, 200.0);
|
precipitation = season_long_low(summer, 10.0, 200.0);
|
||||||
relative_humidity = season_long_high(humidity_fact, 0.50, 0.58);
|
relative_humidity = season_long_high(humidity_fact, 50.0, 58.0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_temperature_gl = season_even(day, temp_night, temp_day);
|
_temperature_gl = season_even(day, temp_night, temp_day);
|
||||||
_temperature_mean = 0.5*(temp_night + temp_day);
|
_temperature_mean_gl = 0.5*(temp_night + temp_day);
|
||||||
|
|
||||||
_relative_humidity = relative_humidity;
|
_relative_humidity_gl = relative_humidity;
|
||||||
_precipitation = precipitation;
|
_precipitation = precipitation;
|
||||||
_has_autumn = true;
|
_has_autumn = true;
|
||||||
_wind = 3.0;
|
_wind = 3.0;
|
||||||
|
@ -423,98 +448,95 @@ void FGClimate::set_continetal()
|
||||||
|
|
||||||
double humidity_fact = season_even(winter, 0.5, 1.0-0.5*day);
|
double humidity_fact = season_even(winter, 0.5, 1.0-0.5*day);
|
||||||
|
|
||||||
double temp_day = _temperature_gl;
|
double temp_day = _temperature_sl;
|
||||||
double temp_night = _temperature_gl;
|
double temp_night = _temperature_sl;
|
||||||
double precipitation = _precipitation;
|
double precipitation = _precipitation;
|
||||||
double relative_humidity = _relative_humidity;
|
double relative_humidity = _relative_humidity_gl;
|
||||||
switch(_classicfication)
|
switch(_classicfication)
|
||||||
{
|
{
|
||||||
case 18: // Dfa: snow, fully humid, hot summer
|
case 18: // Dfa: snow, fully humid, hot summer
|
||||||
temp_night = season_even(summer, -15.0, 13.0);
|
temp_night = season_even(summer, -15.0, 13.0);
|
||||||
temp_day = season_even(summer, -5.0, 30.0);
|
temp_day = season_even(summer, -5.0, 30.0);
|
||||||
precipitation = season_even(summer, 25.0, 65.0);
|
precipitation = season_even(summer, 25.0, 65.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.68, 0.72);
|
relative_humidity = season_even(humidity_fact, 68.0, 72.0);
|
||||||
break;
|
break;
|
||||||
case 19: // Dfb: snow, fully humid, warm summer, warm summer
|
case 19: // Dfb: snow, fully humid, warm summer, warm summer
|
||||||
temp_night = season_even(summer, -17.5, 10.0);
|
temp_night = season_even(summer, -17.5, 10.0);
|
||||||
temp_day = season_even(summer, -7.5, 25.0);
|
temp_day = season_even(summer, -7.5, 25.0);
|
||||||
precipitation = season_even(summer, 30.0, 70.0);
|
precipitation = season_even(summer, 30.0, 70.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.69, 0.81);
|
relative_humidity = season_even(humidity_fact, 69.0, 81.0);
|
||||||
break;
|
break;
|
||||||
case 20: // Dfc: snow, fully humid, cool summer, cool summer
|
case 20: // Dfc: snow, fully humid, cool summer, cool summer
|
||||||
temp_night = season_even(summer, -30.0, 4.0);
|
temp_night = season_even(summer, -30.0, 4.0);
|
||||||
temp_day = season_even(summer, -20.0, 15.0);
|
temp_day = season_even(summer, -20.0, 15.0);
|
||||||
precipitation = season_even(summer, 22.0, 68.0);
|
precipitation = season_even(summer, 22.0, 68.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.70, 0.88);
|
relative_humidity = season_even(humidity_fact, 70.0, 88.0);
|
||||||
break;
|
break;
|
||||||
case 21: // Dfd: snow, fully humid, extremely continetal
|
case 21: // Dfd: snow, fully humid, extremely continetal
|
||||||
temp_night = season_short(summer, -45.0, 4.0);
|
temp_night = season_short(summer, -45.0, 4.0);
|
||||||
temp_day = season_short(summer, -35.0, 10.0);
|
temp_day = season_short(summer, -35.0, 10.0);
|
||||||
precipitation = season_long_low(summer, 7.5, 45.0);
|
precipitation = season_long_low(summer, 7.5, 45.0);
|
||||||
relative_humidity = season_short(humidity_fact, 0.80, 0.90);
|
relative_humidity = season_short(humidity_fact, 80.0, 90.0);
|
||||||
break;
|
break;
|
||||||
case 22: // Dsa: snow, summer dry, hot summer
|
case 22: // Dsa: snow, summer dry, hot summer
|
||||||
temp_night = season_even(summer, -10.0, 10.0);
|
temp_night = season_even(summer, -10.0, 10.0);
|
||||||
temp_day = season_even(summer, 0.0, 30.0);
|
temp_day = season_even(summer, 0.0, 30.0);
|
||||||
precipitation = season_long_high(winter, 2.0, 70.0);
|
precipitation = season_long_high(winter, 2.0, 70.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.48, 0.58);
|
relative_humidity = season_even(humidity_fact, 48.0, 58.08);
|
||||||
break;
|
break;
|
||||||
case 23: // Dsb: snow, summer dry, warm summer
|
case 23: // Dsb: snow, summer dry, warm summer
|
||||||
temp_night = season_even(summer, -15.0, 6.0);
|
temp_night = season_even(summer, -15.0, 6.0);
|
||||||
temp_day = season_even(summer, -4.0, 25.0);
|
temp_day = season_even(summer, -4.0, 25.0);
|
||||||
precipitation = season_long_high(winter, 12.0, 73.0);
|
precipitation = season_long_high(winter, 12.0, 73.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.50, 0.68);
|
relative_humidity = season_even(humidity_fact, 50.0, 68.0);
|
||||||
break;
|
break;
|
||||||
case 24: // Dsc: snow, summer dry, cool summer
|
case 24: // Dsc: snow, summer dry, cool summer
|
||||||
temp_night = season_even(summer, -27.5, 2.0);
|
temp_night = season_even(summer, -27.5, 2.0);
|
||||||
temp_day = season_even(summer, -4.0, 15.0);
|
temp_day = season_even(summer, -4.0, 15.0);
|
||||||
precipitation = season_long_low(summer, 32.5, 45.0);
|
precipitation = season_long_low(summer, 32.5, 45.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.50, 0.60);
|
relative_humidity = season_even(humidity_fact, 50.0, 60.0);
|
||||||
break;
|
break;
|
||||||
case 25: // Dsd: snow, summer dry, extremely continetal
|
case 25: // Dsd: snow, summer dry, extremely continetal
|
||||||
temp_night = season_even(summer, -11.5, -6.5);
|
temp_night = season_even(summer, -11.5, -6.5);
|
||||||
temp_day = season_even(summer, 14.0, 27.0);
|
temp_day = season_even(summer, 14.0, 27.0);
|
||||||
precipitation = season_long_low(summer, 5.0, 90.0);
|
precipitation = season_long_low(summer, 5.0, 90.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.48, 0.62);
|
relative_humidity = season_even(humidity_fact, 48.0, 62.0);
|
||||||
break;
|
break;
|
||||||
case 26: // Dwa: snow, winter dry, hot summer
|
case 26: // Dwa: snow, winter dry, hot summer
|
||||||
temp_night = season_even(summer, -18.0, 16.5);
|
temp_night = season_even(summer, -18.0, 16.5);
|
||||||
temp_day = season_even(summer, -5.0, 25.0);
|
temp_day = season_even(summer, -5.0, 25.0);
|
||||||
precipitation = season_long_low(summer, 5.0, 180.0);
|
precipitation = season_long_low(summer, 5.0, 180.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.60, 0.68);
|
relative_humidity = season_even(humidity_fact, 60.0, 68.0);
|
||||||
break;
|
break;
|
||||||
case 27: // Dwb: snow, winter dry, warm summer
|
case 27: // Dwb: snow, winter dry, warm summer
|
||||||
temp_night = season_even(summer, -28.0, 10.0);
|
temp_night = season_even(summer, -28.0, 10.0);
|
||||||
temp_day = season_even(summer, -12.5, 22.5);
|
temp_day = season_even(summer, -12.5, 22.5);
|
||||||
precipitation = season_long_low(summer, 10.0, 140.0);
|
precipitation = season_long_low(summer, 10.0, 140.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.60, 0.72);
|
relative_humidity = season_even(humidity_fact, 60.0, 72.0);
|
||||||
break;
|
break;
|
||||||
case 28: // Dwc: snow, winter dry, cool summer
|
case 28: // Dwc: snow, winter dry, cool summer
|
||||||
temp_night = season_even(summer, -33.0, 5.0);
|
temp_night = season_even(summer, -33.0, 5.0);
|
||||||
temp_day = season_even(summer, -20.0, 20.0);
|
temp_day = season_even(summer, -20.0, 20.0);
|
||||||
precipitation = season_long_low(summer, 10.0, 110.0);
|
precipitation = season_long_low(summer, 10.0, 110.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.60, 0.78);
|
relative_humidity = season_even(humidity_fact, 60.0, 78.0);
|
||||||
break;
|
break;
|
||||||
case 29: // Dwd: snow, winter dry, extremely continetal
|
case 29: // Dwd: snow, winter dry, extremely continetal
|
||||||
temp_night = season_even(summer, -57.5, 0.0);
|
temp_night = season_even(summer, -57.5, 0.0);
|
||||||
temp_day = season_even(summer, -43.0, 15.0);
|
temp_day = season_even(summer, -43.0, 15.0);
|
||||||
precipitation = season_even(summer, 8.0, 63.0);
|
precipitation = season_even(summer, 8.0, 63.0);
|
||||||
relative_humidity = 0.80;
|
relative_humidity = 80.0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_temperature_gl = season_even(day, temp_night, temp_day);
|
_temperature_gl = season_even(day, temp_night, temp_day);
|
||||||
_temperature_mean = 0.5*(temp_night + temp_day);
|
_temperature_mean_gl = 0.5*(temp_night + temp_day);
|
||||||
|
|
||||||
_relative_humidity = relative_humidity;
|
_relative_humidity_gl = relative_humidity;
|
||||||
_precipitation = precipitation;
|
_precipitation = precipitation;
|
||||||
_has_autumn = true;
|
_has_autumn = true;
|
||||||
_wind = 3.0;
|
_wind = 3.0;
|
||||||
|
|
||||||
double fact_lat = pow(fabs(pos.getLatitudeDeg())/90.0, 2.5);
|
|
||||||
_relative_humidity = season_even(fact_lat, 0.1, 0.8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGClimate::set_polar()
|
void FGClimate::set_polar()
|
||||||
|
@ -527,32 +549,32 @@ void FGClimate::set_polar()
|
||||||
double humidity_fact = season_even(winter, 0.5, 1.0-0.5*day);
|
double humidity_fact = season_even(winter, 0.5, 1.0-0.5*day);
|
||||||
|
|
||||||
// polar climate also occurs high in the mountains
|
// polar climate also occurs high in the mountains
|
||||||
double temp_day = _temperature_gl;
|
double temp_day = _temperature_sl;
|
||||||
double temp_night = _temperature_gl;
|
double temp_night = _temperature_sl;
|
||||||
double precipitation = _precipitation;
|
double precipitation = _precipitation;
|
||||||
double relative_humidity = _relative_humidity;
|
double relative_humidity = _relative_humidity_gl;
|
||||||
switch(_classicfication)
|
switch(_classicfication)
|
||||||
{
|
{
|
||||||
case 30: // EF: polar frost
|
case 30: // EF: polar frost
|
||||||
temp_night = season_long_low(summer, -35.0, -6.0);
|
temp_night = season_long_low(summer, -35.0, -6.0);
|
||||||
temp_day = season_long_low(summer, -32.5, 0.0);
|
temp_day = season_long_low(summer, -32.5, 0.0);
|
||||||
precipitation = season_even(summer, 50.0, 80.0);
|
precipitation = season_even(summer, 50.0, 80.0);
|
||||||
relative_humidity = season_long_low(humidity_fact, 0.65, 0.75);
|
relative_humidity = season_long_low(humidity_fact, 65.0, 75.0);
|
||||||
break;
|
break;
|
||||||
case 31: // ET: polar tundra
|
case 31: // ET: polar tundra
|
||||||
temp_night = season_even(summer, -30.0, 0.0);
|
temp_night = season_even(summer, -30.0, 0.0);
|
||||||
temp_day = season_even(summer, -22.5, 8.0);
|
temp_day = season_even(summer, -22.5, 8.0);
|
||||||
precipitation = season_even(summer, 15.0, 45.0);
|
precipitation = season_even(summer, 15.0, 45.0);
|
||||||
relative_humidity = season_even(humidity_fact, 0.60, 0.88);
|
relative_humidity = season_even(humidity_fact, 60.0, 88.0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_temperature_gl = season_even(day, temp_night, temp_day);
|
_temperature_gl = season_even(day, temp_night, temp_day);
|
||||||
_temperature_mean = 0.5*(temp_night + temp_day);
|
_temperature_mean_gl = 0.5*(temp_night + temp_day);
|
||||||
|
|
||||||
_relative_humidity = relative_humidity;
|
_relative_humidity_gl = relative_humidity;
|
||||||
_precipitation = precipitation;
|
_precipitation = precipitation;
|
||||||
_has_autumn = false;
|
_has_autumn = false;
|
||||||
_wind = 3.0;
|
_wind = 3.0;
|
||||||
|
@ -574,22 +596,22 @@ void FGClimate::set_environment()
|
||||||
precipitation = (precipitation > 240.0) ? 1.0 : precipitation/240.0;
|
precipitation = (precipitation > 240.0) ? 1.0 : precipitation/240.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_temperature_mean > 5.0 || precipitation < 0.1) {
|
if (_temperature_mean_gl > 5.0 || precipitation < 0.1) {
|
||||||
snow_fact = 0.0;
|
snow_fact = 0.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snow_fact = fabs(_temperature_mean) - 5.0;
|
snow_fact = fabs(_temperature_mean_gl) - 5.0;
|
||||||
snow_fact = (snow_fact > 10.0) ? 1.0 : snow_fact/10.0;
|
snow_fact = (snow_fact > 10.0) ? 1.0 : snow_fact/10.0;
|
||||||
snow_fact *= precipitation;
|
snow_fact *= precipitation;
|
||||||
}
|
}
|
||||||
|
|
||||||
_snow_level = (7500.0 - 8000.0*fact_lat)*(1.0 - snow_fact);
|
// The temperature decreases by about 9.8°C per kilometer
|
||||||
_snow_thickness = pow(snow_fact, 2.0);
|
_snow_thickness = pow(snow_fact, 2.0);
|
||||||
_ice_cover = pow(fact_lat, 2.5);
|
_ice_cover = pow(fact_lat, 2.5);
|
||||||
|
|
||||||
// less than 20 mm/month of precipitation is considered dry.
|
// less than 20 mm/month of precipitation is considered dry.
|
||||||
if (_precipitation < 20.0 && _total_annual_precipitation < 240.0)
|
if (_precipitation < 20.0 || _precipitation_annual < 240.0)
|
||||||
{
|
{
|
||||||
_dust_cover = 0.3 - 0.3*sqrtf(_precipitation/20.0);
|
_dust_cover = 0.3 - 0.3*sqrtf(_precipitation/20.0);
|
||||||
_lichen_cover = 0.0;
|
_lichen_cover = 0.0;
|
||||||
|
@ -598,12 +620,12 @@ void FGClimate::set_environment()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double wetness = _precipitation - 20.0;
|
double wetness = _precipitation - 20.0;
|
||||||
wetness = std::min(12.0*wetness/_total_annual_precipitation, 1.0);
|
wetness = std::min(12.0*wetness/_precipitation_annual, 1.0);
|
||||||
|
|
||||||
_dust_cover = 0.0;
|
_dust_cover = 0.0;
|
||||||
_wetness = pow(wetness, 3.0);
|
_wetness = pow(wetness, 3.0);
|
||||||
|
|
||||||
double cover = std::min(_total_annual_precipitation, 990.0)/990.0;
|
double cover = std::min(_precipitation_annual, 990.0)/990.0;
|
||||||
_lichen_cover = 0.5*pow(wetness*cover, 1.5);
|
_lichen_cover = 0.5*pow(wetness*cover, 1.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,15 +780,16 @@ void FGClimate::report()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << " Ground temperature: " << _temperature_gl << " deg. C."
|
std::cout << " Ground temperature: " << _temperature_gl << " deg. C."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << " Mean temperature: " << _temperature_mean << " deg. C."
|
std::cout << " Mean temperature: " << _temperature_mean_gl
|
||||||
<< std::endl;
|
<< " deg. C." << std::endl;
|
||||||
std::cout << " Months precipitation: " << _precipitation << " mm"
|
std::cout << " Months precipitation: " << _precipitation << " mm"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << " Annual precipitation: " << _total_annual_precipitation
|
std::cout << " Annual precipitation: " << _precipitation_annual << " mm"
|
||||||
<< " mm" << std::endl;
|
<< std::endl;
|
||||||
std::cout << " Relative humidity: " << _relative_humidity*100.0 << " %"
|
std::cout << " Relative humidity: " << _relative_humidity_gl << " %"
|
||||||
|
<< std::endl;
|
||||||
|
std::cout << " Dewpoint: " << _dewpoint_gl << " deg. C."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << " Dew point: " << _dew_point << " deg. C." << std::endl;
|
|
||||||
std::cout << " Wind: " << _wind << " km/h" << std::endl << std::endl;
|
std::cout << " Wind: " << _wind << " km/h" << std::endl << std::endl;
|
||||||
std::cout << " Snow level: " << _snow_level << " m." << std::endl;
|
std::cout << " Snow level: " << _snow_level << " m." << std::endl;
|
||||||
std::cout << " Snow thickness.(0.0 = thin .. 1.0 = thick): "
|
std::cout << " Snow thickness.(0.0 = thin .. 1.0 = thick): "
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
#include <osg/Image>
|
#include <osg/Image>
|
||||||
|
|
||||||
// #include <simgear/structure/SGReferenced.hxx>
|
#include <simgear/props/tiedpropertylist.hxx>
|
||||||
#include <simgear/math/SGGeod.hxx>
|
#include <simgear/math/SGGeod.hxx>
|
||||||
|
|
||||||
#define REPORT_TO_CONSOLE 0
|
#define REPORT_TO_CONSOLE 0
|
||||||
|
@ -52,9 +52,9 @@ public:
|
||||||
double get_wetness() { return _wetness; }
|
double get_wetness() { return _wetness; }
|
||||||
double get_lichen_cover() { return _lichen_cover; }
|
double get_lichen_cover() { return _lichen_cover; }
|
||||||
|
|
||||||
double get_dew_point_degc() { return _dew_point; }
|
double get_dewpoint_degc() { return _dewpoint_gl; }
|
||||||
double get_temperature_degc() { return _temperature_gl; }
|
double get_temperature_degc() { return _temperature_gl; }
|
||||||
double get_humidity_pct() { return _relative_humidity; }
|
double get_humidity_pct() { return _relative_humidity_gl; }
|
||||||
double get_wind_kmh() { return _wind; }
|
double get_wind_kmh() { return _wind; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -81,6 +81,8 @@ private:
|
||||||
void update_day_factor();
|
void update_day_factor();
|
||||||
void update_season_factor();
|
void update_season_factor();
|
||||||
|
|
||||||
|
simgear::TiedPropertyList _tiedProperties;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Image> image;
|
osg::ref_ptr<osg::Image> image;
|
||||||
int _image_width = 0;
|
int _image_width = 0;
|
||||||
int _image_height = 0;
|
int _image_height = 0;
|
||||||
|
@ -90,6 +92,7 @@ private:
|
||||||
double _prev_lon = -99999.0;
|
double _prev_lon = -99999.0;
|
||||||
|
|
||||||
SGGeod pos;
|
SGGeod pos;
|
||||||
|
SGPropertyNode_ptr _ground_elev_node;
|
||||||
|
|
||||||
double _sun_latitude_deg = 0.0;
|
double _sun_latitude_deg = 0.0;
|
||||||
double _sun_longitude_deg = 0.0;
|
double _sun_longitude_deg = 0.0;
|
||||||
|
@ -106,7 +109,7 @@ private:
|
||||||
int _classicfication = 0; // Köppen-Geiger classicfication
|
int _classicfication = 0; // Köppen-Geiger classicfication
|
||||||
|
|
||||||
// environment
|
// environment
|
||||||
bool _environment_adjust = true; // enable automatic adjestments
|
bool _environment_adjust = false; // enable automatic adjestments
|
||||||
double _snow_level = 7500.0; // in meters
|
double _snow_level = 7500.0; // in meters
|
||||||
double _snow_thickness = 0.0; // 0.0 = thin, 1.0 = thick
|
double _snow_thickness = 0.0; // 0.0 = thin, 1.0 = thick
|
||||||
double _ice_cover = 0.0; // 0.0 = none, 1.0 = thick
|
double _ice_cover = 0.0; // 0.0 = none, 1.0 = thick
|
||||||
|
@ -116,17 +119,18 @@ private:
|
||||||
|
|
||||||
// weather
|
// weather
|
||||||
bool _weather_update = false; // enable weather updates
|
bool _weather_update = false; // enable weather updates
|
||||||
double _relative_humidity = 0.6; // 0.0 = dry, 1.0 is fully humid
|
double _relative_humidity_sl = 60.0; // 0.0 = dry, 1.0 is fully humid
|
||||||
|
double _relative_humidity_gl = 60.0;
|
||||||
|
|
||||||
double _dew_point = 0.5;
|
double _dewpoint_gl = 5.0;
|
||||||
|
double _dewpoint_sl = 5.0;
|
||||||
double _temperature_gl = 20.0; // ground level temperature in deg. C.
|
double _temperature_gl = 20.0; // ground level temperature in deg. C.
|
||||||
double _temperature_sl = 20.0; // seal level temperature in deg. C.
|
double _temperature_sl = 20.0; // seal level temperature in deg. C.
|
||||||
double _temperature_mean = 20.0; // mean temperature in deg. C.
|
double _temperature_mean_gl = 20.0; // mean temperature in deg. C.
|
||||||
|
double _temperature_mean_sl = 20.0;
|
||||||
double _precipitation = 0.0; // minimal average precipitation in mm/month
|
double _precipitation = 0.0; // minimal average precipitation in mm/month
|
||||||
double _wind = 3.0; // wind in km/h
|
double _wind = 3.0; // wind in km/h
|
||||||
|
double _precipitation_annual = 990.0; // global
|
||||||
// total annual precipitation in mm/month
|
|
||||||
double _total_annual_precipitation = 990.0; // global
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _FGCLIMATE_HXX
|
#endif // _FGCLIMATE_HXX
|
||||||
|
|
Loading…
Reference in a new issue