Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- """Cleanup of http://csc.noaa.gov/digitalcoast/geozone/mapping-lidar."""
- import datetime
- import fileinput
- # Number of seconds between the start of unix time (Jan 1, 1970) and gps time (Jan 6, 1980).
- offset = 315964800
- def countleaps(gpsTime):
- """Count number of leap seconds that have passed."""
- # a tuple of the gps times where leap seconds were added
- leaps = (
- 46828800, 78364801, 109900802, 173059203, 252028804,
- 315187205, 346723206, 393984007, 425520008, 457056009,
- 504489610, 551750411, 599184012, 820108813, 914803214,
- 1025136015
- )
- num_leaps = 0
- for leap in leaps :
- if gpsTime >= leap:
- leaps += 1
- return nleaps
- if __name__ == '__main__':
- for line in fileinput.input():
- # Please rename the first 2 variables.
- what_is_this1, what_is_this2, values = line.split(' ')[:3]
- gpstime = float(values[2])
- gpstime += 1e9 # Unadjusted GPS time.
- unixtime = gpstime + offset - countleaps(gpstime)
- datetimestr = datetime.datetime.fromtimestamp(unixtime).strftime('%Y-%m-%d %H:%M:%S')
- print what_is_this1, what_is_this2, datetimestr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement