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

Comparing timestamps in Parser.getCoordinates and Parser.getPAZ introduces precisions errors

Both {{{Parser.getCoordinates}}} and {{{Parser.getPAZ}}} use the following code to check if a channel response is available for a certain time:

{{{ channel = [cha for cha in channel \ if float(cha.split('/')[1]) < datetime.timestamp \ and float(cha.split('/')[2]) > datetime.timestamp] }}}

This is however prone to precision errors, because the timestamp string is generally not precise up to the seconds, and the conversion to float may introduce other rounding effects.

This gives problems if one needs PAZ or coordinates for a time which is close (or equal) to the start or end time of the response information.

I attach an example to test this behavior.

I also attach a patch which uses datetime comparison instead of float comparison to check the date. The patch also improves the warning ('None or more than one channel with the given description') by splitting it for "none" and "more than one"

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

  • 写回答

7条回答 默认 最新

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

    [satriano] I forgot: I think that the datetime test has to include the equality, both for start and for end time, since normally response files have non overlapping start and end times, e.g. :

    {{{ Start date: 2009,000,00:00:00 End date: 2010,365,23:59:59

    
    ....
    Start date: 2011,001,00:00:00
    ....
    

    }}}

    评论

报告相同问题?