Predicting earthquakes and saving lives - with smartphones
Living in an earthquake zone adds a certain spice to life.
To the normal catastrophes of day-to-day existence, you can add the possibility that the earth will open up underneath you and swallow you whole.
The first earthquake is scary - but unless a massive shaker comes along you quickly become accustomed, even complacent.
This is when being prepared becomes even more important; your survival kit with plenty of bottled water, knowing where - and where not - to shelter.
And actually scrambling into these areas at 5am when a quake hits, instead of rolling over, going back to sleep and assuming it's not the "big one" because you had a late night and don't want to crawl out of bed.
This is where being alerted to the fact this this isn't just a tummy trembler, it's actually a potentially devastating magnitude 7.5 would be useful - because it could save your life.
Unfortunately, early warning systems are hugely expensive pieces of infrastructure to build from scratch.
So a team from the California Institute of Technology (Caltech) has created an app that uses the accelerometer in your smartphone, and turns it into a simple seismometer (device that detects the vibrations from earthquakes).
Richard Guy is part of the team that put together CrowdShake, with graduate computer science student Matt Faulkner.
He manages Caltech's Community Seismic Network, which has been running an earthquake monitoring project for the past three and a half years, to complement the more formal seismic monitoring services.
"In the Pasadena area, which is a relatively small community - it's hardly 10km across - we have hundreds and hundreds of volunteers that we give a very small low-cost accelerometer to, it's actually a seismometer," he says.
The devices either plug into a PC or router, and pick up the vibrations caused by tremors.
Earthquake early warning systems rely on lots of sensors spread over a region. So when an earthquake begins, the closest stations pick up the tremors.
The data they gather is then sent to processing centres, where the intensity is calculated, and the time it will take for the quake to reach other areas. Then alerts are sent out. This system, although more basic, works on the same principles.
The project has hit a few bumps in the road - there's the cost of the the devices, and the fact that some are simply never installed.
So the next logical step was a smartphone app called CrowdShake - meaning no hardware to buy or maintain.
"The attractiveness of smartphones is that they have many things already built in," says Mr Guy.
"The accelerometer is already in the phone, the location is something the phone knows, it's not something that a person has to tell it.
"And of course your smartphone knows exactly what time it is."
They are also easy to use, says Mr Guy.
"From that point of view smartphones are an extraordinarily attractive device for monitoring earthquakes.
"Now on the other hand, they come with very interesting challenges - the sensor, the accelerometer in a smartphone is certainly not of the quality of any sort of a device you would add to your PC or some other setting. So that's a basic challenge."
Distinguishing normal movement from the vibrations from an earthquake is also tricky.
"If there are just enough [phones] that are stationary, which could be a very small percentage, from that we can determine, 'OK, an earthquake is under way and this is how intense it was at a certain point'," he says.
The data is analysed and then pushed back to the community of users.
"Then the receiving phone says, 'Well, I know where I am, I know where it started, I know the time difference between when the event began, I know what time it is now, my little phone app can calculate very, very simply in just a few milliseconds, this is how bad I think it's going to be where I am right now.'
"It can then provide... an alert to this user saying: 'You have so many seconds before a damaging wave will arrive'."
At the moment the app is still a prototype. Implementation across California is unlikely unless it is done by government agencies, as the risk of litigation is so high - for example, should someone be injured during a false alarm, says Mr Guy.
So the target is the developing world - countries with a high risk of earthquake, but without an early warning infrastructure in place - where mobile ownership is common.
The big brother to the Community Seismic Network project is the California Integrated Seismic Network's Earthquake Early Warning System.
"The network of seismometers is really a computer network," says the director of Caltech's Earthquake Engineering Research Laboratory, Tom Heaton.
"We basically monitor all of the shaking that happens at roughly about 400 stations in the western United States, and we have access to that information within about a second of when the shaking occurs at the station."
When a quake is detected members of the network are alerted.
"We've been writing software that does the kind of analysis a human being would do if they had time to do it," he says.
"The one that I work on is called the virtual seismologist, we're trying to teach a computer to be like a seismologist, but unlike a seismologist, computers can stay awake all the time and they don't get bored."
The early warning system has already been proven to work. At Caltech they're working on ways to send alerts to smart devices, which inevitably includes a smartphone app.
"The app gets notification that an earthquake has occurred .... it can project when the shaking will get to the phone and how big it will be. And then the phone can start to countdown and say, shaking in 10, 9, 8,… and even give some idea - strong shaking or weak shaking depending on what we anticipate."
One of the big hold-ups is financing. The project has received funding from the US Geological Survey (USGS) and more recently the Gordon and Betty Moore Foundation, while waiting to find out whether a bill currently in front of the state legislature will implement the system.
Proof that this type of technology works can be found in Japan.
The country has an effective early warning system administered by the Japan Meteorological Agency. Thanks to apps like Yurekuru Call, earthquake alerts can be pushed to smartphones, while the iPhone 5 can do it automatically.
No matter how sophisticated these systems are, there's only so much a warning can do.
In March 2011, the north-east of Japan experienced the most powerful earthquake to hit the country, a magnitude of 9.0. This was followed by a tsunami that inundated the Pacific coast.
In Japan it is called the Great East Japan Earthquake. It is thought that close to 20,000 people were killed.
The early warning system certainly saved lives. But the scale of the disaster was just too big. And the tsunami alert, which takes longer to compute and generate, gave some only 15 minutes to get to higher ground.
The American Red Cross has launched a suite of apps created by UK-based developers 3 Sided Cube for use in natural disasters, one of which is for earthquakes.
It uses the USGS feed giving information on quakes as they happen, and sends alerts to people who have set the app to watch certain areas. It then sends them to a page with more information.
"[We] developed this app to give instant access to information on what to do before, during and after earthquakes with preparedness information developed by trusted Red Cross experts," says the American Red Cross's Matt Goldfeder.
"The app also includes preparedness information for events that may happen after earthquakes, such as fires and tsunamis."
An "I'm safe" button lets you send an alert to family, friends and social networks, where you can also share information. It includes a toolkit that has a torch setting, strobe light and an alarm.
"A recent Red Cross survey shows that nearly one-fifth of Americans say they've received some kind of emergency information from an app they've downloaded. It's important that people can access this information right on their mobile device," says Mr Goldfeder.
Other apps that claim to help in the aftermath include Earthquake Buddy, which will send an alert to four contacts if a phone detects an earthquake, with your GPS co-ordinates attached. For Californians, MyFault shows areas likely to be subject to landslide or liquifaction.
Technology might not be able to save the world. But it might be able give you and your loved ones the edge when it comes to surviving the worst of natural disasters.