Plotting seismic noise. ObsPy, numpy, pandas, matplotlib are required.
import numpy as np
import matplotlib as mpl
import pandas as pd
import obspy as op
print("# numpy version = ",np.__version__)
print("# matplotlib version = ",mpl.__version__)
print("# pandas version = ",pd.__version__)
print("# numpy version = ",np.__version__)
print("# obspy version = ",op.__version__)
import matplotlib.pyplot as plt
from obspy import UTCDateTime
This example uses a 4.0-14.0 passband
band = "4.0-14.0"
This example uses the ftp directory
csv_dir = "http://ncedc.org/ftp/outgoing/taira/EastBay_seismic_noise"
This example uses BK.BRK.00.HHZ
net = "BK" # network ID
sta = "BRK" # station ID
#sta = "BKS"
loc = "00" # location ID
com = "HHZ" # channel ID
nslc = net+"."+sta+"."+loc+"."+com
print("# nslc = ", nslc)
This csv file includes seismic noise at several different frequency bands. Timestamp is UTC
csv_fi = csv_dir+"/"+net+"."+sta+"."+loc+"."+com+".csv"
This rs csv file includes 1-day median noise level (from 6am through 4pm at local time) at the 4.0-14.0 Hz. Timestamp is UTC
#http://ncedc.org/ftp/outgoing/taira/EastBay_seismic_noise/BK.BRK.00.HHZ_4.0-14.0_rs.csv
rs_csv_fi = csv_dir+"/"+net+"."+sta+"."+loc+"."+com+"_"+band+"_rs.csv"
csv_data = pd.read_csv(csv_fi,
sep=",", index_col=0)
csv_data['time'] = pd.to_datetime(csv_data.index)
#print(csv_data)
rs_csv_data = pd.read_csv(rs_csv_fi,
sep=",", index_col=0)
#print(rs_csv_data)
rs_csv_data['time'] = pd.to_datetime(rs_csv_data.index)
#print(rs_csv_data['time'])
Data are plotted at UTC timestamp. Red dashed line: When Bay Area shulter-in-place order was issued (2020-03-17 00:00 local time -> 2020-03-17 07:00 UTC)
plt.figure(figsize=(20, 6))
# 1e+9 for conveting meter -> nanometer
plt.plot(csv_data['time'], csv_data[band]*1e+9, label=com)
plt.plot(rs_csv_data['time'], rs_csv_data[band]*1e+9, label="$\overline{"+com+"}$ (6h-16h)")
#plt.ylim(0.75,3)
ymin = 0
ymax = np.nanpercentile(csv_data[band]*1e+9,95)*1.5
plt.ylim(ymin, ymax)
#2020-03-17 00:00":'BayArea shelter-in-place order' local time
plt.vlines(x=(UTCDateTime("2020-03-17 07:00").datetime), ymin=ymin, ymax=ymax, color="red", linewidth = 2.0, linestyle = "--")
plt.xlim(csv_data['time'][0], csv_data['time'][-1])
plt.ylabel("Displacement (nm)")
plt.title("Seismic Noise for "+nslc+" - Filter ["+band+"] Hz")
plt.legend(loc = "upper right")
plt.savefig(nslc+"_"+band+".png")