from obspy import read
from obspy import UTCDateTime
from obspy.clients.fdsn import Client
from obspy.geodetics.base import gps2dist_azimuth
from obspy.signal.rotate import rotate_ne_rt
from obspy.signal.rotate import rotate_rt_ne
from obspy.signal.rotate import rotate2zne
import obspy as ob
print("# obspy version = ",ob.__version__)
import numpy as np
import scipy as sp
import matplotlib as mpl
print("# numpy version = ",np.__version__)
print("# scipy version = ",sp.__version__)
print("# matplotlib version = ",mpl.__version__)
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import matplotlib.dates as mdates
from scipy import signal
from scipy import ndimage
from scipy.fftpack import fft, ifft
from scipy.linalg import norm
from scipy.stats import pearsonr
from scipy.stats import spearmanr
from scipy.stats import kendalltau
import sys
import os
compute sqrt(total power) for obspy stream data
def total_power_sqrt (st):
st_total_power_sqrt = norm(st[0].data,2)
return st_total_power_sqrt
normalize obspy stream data
def st_normalize(st, val):
st[0].data = st[0].data/val
return st
st = read().select(channel="EHZ")
_plot = st.plot()
st_total_power_sqrt = total_power_sqrt(st)
print(st_total_power_sqrt)
st_norm = st_normalize(st.copy(), st_total_power_sqrt )
_plot = st_norm.plot()