Code Monkey home page Code Monkey logo

earthquake-detector-9000's Introduction

Building a Generalized Earthquake Detector: G.E.D 9000

Idea

The idea is to feed in Spectrogram images to a convolutional neural network in order to detect earthquakes.

The final goal is to make a Generalized Earthquake Detector, meaning it doesn't need to have seen data in a location to be able to find earthquakes.

Dataset

Retrieving and processing the data:

https://github.com/jamesaud/seismic-analysis-toolbox

The data is too large to be held on github, but you can download the data with the toolbox. I will make my dataset available in the future (on Dropbox or something).

On my machine I have roughly 4 million waveforms downloaded!

Code

Written in Pytorch.

If you are familar with Pytorch, the main code will look familiar:

https://github.com/jamesaud/earthquake-detector-9000/blob/master/main.py https://github.com/jamesaud/earthquake-detector-9000/blob/master/pytorch_utils/utils.py

The configuration is in json (or dict in Python):

https://github.com/jamesaud/earthquake-detector-9000/blob/master/config.py

In the 'main' code, if the configuration is set to 'environment', configuration = 'environment' , then it will read in the configuration from validator/config.json.

python main.py runs the neural network.

Performance

Use this model for best performance and efficiency:

https://github.com/jamesaud/earthquake-detector-9000/blob/master/models/mnist_3_component.py

It's an interesting model because it feeds 3 components (N, Z, E), meaning three spectrograms, and then combines features to make a detection.

The convnet does 99.0 - 99.9% accuracy on single location QUALITY datasets.

Many times, the automatic generation of seismic datasets has improperly labeled events or noise. In order to determine what is good quality, use Data Validation.

Data Validation (finding good datasets)

To run the conv net on every location, run:

python data_validate.py

to produce results that tell you the detection accuracy for each location:

https://github.com/jamesaud/earthquake-detector-9000/blob/master/validator/weighted_results_everywhere.csv

Generalized Model

I kept locations that were 97% accurate and higher from the Data Validation step. I used this as my final dataset to train a generalized earthquake detector.

Visualization

Run docker-compose up to get Tensorboard running on localhost:6000

The code in main is configured to write to the folder for visualization.

Tests

There are some tests written:

https://github.com/jamesaud/earthquake-detector-9000/tree/master/tests

Installation

This works with cuda 7.5, because that's what my workstation ran, and required PyTorch version 0.3.x. Now, if you upgrade to PyTorch 0.4 or 1.x there are some breaking changes. It took around 10 minutes to refactor the code after trying to run on version 0.4.x to work again.

Have anaconda installed and run the following command:

conda env create -f environment.yml

enter the new environment

conda activate earthquake

now you are set to run the code:

python main.py

(This won't work until you specify where spectrograms are in the config.py file)

This is a work in progress still. Some of the code does bad practice/unconvential things.

earthquake-detector-9000's People

Contributors

jamesaud avatar

Watchers

James Cloos 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.