xdem
xdem copied to clipboard
Deprecate `nmad` and move to `scipy.stats.median_abs_deviation`?
SciPy have it, I'm not a big fan of the implementation (the name is crazy long), but it's probably going to be the one to last in time.
For the record, from Slack discussions:
- Turns out NumPy didn't want to add it 5 years ago: https://github.com/numpy/numpy/issues/11325, and pointed to statsmodels (which really doesn't make sense to me, given how specific statsmodels is to other things than basic statistical estimators...)
- Thankfully, since SciPy 1.5 (2 and half years ago), there is an implementation in the scipy.stats module that looks pretty flexible: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.median_abs_deviation.html
Hmm, do you mean removing the NMAD function entirely or just the interior functionality?
Our NMAD function does more than just NMAD; it handles masked arrays properly too, which is not always the case for scipy. Our function has a part which may be unnecessary too now where a Raster
s array is extracted. Pretty sure that is not needed any more due to its array interface.
Then it's the question of wanting to write scipy.stats.median_abs_deviation(arr, scale=1.4826)
all the time as well! I do agree, however, that it would be nice to shorten our function using this as the main workhorse.
Yes, I agree writing that every time is a hassle. :sweat:
Maybe just shortening the function is best. And also using scipy.stats.median_abs_deviation()
in the tests?
Where should the nmad
function live, however? xdem.spatialstats.nmad
is not a good place for it... It could almost be in a geoutils.stats
module, if we start moving generic stats functions to GeoUtils (as they are applicable to any raster)?
Could it live in misc? I think it's fine in xDEM as we really don't make any use of it in geoutils... Or once we have a filters module there 😅
Yes, we'll need it in GeoUtils once we have filters! Maybe in a geoutils/stats/
submodule following https://github.com/GlacioHack/xdem/issues/378?