31 lines
874 B
Python
31 lines
874 B
Python
|
import logging
|
||
|
import sys
|
||
|
|
||
|
from obspy import read_inventory, read_events
|
||
|
|
||
|
|
||
|
def count_picks_from_stations(quakeml_file, inventory):
|
||
|
|
||
|
# Read the QuakeML file
|
||
|
try:
|
||
|
events = read_events(quakeml_file)
|
||
|
except Exception as e:
|
||
|
logging.error(f"Error reading QuakeML file: {e}")
|
||
|
sys.exit(1)
|
||
|
|
||
|
# Extract station network and station codes from the inventory
|
||
|
stations = set()
|
||
|
for network in inventory:
|
||
|
for station in network:
|
||
|
stations.add((network.code, station.code))
|
||
|
|
||
|
# Count the number of picks in the QuakeML file that come from the stations in the inventory
|
||
|
pick_count = 0
|
||
|
for event in events:
|
||
|
for pick in event.picks:
|
||
|
net_sta = (pick.waveform_id.network_code, pick.waveform_id.station_code)
|
||
|
if net_sta in stations:
|
||
|
pick_count += 1
|
||
|
|
||
|
return pick_count
|