ZGainsforth
6/3/2017 - 8:01 AM

Bin a numpy array in python

Bin a numpy array in python

def BinArray(S, bin=2):
    Sbin = S.reshape((16, int(S.shape[1]/bin), bin, int(S.shape[2]/bin), bin)).sum(axis=4).sum(axis=2)
    print('Binned Array Shape = ', Sbin.shape)
    imshow(Sbin[Mg_K])
    colorbar()
    print('Al-K map mean: ', np.mean(Sbin[Al_K]), ',   Al-K map max:', np.max(Sbin[Al_K]))
    return Sbin