-
Notifications
You must be signed in to change notification settings - Fork 2
/
clone_inv.py
64 lines (51 loc) · 1.98 KB
/
clone_inv.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 4 11:06:15 2017
Short script to copy over the response information stored in an obspy "inventory"
from one station-channel to a second station-channel.
Caution: There's no checking built into this script to ensure that the attached
response information is actually appropriate for this station-channel.
@author: timb
"""
import obspy
from obspy.core.inventory import Inventory, Network, Station, Channel, Site
#from obspy.clients.nrl import NRL
def clone_inv(inv, net_name, sta_name):
net = Network(
# This is the network code according to the SEED standard.
code=net_name,
# A list of stations. We'll add one later.
stations=[],
# description="A test stations.",
# Start-and end dates are optional.
# start_date=obspy.UTCDateTime(2016, 1, 2))
)
sta = Station(
# This is the station code according to the SEED standard.
code=sta_name,
latitude= inv[0][0].latitude,
longitude= inv[0][0].longitude,
elevation= inv[0][0].elevation,
creation_date=obspy.UTCDateTime(2016, 1, 2),
site=Site(name="station with cloned inv"))
cha = Channel(
# This is the channel code according to the SEED standard.
code="HHZ",
# This is the location code according to the SEED standard.
location_code="",
# Note that these coordinates can differ from the station coordinates.
start_date=inv[0][0][0].start_date,
latitude= inv[0][0][0].latitude,
longitude= inv[0][0][0].longitude,
elevation= inv[0][0][0].elevation,
depth= inv[0][0][0].depth,
# azimuth=0.0,
# dip=-90.0,
sample_rate= inv[0][0][0].sample_rate)
# Now tie it all together.
cha.response = inv[0][0][0].response #response
sta.channels.append(cha)
net.stations.append(sta)
inv.networks.append(net)
return inv