1 // environment.cxx -- routines to model the natural environment
3 // Written by David Megginson, started February 2002.
5 // Copyright (C) 2002 David Megginson - david@megginson.com
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 #include <boost/tuple/tuple.hpp>
30 #include <simgear/props/props.hxx>
31 #include <simgear/math/SGMath.hxx>
33 #include <Main/fg_props.hxx>
35 #include "environment.hxx"
36 #include "atmosphere.hxx"
39 ////////////////////////////////////////////////////////////////////////
41 ////////////////////////////////////////////////////////////////////////
45 // Calculated based on the ISA standard day, as found at e.g.
46 // http://www.av8n.com/physics/altimetry.htm
48 // Each line of data has 3 elements:
50 // temperature factor (dimensionless ratio of absolute temp),
51 // pressure factor (dimensionless ratio)
52 static double atmosphere_data[][3] = {
53 { -3000.00, 1.021, 1.1133 },
54 { 0.00, 1.000, 1.0000 },
55 { 2952.76, 0.980, 0.8978 },
56 { 5905.51, 0.959, 0.8042 },
57 { 8858.27, 0.939, 0.7187 },
58 { 11811.02, 0.919, 0.6407 },
59 { 14763.78, 0.898, 0.5697 },
60 { 17716.54, 0.878, 0.5052 },
61 { 20669.29, 0.858, 0.4468 },
62 { 23622.05, 0.838, 0.3940 },
63 { 26574.80, 0.817, 0.3463 },
64 { 29527.56, 0.797, 0.3034 },
65 { 32480.31, 0.777, 0.2649 },
66 { 35433.07, 0.756, 0.2305 },
67 { 38385.83, 0.752, 0.2000 },
68 { 41338.58, 0.752, 0.1736 },
69 { 44291.34, 0.752, 0.1506 },
70 { 47244.09, 0.752, 0.1307 },
71 { 50196.85, 0.752, 0.1134 },
72 { 53149.61, 0.752, 0.0984 },
73 { 56102.36, 0.752, 0.0854 },
74 { 59055.12, 0.752, 0.0741 },
75 { 62007.87, 0.752, 0.0643 },
76 { 65000.00, 0.752, 0.0557 },
77 { 68000.00, 0.754, 0.0482 },
78 { 71000.00, 0.758, 0.0418 },
79 { 74000.00, 0.761, 0.0362 },
80 { 77000.00, 0.764, 0.0314 },
81 { 80000.00, 0.767, 0.0273 },
82 { 83000.00, 0.770, 0.0237 },
83 { 86000.00, 0.773, 0.0206 },
84 { 89000.00, 0.777, 0.0179 },
85 { 92000.00, 0.780, 0.0156 },
86 { 95000.00, 0.783, 0.0135 },
87 { 98000.00, 0.786, 0.0118 },
88 { 101000.00, 0.789, 0.0103 },
92 static SGInterpTable * _temperature_degc_table = 0;
93 static SGInterpTable * _pressure_inhg_table = 0;
98 if (_temperature_degc_table != 0)
101 _temperature_degc_table = new SGInterpTable;
102 _pressure_inhg_table = new SGInterpTable;
104 for (int i = 0; atmosphere_data[i][0] != -1; i++) {
105 _temperature_degc_table->addEntry(atmosphere_data[i][0],
106 atmosphere_data[i][1]);
107 _pressure_inhg_table->addEntry(atmosphere_data[i][0],
108 atmosphere_data[i][2]);
114 ////////////////////////////////////////////////////////////////////////
115 // Implementation of FGEnvironment.
116 ////////////////////////////////////////////////////////////////////////
118 void FGEnvironment::_init()
122 visibility_m = 32000;
123 temperature_sea_level_degc = 15;
124 temperature_degc = 15;
125 dewpoint_sea_level_degc = 5; // guess
127 pressure_sea_level_inhg = 29.92;
128 pressure_inhg = 29.92;
130 turbulence_magnitude_norm = 0;
131 turbulence_rate_hz = 1;
132 wind_from_heading_deg = 0;
134 wind_from_north_fps = 0;
135 wind_from_east_fps = 0;
136 wind_from_down_fps = 0;
137 altitude_half_to_sun_m = 1000;
138 altitude_tropo_top_m = 10000;
143 _recalc_relative_humidity();
147 FGEnvironment::FGEnvironment()
152 FGEnvironment::FGEnvironment (const FGEnvironment &env)
158 FGEnvironment::~FGEnvironment()
163 FGEnvironment & FGEnvironment::operator = ( const FGEnvironment & other )
170 FGEnvironment::copy (const FGEnvironment &env)
172 elevation_ft = env.elevation_ft;
173 visibility_m = env.visibility_m;
174 temperature_sea_level_degc = env.temperature_sea_level_degc;
175 temperature_degc = env.temperature_degc;
176 dewpoint_sea_level_degc = env.dewpoint_sea_level_degc;
177 dewpoint_degc = env.dewpoint_degc;
178 pressure_sea_level_inhg = env.pressure_sea_level_inhg;
179 wind_from_heading_deg = env.wind_from_heading_deg;
180 wind_speed_kt = env.wind_speed_kt;
181 wind_from_north_fps = env.wind_from_north_fps;
182 wind_from_east_fps = env.wind_from_east_fps;
183 wind_from_down_fps = env.wind_from_down_fps;
184 turbulence_magnitude_norm = env.turbulence_magnitude_norm;
185 turbulence_rate_hz = env.turbulence_rate_hz;
186 pressure_inhg = env.pressure_inhg;
187 density_slugft3 = env.density_slugft3;
188 density_tropo_avg_kgm3 = env.density_tropo_avg_kgm3;
189 relative_humidity = env.relative_humidity;
190 altitude_half_to_sun_m = env.altitude_half_to_sun_m;
191 altitude_tropo_top_m = env.altitude_tropo_top_m;
192 live_update = env.live_update;
196 maybe_copy_value (FGEnvironment * env, const SGPropertyNode * node,
197 const char * name, void (FGEnvironment::*setter)(double))
199 const SGPropertyNode * child = node->getNode(name);
200 // fragile: depends on not being typed
202 if (child != 0 && child->hasValue() &&
203 child->getStringValue()[0] != '\0') {
204 (env->*setter)(child->getDoubleValue());
212 FGEnvironment::read (const SGPropertyNode * node)
214 bool live_update = set_live_update( false );
215 maybe_copy_value(this, node, "visibility-m",
216 &FGEnvironment::set_visibility_m);
218 maybe_copy_value(this, node, "elevation-ft",
219 &FGEnvironment::set_elevation_ft);
221 if (!maybe_copy_value(this, node, "temperature-sea-level-degc",
222 &FGEnvironment::set_temperature_sea_level_degc)) {
223 if( maybe_copy_value(this, node, "temperature-degc",
224 &FGEnvironment::set_temperature_degc)) {
225 _recalc_sl_temperature();
229 if (!maybe_copy_value(this, node, "dewpoint-sea-level-degc",
230 &FGEnvironment::set_dewpoint_sea_level_degc)) {
231 if( maybe_copy_value(this, node, "dewpoint-degc",
232 &FGEnvironment::set_dewpoint_degc)) {
233 _recalc_sl_dewpoint();
237 if (!maybe_copy_value(this, node, "pressure-sea-level-inhg",
238 &FGEnvironment::set_pressure_sea_level_inhg)) {
239 if( maybe_copy_value(this, node, "pressure-inhg",
240 &FGEnvironment::set_pressure_inhg)) {
241 _recalc_sl_pressure();
245 maybe_copy_value(this, node, "wind-from-heading-deg",
246 &FGEnvironment::set_wind_from_heading_deg);
248 maybe_copy_value(this, node, "wind-speed-kt",
249 &FGEnvironment::set_wind_speed_kt);
251 maybe_copy_value(this, node, "turbulence/magnitude-norm",
252 &FGEnvironment::set_turbulence_magnitude_norm);
254 maybe_copy_value(this, node, "turbulence/rate-hz",
255 &FGEnvironment::set_turbulence_rate_hz);
257 // calculate derived properties here to avoid duplicate expensive computations
260 _recalc_alt_dewpoint();
262 _recalc_relative_humidity();
264 set_live_update(live_update);
267 void FGEnvironment::Tie( SGPropertyNode_ptr base, bool archivable )
269 _tiedProperties.setRoot( base );
271 _tiedProperties.Tie( "visibility-m", this,
272 &FGEnvironment::get_visibility_m,
273 &FGEnvironment::set_visibility_m);
275 _tiedProperties.Tie("temperature-sea-level-degc", this,
276 &FGEnvironment::get_temperature_sea_level_degc,
277 &FGEnvironment::set_temperature_sea_level_degc);
279 _tiedProperties.Tie("temperature-degc", this,
280 &FGEnvironment::get_temperature_degc,
281 &FGEnvironment::set_temperature_degc);
283 _tiedProperties.Tie("dewpoint-sea-level-degc", this,
284 &FGEnvironment::get_dewpoint_sea_level_degc,
285 &FGEnvironment::set_dewpoint_sea_level_degc);
287 _tiedProperties.Tie("dewpoint-degc", this,
288 &FGEnvironment::get_dewpoint_degc,
289 &FGEnvironment::set_dewpoint_degc);
291 _tiedProperties.Tie("pressure-sea-level-inhg", this,
292 &FGEnvironment::get_pressure_sea_level_inhg,
293 &FGEnvironment::set_pressure_sea_level_inhg);
295 _tiedProperties.Tie("pressure-inhg", this,
296 &FGEnvironment::get_pressure_inhg,
297 &FGEnvironment::set_pressure_inhg);
299 _tiedProperties.Tie("atmosphere/altitude-half-to-sun", this,
300 &FGEnvironment::get_altitude_half_to_sun_m,
301 &FGEnvironment::set_altitude_half_to_sun_m);
303 _tiedProperties.Tie("atmosphere/altitude-troposphere-top", this,
304 &FGEnvironment::get_altitude_tropo_top_m,
305 &FGEnvironment::set_altitude_tropo_top_m);
307 _tiedProperties.Tie("wind-from-heading-deg", this,
308 &FGEnvironment::get_wind_from_heading_deg,
309 &FGEnvironment::set_wind_from_heading_deg);
311 _tiedProperties.Tie("wind-speed-kt", this,
312 &FGEnvironment::get_wind_speed_kt,
313 &FGEnvironment::set_wind_speed_kt);
315 _tiedProperties.Tie("wind-from-north-fps", this,
316 &FGEnvironment::get_wind_from_north_fps,
317 &FGEnvironment::set_wind_from_north_fps);
319 _tiedProperties.Tie("wind-from-east-fps", this,
320 &FGEnvironment::get_wind_from_east_fps,
321 &FGEnvironment::set_wind_from_east_fps);
323 _tiedProperties.Tie("wind-from-down-fps", this,
324 &FGEnvironment::get_wind_from_down_fps,
325 &FGEnvironment::set_wind_from_down_fps);
327 _tiedProperties.Tie("turbulence/magnitude-norm", this,
328 &FGEnvironment::get_turbulence_magnitude_norm,
329 &FGEnvironment::set_turbulence_magnitude_norm);
331 _tiedProperties.Tie("turbulence/rate-hz", this,
332 &FGEnvironment::get_turbulence_rate_hz,
333 &FGEnvironment::set_turbulence_rate_hz);
335 _tiedProperties.setAttribute( SGPropertyNode::ARCHIVE, archivable );
337 _tiedProperties.Tie("temperature-degf", this,
338 &FGEnvironment::get_temperature_degf);
340 _tiedProperties.Tie("density-slugft3", this,
341 &FGEnvironment::get_density_slugft3); // read-only
343 _tiedProperties.Tie("relative-humidity", this,
344 &FGEnvironment::get_relative_humidity); //ro
346 _tiedProperties.Tie("atmosphere/density-tropo-avg", this,
347 &FGEnvironment::get_density_tropo_avg_kgm3); //ro
350 void FGEnvironment::Untie()
352 _tiedProperties.Untie();
356 FGEnvironment::get_visibility_m () const
362 FGEnvironment::get_temperature_sea_level_degc () const
364 return temperature_sea_level_degc;
368 FGEnvironment::get_temperature_degc () const
370 return temperature_degc;
374 FGEnvironment::get_temperature_degf () const
376 return (temperature_degc * 9.0 / 5.0) + 32.0;
380 FGEnvironment::get_dewpoint_sea_level_degc () const
382 return dewpoint_sea_level_degc;
386 FGEnvironment::get_dewpoint_degc () const
388 return dewpoint_degc;
392 FGEnvironment::get_pressure_sea_level_inhg () const
394 return pressure_sea_level_inhg;
398 FGEnvironment::get_pressure_inhg () const
400 return pressure_inhg;
404 FGEnvironment::get_density_slugft3 () const
406 return density_slugft3;
410 FGEnvironment::get_relative_humidity () const
412 return relative_humidity;
416 FGEnvironment::get_density_tropo_avg_kgm3 () const
418 return density_tropo_avg_kgm3;
422 FGEnvironment::get_altitude_half_to_sun_m () const
424 return altitude_half_to_sun_m;
428 FGEnvironment::get_altitude_tropo_top_m () const
430 return altitude_tropo_top_m;
434 FGEnvironment::get_wind_from_heading_deg () const
436 return wind_from_heading_deg;
440 FGEnvironment::get_wind_speed_kt () const
442 return wind_speed_kt;
446 FGEnvironment::get_wind_from_north_fps () const
448 return wind_from_north_fps;
452 FGEnvironment::get_wind_from_east_fps () const
454 return wind_from_east_fps;
458 FGEnvironment::get_wind_from_down_fps () const
460 return wind_from_down_fps;
464 FGEnvironment::get_turbulence_magnitude_norm () const
466 return turbulence_magnitude_norm;
470 FGEnvironment::get_turbulence_rate_hz () const
472 return turbulence_rate_hz;
476 FGEnvironment::get_elevation_ft () const
482 FGEnvironment::set_visibility_m (double v)
488 FGEnvironment::set_temperature_sea_level_degc (double t)
490 temperature_sea_level_degc = t;
491 if (dewpoint_sea_level_degc > t)
492 dewpoint_sea_level_degc = t;
500 FGEnvironment::set_temperature_degc (double t)
502 temperature_degc = t;
504 _recalc_sl_temperature();
505 _recalc_sl_pressure();
508 _recalc_relative_humidity();
513 FGEnvironment::set_dewpoint_sea_level_degc (double t)
515 dewpoint_sea_level_degc = t;
516 if (temperature_sea_level_degc < t)
517 temperature_sea_level_degc = t;
519 _recalc_alt_dewpoint();
525 FGEnvironment::set_dewpoint_degc (double t)
529 _recalc_sl_dewpoint();
531 _recalc_relative_humidity();
536 FGEnvironment::set_pressure_sea_level_inhg (double p)
538 pressure_sea_level_inhg = p;
546 FGEnvironment::set_pressure_inhg (double p)
550 _recalc_sl_pressure();
556 FGEnvironment::set_wind_from_heading_deg (double h)
558 wind_from_heading_deg = h;
565 FGEnvironment::set_wind_speed_kt (double s)
574 FGEnvironment::set_wind_from_north_fps (double n)
576 wind_from_north_fps = n;
583 FGEnvironment::set_wind_from_east_fps (double e)
585 wind_from_east_fps = e;
592 FGEnvironment::set_wind_from_down_fps (double d)
594 wind_from_down_fps = d;
601 FGEnvironment::set_turbulence_magnitude_norm (double t)
603 turbulence_magnitude_norm = t;
607 FGEnvironment::set_turbulence_rate_hz (double r)
609 turbulence_rate_hz = r;
613 FGEnvironment::set_elevation_ft (double e)
618 _recalc_alt_dewpoint();
620 _recalc_relative_humidity();
625 FGEnvironment::set_altitude_half_to_sun_m (double alt)
627 altitude_half_to_sun_m = alt;
629 _recalc_density_tropo_avg_kgm3();
634 FGEnvironment::set_altitude_tropo_top_m (double alt)
636 altitude_tropo_top_m = alt;
638 _recalc_density_tropo_avg_kgm3();
644 FGEnvironment::_recalc_hdgspd ()
646 wind_from_heading_deg =
647 atan2(wind_from_east_fps, wind_from_north_fps) * SGD_RADIANS_TO_DEGREES;
649 if( wind_from_heading_deg < 0 )
650 wind_from_heading_deg += 360.0;
652 wind_speed_kt = sqrt(wind_from_north_fps * wind_from_north_fps +
653 wind_from_east_fps * wind_from_east_fps)
654 * SG_METER_TO_NM * SG_FEET_TO_METER * 3600;
658 FGEnvironment::_recalc_ne ()
661 wind_speed_kt * SG_NM_TO_METER * SG_METER_TO_FEET * (1.0/3600);
663 wind_from_north_fps = speed_fps *
664 cos(wind_from_heading_deg * SGD_DEGREES_TO_RADIANS);
665 wind_from_east_fps = speed_fps *
666 sin(wind_from_heading_deg * SGD_DEGREES_TO_RADIANS);
669 // Intended to help with the interpretation of METAR data,
670 // not for random in-flight outside-air temperatures.
672 FGEnvironment::_recalc_sl_temperature ()
677 SG_LOG(SG_ENVIRONMENT, SG_DEBUG, "recalc_sl_temperature: using "
678 << temperature_degc << " @ " << elevation_ft << " :: " << this);
682 if (elevation_ft * atmodel::foot >= ISA_def[1].height) {
683 SG_LOG(SG_ENVIRONMENT, SG_ALERT, "recalc_sl_temperature: "
684 << "valid only in troposphere, not " << elevation_ft);
688 // Clamp: temperature of the stratosphere, in degrees C:
689 double t_strato = ISA_def[1].temp - atmodel::freezing;
690 if (temperature_degc < t_strato) temperature_sea_level_degc = t_strato;
691 else temperature_sea_level_degc =
692 temperature_degc + elevation_ft * atmodel::foot * ISA_def[0].lapse;
694 // Alternative implemenation:
695 // else temperature_sea_level_inhg = T_layer(0., elevation_ft * foot,
696 // pressure_inhg * inHg, temperature_degc + freezing, ISA_def[0].lapse) - freezing;
700 FGEnvironment::_recalc_sl_dewpoint ()
703 // FIXME: this will work only for low
705 dewpoint_sea_level_degc = dewpoint_degc + (elevation_ft * .0002);
706 if (dewpoint_sea_level_degc > temperature_sea_level_degc)
707 dewpoint_sea_level_degc = temperature_sea_level_degc;
711 FGEnvironment::_recalc_alt_dewpoint ()
714 // FIXME: this will work only for low
716 dewpoint_degc = dewpoint_sea_level_degc + (elevation_ft * .0002);
717 if (dewpoint_degc > temperature_degc)
718 dewpoint_degc = temperature_degc;
722 FGEnvironment::_recalc_sl_pressure ()
724 using namespace atmodel;
727 SG_LOG(SG_ENVIRONMENT, SG_ALERT, "recalc_sl_pressure: using "
728 << pressure_inhg << " and "
729 << temperature_degc << " @ " << elevation_ft << " :: " << this);
732 pressure_sea_level_inhg = P_layer(0., elevation_ft * foot,
733 pressure_inhg * inHg, temperature_degc + freezing, ISA_def[0].lapse) / inHg;
736 // This gets called at frame rate, to account for the aircraft's
737 // changing altitude.
738 // Called by set_elevation_ft() which is called by FGEnvironmentMgr::update
741 FGEnvironment::_recalc_alt_pt ()
743 using namespace atmodel;
747 if (++count % 1000 == 0) {
748 SG_LOG(SG_ENVIRONMENT, SG_ALERT,
749 "recalc_alt_pt for: " << elevation_ft
750 << " using " << pressure_sea_level_inhg
751 << " and " << temperature_sea_level_degc
757 double press = pressure_inhg * inHg;
758 double temp = temperature_degc + freezing;
759 boost::tie(press, temp) = PT_vs_hpt(elevation_ft * foot,
760 pressure_sea_level_inhg * inHg, temperature_sea_level_degc + freezing);
761 temperature_degc = temp - freezing;
762 pressure_inhg = press / inHg;
766 FGEnvironment::_recalc_density ()
768 double pressure_psf = pressure_inhg * 70.7487;
770 // adjust for humidity
771 // calculations taken from USA Today (oops!) at
772 // http://www.usatoday.com/weather/basics/density-calculations.htm
773 double temperature_degk = temperature_degc + 273.15;
774 double pressure_mb = pressure_inhg * 33.86;
775 double vapor_pressure_mb =
776 6.11 * pow(10.0, 7.5 * dewpoint_degc / (237.7 + dewpoint_degc));
777 double virtual_temperature_degk = temperature_degk / (1 - (vapor_pressure_mb / pressure_mb) * (1.0 - 0.622));
778 double virtual_temperature_degr = virtual_temperature_degk * 1.8;
780 density_slugft3 = pressure_psf / (virtual_temperature_degr * 1718);
781 _recalc_density_tropo_avg_kgm3();
784 // This is used to calculate the average density on the path
785 // of sunlight to the observer for calculating sun-color
787 FGEnvironment::_recalc_density_tropo_avg_kgm3 ()
789 double pressure_mb = pressure_inhg * 33.86;
790 double vaporpressure = 6.11 * pow(10.0, ((7.5 * dewpoint_degc) / (237.7 + dewpoint_degc)));
792 double virtual_temp = (temperature_degc + 273.15) / (1 - 0.379 * (vaporpressure/pressure_mb));
794 double density_half = (100 * pressure_mb * exp(-altitude_half_to_sun_m / 8000))
795 / (287.05 * virtual_temp);
796 double density_tropo = (100 * pressure_mb * exp((-1 * altitude_tropo_top_m) / 8000))
797 / ( 287.05 * virtual_temp);
799 density_tropo_avg_kgm3 = ((density_slugft3 * 515.379) + density_half + density_tropo) / 3;
803 FGEnvironment::_recalc_relative_humidity ()
806 double vaporpressure = 6.11 * pow(10.0, ((7.5 * dewpoint_degc) / ( 237.7 + dewpoint_degc)));
807 double sat_vaporpressure = 6.11 * pow(10.0, ((7.5 * temperature_degc)
808 / ( 237.7 + temperature_degc)) );
809 relative_humidity = 100 * vaporpressure / sat_vaporpressure ;
811 with a little algebra, this gets the same result and spares two multiplications and one pow()
813 double a = (7.5 * dewpoint_degc) / ( 237.7 + dewpoint_degc);
814 double b = (7.5 * temperature_degc) / ( 237.7 + temperature_degc);
815 relative_humidity = 100 * pow(10.0,a-b);
819 FGEnvironment::set_live_update( bool _live_update )
821 bool b = live_update;
822 live_update = _live_update;
827 ////////////////////////////////////////////////////////////////////////
829 ////////////////////////////////////////////////////////////////////////
832 do_interp (double a, double b, double fraction)
834 double retval = (a + ((b - a) * fraction));
839 do_interp_deg (double a, double b, double fraction)
843 if (fabs(b-a) > 180) {
849 return fmod(do_interp(a, b, fraction), 360);
853 FGEnvironment::interpolate( const FGEnvironment & env2,
854 double fraction, FGEnvironment * result) const
856 // don't calculate each internal property every time we set a single value
857 // we trigger that at the end of the interpolation process
858 bool live_update = result->set_live_update( false );
860 result->set_visibility_m
861 (do_interp(get_visibility_m(),
862 env2.get_visibility_m(),
865 result->set_temperature_sea_level_degc
866 (do_interp(get_temperature_sea_level_degc(),
867 env2.get_temperature_sea_level_degc(),
870 result->set_dewpoint_sea_level_degc
871 (do_interp(get_dewpoint_sea_level_degc(),
872 env2.get_dewpoint_sea_level_degc(),
875 result->set_pressure_sea_level_inhg
876 (do_interp(get_pressure_sea_level_inhg(),
877 env2.get_pressure_sea_level_inhg(),
880 result->set_wind_from_heading_deg
881 (do_interp_deg(get_wind_from_heading_deg(),
882 env2.get_wind_from_heading_deg(),
885 result->set_wind_speed_kt
886 (do_interp(get_wind_speed_kt(),
887 env2.get_wind_speed_kt(),
890 result->set_elevation_ft
891 (do_interp(get_elevation_ft(),
892 env2.get_elevation_ft(),
895 result->set_turbulence_magnitude_norm
896 (do_interp(get_turbulence_magnitude_norm(),
897 env2.get_turbulence_magnitude_norm(),
900 result->set_turbulence_rate_hz
901 (do_interp(get_turbulence_rate_hz(),
902 env2.get_turbulence_rate_hz(),
905 // calculate derived properties here to avoid duplicate expensive computations
906 result->_recalc_ne();
907 result->_recalc_alt_pt();
908 result->_recalc_alt_dewpoint();
909 result->_recalc_density();
910 result->_recalc_relative_humidity();
912 result->set_live_update(live_update);
917 // end of environment.cxx