Closed medlin01GA closed 5 years ago
Thanks for reporting this issue and suggesting solutions! I will have a look.
I solved it similar as you suggested by catching the error in iter_event_data and issuing a warning instead. Does it work for you?
Looks good to me, thanks Tom.
The iterator
iter_event_data
does not gracefully handle when the Origin of an Event is missing an expected field. Namely, if any of {latitude, longitude, depth, magnitude, or time} are missing, then the call tostats.update(obj2stats(event=event, station=station))
in functionrf_stats
can raise an unhandled exception. This is difficult for the user to handle in a recoverable way, since the iterator will be left before the user code has a chance to handle it. It should probably be handled (with a warning message) inrf_stats
, and then return an empty object. This would allow the iteratoriter_event_data
to continue yielding events.To reproduce the issue, use a valid Event with valid Origin, and del the
depth
field of the Origin. Then pass such data toiter_event_data
to iterate over.A real example of a typical, valid Origin:
A real example of a bad Origin, missing the depth field, taken from Event id "smi:ISC/evid=611767244":
As a workaround, users could remove bad events from a Catalog before passing it to
iter_event_data
.