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.
 
 
 
 
 
 

63 line
2.8 KiB

  1. #!/bin/bash
  2. ## import common lib
  3. . "$HOME/.noaa.conf"
  4. . "$HOME/.tweepy.conf"
  5. . "$NOAA_HOME/common.sh"
  6. if pgrep "rtl_fm" > /dev/null
  7. then
  8. log "There is an already running rtl_fm instance but I dont care for now, I prefer this pass" "INFO"
  9. pkill -9 -f rtl_fm
  10. fi
  11. # $1 = Satellite Name
  12. # $2 = Frequency
  13. # $3 = FileName base
  14. # $4 = TLE File
  15. # $5 = EPOC start time
  16. # $6 = Time to capture
  17. # $7 = Satellite max elevation
  18. log "Starting rtl_fm record" "INFO"
  19. 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
  20. log "Demodulation in progress (QPSK)" "INFO"
  21. meteor_demod -B -o "${METEOR_OUTPUT}/${3}.qpsk" "${RAMFS_AUDIO}/audio/${3}.wav"
  22. if [ "$DELETE_AUDIO" = true ]; then
  23. log "Deleting audio files" "INFO"
  24. rm "${RAMFS_AUDIO}/audio/${3}.wav"
  25. else
  26. log "Moving audio files out to the SD card" "INFO"
  27. mv "${RAMFS_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/audio/${3}.wav"
  28. fi
  29. log "Decoding in progress (QPSK to BMP)" "INFO"
  30. medet_arm "${METEOR_OUTPUT}/${3}.qpsk" "${METEOR_OUTPUT}/${3}" -cd
  31. rm "${METEOR_OUTPUT}/${3}.qpsk"
  32. if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then
  33. log "I got a successful ${3}.dec file. Creating false color image" "INFO"
  34. medet_arm "${METEOR_OUTPUT}/${3}.dec" "${METEOR_OUTPUT}/${3}-122" -r 65 -g 65 -b 64 -d
  35. convert "${METEOR_OUTPUT}/${3}-122.bmp" "${NOAA_OUTPUT}/images/${3}-122.jpg"
  36. log "Rectifying image to adjust aspect ratio" "INFO"
  37. python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.jpg"
  38. convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-122-rectified.jpg"
  39. convert "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" -channel rgb -normalize "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg"
  40. log "Deleting base image files" "INFO"
  41. rm "${METEOR_OUTPUT}/${3}-122.bmp"
  42. rm "${METEOR_OUTPUT}/${3}.bmp"
  43. rm "${NOAA_OUTPUT}/images/${3}-122.jpg"
  44. sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($5,\"$3\", 1,0);"
  45. pass_id=$(sqlite3 /home/pi/raspberry-noaa/panel.db "select id from decoded_passes order by id desc limit 1;")
  46. if [ -n "$CONSUMER_KEY" ]; then
  47. log "Posting to Twitter" "INFO"
  48. 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"
  49. fi
  50. 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);"
  51. else
  52. log "Decoding failed, either a bad pass/low SNR or a software problem" "ERROR"
  53. fi