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.
 
 
 
 
 
 

67 lines
2.6 KiB

  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 [ "${SUN_ELEV}" -lt "${SUN_MIN_ELEV}" ]; then
  10. log "Sun elev is too low. Meteor IR radiometers are not working" "INFO"
  11. exit 0
  12. fi
  13. if pgrep "rtl_fm" > /dev/null
  14. then
  15. log "There is an already running rtl_fm instance but I dont care for now, I prefer this pass" "INFO"
  16. pkill -9 -f rtl_fm
  17. fi
  18. # $1 = Satellite Name
  19. # $2 = Frequency
  20. # $3 = FileName base
  21. # $4 = TLE File
  22. # $5 = EPOC start time
  23. # $6 = Time to capture
  24. # $7 = Satellite max elevation
  25. log "Starting rtl_fm record" "INFO"
  26. 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
  27. log "Demodulation in progress (QPSK)" "INFO"
  28. meteor_demod -B -o "${METEOR_OUTPUT}/${3}.qpsk" "${RAMFS_AUDIO}/audio/${3}.wav"
  29. if [ "$DELETE_AUDIO" = true ]; then
  30. log "Deleting audio files" "INFO"
  31. rm "${RAMFS_AUDIO}/audio/${3}.wav"
  32. fi
  33. log "Decoding in progress (QPSK to BMP)" "INFO"
  34. medet_arm "${METEOR_OUTPUT}/${3}.qpsk" "${METEOR_OUTPUT}/${3}" -cd
  35. rm "${METEOR_OUTPUT}/${3}.qpsk"
  36. if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then
  37. log "I got a successful ${3}.dec file. Creating false color image" "INFO"
  38. medet_arm "${METEOR_OUTPUT}/${3}.dec" "${METEOR_OUTPUT}/${3}-122" -r 65 -g 65 -b 64 -d
  39. convert "${METEOR_OUTPUT}/${3}-122.bmp" "${NOAA_OUTPUT}/image/${3}-122.jpg"
  40. log "Rectifying image to adjust aspect ratio" "INFO"
  41. python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/image/${3}-122.jpg"
  42. convert -thumbnail 300 "${NOAA_OUTPUT}/image/${3}-122-rectified.jpg" "${NOAA_OUTPUT}/image/thumb/${3}-122-rectified.jpg"
  43. convert "${NOAA_OUTPUT}/image/${3}-122-rectified.jpg" -channel rgb -normalize "${NOAA_OUTPUT}/image/${3}-122-rectified.jpg"
  44. log "Deleting base image files" "INFO"
  45. rm "${METEOR_OUTPUT}/${3}-122.bmp"
  46. rm "${METEOR_OUTPUT}/${3}.bmp"
  47. rm "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.jpg"
  48. sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($5,\"$3\", 1,0);"
  49. if [ -n "$CONSUMER_KEY" ]; then
  50. log "Posting to Twitter" "INFO"
  51. python3 "${NOAA_HOME}/post.py" "$1 EXPERIMENTAL ${START_DATE} Resolución completa: http://weather.reyni.co/image/${FOLDER_DATE}/${3}-122-rectified.jpg" "$7" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified.jpg"
  52. fi
  53. else
  54. log "Decoding failed, either a bad pass/low SNR or a software problem" "ERROR"
  55. fi