Ground Motion Displacement RMS vs Time

an example simple tutorial for getting seismic data, computing the power spectral densities, extracting the RMS and plotting

Required:

  • python
  • obspy (and its dependencies)
  • pandas
  • jupyter
  • notebook

this should be easy to set up in a conda env: conda create -n covid python=3.7 obspy pandas jupyter notebook

Author: Thomas Lecocq @seismotom, Fred Massin @fmassin

Step 1: imports

In [1]:
import imp
import seismosocialdistancing
import datetime
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import matplotlib.patheffects as pe
import numpy as np
import pandas as pd
from obspy import UTCDateTime

Step 2: Define Start/End dates and Seismic Channel

You'll have to make sure the seed_id you request is indeed available from the data_provider

In [29]:
start = UTCDateTime("2020-03-01")
end = UTCDateTime() # () means "now"

network = "CH"
station = "SLOP"#,SZUZ,SGEV,SBERN,SUSI"#,SEPFL,SBAM2" # Urban stations
location = ""
channel = "HGZ,HGE,HGN"
dataset = 'seismoRMSdata/urban-'

data_provider = "ETH"
logo = 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Logo_SED_2014.png/220px-Logo_SED_2014.png'
bans = {"2020-03-13":'Groups >100 banned', 
        "2020-03-20":'Groups >5 banned'}

Step 2: Process PSDs to extract the RMS(displacement)

This can be done for multiple filters at once (freqs below):

In [20]:
myPSDs = seismosocialdistancing.PSDs() #reloadme=myPSDs)
# 'user@hostname' import ssh-key before via `ssh-copy-id user@hostname`
myPSDs.clientpqlx(sshuserhost='SQLX', 
                    network=network,
                    station=station,
                    location=location,
                    channel=channel,
                    start=start,
                    end=end)

# Define frequency bands of interest:
freqs = [(0.1,1.0),(1.0,20.0),(4.0,14.0),(4.0,20.0)]
myPSDs.dRMS(freqs)

Step 3: Custom plot for a single frequency band:

In [43]:
o=myPSDs.plot(mode='*', 
              band = "4.0-14.0",
              bans=bans, 
              logo=logo)
/Users/fmassin/anaconda3/lib/python3.5/site-packages/matplotlib/projections/polar.py:63: RuntimeWarning: invalid value encountered in less
  mask = r < 0
In [ ]:
%autosave 1
import time
time.sleep(2)
%autosave 120
!jupyter nbconvert --to html sqlxSocialDistancing.ipynb
!nbstripout sqlxSocialDistancing.ipynb
Autosaving every 1 seconds