Skip to content

Commit

Permalink
Bug Fix in FederatedASDFDataSet
Browse files Browse the repository at this point in the history
* Fixed a stealthy bug in FederatedASDFDataSet where location codes were
  incorrectly handled.
* Patched safe_iter_event_data to avoid loss of usable data in cases
  when input inventories contain incorrect recording periods
  • Loading branch information
geojunky committed Aug 22, 2024
1 parent c3ab5d7 commit 8411a20
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
22 changes: 14 additions & 8 deletions seismic/ASDFdatabase/_FederatedASDFDataSetImpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,17 +491,23 @@ def get_stations(self, starttime, endtime, network=None, station=None, location=
endtime = UTCDateTime(endtime).timestamp

query = 'select * from wtag where '
if (network): query += " net='%s' "%(network)
if (station):
if(network): query += "and sta='%s' "%(station)
if (network is not None): query += " net='%s' "%(network)
if (station is not None):
if(network is not None): query += "and sta='%s' "%(station)
else: query += "sta='%s' "%(station)
if (location):
if(network or station): query += "and loc='%s' "%(location)
if (location is not None):
if((network is not None) or
(station is not None)): query += "and loc='%s' "%(location)
else: query += "loc='%s' "%(location)
if (channel):
if(network or station or location): query += "and cha='%s' "%(channel)
if (channel is not None):
if((network is not None) or
(station is not None) or
(location is not None)): query += "and cha='%s' "%(channel)
else: query += "cha='%s' "%(channel)
if (network or station or location or channel): query += ' and '
if ((network is not None) or
(station is not None) or
(location is not None) or
(channel is not None)): query += ' and '
query += ' et>=%f and st<=%f' \
% (starttime, endtime)
query += ' group by net, sta, loc, cha'
Expand Down
5 changes: 4 additions & 1 deletion seismic/stream_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ def safe_iter_event_data(events, inventory, get_waveforms, use_rfstats=True, pha
pbar.update(1)
origin_time = (event.preferred_origin() or event.origins[0])['time']
try:
args = (seedid[:-1] + stations[seedid], origin_time)
# exclude datetime from call to get_coordinates to ensure incorrect
# recording periods in the inventory do not lead to loss of usable
# data
args = (seedid[:-1] + stations[seedid], None)
coords = inventory.get_coordinates(*args)
except Exception: # station not available at that time
continue
Expand Down

0 comments on commit 8411a20

Please sign in to comment.