weixin_39747577 2020-11-20 19:47
浏览 0

Unstable resuls in delta value in obspy.core.trace.Trace.__add__()

The program below shows application of the Trace.add delta calculation to check for gaps and overlaps. In both cases below, delta should be the same and have a zero integer value, but this is not the case. If this is a bug, perhaps use of a real delta (new_delta below) would be easier and more robust.

Thanks,

Anthony

{{{

import math from obspy.core.utcdatetime import UTCDateTime

obspy.core.trace.py: lines 556-557

... # delta = int(math.floor(round((rt.stats.starttime - \ ... # lt.stats.endtime) * sr, 7))) - 1 ... sample_rate = 1.0 endtime = UTCDateTime()

starttime = endtime + 0.9999 delta = int(math.floor(round((starttime - endtime) * sample_rate, 7))) - 1 print "delta=", delta delta= -1 new_delta = (starttime - endtime) * sample_rate - 1.0 print "new_delta=", new_delta new_delta= -0.0001 print "int(round(abs(new_delta)))=", int(round(abs(new_delta))) int(round(abs(new_delta)))= 0

starttime = endtime + 1.0001 delta = int(math.floor(round((starttime - endtime) * sample_rate, 7))) - 1 print "delta=", delta delta= 0 new_delta = (starttime - endtime) * sample_rate - 1.0 print "new_delta=", new_delta new_delta= 0.0001 print "int(round(abs(new_delta)))=", int(round(abs(new_delta))) int(round(abs(new_delta)))= 0 }}}

该提问来源于开源项目:obspy/obspy

  • 写回答

25条回答 默认 最新

  • weixin_39747577 2020-11-20 19:47
    关注

    [barsch] In [3057/obspy]: {{{

    !CommitTicketReference repository="obspy" revision="3057"

    • fixes #317 - thanks for reporting
    • unfortunately I can't really write a test case for that, as setting endtime in a Stats object is not allowed - how did you hit this error? ;) }}}
    评论

报告相同问题?