Skip to content

Commit

Permalink
mad_std must ignore nan, since we're filling with nan
Browse files Browse the repository at this point in the history
  • Loading branch information
keflavich committed Jun 10, 2020
1 parent dff97f9 commit c539e33
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions spectral_cube/dask_spectral_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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
Expand Down

0 comments on commit c539e33

Please sign in to comment.