Skip to content

Instantly share code, notes, and snippets.

@guziy
Created July 21, 2014 22:58
Show Gist options
  • Save guziy/fdbe65efa40728f3b7a8 to your computer and use it in GitHub Desktop.
Save guziy/fdbe65efa40728f3b7a8 to your computer and use it in GitHub Desktop.
biggus mean of a stack of masked arrays
import biggus
import numpy as np
def main():
x = np.random.randn(10, 10)
y = np.ma.masked_where(x > 0, x)
yinv = np.ma.masked_where(~y.mask, x)
arrst = biggus.ArrayStack(np.array([biggus.NumpyArrayAdapter(el) for el in [y, yinv]]))
the_mean = biggus.mean(arrst, axis = 0).masked_array()
print np.all(~(y.mask & yinv.mask))
assert np.all(the_mean.mask) == True, "I was expecting the_mean to be completely masked..."
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment