Commit 36c294f5 authored by Matthijs's avatar Matthijs
Browse files

binning with NaN values in array

parent df4dee90
......@@ -120,7 +120,13 @@ def bin_2d_array(arr, new_shape):
shape = (new_shape[0], arr.shape[0] // new_shape[0],
new_shape[1], arr.shape[1] // new_shape[1])
return arr.reshape(shape).sum(-1).sum(1)
if np.any(np.isnan(arr)):
binfactor = 1
for i, s in enumerate(arr.shape):
binfactor *= new_shape[i] / s
return np.nanmean(arr.reshape(shape), axis=(3, 1)) * binfactor
return arr.reshape(shape).sum(-1).sum(1)
def shifted_fft(arr, axes=None):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment