You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

receive.sh 2.0 KiB

6 years ago
6 years ago
6 years ago
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/sh
  2. ## debug
  3. # set -x
  4. . ~/.noaa.conf
  5. ## sane checks
  6. if [ ! -d ${NOAA_HOME} ]; then
  7. mkdir -p ${NOAA_HOME}
  8. fi
  9. if [ ! -d ${NOAA_OUTPUT} ]; then
  10. mkdir -p ${NOAA_OUTPUT}
  11. fi
  12. if [ ! -d ${NOAA_OUTPUT}/audio/ ]; then
  13. mkdir -p ${NOAA_OUTPUT}/audio/
  14. fi
  15. if [ ! -d ${NOAA_OUTPUT}/image/ ]; then
  16. mkdir -p ${NOAA_OUTPUT}/image/
  17. fi
  18. if [ ! -d ${NOAA_HOME}/map/ ]; then
  19. mkdir -p ${NOAA_HOME}/map/
  20. fi
  21. if [ ! -d ${NOAA_HOME}/predict/ ]; then
  22. mkdir -p ${NOAA_HOME}/predict/
  23. fi
  24. if pgrep "rtl_fm" > /dev/null
  25. then
  26. exit 1
  27. fi
  28. # $1 = Satellite Name
  29. # $2 = Frequency
  30. # $3 = FileName base
  31. # $4 = TLE File
  32. # $5 = EPOC start time
  33. # $6 = Time to capture
  34. START_DATE=$(date '+%d-%m-%Y %H:%M')
  35. timeout "${6}" /usr/local/bin/rtl_fm -f "${2}"M -s 60k -g 50 -p 55 -E wav -E deemp -F 9 - | sox -t raw -e signed -c 1 -b 16 -r 60000 - ${NOAA_OUTPUT}/audio/"${3}".wav rate 11025
  36. PASS_START=$(expr "$5" + 90)
  37. SUN_ELEV=$(python2 sun.py $PASS_START)
  38. if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then
  39. ENHANCEMENTS="ZA MCIR MCIR-precip MSA MSA-precip HVC-precip HVCT-precip HVC HVCT"
  40. else
  41. ENHANCEMENTS="ZA MCIR MCIR-precip"
  42. fi
  43. /usr/local/bin/wxmap -T "${1}" -H "${4}" -p 0 -l 0 -o "${PASS_START}" ${NOAA_HOME}/map/"${3}"-map.png
  44. for i in $ENHANCEMENTS; do
  45. /usr/local/bin/wxtoimg -o -m ${NOAA_HOME}/map/"${3}"-map.png -e $i ${NOAA_OUTPUT}/audio/"${3}".wav ${NOAA_OUTPUT}/image/"${3}"-$i.jpg
  46. /usr/bin/convert -quality 90 -format jpg ${NOAA_OUTPUT}/image/"${3}"-$i.jpg -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} $i ${START_DATE}" ${NOAA_OUTPUT}/image/"${3}"-$i.jpg
  47. /usr/bin/gdrive upload --parent 1gehY-0iYkNSkBU9RCDsSTexRaQ_ukN0A ${NOAA_OUTPUT}/image/"${3}"-$i.jpg
  48. done
  49. if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then
  50. python2 ${NOAA_HOME}/post.py "$1 ${START_DATE}" ${NOAA_OUTPUT}/image/$3-MCIR-precip.jpg ${NOAA_OUTPUT}/image/$3-MSA-precip.jpg ${NOAA_OUTPUT}/image/$3-HVC-precip.jpg ${NOAA_OUTPUT}/image/$3-HVCT.jpg
  51. else
  52. python2 ${NOAA_HOME}/post.py "$1 ${START_DATE}" ${NOAA_OUTPUT}/image/$3-MCIR-precip.jpg ${NOAA_OUTPUT}/image/$3-MCIR.jpg
  53. fi