Closed jpjones76 closed 4 years ago
Split from Issue #28.
ungap!
appears unable to resolve negative time gaps less than one sample long. I don't know if I should consider this a bug or an oversight on my part. I recoded gapfill!
recently, which ungap!
calls, acting on the assumption that negative time gaps get fixed by merge!
; but I implicitly wrote merge!
so that negative subsample gaps persist. Not my smartest coding decision.
I'm going to modify gapfill!
to deal with this.
A fix won't make the outputs of SeisIO and ObsPy identical. In your example, the outputs of ObsPy and SeisIO will only match if each pair of samples at an overlapping time comprises two identical values.
A bit of discussion follows.
No "correct" solution exists for different data samples at overlapping times. Each program has its' own method(s) of handling this problem.
overwrites.
merge
since 2015.merge
was broken for most of SAC's history, until v101.6 (2013).allows one to specify how to handle overlapping samples with a keyword: (https://docs.obspy.org/packages/autogen/obspy.core.trace.Trace.__add__.html#obspy.core.trace.Trace.__add__)
averages pointwise pairs in the absence of NaNs after checking for time shifts.
There's an annoyingly common situation in which two trace files contain identical samples that are time-shifted by a few sample intervals. For example, file trace1.sac
ends at 12:00:00; file trace2.sac
starts at 11:59:59.99; both sample at 100 Hz; yet the first two samples of trace2.sac
are identical to the last two samples of trace1.sac
.
fs
or delta
in the file is inexact; for example, a file claims fs = 40.0 Hz but the channel samples at 40.0001 Hz or 39.9999 Hz.fs_true
and fs_nominal
to yield an offset of several samples.I'm testing a robust fix now. The file you included actually has three data problems:
The first two problems have been handled by merge
since I wrote it, but the "remainder" in the negative time jump causes the problem.
Great! Happy to test this new method on my large set of corrupted files.
This issue appears resolved by my tests. It might be worth reflecting on the necessity of the data set if corrupted files continue to cause this much trouble; this issue took around 20 hours of recoding and testing before I found a solution that didn't break my merge!
tests. At some point data become too corrupt to trust, which I fear any weirder errors will suggest. Still, please keep me posted as your current work develops.
Originally posted by @tclements in https://github.com/jpjones76/SeisIO.jl/issues/28#issuecomment-554531721
One more particularly devious example. Here's an mseed file that has > 10 of negative time gaps. After merging, which works,
ungap
throws a bounds error.S has 14 gaps. Then merge the seisdata
S now has 12 gaps. Now try to ungap
which throws a bounds error. For reference, obspy reads 15 overlapping traces but successfully merges and ungaps.
This seems like a pretty rare problem. This is the only day in 20 years of data for this one station I've had an issue with after the latest update.