# A New Spatial Distance Metric for Verification of Precipitation
## 2 Materials and Methods
### Description of the New Method
This can be done by sequentially increasing \(r\) in small steps, starting from \(r=0\), until \(PSS\) becomes larger than 0.5. Alternatively, some more efficient root-finding methods can be utilized to arrive at the correct \(r\) value more quickly (e.g., the Bisection method [10]). 1. _Domain enlargement_ The domain is enlarged by adding a zero-valued border area of width \(\geq r\). We denote the extent of the enlarged domain by \(\mathcal{D}_{\text{enl}}\). Note that the enlargement is only necessary for a limited area domain (it is not needed for a domain that encompasses the whole Earth). 2. _Smoothing_ A new set of new fields \(f^{\prime\prime\prime}_{\text{a}}\) and \(f^{\prime\prime\prime}_{\text{a}}\) is obtained by smoothing the fields \(f^{\prime\prime}_{\text{a}}\) and \(f^{\prime\prime}_{\text{b}}\) via the use of a disc-shaped kernel \[ \begin{split} f^{\prime\prime\prime}_{\text{a}}(x,y,r)& =\frac{1}{A_{\mathcal{C}}}\int\limits_{\mathcal{C}(x,y,r)}f^{ \prime\prime}_{\text{a}}(x^{\prime},y^{\prime})\text{d}A^{\prime},\\ f^{\prime\prime\prime}_{\text{b}}(x,y,r)&=\frac{1 }{A_{\mathcal{C}}}\int\limits_{\mathcal{C}(x,y,r)}f^{\prime\prime}_{\text{b}}( x^{\prime},y^{\prime})\text{d}A^{\prime}.\end{split} \] (5) \(\mathcal{C}(x,y,r)\) represents a disk-shaped area with radius \(r\) and center at \((x,y)\) while \(A_{\mathcal{C}}\) is its area size. The values of \(f^{\prime\prime}_{\text{a}}\) and \(f^{\prime\prime}_{\text{b}}\) outside of the domain are assumed to be zero. The values of fields \(f^{\prime\prime\prime}_{\text{a}}\) and \(f^{\prime\prime\prime}_{\text{b}}\) represent the average of values located inside a circular area (i.e., the neighborhood). The size of the parameter \(r\) defines the size of the neighborhood and directly affects the amount of smoothing (a larger value of \(r\) will result in more smoothed fields, and if \(r=0\) no smoothing is applied). In terms of computational complexity, smoothing is the most costly step in calculating the \(PSD\) value. Luckily, the computational complexity of the smoothing can be significantly reduced by the use of Fast-Fourier-Transform-based convolution [11]. 3. _PSS value_ The value of \(PSS(r)\) can be calculated as \[PSS(r)=1-\frac{1}{2 QA_{\mathcal{D}}}\int\limits_{\mathcal{D}_{\text{enl}}}|f^{ \prime\prime\prime}_{\text{a}}(x,y,r)-f^{\prime\prime\prime}_{\text{b}}(x,y,r )\big{|}\text{d}A.\] (6) with \(A_{\mathcal{D}}\) being the area size of domain \(\mathcal{D}\), and \(Q\) defined by Equation 4. The range of the PSS values is between 0 and 1, with higher values indicating a better spatial match of the smoothed precipitation in the two fields. A PSS value of 0 would only occur when there would be no overlap of the smoothed values in the two fields (this will always happen at \(r=0\) since the precipitation in the non-smoothed fields \(f^{\prime\prime}_{\text{a}}\) and \(f^{\prime\prime}_{\text{b}}\) does not overlap). PSS value will increase with \(r\) since more smoothing makes the fields more similar with PSS asymptoting towards 1 when \(r\rightarrow\infty\). 4. _Calculating the PSD value_ Once the value of \(r_{ PSS=0.5}\) is known, PSD can be calculated as \[PSD=0.808\cdot Q\cdot r_{PSS=0.5}, \tag{7}\]  
A python code package for efficient calculation of the PSD value is freely available on github (for details please refer to the Data Availability Statement at the end of the article). The package can be used for input fields that are available in a rectangular domain with an equidistant grid. It uses Fast-Fourier-Transform-based convolution for computationally efficient smoothing, along with the Bisection method for faster computation of the \(r_{PSS=0.5}\) value.