By Chris Hogg
BBC News, Tokyo
Japan's seismologists want to warn people ahead of earthquakes
Predicting when an earthquake will take place is still just about impossible.
But Japanese scientists say they have come up with the next best thing.
They have developed a warning system that can alert you before the shaking starts.
The new system, which went live at the start of October, is the first time a whole country has been protected in this way.
It is an ambitious attempt to try to prevent large numbers of deaths and injuries in the event of a serious earthquake like that which hit Kobe in 1995 and killed more than 6,400 people.
In Japan earthquakes are a constant danger. On an average day there are three strong enough for you to feel.
Japan has an unrivalled network of seismic sensors, more than 4,000 of them, some deep below the Earth's surface.
Osamu Kamigaichi says even a short warning could save lives
It is the density of that network that has allowed them to create the new earthquake forecasting system.
When the Earth ruptures down below a warning is sent to the surface so fast it arrives before the shaking starts.
"It's not prediction but early detection of an earthquake," said Osamu Kamigaichi from Japan's Meteorological Agency.
"If we can detect the seismic wave at a station very close to the epicentre, and then analyse and estimate the seismic intensity and the arrival time of the wave, and if we can disseminate that information to the public, then people can get ready for strong motion before it arrives."
When an earthquake begins a primary wave travels away from the epicentre.
This travels much faster than the more destructive secondary waves.
Because Japan has so many seismic sensors it can detect the primary wave as early as possible.
New technology has been developed to analyse that data almost instantaneously. Analysis of data from just one station is all that is needed.
Once a wave of a certain intensity is detected an automatic warning is sent to the state broadcaster NHK.
Japan's advanced telecommunications infrastructure is what makes this possible.
An alarm goes off, and a message is automatically displayed on NHK television channels and sounded on the radio.
The message tells people where the earthquake has taken place and how long they have to prepare before the shaking starts.
People can also buy alarm systems connected via the internet to the Meteorological Agency systems.
"We expect that the length of the warning could be anything from a few seconds to several tens of seconds," says Mr Kamigaichi. "But that could be enough to make a difference."
Smaller-scale warning systems exist in parts of Mexico, Taiwan and Turkey. This is the first time it has been deployed on this scale.
It is already being tested in schools. The day I visited a primary school in a Tokyo suburb the children were warned that a drill was about to take place.
Hanging over the back of their chairs in the classrooms were little sacks.
When the alarm went off an announcement was broadcast over the loudspeaker warning them that an earthquake was coming and beginning a countdown so that they knew how long they had to take shelter.
The children reached into their sacks and got out little hoods made of padded material. Most were metallic silver - they looked like little Smurf hats.
Japan carries out regular drills in schools and public areas
The children put the hoods on and crouched down under their desks. The teacher pulled the curtains closed to try to protect them from any shattered glass.
She then lifted up a clear plastic shield - the kind that riot police use - over her head so that she could protect herself while she remained standing, keeping an eye on her pupils.
The few seconds' notice meant that all the precautions possible to take were in place before the countdown reached zero.
"This system has helped us to make the children more aware of what they should do when an earthquake strikes," said the school's headmaster Masaki Hayashi.
"It's good for them for when they grow up. This is just in the earliest stages so they are learning and being educated about this system but when they are older it will be all over the place."
It is not a foolproof system - like a weather forecast they will not always get it right.
But the Japanese believe at the moment it is the best chance they have to protect themselves .