Travis E. Oliphant wrote: > shuwj5...@163.com wrote: snipsnip Travis, thanks for the excellent explanation! It clears something which I think is related to this, I've been wanting to ask on the ml for some time already. Now here's the case. I often have 4d arrays that are actually related sets of satellite imagery, and have the form of [date, band, y, x]. These can get pretty large, so I like to prevent too much broadcasting or reshape-copy-ing when indexing to save some memory. However, I regularly have to apply some boolean index of [date, y, x] to each of the band dimensions (think of the bool mask as a threshold base on just one of the bands). Currently I usually loop over all band indices, e.g.
for b in data.shape[1]: data[:, b, :, :][mask] = 0 Would there be a way to do this in a more numpy-like fashion that is also memory-efficient? Thanks, Vincent. _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion