My attempt to overcome this is based on a probabilistic sampling of terrain elevation in 1000 points before generating a Cumulus layer. That allows to determine a few quantities. What seems to work well is alt_20 (the altitude below which 20% of the terrain are) and alt_median (the altitude below which 50% of the terrain are). The idea behind the algorithm is that air layers would flow around isolated obstacles, but would follow a general slope in terrain - at least up to a point.
The algorithm attempts to place clouds at alt_20, but if the actual elevation is larger, then there is a correction and clouds are shifted upward, but never more than up to alt_med. The actual shift depends on how close the elevation already is to alt_med. The Nasal code is rather short:
- Code: Select all
var get_convective_altitude = func (balt, elevation) {
var alt_offset = getprop(lw~"tmp/tile-alt-offset-ft");
var alt_median = getprop(lw~"tmp/tile-alt-median-ft");
# get the maximal shift
var alt_variation = alt_median - alt_offset;
# get the difference between offset and foot point
var alt_diff = elevation - alt_offset;
# now get the actual shift
var fraction = alt_diff / alt_variation;
if (fraction > 1.0) {fraction = 1.0;} # no placement above maximum shift
if (fraction < 0.0) {fraction = 0.0;} # no downward shift
return balt + alt_diff * fraction;
}
The test cases I've been looking so far work rather well. This is a mesa - note that the clouds group in two layers, one with a given altitude below the mesa plateau, others with a higher altitude above the mesa plateau.
This is Grand Canyon - clouds are placed at rim altitude and not in the Canyon. From my personal experience, that is how clouds actually are placed there.
Finally, a case study in the Alps near Innsbruck. Clouds from convection started at the summits are shifted upward about 1500 ft. I'm not entirely sure if that is how it would look like - I'd appreciate if anyone with mountain flying experience could comment.
Also, if anyone knows more tricky test cases, let me know...