Algorithm

The algorithm iterates over the morphing grids *Di* (*i* = 1, ..., *I*), starting on the coarsest 3-by3 grid *D*1, until it reaches the finest morphing grid *DI*. For each iteration, the three main steps are similar to those in Reference [32] and are illustrated in Figure 1.

1. **Smoothing** of the images *u* and *v*: the images are smoothed by convolution with a 2D-Gaussian

$$G\_{2D} \left( \mathbf{x}, y \right) \quad = \quad \frac{1}{2\pi\sigma^2} \exp\left( -\frac{\mathbf{x}^2 + y^2}{2\sigma^2} \right) \dots$$

where *σ* = 0.05/ 22*<sup>i</sup>* + 1 . The finer the grid *Di* is, the narrower the Gaussian is. Thus, for small *i*, the fine features are ignored and the focus is given to the large-scale ones. When *i* increases, more and more fine features are taken into account. This way, *Ti* for small *i* will make the larger features match. Then, for increasing *i*, more and more detailed images are matched.

The cost function *J* is often non-convex with respect to *T* and so can have several local minima. The smoothing combined with the hierarchy of grids reduce the local minima problem. They ensure that the large-scale features are fitting first, hence avoiding local minima.

After the smoothing, the two fields are normalized such that their maximum is the same. The images obtained after smoothing and normalization are noted as *u*˜*<sup>i</sup>* and *v*˜*i*.


There is a number of inequality constraints on this minimization problem, due to our requirements of invertibility. An iterative barrier approach is used to transform this constrained minimization problem into an unconstrained one [34,35]. In the barrier approach, the minimization is applied to a penalized cost function *Jp*(*T*) = *J*(*T*) + *β* ∑*<sup>h</sup> Ch*(*T*), where *Ch* are the constraint functions and *β* the barrier coefficient (over which we iterate when the constraints are not respected). The constraints and the minimization method are described with more details in Appendix A.

**Figure 1.** Algorithm for the automatic registration.

The python scripts for the automatic registration and the morphing are available online (Supplementary https://github.com/clecoz/precipitation-morphing.git). The scripts permit to reproduce the results for the synthetic case described below.
