Fix reftek130 malformed eh header - #3743
Conversation
… add fallback_sampling_rate parameter for malformed EH headers Added fallback_sampling_rate parameter to handle cases where the sampling rate cannot be parsed from the EH packet. Updated relevant methods to utilize this new parameter.
Old REFTEK DAS firmware sometimes wrote blank or scrambled fields in the EH packet binary header. This adds a try/except around the converter call in EHPacket.__init__ so that malformed fields are set to None with a warning instead of raising ValueError and preventing the entire file from being read. This is part of the same fix as the core.py change - the two together allow reading of REFTEK files recorded with old firmware.
|
This seems like curious edge cases, but then again, I don't think it will hurt much to add anyway. Can you add a small example file, just a handful of reftek packets long would be ideal, that showcases the problem, and then also a short test case for the new functionality would be needed. Also changelog. All of this is part of the pull request template we put in place. |
|
|
||
| >>> from obspy import read | ||
| >>> st = read("file.rt130", format="REFTEK130", | ||
| ... fallback_sampling_rate=100.0) # doctest: +SKIP |
There was a problem hiding this comment.
The part with "Example usage: ... " and the code block can be removed. No need to show how to use a simple kwarg. Should be clear from the description. The builtin keyword None needs to go into double backticks for sphinx:
``None``
| read the headers. | ||
| :type fallback_sampling_rate: float, optional | ||
| :param fallback_sampling_rate: Sampling rate to use if the sampling | ||
| rate field in the EH packet cannot be parsed. |
There was a problem hiding this comment.
There is more detail info in the other docstring, so I would either link to there like...
More detail, see :func:`_read_reftek130`
.. or simply put the same detail info here too
megies
left a comment
There was a problem hiding this comment.
Needs a small test file and test case testing both behaviors (raising exception vs. successful reading with warning), then also changelog and some other minor changes
Add test fixtures for malformed EH header fix
Added a new parameter to handle malformed sampling rates in EH packet headers and updated the changelog accordingly.
Removed example usage for fallback_sampling_rate parameter and clarified its description.
|
Added the test fixtures, test cases (covering both the raise-without-fallback and read-with-fallback behaviors, plus a case for other malformed EH fields), changelog entry, and cleaned up the docstrings as requested. Ready for another look. |
Old REFTEK DAS firmware sometimes wrote blank or scrambled
fields in the EH packet binary header, causing ObsPy to raise a
ValueError even though the DT packets containing actual waveform data
are intact.
This PR makes two changes:
to_stream() so users can specify the sampling rate when the EH
packet sampling_rate field cannot be parsed
are set to None with a warning instead of crashing
Tested on real data from REFTEK units deployed in the Koyna-Warna
seismic network (India) circa 2006-2008.