CC of horizontal components (rotate cc to obtain RR,TT) #245
-
I would like to generate cross-correlations of the horizontal (Radial and Transverse) components from 3 component ZNE data. The documentation suggests that best practice is to compute the full tensor and then rotate afterwards. I'm looking for some guidance on how to do this last step please! I believe the relevant configuration setting is: This gives me 3 output directories when I run I would like to take the .mseed files from each of these directories and rotate them in ObsPy to produce ZRT output, using the ZE file as my E component of my stream, ZN as my N component, etc. The backazimuth that I would rotate to is that between the first and second station in my pair. Is this the correct approach? Thanks in advance for any help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hey, sorry for the delay. This code will be part of the next release indeed. In principle, you have to compute The following code will read the import os, glob, logging
from obspy import read
from msnoise.api import *
db = connect()
filterid = 2
c = np.cos
s = np.sin
for comp in ["ZZ","EE","NN","EN","NE","RR","TT"]:
dir = "STACKS/%02i/REF/%s"%(filterid, comp)
if not os.path.isdir(dir):
os.makedirs(dir)
for sta1,sta2 in get_station_pairs(db):
station1 = "%s.%s" % (sta1.net, sta1.sta)
station2 = "%s.%s" % (sta2.net, sta2.sta)
print(station1, station2)
comps = {}
for comp in ["ZZ","EE","NN","EN","NE"]:
tmp1 = read("STACKS/%02i/REF/%s/%s_%s.MSEED"%(filterid, comp, station1.replace(".","_"),station2.replace(".","_")), format="MSEED")[0]
comps[comp] = tmp1.data
X0, Y0, c0 = (sta1.X, sta1.Y, sta1.coordinates)
X1, Y1, c1 = (sta2.X, sta2.Y, sta1.coordinates)
if c0 == c1:
coordinates = c0
else:
coordinates = 'MIX'
az = azimuth(coordinates, X0, Y0, X1, Y1)
dist = get_interstation_distance(sta1,sta2)
print("Azimuth", az)
print("Distance", dist)
t = np.deg2rad(az)
p = np.deg2rad(az-180)
rotation_operator = np.array([[-c(t)*c(p), c(t)*s(p),-s(t)*s(p), s(t)*c(p)],
[-s(t)*s(p),-s(t)*c(p),-c(t)*c(p),-c(t)*s(p)],
[-c(t)*s(p),-c(t)*c(p), s(t)*c(p), s(t)*s(p)],
[-s(t)*c(p), s(t)*s(p), c(t)*s(p),-c(t)*c(p)]])
[TT, RR, TR, RT] = np.dot(rotation_operator, np.array([comps["EE"], comps["EN"], comps["NN"], comps["NE"]]))
tmp1.data = TT
tmp1.write("STACKS/%02i/REF/TT/%s_%s.MSEED"%(filterid, station1.replace(".","_"),station2.replace(".","_")), format="MSEED")
tmp1.data = RR
tmp1.write("STACKS/%02i/REF/RR/%s_%s.MSEED"%(filterid, station1.replace(".","_"),station2.replace(".","_")), format="MSEED")
del tmp1
|
Beta Was this translation helpful? Give feedback.
Hey, sorry for the delay. This code will be part of the next release indeed.
In principle, you have to compute
EE,NN,EN,NE
for computingRR,TT
.The following code will read the
REF
stacks and compute the radial-radial and transverse-transverse components, using the station database for defining the azimuths: