From 30668f28b81e35dc957f8de94633a48c477f9942 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Mon, 28 Sep 2020 20:53:00 -0300 Subject: [PATCH] split twitter conditionals from database conditionals, mark passes as inactive --- receive.sh | 28 ++++++++++++++++------------ receive_meteor.sh | 26 +++++++++++--------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/receive.sh b/receive.sh index f62d842..875db59 100755 --- a/receive.sh +++ b/receive.sh @@ -28,10 +28,6 @@ fi log "Starting rtl_fm record" "INFO" timeout "${6}" /usr/local/bin/rtl_fm ${BIAS_TEE} -f "${2}"M -s 60k -g 50 -p 55 -E wav -E deemp -F 9 - | /usr/bin/sox -t raw -e signed -c 1 -b 16 -r 60000 - "${RAMFS_AUDIO}/audio/${3}.wav" rate 11025 -if [ ! -d "{NOAA_OUTPUT}/image/${FOLDER_DATE}" ]; then - mkdir -m 775 -p "${NOAA_OUTPUT}/image/${FOLDER_DATE}" -fi - if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then ENHANCEMENTS="ZA MCIR MCIR-precip MSA MSA-precip HVC-precip HVCT-precip HVC HVCT" daylight="true" @@ -44,25 +40,33 @@ log "Bulding pass map" "INFO" /usr/local/bin/wxmap -T "${1}" -H "${4}" -p 0 -l 0 -o "${PASS_START}" "${NOAA_HOME}/map/${3}-map.png" for i in $ENHANCEMENTS; do log "Decoding image" "INFO" - /usr/local/bin/wxtoimg -o -m "${NOAA_HOME}/map/${3}-map.png" -e "$i" "${RAMFS_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/image/${3}-$i.jpg" - /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" - /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/image/${3}-$i.jpg" "${NOAA_OUTPUT}/image/thumb/${3}-$i.jpg" + /usr/local/bin/wxtoimg -o -m "${NOAA_HOME}/map/${3}-map.png" -e "$i" "${RAMFS_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/images/${3}-$i.jpg" + /usr/bin/convert -quality 90 -format jpg "${NOAA_OUTPUT}/images/${3}-$i.jpg" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} $i ${START_DATE}" "${NOAA_OUTPUT}/images/${3}-$i.jpg" + /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-$i.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-$i.jpg" done +if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then + sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($5,\"$3\", 1,1);" +else + sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($5,\"$3\", 0,1);" +fi + +pass_id=$(sqlite3 /home/pi/raspberry-noaa/panel.db "select id from decoded_passes order by id desc limit 1;") + if [ -n "$CONSUMER_KEY" ]; then log "Posting to Twitter" "INFO" if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then - sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($5,\"$3\", 1,1);" - python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE}" "$7" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MCIR-precip.jpg" "${NOAA_OUTPUT}/image/$3-MSA-precip.jpg" "${NOAA_OUTPUT}/image/$3-HVC-precip.jpg" "${NOAA_OUTPUT}/image/$3-HVCT-precip.jpg" + python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE} Mas imagenes: https://weather.reyni.co/detail.php?id=$pass_id" "$7" "${NOAA_OUTPUT}/images/$3-MCIR-precip.jpg" "${NOAA_OUTPUT}/images/$3-MSA-precip.jpg" "${NOAA_OUTPUT}/images/$3-HVC-precip.jpg" "${NOAA_OUTPUT}/images/$3-HVCT-precip.jpg" else - sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($5,\"$3\", 0,1);" - python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE}" "$7" "${NOAA_OUTPUT}/image/$3-MCIR-precip.jpg" "${NOAA_OUTPUT}/image/$3-MCIR.jpg" + python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE} Mas imagenes: https://weather.reyni.co/detail.php?id=$pass_id" "$7" "${NOAA_OUTPUT}/images/$3-MCIR-precip.jpg" "${NOAA_OUTPUT}/images/$3-MCIR.jpg" fi fi +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);" + if [ "$DELETE_AUDIO" = true ]; then log "Deleting audio files" "INFO" rm "${RAMFS_AUDIO}/audio/${3}.wav" else - log "Moving audio files out of the SD card" "INFO" + log "Moving audio files out to the SD card" "INFO" mv "${RAMFS_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/audio/${3}.wav" fi diff --git a/receive_meteor.sh b/receive_meteor.sh index 064c74a..2383b78 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -5,15 +5,6 @@ . "$HOME/.tweepy.conf" . "$NOAA_HOME/common.sh" -## pass start timestamp and sun elevation -PASS_START=$(expr "$5" + 90) -SUN_ELEV=$(python3 "$NOAA_HOME"/sun.py "$PASS_START") - -if [ "${SUN_ELEV}" -lt "${SUN_MIN_ELEV}" ]; then - log "Sun elev is too low. Meteor IR radiometers are not working" "INFO" - exit 0 -fi - if pgrep "rtl_fm" > /dev/null then log "There is an already running rtl_fm instance but I dont care for now, I prefer this pass" "INFO" @@ -37,6 +28,9 @@ meteor_demod -B -o "${METEOR_OUTPUT}/${3}.qpsk" "${RAMFS_AUDIO}/audio/${3}.wav" if [ "$DELETE_AUDIO" = true ]; then log "Deleting audio files" "INFO" rm "${RAMFS_AUDIO}/audio/${3}.wav" +else + log "Moving audio files out to the SD card" "INFO" + mv "${RAMFS_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/audio/${3}.wav" fi log "Decoding in progress (QPSK to BMP)" "INFO" @@ -47,20 +41,22 @@ rm "${METEOR_OUTPUT}/${3}.qpsk" if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then log "I got a successful ${3}.dec file. Creating false color image" "INFO" medet_arm "${METEOR_OUTPUT}/${3}.dec" "${METEOR_OUTPUT}/${3}-122" -r 65 -g 65 -b 64 -d - convert "${METEOR_OUTPUT}/${3}-122.bmp" "${NOAA_OUTPUT}/image/${3}-122.jpg" + convert "${METEOR_OUTPUT}/${3}-122.bmp" "${NOAA_OUTPUT}/images/${3}-122.jpg" log "Rectifying image to adjust aspect ratio" "INFO" - python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/image/${3}-122.jpg" - convert -thumbnail 300 "${NOAA_OUTPUT}/image/${3}-122-rectified.jpg" "${NOAA_OUTPUT}/image/thumb/${3}-122-rectified.jpg" - convert "${NOAA_OUTPUT}/image/${3}-122-rectified.jpg" -channel rgb -normalize "${NOAA_OUTPUT}/image/${3}-122-rectified.jpg" + python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.jpg" + convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-122-rectified.jpg" + convert "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" -channel rgb -normalize "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" log "Deleting base image files" "INFO" rm "${METEOR_OUTPUT}/${3}-122.bmp" rm "${METEOR_OUTPUT}/${3}.bmp" - rm "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.jpg" + rm "${NOAA_OUTPUT}/images/${3}-122.jpg" sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($5,\"$3\", 1,0);" + pass_id=$(sqlite3 /home/pi/raspberry-noaa/panel.db "select id from decoded_passes order by id desc limit 1;") if [ -n "$CONSUMER_KEY" ]; then log "Posting to Twitter" "INFO" - 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" + 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" fi + 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);" else log "Decoding failed, either a bad pass/low SNR or a software problem" "ERROR" fi