ARGODEV-159: Convert noise
Jira Issue
ARGODEC-159 (https://jira.ceh.ac.uk/browse/ARGODEV-159)
Python Implementation
Algorithm is mostly the same.
- Changed the function name from noise to noise_variance to better reflect what the function is actually doing.
- Added some more in-depth documentation, and added an error message for the situation where no unique points are given.
Testing
Wrote 3 tests:
- Check that the return type of noise_variance is a float
- Check that we get a 0 if the points given to the function are the same
- Check that, if given some real data, we get the expected result
Old Matlab Implementation
Calculates the variance in the noise of the salinity data for the historical data. In this case, the noise is simply the difference in salinity between each data point and its closest other data point (in terms of space). We then take the sum all of the differences squared over two times the number of data points to find the variance in the noise. In other words
Noise_Var(X) = Sum(D^2) / 2*N
where D is the difference between salinity of each data point and its closest data point (min(Xi - X)), and N is the number of data points.
This is explained in more detail in HERE