Something that has been nagging at me for a while is the common warning
InternalMSEEDWarning: readMSEEDBuffer(): Not a SEED record. Will skip bytes …
…when trying to read a malformed miniseed file (seems to happen if a seedlink transmission is interrupted in a particular way, but also pretty common for older temporary networks). The problem is that in many cases, I only see the error randomly when working with thousands++ of files and there is nothing in the warning that helps identify the offending bit of data.
This is likely more of an libmseed issue, but can anyone think of an easy way to add, at least some or all of the NSLC header info to this warning? Hack would be somewhere in obspy/io/mseed.headers.py I imagine but not obvious enough for me, or perhaps that info isn’t easily accessible in the below
class _LibmseedWrapper(object):
"""
Wrapper object around libmseed that tries to guarantee that all warnings
and errors within libmseed are properly converted to their Python
counterparts.
Might be a bit overengineered but it does the trick and is completely
transparent to the user.
"""
def __init__(self, lib):
self.lib = lib
self.verbose = True
def __getattr__(self, item):
func = getattr(self.lib, item)
def _wrapper(*args):
# Collect exceptions. They cannot be raised in the callback as
# they could never be caught then. They are collected and raised
# later on.
_errs = []
_warns = []
def log_error_or_warning(msg):
msg = msg.decode()
if msg.startswith("ERROR: "):
msg = msg[7:].strip()
_errs.append(msg)
if msg.startswith("INFO: "):
msg = msg[6:].strip()
_warns.append(msg)
diag_print = \
C.CFUNCTYPE(None, C.c_char_p)(log_error_or_warning)
def log_message(msg):
if self.verbose:
print(msg[6:].strip())
log_print = C.CFUNCTYPE(None, C.c_char_p)(log_message)
# Hookup libmseed's logging facilities to it's Python callbacks.
self.lib.setupLogging(diag_print, log_print)
try:
return func(*args)
finally:
for _w in _warns:
warnings.warn(_w, InternalMSEEDWarning)
if _errs:
msg = ("Encountered %i error(s) during a call to "
"%s():\n%s" % (
len(_errs), item, "\n".join(_errs)))
raise InternalMSEEDError(msg)
return _wrapper