Skip to content

Commit

Permalink
Merge pull request #10 from greglucas/add-network-code
Browse files Browse the repository at this point in the history
ENH: Add ability to download sites based on network codes
  • Loading branch information
greglucas authored Nov 13, 2023
2 parents 3ac04d0 + e1bac51 commit 2de4f86
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bezpy/mt/datalogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self):
self.zpk = None
self.timedelays = None

def download_iris_waveforms(self, name, start_time, end_time):
def download_iris_waveforms(self, name, start_time, end_time, network_code="EM"):
"""Download waveforms from the IRIS client."""
# The only reason we are putting a global in here is because
# of how long it takes to create the Client, and with multiple
Expand All @@ -40,7 +40,7 @@ def download_iris_waveforms(self, name, start_time, end_time):
# The channels are
# E: LQN/LQE
# B: LFN/LFE/LFZ
stream = _IRIS_CLIENT.get_waveforms("EM", name, "*", "*",
stream = _IRIS_CLIENT.get_waveforms(network_code, name, "*", "*",
UTCDateTime(start_time),
UTCDateTime(end_time))
# Convert the stream to a pandas DataFrame
Expand Down
5 changes: 4 additions & 1 deletion bezpy/mt/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ def read_xml(fname):
# Store the parsed root xml element
site.xml = root
site.product_id = get_text(root, "ProductId")

# Metadata url contains the network code
metadata_url = get_text(root.find("ExternalUrl"), "Url")
# http://www.iris.edu/mda/EM/VAQ58 -> EM
site.network_code = metadata_url.split("/")[-2]
loc = xml_site.find("Location")
site.latitude = convert_float(get_text(loc, "Latitude"))
site.longitude = convert_float(get_text(loc, "Longitude"))
Expand Down
3 changes: 2 additions & 1 deletion bezpy/mt/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ def download_waveforms(self):

self.waveforms = self.datalogger.download_iris_waveforms(self.name,
self.start_time,
self.end_time)
self.end_time,
network_code=self.network_code)

def load_waveforms(self, directory="./"):
"""Load the waveform data that has already been downloaded."""
Expand Down

0 comments on commit 2de4f86

Please sign in to comment.