iTemblor

iTemblor was the first application I ever published for the then nascent Apple app store back in 2009. It's been on the store ever since.

Originally I was motivated to learn more about the iPhone's onboard accelerometer and to see if I could use it in a simple seismological application that would be both playful and educational.

Mid last year 2020 I completely rewrote iTemblor as an exercise to learn SwiftUI.

As it turns out, producing almost any app has at least one challenge (and usually more). In the case of iTemblor one challenge was properly synchronizing the writing and reading of the acceleration data, which occurs at very high rates. As it turns out, iOS provides excellent tools to handle this.

Balancing the various parameters to obtain a good visual experience was another challenge and I am sure the current experience could be improved further. It's a matter of trial and error and time invested.

The Data

The nuts and bolts of the current data processing configuration are the following:

  • The instantaneous acceleration data is obtained from the accelerometer at a frequency of 100 hertz or every 0.01 seconds
  • The length of the time series is chosen to be 1024 points, which translates to 10.24 seconds of data at any given time
  • The time series is (re)plotted at a refresh rate of 20 hertz or 0.05 seconds

Plotting The Data

As mentioned the instantaneous data is plotted every 0.05 seconds. This value represents a balance between arrival of new data and the time required to read,  process and plot the data. If we refresh much more slowly the result is a jittery plot with missing data, much faster and the entire data processing pipeline becomes blocked up waiting on itself.

In the case of the Time Series View we plot the 3 component acceleration data (x, y and z) in a continuous fashion as a percentage of gravity (g) with time moving from right to left. The orange time series represents the pure acceleration signal with the effect of gravity removed. The green time series is further processed by high pass filtering the data to 10 hertz to remove higher frequency spikes as one shakes or taps the phone.

It's the green time series that we also use in the Seismoscope View where we use the x and y components of acceleration to determine the direction of motion in the 2D plane (this is why you need to hold the phone flat to properly use this view). The x and y components are then used in combination to calculate the corresponding MMI value from an empirical relationship between horizontal Peak Ground Acceleration (PGA) and MMI (see Gutenberg & Richter (1942; 1956) and Elementary Seismology - Richter (1958)). All MMI values between VI and XII are then (re)plotted at the stated refresh interval.

A final comment relates back to the 10 hertz high pass filter and the empirical Richter PGA - MMI relationship. Most of the energy produced by large earthquakes, especially those that produce MMI >= 6, propagates at frequencies less than 10 hertz (typically much less) and is recorded by seismometers sensitive to this spectrum. Therefore, we need to filter out the high frequency spikes from our accelerometer data to attempt to align this data best as possible with the data used in the empirically derived relationships.

I could have reasonably chosen the high pass filter cutoff to be lower, say <= 5 hertz, but then there would not have been much signal left to see; another trade-off with the iPhone implementation.

And so I'll close with my usual caveat -  earthquakes are very complex and variable processes, therefore, iTemblor results should be viewed as approximate at best and be used for educational and entertainment purposes only.