Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

receive_meteor.sh 2.8 KiB

4 lat temu
4 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. ## import common lib
  3. . "$HOME/.noaa.conf"
  4. . "$HOME/.tweepy.conf"
  5. . "$NOAA_HOME/common.sh"
  6. ## pass start timestamp and sun elevation
  7. PASS_START=$(expr "$5" + 90)
  8. SUN_ELEV=$(python3 "$NOAA_HOME"/sun.py "$PASS_START")
  9. if pgrep "rtl_fm" > /dev/null
  10. then
  11. log "There is an already running rtl_fm instance but I dont care for now, I prefer this pass" "INFO"
  12. pkill -9 -f rtl_fm
  13. fi
  14. # $1 = Satellite Name
  15. # $2 = Frequency
  16. # $3 = FileName base
  17. # $4 = TLE File
  18. # $5 = EPOC start time
  19. # $6 = Time to capture
  20. # $7 = Satellite max elevation
  21. log "Starting rtl_fm record" "INFO"
  22. timeout "${6}" /usr/local/bin/rtl_fm ${BIAS_TEE} -M raw -f "${2}"M -s 288k -g 48 -p 1 | sox -t raw -r 288k -c 2 -b 16 -e s - -t wav "${RAMFS_AUDIO}/audio/${3}.wav" rate 96k
  23. log "Demodulation in progress (QPSK)" "INFO"
  24. meteor_demod -B -o "${METEOR_OUTPUT}/${3}.qpsk" "${RAMFS_AUDIO}/audio/${3}.wav"
  25. if [ "$DELETE_AUDIO" = true ]; then
  26. log "Deleting audio files" "INFO"
  27. rm "${RAMFS_AUDIO}/audio/${3}.wav"
  28. else
  29. log "Moving audio files out to the SD card" "INFO"
  30. mv "${RAMFS_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/audio/${3}.wav"
  31. fi
  32. log "Decoding in progress (QPSK to BMP)" "INFO"
  33. medet_arm "${METEOR_OUTPUT}/${3}.qpsk" "${METEOR_OUTPUT}/${3}" -cd
  34. rm "${METEOR_OUTPUT}/${3}.qpsk"
  35. if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then
  36. if [ "${SUN_ELEV}" -lt "${SUN_MIN_ELEV}" ]; then
  37. log "I got a successful ${3}.dec file. Decoding APID 68" "INFO"
  38. medet_arm "${METEOR_OUTPUT}/${3}.dec" "${NOAA_OUTPUT}/images/${3}-122" -r 68 -g 68 -b 68 -d
  39. else
  40. log "I got a successful ${3}.dec file. Creating false color image" "INFO"
  41. medet_arm "${METEOR_OUTPUT}/${3}.dec" "${NOAA_OUTPUT}/images/${3}-122" -r 65 -g 65 -b 64 -d
  42. fi
  43. log "Rectifying image to adjust aspect ratio" "INFO"
  44. python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.bmp"
  45. rm "${METEOR_OUTPUT}/${3}-122.bmp"
  46. rm "${METEOR_OUTPUT}/${3}.bmp"
  47. sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($5,\"$3\", 1,0);"
  48. pass_id=$(sqlite3 /home/pi/raspberry-noaa/panel.db "select id from decoded_passes order by id desc limit 1;")
  49. if [ -n "$CONSUMER_KEY" ]; then
  50. log "Posting to Twitter" "INFO"
  51. python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE} Resolución completa: https://weather.reyni.co/detail.php?id=$pass_id" "$7" "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg"
  52. fi
  53. sqlite3 /home/pi/raspberry-noaa/panel.db "update predict_passes set is_active = 0 where (predict_passes.pass_start) in (select predict_passes.pass_start from predict_passes inner join decoded_passes on predict_passes.pass_start = decoded_passes.pass_start where decoded_passes.id = $pass_id);"
  54. else
  55. log "Decoding failed, either a bad pass/low SNR or a software problem" "ERROR"
  56. fi