University of Auckland researcher David Coppin uses a model to label and track precipitation systems along coastlines in the tropics. After working with NeSI’s Consultancy Team, his code is running nearly four times faster. Photo by Brian Cook/ Unsplash.

Tracking coastal precipitation systems in the tropics

"The new code implemented is much faster and runs more efficient on NeSI platforms, which allows me to concentrate more on my research and less on computer science aspects."

Coastal precipitation plays an important role in the economy of island nations. Impacts from too much or too little precipitation can range from losses in agricultural productivity, to unexpected infrastructure costs, to spikes in sales of particular products or services.

“Land-sea breezes, mountains, and the influence of large-scale circulation all have a role in modulating the daily cycle that brings most of the rain that falls on islands,” says University of Auckland researcher David Coppin. “Using a high-resolution model we’ve been able to simulate the cloud processes over a virtual island of idealized geography, with mountains and vegetation cover. By varying the altitude, size, and aspect ratio of the island, we can investigate the influence of these geographic characteristics, and study the fundamental mechanisms of the daily precipitation. On the other hand, we have a lot of satellite data but most of the time, they only give you an estimate of precipitation and it is really hard to get a precise idea of what is generating this rain.”

To bridge the gap between between models and observations, they decided to focus on the cloud systems themselves and to study their temporal and spatial evolution over several years.

“In order to get precipitation right, we first need to get the clouds right and to understand where they come from,” says David. “This is a challenge because, during the day, clouds and precipitation will evolve in size, merge with other precipitating systems, or break into smaller systems.”

David and his colleagues had a model that labels and tracks precipitation systems, associating a colour to each precipitation system so that researchers can track its origin and temporal and spatial evolution. The model is initialized by satellite data and took about three to four hours to simulate one day globally over the Earth’s tropics.

Pictured above is an example of labeling of coastal precipitation systems over Madagascar, created using David Coppin’s model, written in collaboration with NeSI team members. Each colour corresponds to a different precipitation system.


The model was effective on a small scale, but it would have taken two to three months of compute time to label precipitation systems over an entire year. Effectively, the researchers would have had to wait for many months to get their results. So, David sought the help of Alexander Pletzer and Chris Scott from NeSI’s Consultancy Team.

First, Alexander and Chris profiled David’s code to identify any performance bottlenecks. They found that 34-37% of the execution time was spent in one function. Reimplementing this function in C++ improved the performance by 30%. However, additional performance gains would be difficult to achieve without a complete re-design of some key data structures.

NeSI identified three areas of improvement. First, the code used Python’s “numpy” arrays, which are highly optimised to run on high performance computers. These arrays were, however, not a good fit for the problem because they associated precipitation labels to every cell in the grid, even cells with no precipitation or away from any coastline, which was not very computationally efficient. This could be addressed by using a sparse representation of precipitation, which does not consume any memory over “dry” regions.

Secondly, a problem was that precipitation systems arise and disappear over time. In the accounting, labels had to be created and removed from a list dynamically, which was difficult to implement correctly. The solution was to use data structures that can grow and shrink dynamically in time.

Lastly, NeSI’s team recommended David replace the least square computation used to approximate systems with ellipses, with one that uses the method of inertia. David’s code relied on a function from the skimage library to approximate the contour of a precipitation system with an ellipse. This caused problems when the contour of the system touched the boundary of the domain or when the system had split into more than one part. The method described below overcomes these shortcomings.

Schematics showing how the method of inertia can be used to approximate a collection of precipitation cells with an ellipse. Order zero of the method gives the total mass (number of precipitation cells in this case), order 1 gives the centre of gravity (location of the system) and order 2 the inertia tensor from which the principal axes of the ellipse can be computed.  


Over large regions, NeSI’s team expected significant improvements to productivity from the three above recommendations and convinced David to re-design his code around these data structures. NeSI also delivered a first implementation of the code.

With NeSI’s help, David re-implemented his code and it now runs nearly 4-6 times faster, uses less memory, and his entire model is more robust and efficient at handling the complexities of his precipitation model. Thanks to NeSI’s guidance, David moved the code development under git version control, which allows collaborative code development and ensures that it is always possible to roll back to an earlier version.

Increase of performance of new tracking code compared to the original code is dependent on the problem size. The larger the problem the higher the pay-off.

“It was great working with NeSI and especially Alex and Chris,” said David. “They helped me solve technical problems I would never have been able to sort out on my own. The new code implemented is much faster and runs more efficient on NeSI platforms, which allows me to concentrate more on my research and less on computer science aspects. Thanks to continuous collaboration along the code building, I am now able to maintain and develop it on my own. I learnt a lot from this project and I am really glad that NeSI offers us this kind of expertise for long-term project that requires a lot of work.”


Need some help with your research project? NeSI’s computational science team can assist with code optimisation, parallelisation, porting to GPUs, custom code development, and many other tasks. Email if you are interested to find out more or if you have a task you’d like NeSI to help you tackle.


Next Case Study

Annika Seppala NeSI case study climate simulations

Powering global climate simulations

"The fact that NeSI can provide support to things like getting the code to work puts New Zealand in an amazing position worldwide.”