josuemtzmo / trackeddy

Tracking eddy algorithm:
http://trackeddy.readthedocs.io/
MIT License
46 stars 18 forks source link

scipy.ndimage.filter handles NaNs as zeros #2

Closed navidcy closed 5 years ago

navidcy commented 5 years ago

Using scipy's ndimage filters, as for example in https://github.com/josuemtzmo/trackeddy/blob/313380dfffd40f70e62fbf2f6b7373900138c9f6/trackeddy/tracking.py#L763 induces some errors as scipy.ndimage handles NaN (e.g., points which correspond to land) as zeros and this affects the average.

An alternative way that does not suffer from this is astropy.convolution.

josuemtzmo commented 5 years ago

Thank you for reporting and reminding me about this. I've switched the uniform_filter to astropy.convolution.convolve. However, as a record of this, the gaussian_filter still implemented using scipy's ndimage, I couldn't find in a quick look an option to replace it:

https://github.com/josuemtzmo/trackeddy/blob/36070d311a82ecb1e0e79f10e9fddb5580043ff9/trackeddy/tracking.py#L760-L769