【问题标题】:Converting GPS time to UTC将 GPS 时间转换为 UTC
【发布时间】:2022-01-24 09:41:44
【问题描述】:

作为我硕士项目的一部分,我使用 RTK 接收器收集数据,并将一些 x、y、z、时间数据与科学测量相匹配,我需要转换一些 GPS 时间(GPS 周和自 GPS 开始以来的毫秒数周) 到 UTC (hh:mm:ss:ms)。 有人可以指导我吗?

例如: data example to convert 干杯

【问题讨论】:

标签: python timestamp gps data-science utc


【解决方案1】:

您可以尝试以下方法吗:

from datetime import datetime, timedelta
import pytz

def gps_datetime(time_week, time_ms, leap_seconds=18):
    gps_epoch = datetime(1980, 1, 6, tzinfo=pytz.utc)
    return gps_epoch + timedelta(weeks=time_week, 
                                 milliseconds=time_ms, 
                                 seconds=-leap_seconds)
# from your example
print(gps_datetime(2193, 377638200))

输出:

datetime.datetime(2022, 1, 20, 8, 53, 58, 200000, tzinfo=<UTC>)

【讨论】:

  • Tnx 因为它有效我只需要检查科学测量的时间是否完全相同。
  • 很高兴它有帮助。快乐编码!!!
  • 我假设 'leap_seconds' 参数应该设置为 18,因为到目前为止 GPS 到 UTC 之间有 18 个闰秒。我在转换后的时间和我想按时间匹配的测量的 UTC 时间之间仍然存在偏差。有什么想法吗?
  • 已更新至 18。立即查看。
猜你喜欢
  • 1970-01-01
  • 2021-07-22
  • 1970-01-01
  • 2020-12-07
  • 1970-01-01
  • 2013-02-03
  • 2018-09-02
  • 2017-04-27
相关资源
最近更新 更多