Created
August 16, 2016 14:13
-
-
Save daniestevez/45f386a5bf376507d93e93f19aeb189f to your computer and use it in GitHub Desktop.
Radiosonde to NMEA script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 -u | |
import sys | |
for line in sys.stdin: | |
s = line.split(' ') | |
if len(s) < 14: | |
continue | |
time = s[4] | |
lat = s[7] | |
lon = s[10] | |
alt = s[13] | |
t = time.split(':') | |
time = t[0] + t[1] + t[2].split('.')[0] | |
l = lat.split('.') | |
if l[0][0] == '-': | |
ns = 'S' | |
l[0] = l[0][1:] | |
else: | |
ns = 'N' | |
lat = l[0] + str(float('0.'+l[1])*60)[:6] | |
l = lon.split('.') | |
if l[0][0] == '-': | |
ew = 'W' | |
l[0] = l[0][1:] | |
else: | |
ew = 'E' | |
lon = l[0] + str(float('0.'+l[1])*60)[:6] | |
print("$GPRMC,{},A,{},{},{},{},0.0,0.0,010100,,,".format(time,lat,ns,lon,ew)) | |
print("$GPGGA,{},{},{},{},{},1,08,1.0,{},M,0.0,M,,".format(time,lat,ns,lon,ew,alt)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment