GithubHelp home page GithubHelp logo

lskk / motionrecorder1 Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 2.91 MB

Motion Recorder 1.x (React Native-based) for accelerometer, gyroscope, and magnetometer, development is suspended for now. Use Motion Recorder 2.x: https://github.com/lskk/motionrecorder2

JavaScript 61.48% Python 10.05% Java 8.37% Objective-C 20.10%

motionrecorder1's Introduction

Motion Recorder

Motion Recorder for accelerometer, gyroscope, and magnetometer.

Used for waveform/motion analysis, generate training data set for pattern recognition and machine learning, and seismic research, especially in LSKK and PPTIK Institut Teknologi Bandung (ITB). Initially we want to save to miniSEED format (to make it easier to analyze using SRC Waves or SeisGram2K), however as there is currently no miniSEED library for JavaScript, we decided to save in custom JSON format instead, which can be both saved to files and inserted into MongoDB directly.

Future plan: Server-side converter using Python/ObsPy to export the JSON waveform data to miniSEED format.

Full source code is available at https://github.com/lskk/motionrecorder

Recorded data

from http://www.fdsn.org/pdf/SEEDManual_V2.4.pdf : Orientation Code

  • Z N E Traditional (Vertical, North-South, East-West) (see 5 degree convention above)
  • A B C Triaxial (Along the edges of a cube turned up on a corner)
  1. [DONE_xyz] Accelerometer (x, y, z and/or Z, N, E?) in m/s^2 + samplingRate. SNA, SNB, SNC, SNZ, SNN, SNE. Channel flag: G.
  2. [DONE_xyz] Geomagnetic Field (calibrated) (x, y, z) in μT (Android) or T (SEED) + samplingRate. SFA. SFB, SFC, SFZ, SFN, SFE. Channel flag: G.
  3. Orientation (x, y, z) in degree or rad (?) + samplingRate.
  4. [DONE_xyz] Gyroscope (x, y, z) in rad/s + samplingRate. SJA, SJB, SJC. Channel flag: G.
  5. Light in lux
  6. Promixity in cm
  7. [TODO] Gravity (x, y, z) in m/s^2
  8. Linear acceleration (x, y, z or Z, N, E?) in m/s^2 + samplingRate
  9. Rotation vector (x, y, z) (unitless) + scalar + samplingRate
  10. Step counter in steps + samplingRate
  11. Pressure. Barometer/pressure in Pa. SDO. flag: W/H.
  12. [TODO] Location (latitude, longitude, accuracy; provider)
  13. [TODO] Elevation (m)
  14. [TODO] UTC timestamp at start and end of recording
  15. [DONE] Device: brand/model/deviceCountry, System: systemName/systemVersion

JSON Schema

A miniSEED file supports multiple stations, each station with multiple channels.

QuakeZone JSON also supports multiple stations, in order to facilitate each data exchange for a single seismic event (with waveforms from multiple stations). However, Motion Recorder only writes one station (i.e. device) per document, and multiple channels (traces) for that station. We use ObsPy's Stream conventions and metadata field names, so each station is only uniquely identified by a trace/s network-station-location combination.

Station schema uses the modern StationXML. ObsPy interpretation: https://docs.obspy.org/tutorial/code_snippets/stationxml_file_from_scratch.html.

To aid classification training, we also add annotations:

{"motionCategory": "", "motionSubCategory": ""}

{
    "_id": "(autogenerated by MongoDB)",
    "source": "Motion Recorder",
    "networks": [
        {
            "code": "",
            "startDate": "",
            "endDate": "",
            "stations": [
                {
                    "code": "X001",
                    "startDate": "",
                    "endDate": "",
                    "latitude": 1.0, // Note that these coordinates can differ from the station coordinates.
                    "longitude": 2.0,
                    "elevation": 345.0,
                    "site": "",
                    "operator": {
                        "agencies": [],
                        "contacts": [
                            {
                                "name": "...",
                                "agency": "...",
                                "email": "...",
                                "phone": "..."
                            }
                        ],
                        "webSite": "https://..."
                    },
                    "creationDate": "...",
                    "terminationDate": "...",
                    "channels": [
                        {
                            "code": "SNZ", // This is the channel code according to the SEED standard.
                            "startDate": "",
                            "endDate": "",
                            "locationCode": "", // This is the location code according to the SEED standard.
                            "latitude": 1.0, // Note that these coordinates can differ from the station coordinates.
                            "longitude": 2.0,
                            "elevation": 345.0,
                            depth: 10.0, // The local depth or overburden of the instrument's location. For downhole instruments, the depth of the instrument under the surface ground level. For underground vaults, the distance from the instrument to the local ground level above.
                            // azimuth: 0.0, // Azimuth of the sensor in degrees from north, clockwise.
                            // dip: -90.0, // Dip of the instrument in degrees, down from horizontal
                            // The type of data this channel collects. Corresponds to channel flags in SEED blockette 52. The SEED volume producer could use the first letter of an Output value as the SEED channel flag.
                            "types": [
                                "TRIGGERED",
                                "CONTINUOUS"
                                "HEALTH"
                                "GEOPHYSICAL",
                                "WEATHER",
                                "FLAG",
                                "SYNTHESIZED",
                                "INPUT",
                                "EXPERIMENTAL",
                                "MAINTENANCE",
                                "BEAM"
                            ],
                            "storageFormat": "",
                            "clockDrift": 0.0,
                            "calibrationUnits": "",
                            "sensor": "",
                            "preAmplifier": "",
                            "dataLogger": "",
                            "equipment": "",
                            "response": {
                                "instrumentSensitivity": {
                                    // A scalar that, when applied to the  data values, converts the data to different units (e.g. Earth units)
                                    "value": 1000,
                                    // The frequency (in Hertz) at which the Value is valid.
                                    "frequency": 40,
                                    // The units of the data as input from the perspective of data acquisition. After correcting data for this response, these would be the resulting units.
                                    "inputUnits": {
                                        // Name of units, e.g. "M/S", "V", "PA".
                                        "name": "M/S",
                                        "description": ""
                                    },
                                    // The units of the data as output from the perspective of data acquisition. These would be the units of the data prior to correcting for this response.
                                    "outputUnits": {
                                        // Name of units, e.g. "M/S", "V", "PA".
                                        "name": "",
                                        "description": ""
                                    }

                                },
                                "stages": [...]
                            }

                            sample_rate: 200
                        },
                        {
                            "code": "SNN",
                            ...
                        },
                        {
                            "code": "SNE",
                            ...
                        }
                    ]
                }
            ]
        }
    ],
    "traces": [
        {
            "network": "XX",
            "station": "X001",
            "location": "", 
            "channel": "SNZ",
            "starttime": "2003-05-29T02:13:22.043400Z",
            "endtime": "2003-05-29T02:18:20.693400Z",
            "sampling_rate": 40.0,
            "delta": 0.025, // fractional seconds
            "npts": 11947, // number of sample points
            "calib": 1.0,
            "values": [
                // null not allowed
            ]
        }
    ],
}

Sampling rate

Initially the target sampling rate is 40 Hz.

However, using react-native-sensors the actual rate is about 50% of the target sampling rate (with stable use):

  • asus/ASUS_Z01RD/GB (Zenfone 5Z) accelerometer+gyroscope+magnetometer: ~20 Hz with interval 25ms, ~40 Hz with interval 13ms. ~80 Hz with target 160 Hz except magnetometer stuck at ~75 Hz.
  • Samsung A50: accelerometer 53-66 Hz, gyroscope 54-65 Hz, magnetometer 50-61 Hz

Sensor models:

  • Zenfone 5Z: ICM20626 accelerometer, ICM20626 gyroscope, ak0991x magnetometer

For Zenfone 5Z, target of 55 Hz consistently achieves ~40 Hz with 3 sensors, interpolation/resampling (both upsampling and downsampling) will be necessary.

WARNING: react-native-svg-charts rendering is significantly reducing sensor performance. BarChart is fastest, followed by LineChart-curveLinear, then LineChart-curveStep.

TODOs

  • Resample
  • check with Samsung A50 and Vivo Y17. We may need to interpolate in-between samples.
  • Gravitation vector.
  • GPS.

miniSEED channels

  1. SNZ: Short-period 10-80 Hz, Accelerometer, Vertical.
  2. SNN: Short-period 10-80 Hz, Accelerometer, North-South.
  3. SNE: Short-period 10-80 Hz, Accelerometer, East-West.
  4. SFZ: Short-period 10-80 Hz, Magnetometer, Vertical.
  5. SFN: Short-period 10-80 Hz, Magnetometer, North-South.
  6. SFE: Short-period 10-80 Hz, Magnetometer, East-West.

Metadata

Blockette 1000 - Data Only (MiniSEED) Blockette. Data records by themselves do not contain enough information by themselves to allow time series data to be plotted or even simply analyzed. With the addition of a small amount of additional information these limitations are removed. Blockette 1000 is the Data Only (MiniSEED) Blockette that will allow SEED data records to be self-sufficient in terms of defining a time series.

stats = {'network': 'BW', 'station': 'RJOB', 'location': '',
        'channel': 'WLZ', 'npts': len(data), 'sampling_rate': 0.1,
        'mseed': {'dataquality': 'D'}}

Network Station(4-chars) Location(2-digit, optional)

e.g. "XX:X001::SNZ"

To get actual units, divide the counts by gain.

Upload Key

From Google Drive/PSN_Tsunami/sysadmin, copy the quakezone.keystore (upload key) file into the android/app directory in your project folder.

The App Signing Key is managed by Google Play Console.

References

  1. IRIS - Data Formats: SAC, SEED, miniSEED
  2. Anything to MiniSEED

motionrecorder1's People

Contributors

ceefour avatar

Stargazers

Akbar Yahya avatar  avatar

Watchers

James Cloos avatar Masihkasar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.