Python Peak Detection Algorithm