Tuesday, January 26, 2021

Rain shadows in the regions

 Consider this regional map from an earlier version of Undiscovered Worlds:


There is rain coming in from the north and east of that mountain range. The mountains are stopping it, creating desert beyond - but the rain extends for some way past them, as if it hasn't quite realised it's hit the mountains.

This is caused by two things. First, precipitation at the global level was being calculated several cells at at time: every "splash" of precipitation covered an area. That meant that when precipitation fell on mountains, it would fall around them too, on both sides. Second, when the precipitation maps were smoothed, no account was taken of mountains, which meant that precipitation was effectively smeared over the map into places it shouldn't have been.

In my recent climate overhaul, both of these issues have been addressed. Global precipitation is now calculated with a much finer grain. And the smoothing routines now take mountains into account: precipitation from one cell can be averaged with precipitation from another cell only if there is a route between them that isn't blocked by mountain ranges. This means that when mountains block precipitation, they really do block it. As a result, we get regional maps like this:


Here, you can see a clear difference between the wetter land to the west of the mountains and the drier to the east, without any jarring bleed over from one side to the other. (I'm aware, by the way, that it's not tremendously realistic to have rivers flowing parallel to mountain ranges or even edging towards them like that, and doing some tinkering to prevent it is on the to-do list.) Here's what the precipitation map looks like of this region:


That shows the difference, and the sharpness of the transition, even more clearly.

Now you'll notice on that precipitation map that the mountains themselves experience higher precipitation even than the coastal strip to the west, as they should. But those areas of higher precipitation on the mountains look quite blocky. That's an inevitable consequence of the changes I made to the global precipitation model: precipitation over mountains isn't being smoothed any more, for fear of messing up the rain shadows, and so there are sharp transitions from one cell to the next. That is reflected on the regional map with these square blocks of precipitation.

When I was reworking the global precipitation, I anticipated that this would happen, and I was worried that it would look dreadful on the regional map. I was pleased to see that, although the precipitation map does display the expected blockiness, this isn't reflected in the regional map, or indeed the climate map. That's because these blocks of precipitation are over mountains, which have dramatically varying elevation, which disrupts any visual artefacts that the blocky precipitation areas might create.

But on lower mountain ranges, the effect is much more noticeable:


In this region the mountains are lower and there is only a fairly slight rain shadow, but there is still higher precipitation in the mountains, and you can see there are blocks of heavy precipitation on tiles where the mountain ridges aren't as high or extensive as those in the previous examples. As a result, the heavy precipitation is visible on the flat land around, creating those ugly green splodges. So, annoyingly, I'm going to have to do something about this.

The first step is this. As things currently stand, the precipitation in the relief map is calculated by means of a diamond-square algorithm over the whole map. This is seeded using the precipitation values in the global map for the relevant tiles. It's fairly straightforward to change things so that for any tile containing mountains, the precipitation map for that tile is instead seeded using the precipitation value that is the average of all surrounding tiles that don't contain mountains. If there are none (i.e. if this is a tile entirely surrounded by mountainous tiles), it uses the average of all of the seeds being used by its neighbouring mountainous tiles. In this way, every tile that has mountains in has its precipitation calculated as if it didn't, effectively. That means the precipitation will be lower. 

That yields this:


This is much better. There are a couple of rather annoying straight artefacts there, with the greener areas around some of the mountains in the middle, but it's much better than what we had. I'm not sure what's causing those - there isn't substantially higher rainfall there - I think that the algorithms I'm using to blend the colours in the relief maps have become a bit too sensitive to higher rainfall and are too enthusiastic about making it show greener. Some tinkering will need to be done there too.

Now we need to put the mountain precipitation back again, but only on the actual mountains themselves. For each tile where we've reduced the precipitation in the way described above, we'll assume that the wind is blowing from the neighbouring tile with the most precipitation that isn't a mountain tile. Then all we have to do is go through our tile, and wherever there's a slope going upwards in the direction that the wind is blowing, we'll increase the precipitation.

Here's the resulting precipitation map for that region:


Compare that to the elevation map for the same region:


As always, it's not perfect, but I think it's much better than what we had before.

The effect isn't as good on more substantial mountain ranges, where the precipitation looks a bit of a mess:


Here, though, the mountains themselves are craggy enough to mask all this, so the relief map looks OK:


You'll notice that there's still some bleeding of rainfall going over these mountains - some green areas to the northeast, and around that massif that extends out into the drier plains. I think this is caused by the fact that there are gaps in this range, and so the rainfall smoothing routines at the global level are allowing some tiles on one side of the range to be influenced by the rainfall in tiles on the other, as there's a clear (though not straight) path between them. Maybe that's OK. And only some ranges are having this effect - you can see on the others I've posted it's happening far less. And even more importantly, I think it's still far better than what I had to start with - compare this to the first picture up above!

Thursday, January 21, 2021

Climates again

The resizing of the world map showed up a lot of problems with the climate simulation. In particular, I found that on a larger scale, the methods I was using to track precipitation - of following lines of precipitation from the coasts inland - didn't work. They resulted in a stringy appearance. I also found that some of the climate classification calculations were incorrect, and basically all sorts of stuff was wrong. So I've taken the opportunity to do a fairly substantial overhaul of the whole system.

As always, remember that climate simulation is staggeringly complex and difficult, and my model can only hope, at best, to produce something vaguely believable. Still, I think it's an improvement. This is what I've done:

  • Rewritten the prevailing wind precipitation, so that UW tracks all of it in a single sweep rather than line-by-line. This allows the rainfall to bloom out as it moves across the land, avoiding the sometimes annoyingly straight lines between areas of high and low precipitation that we had before. It can do this across areas with no prevailing wind, too, though it loses strength as it does so.
  • Done the same thing with the monsoon precipitation. Instead of the "blobs" approach that I used before, we now have monsoons sweeping inland in great swathes. These now create proper savannahs as well.
  • Changed all precipitation to be calculated at a finer grain, ensuring that it doesn't blur across mountain ranges as it used to.
  • Made the bands of winds much wobblier, to create more variation in the latitudes at which deserts tend to appear.
  • Added more precipitation in general, particular at temperate/subtropical latitudes.
  • Reduced the amount of precipitation that falls on mountains (though not reduced the strength of rain shadows to match), ensuring that rainforest no longer appears quite so often on high ground in the middle of deserts.
  • Made temperatures more extreme as you get further from the sea.
  • Rewritten the functions that force Mediterranean climates so that they appear more naturally.
  • Added functions to force subpolar climates in roughly the appropriate latitudes.
  • Fine-tuned the temperature calculations by latitude to ensure that climates appear at the appropriate points.
  • Reworked the climate classifications to be more accurate, and ensured that the colour scheme matches the standard one.
  • Reworked the depiction of temperature and rainfall on the relief map to reflect the different climates a little more realistically.
  • Added a new colour for cold deserts on the relief map.
Most of this involved throwing in lots of magic numbers and twiddling them until things looked less bad. And most of that involved trying to get things back to how they were when I started. Still, I think the result is better than what I had before. There are still issues - my climates don't form such large, neat areas as they do in the real world; there's an annoying tendency for warm-summer humid continental areas to alternate with subpolar ones, which I can't get rid of without messing up everything else; there's too much tundra; the transition between rainforest and savannah is often too abrupt; but overall it's broadly doable. Oh and of course it's all much slower now, but it's worth it to get a more plausible final result.

So here are some global maps, in both their relief and climate versions. Climates are classified according to the Köppen-Geiger climate classification, and shown using the same colours (based on Peel, Finlayson, and Mcmahon 2007).








Now of course doing all that has messed up how precipitation is calculated at the regional level, so I need to rework that too! Yay!