25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

90 lines
3.5 KiB

  1. #!/bin/bash
  2. ## import common lib
  3. . "$HOME/.noaa.conf"
  4. . "$HOME/.tweepy.conf"
  5. . "$NOAA_HOME/common.sh"
  6. SYSTEM_MEMORY=$(free -m | awk '/^Mem:/{print $2}')
  7. if [ "$SYSTEM_MEMORY" -lt 2000 ]; then
  8. log "The system doesn't have enough space to store a Meteor pass on RAM" "INFO"
  9. RAMFS_AUDIO="${METEOR_OUTPUT}"
  10. fi
  11. if [ "$FLIP_METEOR_IMG" == "true" ]; then
  12. log "I'll flip this image pass because FLIP_METEOR_IMG is set to true" "INFO"
  13. FLIP="-rotate 180"
  14. else
  15. FLIP=""
  16. fi
  17. ## pass start timestamp and sun elevation
  18. PASS_START=$(expr "$5" + 90)
  19. SUN_ELEV=$(python3 "$NOAA_HOME"/sun.py "$PASS_START")
  20. if pgrep "rtl_fm" > /dev/null
  21. then
  22. log "There is an already running rtl_fm instance but I dont care for now, I prefer this pass" "INFO"
  23. pkill -9 -f rtl_fm
  24. fi
  25. # $1 = Satellite Name
  26. # $2 = Frequency
  27. # $3 = FileName base
  28. # $4 = TLE File
  29. # $5 = EPOC start time
  30. # $6 = Time to capture
  31. # $7 = Satellite max elevation
  32. log "Starting rtl_fm record" "INFO"
  33. 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
  34. log "Normalization in progress" "INFO"
  35. sox "${RAMFS_AUDIO}/audio/${3}.wav" "${METEOR_OUTPUT}/${3}.wav" gain -n
  36. log "Demodulation in progress (QPSK)" "INFO"
  37. meteor_demod -B -o "${METEOR_OUTPUT}/${3}.qpsk" "${METEOR_OUTPUT}/${3}.wav"
  38. if [ "$DELETE_AUDIO" = true ]; then
  39. log "Deleting audio files" "INFO"
  40. rm "${METEOR_OUTPUT}/audio/${3}.wav"
  41. rm "${RAMFS_AUDIO}/audio/${3}.wav"
  42. fi
  43. log "Decoding in progress (QPSK to BMP)" "INFO"
  44. medet_arm "${METEOR_OUTPUT}/${3}.qpsk" "${METEOR_OUTPUT}/${3}" -cd
  45. rm "${METEOR_OUTPUT}/${3}.qpsk"
  46. if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then
  47. if [ "${SUN_ELEV}" -lt "${SUN_MIN_ELEV}" ]; then
  48. log "I got a successful ${3}.dec file. Decoding APID 68" "INFO"
  49. medet_arm "${METEOR_OUTPUT}/${3}.dec" "${METEOR_OUTPUT}/${3}-122" -r 68 -g 68 -b 68 -d
  50. convert "${METEOR_OUTPUT}/${3}-122.bmp" -channel RGB -negate $FLIP "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.png"
  51. else
  52. log "I got a successful ${3}.dec file. Creating false color image" "INFO"
  53. medet_arm "${METEOR_OUTPUT}/${3}.dec" "${METEOR_OUTPUT}/${3}-122" -r 65 -g 65 -b 64 -d
  54. convert "${METEOR_OUTPUT}/${3}-122.bmp" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.png"
  55. fi
  56. log "Rectifying image to adjust aspect ratio" "INFO"
  57. python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.png"
  58. convert "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified.png" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} ${START_DATE} Elevacion: $7°" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified-text.png"
  59. if [ -n "$CONSUMER_KEY" ]; then
  60. log "Posting to Twitter" "INFO"
  61. python3 "${NOAA_HOME}/post.py" "$1 EXPERIMENTAL ${START_DATE} Resolución completa: http://weather.reyni.co/image/${FOLDER_DATE}/${3}-122-rectified-text.jpg" "$7°" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified-text.png"
  62. fi
  63. rm "${METEOR_OUTPUT}/${3}.bmp"
  64. rm "${METEOR_OUTPUT}/${3}-122.bmp"
  65. rm "${METEOR_OUTPUT}/${3}-122.png"
  66. rm "${METEOR_OUTPUT}/${3}.dec"
  67. rm "${METEOR_OUTPUT}/${3}-122.png"
  68. rm "${METEOR_OUTPUT}/${3}-122-rectified.png"
  69. rm "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.png"
  70. rm "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified.png"
  71. #rm "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified-text.png"
  72. else
  73. log "Decoding failed, either a bad pass/low SNR or a software problem" "ERROR"
  74. fi