From c539e3323f015ef893c0c5d9214d09c9b09e143d Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Tue, 9 Jun 2020 11:04:00 -0400 Subject: [PATCH] mad_std must ignore nan, since we're filling with nan --- spectral_cube/dask_spectral_cube.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spectral_cube/dask_spectral_cube.py b/spectral_cube/dask_spectral_cube.py index 7d75b546a..d39a74f1e 100644 --- a/spectral_cube/dask_spectral_cube.py +++ b/spectral_cube/dask_spectral_cube.py @@ -597,7 +597,7 @@ def std(self, axis=None, ddof=0, **kwargs): @projection_if_needed @ignore_warnings - def mad_std(self, axis=None, **kwargs): + def mad_std(self, axis=None, ignore_nan=True, **kwargs): """ Use astropy's mad_std to compute the standard deviation """ @@ -608,11 +608,14 @@ def mad_std(self, axis=None, **kwargs): # In this case we have to load the full data - even dask's # nanmedian doesn't work efficiently over the whole array. self._warn_slow('mad_std') - return stats.mad_std(data, **kwargs) + return stats.mad_std(data, ignore_nan=ignore_nan, **kwargs) else: # Rechunk so that there is only one chunk along the desired axis data = data.rechunk([-1 if i == axis else 'auto' for i in range(3)]) - return self._compute(data.map_blocks(stats.mad_std, drop_axis=axis, axis=axis, **kwargs)) + return self._compute(data.map_blocks(stats.mad_std, drop_axis=axis, + axis=axis, + ignore_nan=ignore_nan, + **kwargs)) @projection_if_needed @ignore_warnings