1
0
Fork 0

Merge remote branch 'gitorious/master'

This commit is contained in:
Tim Moore 2010-06-15 23:23:33 +02:00
commit 7f8c50d92d
21 changed files with 2039 additions and 185 deletions

BIN
Docs/KLSV-10_00.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

BIN
Docs/KLSV-12_00.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

BIN
Docs/KLSV-15_00.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

BIN
Docs/KLSV-17_30.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

BIN
Docs/KLSV-19_00.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

BIN
Docs/KLSV-5_00.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
Docs/KLSV-7_00.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

View file

@ -7,7 +7,7 @@
<body>
<h1>Local Weather Package - v0.61</h1>
<h1>Local Weather Package - v0.7</h1>
<h2>1. Introduction</h2>
@ -15,9 +15,9 @@ The aim of a local weather system is to simulate weather phenomena tied to speci
This is in contrast to the current (v.2.0.0) weather system of Flightgear where weather changes affect the weather everywhere in the simulated world and are (with few exceptions) not tied to specific locations. In such a system, it is impossible to observe e.g. the approach of a rainfront while flying in sunshine.<p>
The local weather package ultimately aims to provide the functionality to simulate such local phenomena. In version 0.61, the package supplies various cloud placement algorithms, as well as local control over most major weather parameters (visibility, pressure, temperature, rain, snow, thermal lift...) through interpolation routines and event volumes. For long-range flights, it automatically provides transitions between different weather patterns. However, basically all features currently present can and will eventually be improved.<p>
The local weather package ultimately aims to provide the functionality to simulate such local phenomena. In version 0.7, the package supplies various cloud placement algorithms, as well as local control over most major weather parameters (visibility, pressure, temperature, rain, snow, thermal lift, turbulence...) through interpolation routines and event volumes. The package contains a fairly detailed algorithm to generate convective clouds and thermals with a realistic distribution. For long-range flights, it automatically provides transitions between different weather patterns like fronts and low and high pressure areas. However, basically all features currently present can and will eventually be improved.<p>
As of version 0.61, the system does not contain dynamics (development of convective clouds, wind displacement of clouds...). Since wind and dynamics are closely related, any wind parameters can currently <i>not</i> be controlled from the local weather algorithms.<p>
As of version 0.7, the system does not contain dynamics (development of convective clouds, wind displacement of clouds...). Since wind and dynamics are closely related, any wind parameters can currently <i>not</i> be controlled from the local weather algorithms.<p>
<h2>2. Installation</h2>
@ -49,13 +49,13 @@ The pattern can then be randomized in x, y and altitude. Basically, specifying n
<h3>The convective system</h3>
The convective system places Cumulus clouds centered on the current position based on the underlying terrain. Currently it models daily variation of convective strength and the latitude variation based on a simple sinusoidal model (i.e. it produces different results when called in the morning than at noon), but it does not take into account seasonal variation (i.e. it assumes the date to be the equinox). This will be significantly improved in the future. The actual placement is chosen based on the type of the underlying terrain, with Cumulus development more likely over city areas than on water. The parameters for this need fine-tuning and are currently rather rough, but they lead for example to pronounced differences between land and sea in coastal regions. The following picture shows the result of a call of the system in the afternoon over TNCM.<p>
The convective system places Cumulus clouds centered on the current position based on the underlying terrain. Currently it models daily variation of convective strength and the latitude variation based on a simple sinusoidal model (i.e. it produces different results when called in the morning than at noon), but it does not take into account seasonal variation (i.e. it assumes the date to be the equinox). This will be significantly improved in the future. The actual placement is chosen based on the type of the underlying terrain, with Cumulus development more likely over city areas than on water. Details of the algorithm are described in the appendix. The parameters for this need fine-tuning and are currently rather rough, but they lead for example to pronounced differences between land and sea in coastal regions. The following picture shows the result of a call of the system in the afternoon over TNCM.<p>
<center>
<img src="clouds-cumulus_afternoon.jpg">
</center><p>
Clouds are placed in a constant altitude <i>alt</i> (this is going to be changed in the future) in a tile with given <i>size</i> where the size measures the distance to the tile border, i.e. a size parameter of 15 km corresponds to a 30x30 km region. Clouds are placed with constant density for given terrain type, so be careful with large area placements! <i>strength</i> is an overall multiplicative factor to fine-tune.
Unless 'Terrain presampling' is active, clouds are placed in a constant altitude <i>alt</i> in a tile with given <i>size</i> where the size measures the distance to the tile border, i.e. a size parameter of 15 km corresponds to a 30x30 km region. When 'Terrain presampling' is selected, the distribution of clouds in altitude is determined by a more complicated algorithm described in the appendix. Clouds are placed with constant density for given terrain type, so be careful with large area placements! <i>strength</i> is an overall multiplicative factor to fine-tune.
<h3>The barrier cloud system</h3>
@ -91,13 +91,18 @@ The second menu is used to place complete weather tiles based on low-level calls
The dropdown menu is used to select the type of weather tile to build. The menu contains two groups of tiles - the first six are classified by airmass, whereas the last two are scenarios intended for soaring. In addition, two parameters can be entered. The first is the tile orientation. Some tiles, most notably incoming fronts, have a direction along which the weather changes. The tiles are set up in such a way that fronts come from north, changing orientation rotates the whole tile to the specified direction. As soon as wind is implemented in the local weather system, the tile orientation will essentially also govern the wind direction (clearly, there is a relation between from where a front comes and the wind direction). Currently, the functionality of tile orientation is there, but mostly untested and at the moment not particularly useful.<p>
The second parameter, the altitude offset, is as of now a provisorium. Cloud layer placement calls are specified for absolute altitudes and calibrated at sea level. As a result, layers are placed too low in mountainous terrain. Eventually, the system is to receive a terrain presampling function to determine just where exactly low cloud layers should be placed when a weather tile is set up. Until this is in place, the user must manually specify a suitable altitude offset for all cloud layers.<p>
The second parameter, the altitude offset, is to manually adjust the altitude level of clouds in the absence of terrain presampling. Cloud layer placement calls are then specified for absolute altitudes and calibrated at sea level. As a result, layers are placed too low in mountainous terrain, hence the need for an offset. <p>
The dropdown menu for the tile selection mode controls the long-range behaviour of weather. It specifies according to what rules tiles are automatically generated once the aircraft reaches the border of the original tile. The option 'single tile' creates a single weather tile as specified without automatic generation of further tiles. The option 'repeat tile' creates new tiles of the same type as the originally selected tile. This does not mean that weather will be unchanged during flight, as both parameters like pressure, temperature and visibility as well as the positioning of cloud banks are randomized to some degree. In addition, each tile typically contains 2-5 different cloud scenarios, so five repeated generations of 'low-pressure-border' tiles may never result in the same arrangement of cloud layers. Necertheless, the option will keep weather conditions roughly the same. This is different with the (somewhat optimistically named) 'realistic weather'. This option allows transitions between different airmasses, thus one may select 'low-pressure-core' initially, but as the flight goes on, eventually a region of high pressure and clear skies may be reached. Currently this change between airmasses does not include transitions across fronts. Moreover, it does not cover arctic or tropical weather conditions - those will be covered in a future release. Note that 'realistic weather' does not work for the two soaring scenarios.<p>
The dropdown menu for the tile selection mode controls the long-range behaviour of weather. It specifies according to what rules tiles are automatically generated once the aircraft reaches the border of the original tile. The option 'single tile' creates a single weather tile as specified without automatic generation of further tiles. The option 'repeat tile' creates new tiles of the same type as the originally selected tile. This does not mean that weather will be unchanged during flight, as both parameters like pressure, temperature and visibility as well as the positioning of cloud banks are randomized to some degree. In addition, each tile typically contains 2-5 different cloud scenarios, so five repeated generations of 'low-pressure-border' tiles may never result in the same arrangement of cloud layers. Necertheless, the option will keep weather conditions roughly the same. This is different with the (somewhat optimistically named) 'realistic weather'. This option allows transitions between different airmasses, thus one may select 'low-pressure-core' initially, but as the flight goes on, eventually a region of high pressure and clear skies may be reached. Currently this change between airmasses does not include transitions across fronts. Moreover, it does not cover transitions to arctic or tropical weather conditions - those will be covered in a future release. Note that 'realistic weather' does not work for the two soaring scenarios, 'repeat tile' does not work for any tile which is part of a front.<p>
The menu then contains four options. 'Terrain presampling' is currently not yet functional. 'Worker threads' is an option to distribute the work flow. Usually, the local weather package will compute a task till it is done before starting the next. Thus, creating a new weather tile may lead to a few seconds freeze, before Flightgear continues normally. With 'worker threads' selected, computations will be split across several frames. The advantage is that Flightgear stays responsive during loading and unloading of weather tiles, and in general the flight continues smoothly, albeit with reduced framerate. However, selecting this option does not guarantee that an operation is finished by the time another is beginning - thus there may be situations in which the loading of a new tile blocks unloading of an old one and so on, in essence leading to processes competing for access to the weather array, resulting in an extended period of very low framerates. Dependent on system performance, this may or may not be acceptable to the user. 'asymmetric range' is an experimental performance-improving option (see below). Finally, 'detailed clouds' will change the technique for generating Cumulus clouds from a multilayer model to multiple cloudlets filling a box. This improves the visual appearance of the clouds significantly, albeit at the expense of a (significant) loss of framerate. Rendering multiple tiles of dense Cumulus development with detailed clouds will quite possibly freeze even a powerful system. <p>
The final option, 'METAR', generates weather according to parsed METAR information. This information must be made available in the property tree. Currently this is <b>not</b> done automatically and the METAR system does <b>not</b> work with real-weather-fetch, this needs some work on the Flightgear core.<p>
Below the menu are four tickboxes. 'Terrain presampling' finds the distribution of altitude in the terrain before placing a cloud layer. As a result, the layers or clouds are automatically placed at the correct altitude above ground in level terrain. In mountain regions, cloud placement is fairly tricky, and the algorithm analyzes quantities like the median altitude to determine what to do. The appendix contains a detailed description of the algorithm. If the box is ticked, the altitude offset specified above is not parsed.<p>
'Worker threads' is an option to distribute the work flow. Usually, the local weather package will compute a task till it is done before starting the next. Thus, creating a new weather tile may lead to a few seconds freeze, before Flightgear continues normally. With 'worker threads' selected, computations will be split across several frames. The advantage is that Flightgear stays responsive during loading and unloading of weather tiles, and in general the flight continues smoothly, albeit with reduced framerate. However, selecting this option does not guarantee that an operation is finished by the time another is beginning - thus there may be situations in which the loading of a new tile blocks unloading of an old one and so on, in essence leading to processes competing for access to the weather array, resulting in an extended period of very low framerates. Dependent on system performance, this may or may not be acceptable to the user. 'asymmetric range' is an experimental performance-improving option (see below). Finally, 'detailed clouds' will change the technique for generating Cumulus clouds from a multilayer model to multiple cloudlets filling a box. This improves the visual appearance of the clouds significantly, albeit at the expense of a (significant) loss of framerate. Rendering multiple tiles of dense Cumulus development with detailed clouds will quite possibly freeze even a powerful system. <p>
The slider 'Thermal properties' is only relevant for soaring scenarios. It governs the rato of maximum lift to radius of a thermal. A setting close to 'low convection' creates large thermals with relatively small lift and virtually no turbulence, a setting close to 'rough day' creates very narrow, turbulent thermals with large lift. Unless thermals are placed, no other weather tile is affected by the settings.<p>
The following pictures show the results of tile setups 'Low-pressure-border' and 'High-pressure-border':<p>
@ -119,6 +124,12 @@ The package contains a number of different cloud models, both static ones for Ci
These are rendered by a different technique: While the default Cumulus models consist of multiple layers rotated around the center of the model, the detailed Cumulus clouds consist of multiple (up to 24) individual cloudlets, rotating each around its own center, randomly distributed into a box. This not only improves the visual appearance, but also leads to a more realistic distribution of cloud sizes and shapes in the sky. In addition, when circling below the cloud (as done when soaring) the effect of the cloudlet rotation is less pronounced. The price to pay is that rendering detailed clouds costs about a factor 4 more performance, so they may not be suitable for all systems.<p>
More complex clouds are rendered in sandwitched layers of several different textures. An example are Cumulonimbus towers, which use diffuse textures on the bottom, changing to more structured textures in the upper part of the cloud. With up to 2000 cloudlets, skies with multiple thunderstorms may not render with sufficient framerates on every system.<p>
<center>
<img src="clouds-tropical02.jpg">
</center><p>
The general problem is finding a good balance between spending a lot of CPU time to make a single cloud model appear perfect, and the performance degradation that occurs if hundreds of clouds are placed in the sky. The basic aim is to provide realistic appearance for clouds from a standard view position (in cockpit looking forward), to retain acceptable appearance from other positions and to allow large cloud layers.<p>
@ -171,9 +182,11 @@ The <i>local-weather/effect-volumes/</i> subfolder contains the management of th
<i>local-weather/tiles</i> stores the information of the 9 managed weather tiles (the one the airplane is currently in, and the 8 surrounding it). By default each directory contains the tile center coordinates and a flag if it has been generated. Tiles are not generated unless a minimum distance to the tile center has been reached. Once this happens, the tile type is written as a code, and the cloud, interpolation and effect volume information corresponding to the tile is generated. <p>
<i>local-weather/METAR</i> is used to store the METAR information for the METAR based tile setup. This must include latitude, longitude and altitude of a weather station, temperature, dewpoint, pressure, wind direction and speed, rain, snow and thunderstorm information as well as cloud layer altitude and coverage in oktas. Any properties set here will be executed when 'METAR' is selected as tile selection mode as long as <i>local-weather/METAR/available-flag</i> is set to 1 (this flag is set to zero whenever a tile has been created from METAR info to indicate that the information has been used, so if the user wants to reuse the information, then the flag must be reset).<p>
<h2>7. Weather tile setup</h2>
Examples for weather tile setup can be found in <i>Nasal/weather-tiles.nas</i>. Each tile is generated by a sequence of Nasal function calls to first set weather stations, then to draw the cloud layers, and effect volumes. Finally, all necessary loops must be started. It is a bit awkward to have to write in Nasal to customize the system, but I can't think of a reasonable GUI for the task, except marking every placement on a map which exceeds my coding skills a bit. The problem is that there is no real standard solution - every weather tile needs different calls, sometimes a large one generating many clouds, sometimes several smaller ones.<p>
Examples for weather tile setup can be found in <i>Nasal/weather-tiles.nas</i>. Each tile is generated by a sequence of Nasal function calls to first set weather stations, then to draw the cloud layers, and effect volumes. It is a bit awkward to have to write in Nasal to customize the system, but I can't think of a reasonable GUI for the task, except marking every placement on a map which exceeds my coding skills a bit. The problem is that there is no real standard solution - every weather tile needs different calls, sometimes a large one generating many clouds, sometimes several smaller ones.<p>
The first important call sets up the conditions to be interpolated:<p>
@ -193,7 +206,7 @@ With default settings, the local weather package generates a 40x40 km weather ti
* a further reduction in the amount of simultaneously generated tiles can be achieved by changing the ranges. These are exposed in the property tree as <i>local-weather/config/distance-to-load-tile-m</i> and <i>local-weather/config/distance-to-remove-tile-m</i>. Note that the removal range <b>must</b> be larger than the loading range - otherwise just generated tiles will be immediately unloaded! Ranges below 20 km will guarantee that only one tile is loaded at a time, but will create empty spots when no tile is loaded. A range above 28 km will guarantee that the aircraft never flies in an empty tile, but empty sky in front will be visible. Finally, ranges above 56 km guarantee that all 9 tiles (a region of 120x120 km) are managed at all times - but will most likely cause a severe drop in framerate for most scenarios.<p>
* if this does not help, try avoiding scenarios with large cloud count. As a rule, low pressure areas have high cloud count, high pressure areas have a low cloud count. <p>
* if this does not help, try avoiding scenarios with large cloud count. As a rule, low pressure areas have high cloud count, high pressure areas have a low cloud count. Do not use 'detailed clouds', which tend to generate large cloud counts.<p>
* a drastic solution is to set the visual ranges lower. Currently, cloud models are set to be visible up to 30 km. Changing the visibility range in the range animation of all cloud model xml wrappers will improve performance accordingly. To achieve a nice fading into the background instead of a sudden disappearance, it is recommended to adjust the visibility range in the shaders accordingly. It would probably be good to expose the visual range as a property, but currently it's not yet done, as passing a property to the shader requires Flightgear CVS and cannot be done in 2.0.0.<p>
@ -209,18 +222,130 @@ Performance for overcast layers currently is a limiting issue and there are a fe
* Rain and snow may not start properly. For me, rain is only generated when I switch 'Shader effects' on and off in the menu on startup, otherwise neither moving the menu slider nor entering an effect volume generate rain. This seems to be a bug of some Flightgear versions, not of the local weather system.<p>
* Especially with multiple overcast layers, loading and unloading weather tiles may take a long time / cause severe drops in framerate. Please refer to performance tuning to solve such problems. In general, overcast layers do require a system on the high end of the performance scale to render properly.<p>
* Especially with multiple overcast layers and weather fronts, loading and unloading weather tiles may take a long time / cause severe drops in framerate. Please refer to performance tuning to solve such problems. In general, overcast layers and tropical weather tiles do require a system on the high end of the performance scale to render properly.<p>
* The local weather package is able to occasionally trigger errors like 'Warning:: Picked up error in TriangleIntersect'. These seem to be a problem in the core Flightgear code - the package does nothing but placing normal (rather simple) AC3D models into the scenery.<p>
* The thermals in the soaring scenarios need a CVS patch to work.<p>
<h2>10. Credits</h2>
<h2><a name="appendix_A">Appendix A: An introduction to the algorithms</a></h2>
This section describes the more complicated cloud placement algorithms in some detail. It is intended for readers who are interested in understanding (and possibly modifying) what creates the weather they get to see.
<h3>The convective algorithm and the properties of thermals</h3>
The convective algorithm is used to place Cumulus clouds as well as thermals. Thermals are by default not placed to save CPU time unless a tile designed for soaring is selected, but they can be generated for any weather tile by setting <i>local-weather/tmp/generate-thermal-lift-flag</i> to either 1 (constant-strength thermals) or 2 (detailed thermal model).<p>
At the core of the convective algorithm is the concept of locally available thermal energy. The source of this energy is solar radiation. The flux of solar energy depends on the angle of incident sunlight with the terrain surface. It is possibly (though computationally very expensive) to compute this quantity, but the algorithm uses a proxy instead. The daily angle of the sun at the equator assuming flat terrain is modelled as <i>0.5 * (1.0-cos(t/24.0*2pi))</i> with t expressed in hours, a function that varies between zero at midnight and 1 at noon. There is a geographical correction to this formula which goes with <i>cos(latitude)</i>, taking care of the fact that the sun does not reach the zenith at higher latitudes. Both the yearly summer/winter variation of the solar position in the sky and the terrain slope are neglected.<p>
However, the incident energy does not equal the available energy, since some of this energy is reflected back into space, either by high clouds, or by the terrain itself. The reflection by high clouds is not explicitly included in the algorithm - but since in creating a weather tile, one must setup both the high altitude clouds and the convective system, it can easily be included approximately by calling the convective system with a strength that is reduced according to the density of high-altitude clouds. The reflection by the terrain is encoded in the probability <i>p</i> that a given landcover will lead to a thermal. <i>p</i> ranges from 0.35 for rock or concrete surface which heat very well in the sun to 0.01 over water or ice which reflect most of the energy back into space.<p>
The algorithm now tries to place a number <i>n</i> of clouds in a random position where <i>n</i> is a function of the user-specified strength of development, modified by the daily and geographical factors as described above. However, a cloud is only placed at a position with probability <i>p</i>, so a call to the convective system over city terrain will lead to significantly more clouds than a call with the same strength over water.<p>
The next task is to determine how the available thermal energy is released in convection across different thermals. There can be for example many weak thermals, or few strong thermals for the same energy. The empirical observation is that the number of thermals and clouds peaks around noon, whereas the strength of thermals peaks in the afternoon. The algorithm thus assigns a strength <i>1.5 * rand() + (2.0 * p))</i> to each cloud, which is again modified by a sinusoidal function with a peak shifted from noon to 15:30.<p>
Based on this strength parameter <i>s</i>, a cloud model is chosen, and the maximal thermal lift (in ft/s) is calculated as <i>3 + 1 * (s -1)</i> (note that this means that not every cloud is associated with lift). By default, the radius of thermals is assumed to range from 500 to 1000 m. The slider 'thermal properites' in the menu allows to modify the balance between radius and lift from these values. Since the flow profile in a thermal is approximately quadratic, requiring the same flux means that increasing the maximal lift by a factor <i>f</i> leads to a radius reduced by <i>1/f</i>. Moving the thermal properties slider to 'rough day' thus generates narrow thermals with large maximal lift and sink (which are more difficult to fly), moving it to low convection instead generates large thermals with weak lift.<p>
The following series of pictures, taken over KLSV (Nellis AFB, Las Vegas) illustrates the algorithm at work.<p>
At 7:00 am, the thermal activity is weak, and there is no lift available in thermals yet.<p>
<center>
<img src="./KLSV-7_00.jpg">
</center><p>
Some activity starts around 10:00 am the average available lift is 0.3 m/s, the more active clouds tend to be above city terrain.
<center>
<img src="KLSV-10_00.jpg">
</center><p>
At 12:00 noon, the maximal cloud number is reached. The average available lift is 1 m/s, in peaks up to 2 m/s.
<center>
<img src="KLSV-12_00.jpg">
</center><p>
The maximum of lift strength is reached close to 15:00 pm. The average lift is now 1.5 m/s, in peaks up to 3 m/s, and the strong convection leads to beginning overdevelopment, some clouds reach beyond the first inversion layer and tower higher up. At this point, the clouds may also overdevelop into a thunderstorm (which is not modelled explicitly by the convective algorithm as it requires somewhat different modelling, but is taken into account in the weather tiles).<p>
<center>
<img src="KLSV-15_00.jpg">
</center><p>
At 17:30 pm, the lift is still strong, 1.5 m/s on average and 2.5 m/s in peaks, but compared with the situation at noon, there are fewer clouds with stronger lift.<p>
<center>
<img src="KLSV-17_30.jpg">
</center><p>
At sunset around 19:00 pm, the number of clouds decreases quickly, but there is still a lot of residual thermal energy (the ground has not cooled down yet), therefore thermal lift of on average 1 m/s is still available even without solar energy input.
<center>
<img src="KLSV-19_00.jpg">
</center><p>
While not accurate in every respect, the model works fairly well to reproduce the actual time dependence of convective clouds and thermal lift during the day.<p>
<h3>The terrain presampling and cloud altitude determination algorithm</h3>
While the meaning of a cloud layer altitude is rather obvious in level terrain, this quickly becomes a highly non-trivial question in mountaineous terrain where the elevation of the terrain is more difficult to define. Observation of weather patterns in mountain regions suggests that clouds follow changes in terrain elevation to some degree, but not all cloud types do to the same degree. While convective clouds follow a change in elevation more readily even on small distance scales, layered clouds don't do so. The purpose of the terrain presampling and cloud altitude determination algorithm is to capture this behaviour as closely as possible.<p>
In nature, what determines the altitude of various clouds are the properties of air layers. In general, clouds become visible at the condensation altitude, i.e. when temperature and dew point merge and the relative humidity of air exceeds 100%. In conditions where there is a lot of vertical air movement (i.e. for Cumulus clouds), the conditions are much more local than in situations with lack of vertical movement (i.e. for layered clouds).<p>
In the algorithm, various proxies for the structure of air layers and hence the condensation altitude are used. It is assumed that air layers must follow the general slope of the terrain (because there is nowhere else to go), but can (at least to some degree) flow around isolated obstacles. To get the general layout of the terrain, the algorithm first samples the altitude of an 80x80 km square around the 40x40 weather tile to be created. The choice of a larger sampling area reduces the sensitvity of the outcome to purely local terrain features and prevent pronounced transitions from one tile to the next. The result of this sampling is a distribution of probability to find the terrain at a given altitude:<p>
<center>
<img src="terrain1.jpg">
</center><p>
For instance, the terrain around Geneva is mostly flat around 1000 ft (where the peak of the distribution lies) with some mountains up to 4500 ft nearby. Based on such distributions, the algorithm next determines the minimum altitude <i>alt_min</i>, the maximum altitude <i>alt_max</i>, the altitude below which 20% of the terrain are found <i>alt_20</i> and the median altitude below which 50% of the terrain are found <i>alt_med</i>.<p>
Cumulus clouds are always placed at a constant altitude above <i>alt_20</i>. This is done to ensure gorges and canyons do not provide a minimum in otherwise flat terrain so that clouds appear down in the gorge as opposed to on the rim where they would naturally occur. Basically, layers are assumed not to trace too fine structures in the terrain, so at least 20% of the terrain are required. In the test case of Grand Canyon, the algorithm correctly places the clouds at rim altitude rather than down in the canyon:
<center>
<img src="cloud_altitude_02.jpg">
</center><p>
However, convective clouds are given some freedom to adjust to the terrain. The maximally possible upward shift is given by <i>alt_med - alt_20</i>. This is based on the notion that above <i>alt_med</i>, the terrain is not a significant factor any more because the air can simply flow around any obstacle. However, this maximal shift is not always used - if the cloud is placed far above the terrain in the first place, it would not follow the terrain much. Thus, a factor of <i>1000 ft / altitude above terrain</i>, required to be between 0 and 1, modifies the shift. As a result, a cloud layer placed high above the terrain has no sensitivity to terrain features. The result of this procedure is that clouds show some degree of following terrain elevation, as seen here in Grenoble<p>
<center>
<img src="cloud_altitude_03.jpg">
</center><p>
but they do not follow all terrain features, especially not single isolated peaks as seen here at the example of Mt. Rainier:
<center>
<img src="cloud_altitude_01.jpg">
</center><p>
Finally, layered clouds have essentially no capability to shift with terrain elevation. Moreover, they are caused by large-scale weather processes, hence they do not usually shift upward over even large mountain massives. Currently, the model places them at <i>0.5 * (alt_min + alt_20)</i> base altitude in order to retain, even in mountains, the sensitivity to the flat terrain surrounding the massiv. usually this works well, but may have a problem with gorges in flat terrain. The following picture shows a Nimbostratus layer close to Grenoble:<p>
<center>
<img src="cloud_altitude_04.jpg">
</center><p>
<h3>The offline large scale weather pattern</h3>
The local weather package generates semi-plausible weather changes even in the absence of METAR information. These weather patterns are encoded in an algorithm governing the rules which weather tiles can have common borders.<p>
Weather tiles are classified chiefly by air pressure. What is currently in the models are three classes for a low pressure system, four different classes for the system of weather fronts and airmasses spiralling into the low pressure system and three classes for a hugh pressure system. The general rule is that low pressure tiles contain layered clouds, overcast skies and rain whereas the high pressure tiles contain clear skies and few convective clouds. The topology assumed for the weather system is apparent in the following diagram:
<center>
<img src="weather_patterns.jpg">
</center><p>
A transition between classes is possible whenever a class has a common border. However, if a transition actually takes place is probabilistic. Typically, the probability not to make a transition is about 80%. Since changes are only triggered for weather tiles one is actually in, the average distance over which weather patterns persist is 160 km. An exception to this are fronts - weather front tiles trigger changes based on direction rather than probability, so a warmfront will always be a sequence of 4 tiles, a coldfront will always be a small-scale phenomenon crossed within 30 km.
To avoid unrealistically large changes in pressure when generating a transition and randomly sampling central pressure in tiles from two different pressure classes, a monitoring algorithm limits the pressure difference between tiles to 2 mbar and ensures a slow transition from high pressure to low pressure regions.<p>
The weather algorithm is currently not able to handle the transition to tropical weather in the Hadley cell close to the equator, although tropical weather exists as a standalone tile and can be used in repetitive mode.<p>
<h2>Credits</h2>
The model of a thermal has been developed by Patrice Poly. The shader code used to transform clouds is heavily based on prior work by Stuart Buchanan.<p>
Thorsten Renk, May 2010
Thorsten Renk, June 2010
</body>

BIN
Docs/cloud_altitude_01.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
Docs/cloud_altitude_02.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

BIN
Docs/cloud_altitude_03.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

BIN
Docs/cloud_altitude_04.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
Docs/clouds-tropical02.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 19 KiB

BIN
Docs/terrain1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
Docs/weather_patterns.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View file

@ -88,19 +88,13 @@
</high>
</axis>
<!-- Buttons on the Yoke -->
<button n="0"> <!-- Labled as E -->
<desc>Change View</desc>
<binding>
<command>nasal</command>
<script>
v = getprop("/sim/current-view/view-number");
v = v + 1;
if (v > 4) {
v = 0;
}
setprop("/sim/current-view/view-number", v);
</script>
</binding>
<button n="0">
<desc>Cycle View</desc>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>view.stepView(1)</script>
</binding>
</button>
<button n="1"> <!-- Labled as D -->
<desc>Toggle parking break</desc>
@ -217,4 +211,26 @@
</binding>
</mod-up>
</button>
<button n="20">
<desc>thrust reverse</desc>
<repeatable type="bool">false</repeatable>
<binding>
<command>nasal</command>
<script>
props.setAll("/controls/engines/engine", "reverser", 1);
props.setAll("/controls/engines/engine", "throttle", 1);
gui.popupTip("Thrust reverse on!");
</script>
</binding>
<mod-up>
<binding>
<command>nasal</command>
<script>
props.setAll("/controls/engines/engine", "reverser", 0);
props.setAll("/controls/engines/engine", "throttle", 0);
gui.popupTip("Thrust reverse off!");
</script>
</binding>
</mod-up>
</button>
</PropertyList>

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,7 @@ var tile_management_loop = func {
var tNode = props.globals.getNode(lw~"tiles", 1).getChildren("tile");
var viewpos = geo.aircraft_position(); # using viewpos here triggers massive tile ops for tower view...
var code = getprop(lw~"tiles/code");
var code = getprop(lw~"tiles/tile[4]/code");
var i = 0;
var d_min = 100000.0;
var i_min = 0;
@ -46,8 +46,9 @@ foreach (var t; tNode) {
{
setprop(lw~"tiles/tile-counter",getprop(lw~"tiles/tile-counter")+1);
print("Building tile unique index ",getprop(lw~"tiles/tile-counter"));
generate_tile(code, tpos.lat(), tpos.lon(),0);
generate_tile(code, tpos.lat(), tpos.lon(),i);
t.getNode("generated-flag").setValue(1);
t.getNode("code",1).setValue(getprop(lw~"tiles/code"));
t.getNode("tile-index",1).setValue(getprop(lw~"tiles/tile-counter"));
}
@ -68,6 +69,8 @@ foreach (var t; tNode) {
change_active_tile(i_min);
}
if (getprop(lw~"tile-loop-flag") ==1) {settimer(tile_management_loop, 5.0);}
}
@ -77,10 +80,31 @@ if (getprop(lw~"tile-loop-flag") ==1) {settimer(tile_management_loop, 5.0);}
# tile generation call
###################################
var generate_tile = func (code, lat, lon, index) {
var generate_tile = func (code, lat, lon, dir_index) {
setprop(lw~"tiles/tmp/latitude-deg", lat);
setprop(lw~"tiles/tmp/longitude-deg",lon);
setprop(lw~"tiles/tmp/code",code);
# now see if we need to presample the terrain
if ((getprop(lw~"tmp/presampling-flag") == 1) and (getprop(lw~"tmp/presampling-status") == "idle"))
{
local_weather.terrain_presampling_start(lat, lon, 1000, 40000, getprop(lw~"tmp/tile-orientation-deg"));
return;
}
# now allow for some change in tile orientation
var alpha = getprop(lw~"tmp/tile-orientation-deg");
alpha = alpha + 2.0 * (rand()-0.5) * 10.0;
# account for the systematic spin of weather systems around a low pressure core dependent on hemisphere
if (lat >0.0) {alpha = alpha -3.0;}
else {alpha = alpha +3.0;}
setprop(lw~"tmp/tile-orientation-deg",alpha);
if (getprop(lw~"tmp/tile-management") == "repeat tile")
{
@ -97,6 +121,9 @@ if (getprop(lw~"tmp/tile-management") == "repeat tile")
else if (code == "low_pressure_border") {weather_tiles.set_low_pressure_border_tile();}
else if (code == "low_pressure") {weather_tiles.set_low_pressure_tile();}
else if (code == "low_pressure_core") {weather_tiles.set_low_pressure_core_tile();}
else if (code == "cold_sector") {weather_tiles.set_cold_sector_tile();}
else if (code == "warm_sector") {weather_tiles.set_warm_sector_tile();}
else if (code == "tropical_weather") {weather_tiles.set_tropical_weather_tile();}
}
else if (getprop(lw~"tmp/tile-management") == "realistic weather")
{
@ -104,38 +131,108 @@ else if (getprop(lw~"tmp/tile-management") == "realistic weather")
if (code == "low_pressure_core")
{
if (rn > 0.3) {weather_tiles.set_low_pressure_core_tile();}
if (rn > 0.2) {weather_tiles.set_low_pressure_core_tile();}
else {weather_tiles.set_low_pressure_tile();}
}
else if (code == "low_pressure")
{
if (rn > 0.3) {weather_tiles.set_low_pressure_tile();}
else if (rn > 0.15) {weather_tiles.set_low_pressure_core_tile();}
if (rn > 0.2) {weather_tiles.set_low_pressure_tile();}
else if (rn > 0.1) {weather_tiles.set_low_pressure_core_tile();}
else {weather_tiles.set_low_pressure_border_tile();}
}
else if (code == "low_pressure_border")
{
if (rn > 0.3) {weather_tiles.set_low_pressure_border_tile();}
else if (rn > 0.15) {weather_tiles.set_low_pressure_tile();}
if (rn > 0.4) {weather_tiles.set_low_pressure_border_tile();}
else if (rn > 0.3) {weather_tiles.set_cold_sector_tile();}
else if (rn > 0.2) {weather_tiles.set_warm_sector_tile();}
else if (rn > 0.1) {weather_tiles.set_low_pressure_tile();}
else {weather_tiles.set_high_pressure_border_tile();}
}
else if (code == "high_pressure_border")
{
if (rn > 0.3) {weather_tiles.set_high_pressure_border_tile();}
else if (rn > 0.15) {weather_tiles.set_high_pressure_tile();}
if (rn > 0.4) {weather_tiles.set_high_pressure_border_tile();}
else if (rn > 0.3) {weather_tiles.set_cold_sector_tile();}
else if (rn > 0.2) {weather_tiles.set_warm_sector_tile();}
else if (rn > 0.1) {weather_tiles.set_high_pressure_tile();}
else {weather_tiles.set_low_pressure_border_tile();}
}
else if (code == "high_pressure")
{
if (rn > 0.3) {weather_tiles.set_high_pressure_tile();}
else if (rn > 0.15) {weather_tiles.set_high_pressure_border_tile();}
if (rn > 0.2) {weather_tiles.set_high_pressure_tile();}
else if (rn > 0.1) {weather_tiles.set_high_pressure_border_tile();}
else {weather_tiles.set_high_pressure_core_tile();}
}
else if (code == "high_pressure_core")
{
if (rn > 0.3) {weather_tiles.set_high_pressure_core_tile();}
if (rn > 0.2) {weather_tiles.set_high_pressure_core_tile();}
else {weather_tiles.set_high_pressure_tile();}
}
else if (code == "cold_sector")
{
if (rn > 0.3) {weather_tiles.set_cold_sector_tile();}
else if (rn > 0.2)
{
if ((dir_index ==0) or (dir_index ==1) or (dir_index==2))
{weather_tiles.set_warmfront1_tile();}
else if ((dir_index ==3) or (dir_index ==5))
{weather_tiles.set_cold_sector_tile();}
else if ((dir_index ==6) or (dir_index ==7) or (dir_index==8))
{weather_tiles.set_coldfront_tile();}
}
else if (rn > 0.1) {weather_tiles.set_low_pressure_border_tile();}
else {weather_tiles.set_high_pressure_border_tile();}
}
else if (code == "warm_sector")
{
if (rn > 0.3) {weather_tiles.set_warm_sector_tile();}
else if (rn > 0.2)
{
if ((dir_index ==0) or (dir_index ==1) or (dir_index==2))
{weather_tiles.set_coldfront_tile();}
else if ((dir_index ==3) or (dir_index ==5))
{weather_tiles.set_warm_sector_tile();}
else if ((dir_index ==6) or (dir_index ==7) or (dir_index==8))
{weather_tiles.set_warmfront4_tile();}
}
else if (rn > 0.1) {weather_tiles.set_low_pressure_border_tile();}
else {weather_tiles.set_high_pressure_border_tile();}
}
else if (code == "warmfront1")
{
if ((dir_index ==0) or (dir_index ==1) or (dir_index==2))
{weather_tiles.set_warmfront2_tile();}
else if ((dir_index ==3) or (dir_index ==5))
{weather_tiles.set_warmfront1_tile();}
else if ((dir_index ==6) or (dir_index ==7) or (dir_index==8))
{weather_tiles.set_cold_sector_tile();}
}
else if (code == "warmfront2")
{
if ((dir_index ==0) or (dir_index ==1) or (dir_index==2))
{weather_tiles.set_warmfront3_tile();}
if ((dir_index ==3) or (dir_index ==5))
{weather_tiles.set_warmfront2_tile();}
if ((dir_index ==6) or (dir_index ==7) or (dir_index==8))
{weather_tiles.set_warmfront1_tile();}
}
else if (code == "warmfront3")
{
if ((dir_index ==0) or (dir_index ==1) or (dir_index==2))
{weather_tiles.set_warmfront4_tile();}
if ((dir_index ==3) or (dir_index ==5))
{weather_tiles.set_warmfront3_tile();}
if ((dir_index ==6) or (dir_index ==7) or (dir_index==8))
{weather_tiles.set_warmfront2_tile();}
}
else if (code == "warmfront4")
{
if ((dir_index ==0) or (dir_index ==1) or (dir_index==2))
{weather_tiles.set_warm_sector_tile();}
if ((dir_index ==3) or (dir_index ==5))
{weather_tiles.set_warmfront4_tile();}
if ((dir_index ==6) or (dir_index ==7) or (dir_index==8))
{weather_tiles.set_warmfront3_tile();}
}
} # end if mode == realistic weather
}
@ -152,8 +249,6 @@ var n = 100;
var flag_mod = 0;
#var mvec = props.globals.getNode("models", 1).getChildren("model");
#var msize = size(mvec);
var status = getprop(lw~"tmp/thread-status");
@ -286,6 +381,7 @@ var lat = t.getNode("latitude-deg").getValue();
var lon = t.getNode("longitude-deg").getValue();
var alpha = getprop(lw~"tmp/tile-orientation-deg");
if (index == 0)
{
copy_entry(4,8);
@ -383,6 +479,7 @@ else if (index == 8)
create_neighbour(lat,lon,8,alpha);
}
}
#####################################
@ -400,6 +497,7 @@ t.getNode("latitude-deg").setValue(f.getNode("latitude-deg").getValue());
t.getNode("longitude-deg").setValue(f.getNode("longitude-deg").getValue());
t.getNode("generated-flag").setValue(f.getNode("generated-flag").getValue());
t.getNode("tile-index").setValue(f.getNode("tile-index").getValue());
t.getNode("code").setValue(f.getNode("code").getValue());
}
#####################################
@ -426,6 +524,7 @@ t.getNode("latitude-deg",1).setValue(blat + get_lat(x,y,phi));
t.getNode("longitude-deg",1).setValue(blon + get_lon(x,y,phi));
t.getNode("generated-flag",1).setValue(0);
t.getNode("tile-index",1).setValue(-1);
t.getNode("code",1).setValue("");
}
#####################################
@ -446,24 +545,28 @@ setprop(lw~"tiles/tile[0]/latitude-deg",blat + get_lat(x,y,phi));
setprop(lw~"tiles/tile[0]/longitude-deg",blon + get_lon(x,y,phi));
setprop(lw~"tiles/tile[0]/generated-flag",0);
setprop(lw~"tiles/tile[0]/tile-index",-1);
setprop(lw~"tiles/tile[0]/code","");
x = 0.0; y = 40000.0;
setprop(lw~"tiles/tile[1]/latitude-deg",blat + get_lat(x,y,phi));
setprop(lw~"tiles/tile[1]/longitude-deg",blon + get_lon(x,y,phi));
setprop(lw~"tiles/tile[1]/generated-flag",0);
setprop(lw~"tiles/tile[1]/tile-index",-1);
setprop(lw~"tiles/tile[1]/code","");
x = 40000.0; y = 40000.0;
setprop(lw~"tiles/tile[2]/latitude-deg",blat + get_lat(x,y,phi));
setprop(lw~"tiles/tile[2]/longitude-deg",blon + get_lon(x,y,phi));
setprop(lw~"tiles/tile[2]/generated-flag",0);
setprop(lw~"tiles/tile[2]/tile-index",-1);
setprop(lw~"tiles/tile[2]/code","");
x = -40000.0; y = 0.0;
setprop(lw~"tiles/tile[3]/latitude-deg",blat + get_lat(x,y,phi));
setprop(lw~"tiles/tile[3]/longitude-deg",blon + get_lon(x,y,phi));
setprop(lw~"tiles/tile[3]/generated-flag",0);
setprop(lw~"tiles/tile[3]/tile-index",-1);
setprop(lw~"tiles/tile[3]/code","");
# this is the current tile
x = 0.0; y = 0.0;
@ -471,30 +574,36 @@ setprop(lw~"tiles/tile[4]/latitude-deg",blat + get_lat(x,y,phi));
setprop(lw~"tiles/tile[4]/longitude-deg",blon + get_lon(x,y,phi));
setprop(lw~"tiles/tile[4]/generated-flag",1);
setprop(lw~"tiles/tile[4]/tile-index",1);
setprop(lw~"tiles/tile[4]/code","");
x = 40000.0; y = 0.0;
setprop(lw~"tiles/tile[5]/latitude-deg",blat + get_lat(x,y,phi));
setprop(lw~"tiles/tile[5]/longitude-deg",blon + get_lon(x,y,phi));
setprop(lw~"tiles/tile[5]/generated-flag",0);
setprop(lw~"tiles/tile[5]/tile-index",-1);
setprop(lw~"tiles/tile[5]/code","");
x = -40000.0; y = -40000.0;
setprop(lw~"tiles/tile[6]/latitude-deg",blat + get_lat(x,y,phi));
setprop(lw~"tiles/tile[6]/longitude-deg",blon + get_lon(x,y,phi));
setprop(lw~"tiles/tile[6]/generated-flag",0);
setprop(lw~"tiles/tile[6]/tile-index",-1);
setprop(lw~"tiles/tile[6]/code","");
x = 0.0; y = -40000.0;
setprop(lw~"tiles/tile[7]/latitude-deg",blat + get_lat(x,y,phi));
setprop(lw~"tiles/tile[7]/longitude-deg",blon + get_lon(x,y,phi));
setprop(lw~"tiles/tile[7]/generated-flag",0);
setprop(lw~"tiles/tile[7]/tile-index",-1);
setprop(lw~"tiles/tile[7]/code","");
x = 40000.0; y = -40000.0;
setprop(lw~"tiles/tile[8]/latitude-deg",blat + get_lat(x,y,phi));
setprop(lw~"tiles/tile[8]/longitude-deg",blon + get_lon(x,y,phi));
setprop(lw~"tiles/tile[8]/generated-flag",0);
setprop(lw~"tiles/tile[8]/tile-index",-1);
setprop(lw~"tiles/tile[8]/code","");
}
###################

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,7 @@
<name>local_weather_tiles</name>
<width>300</width>
<height>300</height>
<height>330</height>
<modal>false</modal>
@ -19,7 +19,7 @@
<combo>
<x>10</x>
<y>220</y>
<y>270</y>
<width>280</width>
<height>25</height>
<live>true</live>
@ -30,6 +30,13 @@
<value>Low-pressure-border</value>
<value>Low-pressure</value>
<value>Low-pressure-core</value>
<value>Cold-sector</value>
<value>Coldfront</value>
<value>Warmfront-1</value>
<value>Warmfront-2</value>
<value>Warmfront-3</value>
<value>Warmfront-4</value>
<value>Tropical</value>
<value>---</value>
<!--<value>Altocumulus sky</value>-->
<!--<value>Broken layers</value>-->
@ -39,7 +46,7 @@
<value>Blue thermals</value>
<!--<value>Incoming rainfront</value>-->
<!--<value>8/8 stratus sky</value>-->
<!--<value>Test tile</value>-->
<value>Test tile</value>
<!--<value>Summer rain</value>-->
<binding>
<command>dialog-apply</command>
@ -48,13 +55,13 @@
<text>
<x>10</x>
<y>170</y>
<y>220</y>
<label>orientation (deg)</label>
</text>
<input>
<x>115</x>
<y>170</y>
<y>220</y>
<width>40</width>
<height>25</height>
<property>/local-weather/tmp/tile-orientation-deg</property>
@ -62,13 +69,13 @@
<text>
<x>155</x>
<y>170</y>
<y>220</y>
<label>alt. offset (ft)</label>
</text>
<input>
<x>240</x>
<y>170</y>
<y>220</y>
<width>50</width>
<height>25</height>
<property>/local-weather/tmp/tile-alt-offset-ft</property>
@ -76,13 +83,13 @@
<text>
<x>10</x>
<y>130</y>
<y>180</y>
<label>tile selection mode</label>
</text>
</text>
<combo>
<x>150</x>
<y>130</y>
<y>180</y>
<width>140</width>
<height>25</height>
<live>true</live>
@ -90,6 +97,7 @@
<value>single tile</value>
<value>repeat tile</value>
<value>realistic weather</value>
<value>METAR</value>
<binding>
<command>dialog-apply</command>
</binding>
@ -97,7 +105,7 @@
<checkbox>
<x>10</x>
<y>90</y>
<y>140</y>
<width>15</width>
<height>15</height>
<label>Terrain presampling</label>
@ -109,7 +117,7 @@
<checkbox>
<x>150</x>
<y>90</y>
<y>140</y>
<width>15</width>
<height>15</height>
<label>Worker threads</label>
@ -121,7 +129,7 @@
<checkbox>
<x>10</x>
<y>60</y>
<y>110</y>
<width>15</width>
<height>15</height>
<label>asymmetric range</label>
@ -133,7 +141,7 @@
<checkbox>
<x>150</x>
<y>60</y>
<y>110</y>
<width>15</width>
<height>15</height>
<label>detailed clouds</label>
@ -143,6 +151,37 @@
</binding>
</checkbox>
<text>
<x>10</x>
<y>75</y>
<label>Thermal properties:</label>
</text>
<text>
<x>10</x>
<y>50</y>
<label>rough day</label>
</text>
<slider>
<x>80</x>
<y>50</y>
<width>90</width>
<height>20</height>
<min>0.3</min>
<max>1.5</max>
<property>/local-weather/config/thermal-properties</property>
<binding>
<command>dialog-apply</command>
</binding>
</slider>
<text>
<x>180</x>
<y>50</y>
<label>low convection</label>
</text>
<group>
<x>10</x>
<y>10</y>