A P wave-based, on-site method for earthquake early warning