revamped weighted mean with np.ma, fixed bugs