Thursday, November 29, 2018

Mars global hydrology at full MOLA resolution

Close readers of this blog may remember a post from 2016 where I discussed my early efforts to perform hydrological simulations on Mars.

That is, I performed the simulations on my computer, which like me resides on Earth, but the topic was Mars. This was thanks to the incredible Mars Orbital Laser Altimeter (MOLA) dataset, and at length I was able to produce data like the plot below, showing rivers forming between flooded craters.

At the end of the blog, I mentioned that this simulation failed to exploit the full MOLA dataset. Indeed, I had reduced the resolution from a maximum of about 500m to around 15km. 15km isn't really enough to resolve finer erosive details on Mars, or get a good look at the landscape, but it's all I had the time and expertise to do at the time.

Earlier this year, I decided to revisit the problem and resolved to teach myself how to use Python for these sorts of problems. If you want to follow along, you can clone my repo at and run your own simulation. And yes, I will take pull requests if you have an improvement or modification!


I found simulating the full resolution model quite challenging. To recap, the full MOLA dataset encapsulates the topography of the entire planet at 500m resolution. This corresponds to an array of size 20,000x40,000. When other aspects of my data structure are included, the total file size is about 100GB per time step! Naturally, I broke the global domain into 32 smaller subdomains that could actually fit within RAM.

To enable quick convergence to the solution, I began by dumping 150m of water (which can be adjusted in the code) uniformly all over the planet, then turned on an evaporation/precipitation routine, and ran the whole thing at greatly-reduced resolution. When the solution approached convergence, I doubled the resolution and repeated the procedure. All in all, I doubled the resolution about 10 times, achieving a global solution in roughly two weeks on my 2011-era laptop. 

Once I had the complete data, I wanted to reproduce my earlier plots and depict information about river/lake/ocean depth, flow rate, gradient, and so on. Despite careful use of perceptually uniform color maps and other tricks, I found the results mostly unsatisfactory. They just didn't feel right. So I carefully backed up the data and moved onto other things.

But every now and then I'd lie awake at night and wonder "How can I plot this 100GB dataset in a satisfactory way?" At 300dpi a printed poster would stretch 10 feet by 20 feet! It's a big planet. And I wanted what amounted to a color function that was both beautiful and precise. That showed the accessibility of the landscape and told a story about it too. 

Last week, I was talking with some friends about the pathological drainage patterns of the California/Nevada/Utah desert when it finally occurred to me how to solve this problem. Humans have built in hardware that can read landscape. If I could transform the data into a familiar enough landscape, our brains would interpret and read what was going on. That was the hope, although of course Mars has many more craters than Earth.

So I took some screenshots from Google Earth and analysed their pixels in the space of hue, saturation, and brightness (HSV). This is an alternative to the more familiar red green blue (RGB) encoding of color. 
The trend here is from reasonably bright, red/pink, desaturated landscape to blue, dark, saturated water, via green, dark, desaturated foliage. I decided to use a Viking-derived true color image of Mars to provide the color of the unflooded landscape; a generic pinky red was too uniform and blank looking. 
At full resolution (10000x20000 pixels) this image is only 2x lower resolution than the original MOLA dataset! That corresponds to roughly 1km per pixel. 

Once I had finished tweaking a function that took the altitude, gradient, slope, and water depth of a particular pixel and output a color, all that remained was to render the entire image. This took quite a while, mostly because of bugs that I only discovered half way through the process! For the final step, I was able to use the synthetic terraformed Mars surface image I had produced as an image layer in Google Earth to reproduce the "click and zoom" experience we all know and love.

I'm quite happy with the results. At the global scale, it looks really awesome.
But you can also zoom in to look at tiny details!
And further!
As always, if one zooms too far, pixels appear! 

To save you the trouble of replicating my plotting algorithms, you can access the full resolution renders here: . If you're interested in getting access to the raw data and don't have time to run the simulation yourself (preferably with unique water and precipitation values) then get in touch. I'd love to see what other people can make out of this data!

As happy as I am with this plot, it is not perfect. Perhaps in future I will find time to fix the following issues:

- Vegetation is a huge hack. It shouldn't be too hard to program vegetation color and cover according to insolation angle, altitude, latitude, and water availability. Similarly, high altitude water could be colored for snow.

- Hydrological accuracy isn't great. Some sections of the planet have much too much water, and others much too little, based on existing erosive patterns. Some of this is due to resolution limitations, and some is due to poor convergence of underlying data. 

- Climate accuracy. I devised precipitation to be proportional to altitude, as with orogenic rainfall. But prevailing winds (which I didn't model) would cause rain shadowing and other excitement. I think the next decade will see the maturation of generic global climate models, which would be awesome to apply here.

- Resolution limitation. I recently discovered that the Mars Reconnaissance Orbiter's CTX imager has imaged about 60% of the planet at 6m stereo resolution, so now I'm itching to prototype a data pipeline to perform photogrammetric enhancement of the MOLA dataset. At 6m resolution, the global topo dataset would grow from 8 billion numbers to about 50 trillion, and even my laptop might struggle to compute the full river systems. But 6m would be adequate to resolve crater canyon drainages and enable even more zoom than ever before.

I will continue to post screen grabs of enticing bays, islands, and crater chains at from time to time, as I explore this new landscape and imagine the possibilities.