Skip to content

Instantly share code, notes, and snippets.

@K4KDR
Last active December 11, 2022 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save K4KDR/68a8f1fd2bde2e4a0f5d6e22d0547448 to your computer and use it in GitHub Desktop.
Save K4KDR/68a8f1fd2bde2e4a0f5d6e22d0547448 to your computer and use it in GitHub Desktop.
01-Mar-2017_shell_script_&_Python_code_to_decode_LMS-6_radiosondes
#!/usr/bin/python2.7
#
# to run: ./csv2kml.py from within working directory where this script & lms6 decoder files are located
# NOTE: ./data/lat-long-alt.csv files must already exist (is created by rf2csv.sh script)
#
#
# using "while" to loop program until broken out w/ CTL-c
#
while True:
#
# delete non-ascii characters
#
import unicodedata
import codecs
infile = codecs.open('./data/lat-long-alt.csv','r',encoding='utf-8',errors='ignore')
outfile = codecs.open('./data/lat-long-alt--only-ascii.csv','w',encoding='utf-8',errors='ignore')
for line in infile.readlines():
for word in line.split():
outfile.write(word+" ")
outfile.write("\n")
infile.close()
outfile.close()
#
# delete blank lines
#
with open("./data/lat-long-alt--only-ascii.csv","r") as f, open("./data/lat-long-alt--no-blank-lines.csv","w") as outfile:
for i in f.readlines():
if not i.strip():
continue
if i:
outfile.write(i)
#
# from each line in csv file, extract long, lat, & alt; save to properly formatted kml file
#
import csv
import simplekml
inputfile = csv.reader(open('./data/lat-long-alt--no-blank-lines.csv','r'))
kml=simplekml.Kml()
style = simplekml.Style()
style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png'
style.iconstyle.color = simplekml.Color.red
for row in inputfile:
pnt = kml.newpoint()
pnt.coords = [(row[1],row[0],row[2])]
pnt.style = style
pnt.extrude = 1
pnt.altitudemode = simplekml.AltitudeMode.relativetoground
kml.networklinkcontrol.minrefreshperiod = 20
#
# NOTE: adjust KML save file/folder detail to suit your environment
#
kml.save('/home/k4kdr/Dropbox/Public/kml/k4kdr-radiosonde-track.kml')
#
# echo current time onto screen
#
import datetime
now = datetime.datetime.now()
print "Last KML update : ",
print now.strftime("%Y-%m-%d %H:%M:%S")
#
# pause program loop for 15 seconds
#
import time
time.sleep(15) # delays for 15 seconds
#!/bin/bash
#
# Monitors audio from SDR or recorded file; decodes lms-6 radiosonde telemetry; writes output to screen & saves in CSV file
# NOTE: "stdbuf -oL" command used to limit buffer to a single line
#
# LMS6 decoder application from: https://github.com/rs1729/RS
#
#
# to run: ./rf2csv.sh from within working directory where this script & lms6 decoder files are located
#
#
# make ./data directory if it does not already exist
#
mkdir -p data
sox -d -t wav - lowpass 2600 2>/dev/null | stdbuf -oL ./lms6-decoder -v | stdbuf -oL tee /dev/tty | stdbuf -oL cut -c46-54,63-72,82-89 --output-delimiter=',' > ./data/lat-long-alt.csv
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment