added comments, and got rid of 'invalid value encountered in greater' caused by localminima with > np.NAN