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