From b88fcec50cc943492a782dd9750ebbf4e0888ee5 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 27 Sep 2020 20:30:38 -0300 Subject: [PATCH 01/57] add a migration script for web panel view --- migrate_data.sh | 39 +++++++++++++++++++++++++++++++++++++++ panel.sql | 13 +++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 migrate_data.sh create mode 100644 panel.sql diff --git a/migrate_data.sh b/migrate_data.sh new file mode 100644 index 0000000..b4e1028 --- /dev/null +++ b/migrate_data.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# TODO: Warn the user +BASEPATH="/var/www/wx/image" +FINALPATH="/var/www/wx/images" +SAT_NAMES="NOAA15 NOAA18 NOAA19 METEOR-M2" +DB_PATH="/var/ramfs/panel.db" + +cd "$BASEPATH" || exit 1 +mkdir -p "$FINALPATH" + +for filename in $(find . -name *.jpg); do + basename="$(echo "$filename" | sed 's~.*/~~')" + for prefix in $SAT_NAMES; do + basedate="$(echo "$basename" | sed -e "s/^$prefix//" | cut -f1,2 -d'-' | sed -e "s/-//")" + if [[ $basename == *"$prefix"* ]]; then + sat_name=$prefix + fi + done + + date_normalized=$(echo "$basedate" | sed -e "s/^$sat_name//;s/./&:/12;s/./&:/10;s/./& /8;s/./&\//6;s/./&\//4") + epoch_date=$(date "+%s" -d "$date_normalized") + passname=$(echo "$basename" | cut -f1,2 -d'-') + echo "Migration in progress: $basename" + cp "$BASEPATH/$filename" "$FINALPATH" + if [[ $basename == *"METEOR"* ]]; then + sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);" + elif [[ $basename == *"ZA"* ]]; then + if [[ -f "$FINALPATH/$passname-MSA.jpg" ]]; then + sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,1);" + else + sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",0,1);" + fi + fi + echo "Done." + echo "" +done + + diff --git a/panel.sql b/panel.sql new file mode 100644 index 0000000..3aac464 --- /dev/null +++ b/panel.sql @@ -0,0 +1,13 @@ +create table predict_passes( + sat_name text not null, + pass_start timestamp primary key default (strftime('%s', 'now')) not null, + pass_end timestamp default (strftime('%s', 'now')) not null, + max_elev int not null); + + +CREATE TABLE decoded_passes( + id integer primary key autoincrement, + pass_start integer, + file_path text not null, + daylight_pass boolean, is_noaa boolean, + foreign key(pass_start) references passes(pass_start)); From 6550fe70ad43ec852821477da1ebe93a1c40e1db Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 27 Sep 2020 20:30:54 -0300 Subject: [PATCH 02/57] store received images in database, also change file path on disk --- receive.sh | 13 +++++++++---- receive_meteor.sh | 8 +++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/receive.sh b/receive.sh index 084e581..4ba9660 100755 --- a/receive.sh +++ b/receive.sh @@ -34,23 +34,28 @@ 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" else ENHANCEMENTS="ZA MCIR MCIR-precip" + daylight="false" fi 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" "${NOAA_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-$i.jpg" - /usr/bin/convert -quality 90 -format jpg "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-$i.jpg" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} $i ${START_DATE}" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-$i.jpg" + /usr/local/bin/wxtoimg -o -m "${NOAA_HOME}/map/${3}-map.png" -e "$i" "${NOAA_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 done if [ -n "$CONSUMER_KEY" ]; then log "Posting to Twitter" "INFO" if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then - python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE}" "$7" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MCIR-precip.jpg" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MSA-precip.jpg" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-HVC-precip.jpg" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-HVCT-precip.jpg" + 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" else - python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE}" "$7" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MCIR-precip.jpg" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MCIR.jpg" + 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" fi fi diff --git a/receive_meteor.sh b/receive_meteor.sh index 52d99d1..75ecea1 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -51,14 +51,16 @@ 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/${FOLDER_DATE}/${3}-122.jpg" + convert "${METEOR_OUTPUT}/${3}-122.bmp" "${NOAA_OUTPUT}/image/${3}-122.jpg" log "Rectifying image to adjust aspect ratio" "INFO" - python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.jpg" - convert "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified.jpg" -channel rgb -normalize "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified.jpg" + 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" 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" + sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($5,\"$3\", 1,0);" 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" From c81e3e8a5fd5853251122ad7c9210460a3cdc439 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 27 Sep 2020 20:31:15 -0300 Subject: [PATCH 03/57] store prediction passes on database --- schedule_meteor.sh | 1 + schedule_sat.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/schedule_meteor.sh b/schedule_meteor.sh index ffc5f45..4ff270f 100755 --- a/schedule_meteor.sh +++ b/schedule_meteor.sh @@ -25,6 +25,7 @@ while [ "$(date --date="@${var2}" +%D)" = "$(date +%D)" ]; do echo "${SATNAME}" "${OUTDATE}" "$MAXELEV" echo "${NOAA_HOME}/receive_meteor.sh \"${1}\" $2 ${SATNAME}${OUTDATE} "${NOAA_HOME}"/predict/weather.tle \ ${var1} ${TIMER} ${MAXELEV}" | at "$(date --date="TZ=\"UTC\" ${START_TIME}" +"%H:%M %D")" + sqlite3 /home/pi/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$SATNAME\",$var1,$var2,$MAXELEV);" fi NEXTPREDICT=$(expr "${var2}" + 60) PREDICTION_START=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | head -1) diff --git a/schedule_sat.sh b/schedule_sat.sh index db2fddf..9ce0534 100755 --- a/schedule_sat.sh +++ b/schedule_sat.sh @@ -31,6 +31,7 @@ while [ "$(date --date="@${var2}" +%D)" = "$(date +%D)" ]; do echo "${SATNAME}" "${OUTDATE}" "$MAXELEV" echo "${NOAA_HOME}/receive.sh \"${1}\" $2 ${SATNAME}${OUTDATE} "${NOAA_HOME}"/predict/weather.tle \ ${var1} ${TIMER} ${MAXELEV}" | at "$(date --date="TZ=\"UTC\" ${START_TIME}" +"%H:%M %D")" + sqlite3 /home/pi/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$SATNAME\",$var1,$var2,$MAXELEV);" fi NEXTPREDICT=$(expr "${var2}" + 60) PREDICTION_START=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | head -1) From 281fb4233199aa4ccbd50e8110685f8b6ebbe18d Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 27 Sep 2020 20:31:44 -0300 Subject: [PATCH 04/57] install sqlite, php and php sqlite driver, modify nginx template --- install.sh | 5 ++++- templates/nginx.cfg | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 742f6f1..812e9f6 100755 --- a/install.sh +++ b/install.sh @@ -54,7 +54,10 @@ sudo apt install -yq predict \ libxft2 \ libjpeg9 \ libjpeg9-dev \ - socat + socat \ + php7.2-fpm \ + php7.2-sqlite \ + sqlite3 sudo pip3 install numpy ephem tweepy Pillow log_done "Packages installed" diff --git a/templates/nginx.cfg b/templates/nginx.cfg index aacb918..7e5979a 100644 --- a/templates/nginx.cfg +++ b/templates/nginx.cfg @@ -1,7 +1,7 @@ server { listen 80 default_server; root /var/www/wx; - index index.html index.htm index.nginx-debian.html; + index index.php index.html index.htm index.nginx-debian.html; autoindex on; server_name wx.home; @@ -9,4 +9,9 @@ server { location / { try_files $uri $uri/ =404; } + + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; + } } From ca0dbdcab4417d5c2a95db603aec0782cb4339a5 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 27 Sep 2020 20:39:21 -0300 Subject: [PATCH 05/57] Use ramfs to record audio --- common.sh | 4 ++-- receive.sh | 8 ++++---- receive_meteor.sh | 10 +++------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/common.sh b/common.sh index b24f3dd..85af1c6 100755 --- a/common.sh +++ b/common.sh @@ -45,8 +45,8 @@ if [ ! -d "${METEOR_OUTPUT}/audio/" ]; then mkdir -m 775 -p "${METEOR_OUTPUT}/audio/" fi -if [ ! -d "${NOAA_AUDIO}/audio/" ]; then - mkdir -m 775 -p "${NOAA_AUDIO}/audio/" +if [ ! -d "${RAMFS_AUDIO}/audio/" ]; then + mkdir -m 775 -p "${RAMFS_AUDIO}/audio/" fi if [ ! -d "${NOAA_OUTPUT}/image/" ]; then diff --git a/receive.sh b/receive.sh index 4ba9660..c3b3522 100755 --- a/receive.sh +++ b/receive.sh @@ -26,7 +26,7 @@ fi # $7 = Satellite max elevation 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 - "${NOAA_AUDIO}/audio/${3}.wav" rate 11025 +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}" @@ -44,7 +44,7 @@ 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" "${NOAA_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/image/${3}-$i.jpg" + /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 done @@ -61,8 +61,8 @@ fi if [ "$DELETE_AUDIO" = true ]; then log "Deleting audio files" "INFO" - rm "${NOAA_AUDIO}/audio/${3}.wav" + rm "${RAMFS_AUDIO}/audio/${3}.wav" else log "Moving audio files out of the SD card" "INFO" - mv "${NOAA_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/audio/${3}.wav" + mv "${RAMFS_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/audio/${3}.wav" fi diff --git a/receive_meteor.sh b/receive_meteor.sh index 75ecea1..064c74a 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -29,18 +29,14 @@ fi # $7 = Satellite max elevation log "Starting rtl_fm record" "INFO" -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 "${METEOR_OUTPUT}/audio/${3}.wav" rate 96k - -log "Normalization in progress" "INFO" -sox "${METEOR_OUTPUT}/audio/${3}.wav" "${METEOR_OUTPUT}/${3}.wav" gain -n +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 log "Demodulation in progress (QPSK)" "INFO" -meteor_demod -B -o "${METEOR_OUTPUT}/${3}.qpsk" "${METEOR_OUTPUT}/${3}.wav" +meteor_demod -B -o "${METEOR_OUTPUT}/${3}.qpsk" "${RAMFS_AUDIO}/audio/${3}.wav" if [ "$DELETE_AUDIO" = true ]; then log "Deleting audio files" "INFO" - rm "${METEOR_OUTPUT}/audio/${3}.wav" - rm "${METEOR_OUTPUT}/${3}.wav" + rm "${RAMFS_AUDIO}/audio/${3}.wav" fi log "Decoding in progress (QPSK to BMP)" "INFO" From ca2a491ab86944db64c75398206606e4a74581a5 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 27 Sep 2020 20:41:52 -0300 Subject: [PATCH 06/57] add panel.db to ignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6e1aa5d..2bf73c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ predict/ map/ +panel.db From 95ac0682a4aff1ec7c8cde9f45284e582b1f9717 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 27 Sep 2020 20:44:28 -0300 Subject: [PATCH 07/57] branding --- post.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/post.py b/post.py index 4252064..6d8f338 100755 --- a/post.py +++ b/post.py @@ -23,4 +23,4 @@ for filename in filenames: res = api.media_upload(filename) media_ids.append(res.media_id) -api.update_status(status=argentinaFlag + ' Imagen satelital: ' + sys.argv[1] + '. Elevacion maxima: ' + sys.argv[2] + ' grados. #NOAA #weather #argentinaimagenes #noaasatellite #clima #wxtoimg #raspberrypi #argentina #argentinasat', media_ids=media_ids) +api.update_status(status=argentinaFlag + ' Imagen satelital: ' + sys.argv[1] + '. Elevacion maxima: ' + sys.argv[2] + ' grados. #NOAA #weather #argentinaimagenes #noaasatellite #clima #wxtoimg #raspberrynoaa #argentina #argentinasat', media_ids=media_ids) From 1996f25f95fe2b571f4e405f2b96b9e51fd0379e Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 27 Sep 2020 21:13:41 -0300 Subject: [PATCH 08/57] write dummy data for old passes on prediction table --- migrate_data.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/migrate_data.sh b/migrate_data.sh index b4e1028..6317d45 100644 --- a/migrate_data.sh +++ b/migrate_data.sh @@ -25,7 +25,10 @@ for filename in $(find . -name *.jpg); do cp "$BASEPATH/$filename" "$FINALPATH" if [[ $basename == *"METEOR"* ]]; then sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);" + sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);" + sqlite3 "$DB_PATH" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);" elif [[ $basename == *"ZA"* ]]; then + sqlite3 "$DB_PATH" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);" if [[ -f "$FINALPATH/$passname-MSA.jpg" ]]; then sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,1);" else From 3ea741774930cb0e5f71c6088227c203af57a236 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 27 Sep 2020 21:13:52 -0300 Subject: [PATCH 09/57] typo --- receive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receive.sh b/receive.sh index c3b3522..b1abb71 100755 --- a/receive.sh +++ b/receive.sh @@ -51,7 +51,7 @@ done 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); + 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" 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);" From f5bc3b91d0c420e8c9dbdaf9a925ed4730353940 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 27 Sep 2020 21:23:18 -0300 Subject: [PATCH 10/57] replace var name for ramfs --- templates/noaa.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/noaa.conf b/templates/noaa.conf index f408711..fd188d1 100644 --- a/templates/noaa.conf +++ b/templates/noaa.conf @@ -1,7 +1,7 @@ NOAA_HOME=/home/pi/raspberry-noaa NOAA_OUTPUT=/var/www/wx METEOR_OUTPUT=/var/www/wx/meteor -NOAA_AUDIO=/var/ramfs +RAMFS_AUDIO=/var/ramfs SAT_MIN_ELEV=30 METEOR_MIN_ELEV=30 SUN_MIN_ELEV=10 @@ -9,4 +9,4 @@ LOG_LEVEL=DEBUG LAT=change_latitude LON=change_longitude BIAS_TEE="enable_bias_tee" -DELETE_AUDIO=true \ No newline at end of file +DELETE_AUDIO=true From 83e5d1ca3231470e9720e090f4e71b2ff99e3539 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 27 Sep 2020 21:23:36 -0300 Subject: [PATCH 11/57] use ramfs to speed up writing --- migrate_data.sh | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/migrate_data.sh b/migrate_data.sh index 6317d45..ad453df 100644 --- a/migrate_data.sh +++ b/migrate_data.sh @@ -1,13 +1,25 @@ #!/bin/bash +## import common lib +. "$HOME/.noaa.conf" +. "$HOME/.tweepy.conf" +. "$NOAA_HOME/common.sh" + # TODO: Warn the user BASEPATH="/var/www/wx/image" FINALPATH="/var/www/wx/images" SAT_NAMES="NOAA15 NOAA18 NOAA19 METEOR-M2" -DB_PATH="/var/ramfs/panel.db" +DB_PATH="${NOAA_HOME}/panel.db" + + +( + cd "${RAMFS_AUDIO}" || exit 1 + sqlite3 < "${NOAA_HOME}/panel.sql" +) + cd "$BASEPATH" || exit 1 -mkdir -p "$FINALPATH" +mkdir -p "$FINALPATH/thumb" for filename in $(find . -name *.jpg); do basename="$(echo "$filename" | sed 's~.*/~~')" @@ -23,18 +35,20 @@ for filename in $(find . -name *.jpg); do passname=$(echo "$basename" | cut -f1,2 -d'-') echo "Migration in progress: $basename" cp "$BASEPATH/$filename" "$FINALPATH" + convert -thumbnail 300 "$BASEPATH/$filename" "$FINALPATH/thumb/$filename" if [[ $basename == *"METEOR"* ]]; then - sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);" - sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);" - sqlite3 "$DB_PATH" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);" + sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);" + sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);" + sqlite3 "${RAMFS_AUDIO}/panel.db" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);" elif [[ $basename == *"ZA"* ]]; then - sqlite3 "$DB_PATH" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);" + sqlite3 "${RAMFS_AUDIO}/panel.db" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);" if [[ -f "$FINALPATH/$passname-MSA.jpg" ]]; then - sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,1);" + sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,1);" else - sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",0,1);" + sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",0,1);" fi fi + mv "${RAMFS_AUDIO}/panel.db" "$DB_PATH" echo "Done." echo "" done From daf001b7656b5325b795bab39d56703e8ff8203f Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 27 Sep 2020 21:34:21 -0300 Subject: [PATCH 12/57] typo --- migrate_data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrate_data.sh b/migrate_data.sh index ad453df..1202b1c 100644 --- a/migrate_data.sh +++ b/migrate_data.sh @@ -35,7 +35,7 @@ for filename in $(find . -name *.jpg); do passname=$(echo "$basename" | cut -f1,2 -d'-') echo "Migration in progress: $basename" cp "$BASEPATH/$filename" "$FINALPATH" - convert -thumbnail 300 "$BASEPATH/$filename" "$FINALPATH/thumb/$filename" + convert -thumbnail 300 "$BASEPATH/$filename" "$FINALPATH/thumb/$basename" if [[ $basename == *"METEOR"* ]]; then sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);" sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);" From 1443285acff706108fe3543fb41384edeb90294e Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 27 Sep 2020 21:57:34 -0300 Subject: [PATCH 13/57] meteor filenames differs from noaa --- migrate_data.sh | 6 +++++- receive.sh | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/migrate_data.sh b/migrate_data.sh index 1202b1c..d7455b3 100644 --- a/migrate_data.sh +++ b/migrate_data.sh @@ -32,7 +32,11 @@ for filename in $(find . -name *.jpg); do date_normalized=$(echo "$basedate" | sed -e "s/^$sat_name//;s/./&:/12;s/./&:/10;s/./& /8;s/./&\//6;s/./&\//4") epoch_date=$(date "+%s" -d "$date_normalized") - passname=$(echo "$basename" | cut -f1,2 -d'-') + if [[ $basename == *"METEOR"* ]]; then + passname=$(echo "$basename" | cut -f1,2,3 -d'-') + else + passname=$(echo "$basename" | cut -f1,2 -d'-') + fi echo "Migration in progress: $basename" cp "$BASEPATH/$filename" "$FINALPATH" convert -thumbnail 300 "$BASEPATH/$filename" "$FINALPATH/thumb/$basename" diff --git a/receive.sh b/receive.sh index b1abb71..f62d842 100755 --- a/receive.sh +++ b/receive.sh @@ -46,7 +46,7 @@ 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/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/image/${3}-$i.jpg" "${NOAA_OUTPUT}/image/thumb/${3}-$i.jpg" done if [ -n "$CONSUMER_KEY" ]; then log "Posting to Twitter" "INFO" From 53c15355f4136c5947aa10a9f831bd29a44a4124 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Mon, 28 Sep 2020 20:51:13 -0300 Subject: [PATCH 14/57] fix folder path --- common.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/common.sh b/common.sh index 85af1c6..a008ff0 100755 --- a/common.sh +++ b/common.sh @@ -25,7 +25,6 @@ log() { ## current date and folder structure START_DATE=$(date '+%d-%m-%Y %H:%M') -FOLDER_DATE="$(date +%Y)/$(date +%m)/$(date +%d)" ## sane checks if [ ! -d "${NOAA_HOME}" ]; then @@ -49,8 +48,8 @@ if [ ! -d "${RAMFS_AUDIO}/audio/" ]; then mkdir -m 775 -p "${RAMFS_AUDIO}/audio/" fi -if [ ! -d "${NOAA_OUTPUT}/image/" ]; then - mkdir -m 775 -p "${NOAA_OUTPUT}/image/" +if [ ! -d "${NOAA_OUTPUT}/images/" ]; then + mkdir -m 775 -p "${NOAA_OUTPUT}/images/" fi if [ ! -d "${NOAA_HOME}/map/" ]; then @@ -60,7 +59,3 @@ fi if [ ! -d "${NOAA_HOME}/predict/" ]; then mkdir -m 775 -p "${NOAA_HOME}/predict/" fi - -if [ ! -d "${NOAA_OUTPUT}/image/${FOLDER_DATE}" ]; then - mkdir -m 775 -p "${NOAA_OUTPUT}/image/${FOLDER_DATE}" -fi From 13e6dc3e256b0a86917bc2a4d283e77312b1aa70 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Mon, 28 Sep 2020 20:51:49 -0300 Subject: [PATCH 15/57] add is_active to grey out old passes on passes list --- schedule_meteor.sh | 6 ++++-- schedule_sat.sh | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/schedule_meteor.sh b/schedule_meteor.sh index 4ff270f..f8541c0 100755 --- a/schedule_meteor.sh +++ b/schedule_meteor.sh @@ -18,14 +18,16 @@ while [ "$(date --date="@${var2}" +%D)" = "$(date +%D)" ]; do var3=$(echo "$START_TIME" | cut -d " " -f 2 | cut -d ":" -f 3) TIMER=$(expr "${var2}" - "${var1}" + "${var3}") OUTDATE=$(date --date="TZ=\"UTC\" ${START_TIME}" +%Y%m%d-%H%M%S) + PASS_START=$(expr "$5" + 90) + SUN_ELEV=$(python3 "$NOAA_HOME"/sun.py "$PASS_START") - if [ "${MAXELEV}" -gt "${METEOR_MIN_ELEV}" ]; then + if [ "${MAXELEV}" -gt "${METEOR_MIN_ELEV}" ] && [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then log "Pass is above ${METEOR_MIN_ELEV}, that is OK for me" "INFO" SATNAME=$(echo "$1" | sed "s/ //g") echo "${SATNAME}" "${OUTDATE}" "$MAXELEV" echo "${NOAA_HOME}/receive_meteor.sh \"${1}\" $2 ${SATNAME}${OUTDATE} "${NOAA_HOME}"/predict/weather.tle \ ${var1} ${TIMER} ${MAXELEV}" | at "$(date --date="TZ=\"UTC\" ${START_TIME}" +"%H:%M %D")" - sqlite3 /home/pi/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$SATNAME\",$var1,$var2,$MAXELEV);" + sqlite3 /home/pi/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev,is_active) values (\"$SATNAME\",$var1,$var2,$MAXELEV,1);" fi NEXTPREDICT=$(expr "${var2}" + 60) PREDICTION_START=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | head -1) diff --git a/schedule_sat.sh b/schedule_sat.sh index 9ce0534..a5ef0b8 100755 --- a/schedule_sat.sh +++ b/schedule_sat.sh @@ -31,7 +31,7 @@ while [ "$(date --date="@${var2}" +%D)" = "$(date +%D)" ]; do echo "${SATNAME}" "${OUTDATE}" "$MAXELEV" echo "${NOAA_HOME}/receive.sh \"${1}\" $2 ${SATNAME}${OUTDATE} "${NOAA_HOME}"/predict/weather.tle \ ${var1} ${TIMER} ${MAXELEV}" | at "$(date --date="TZ=\"UTC\" ${START_TIME}" +"%H:%M %D")" - sqlite3 /home/pi/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$SATNAME\",$var1,$var2,$MAXELEV);" + sqlite3 /home/pi/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev,is_active) values (\"$SATNAME\",$var1,$var2,$MAXELEV, 1);" fi NEXTPREDICT=$(expr "${var2}" + 60) PREDICTION_START=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | head -1) From 87d4aaf4bb60d59f40e56206c775eccad13d75b5 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Mon, 28 Sep 2020 20:51:59 -0300 Subject: [PATCH 16/57] add is_active to grey out old passes on passes list --- panel.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/panel.sql b/panel.sql index 3aac464..97db8b4 100644 --- a/panel.sql +++ b/panel.sql @@ -2,7 +2,8 @@ create table predict_passes( sat_name text not null, pass_start timestamp primary key default (strftime('%s', 'now')) not null, pass_end timestamp default (strftime('%s', 'now')) not null, - max_elev int not null); + max_elev int not null, + is_active boolean); CREATE TABLE decoded_passes( From 30668f28b81e35dc957f8de94633a48c477f9942 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Mon, 28 Sep 2020 20:53:00 -0300 Subject: [PATCH 17/57] 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 From cec3632ccbf4a17265ba71cb3fe157dd281821d3 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Mon, 28 Sep 2020 21:21:59 -0300 Subject: [PATCH 18/57] add migration process comments --- migrate_data.sh | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/migrate_data.sh b/migrate_data.sh index d7455b3..f9501ef 100644 --- a/migrate_data.sh +++ b/migrate_data.sh @@ -5,27 +5,41 @@ . "$HOME/.tweepy.conf" . "$NOAA_HOME/common.sh" -# TODO: Warn the user +# This is the original path where images were stored BASEPATH="/var/www/wx/image" + +# This is the destination path (AKA the new path) FINALPATH="/var/www/wx/images" + +# This is a list of satellite names SAT_NAMES="NOAA15 NOAA18 NOAA19 METEOR-M2" -DB_PATH="${NOAA_HOME}/panel.db" +# Here's where the database will live +DB_PATH="${NOAA_HOME}/panel.db" ( + # To speed up the migration process and + # reduce the SD card wear, the database + # operations are done over the RAMFS + # partition cd "${RAMFS_AUDIO}" || exit 1 sqlite3 < "${NOAA_HOME}/panel.sql" ) cd "$BASEPATH" || exit 1 + +# The webpanel have thumbnails! mkdir -p "$FINALPATH/thumb" +# Find all the images for filename in $(find . -name *.jpg); do + # Grab just the filename without the yyyy/mm/dd path basename="$(echo "$filename" | sed 's~.*/~~')" for prefix in $SAT_NAMES; do basedate="$(echo "$basename" | sed -e "s/^$prefix//" | cut -f1,2 -d'-' | sed -e "s/-//")" if [[ $basename == *"$prefix"* ]]; then + # Grab the satellite name from the file name sat_name=$prefix fi done @@ -33,25 +47,31 @@ for filename in $(find . -name *.jpg); do date_normalized=$(echo "$basedate" | sed -e "s/^$sat_name//;s/./&:/12;s/./&:/10;s/./& /8;s/./&\//6;s/./&\//4") epoch_date=$(date "+%s" -d "$date_normalized") if [[ $basename == *"METEOR"* ]]; then + # Meteor files have one more dash on its name passname=$(echo "$basename" | cut -f1,2,3 -d'-') else passname=$(echo "$basename" | cut -f1,2 -d'-') fi echo "Migration in progress: $basename" cp "$BASEPATH/$filename" "$FINALPATH" + + # Create thumbnails for old images convert -thumbnail 300 "$BASEPATH/$filename" "$FINALPATH/thumb/$basename" if [[ $basename == *"METEOR"* ]]; then - sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);" - sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);" - sqlite3 "${RAMFS_AUDIO}/panel.db" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);" + # Insert each pass on the database. Also insert the pass prediction + sqlite3 "${RAMFS_AUDIO}/panel.db" "INSERT INTO decoded_passes (pass_start, file_path, daylight_pass, is_noaa) VALUES ($epoch_date,\"$passname\",1,0);" + sqlite3 "${RAMFS_AUDIO}/panel.db" "INSERT OR REPLACE INTO predict_passes (sat_name,pass_start,pass_end,max_elev) VALUES (\"$sat_name\",$epoch_date,$epoch_date,0);" elif [[ $basename == *"ZA"* ]]; then - sqlite3 "${RAMFS_AUDIO}/panel.db" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);" + sqlite3 "${RAMFS_AUDIO}/panel.db" "INSERT OR REPLACE INTO predict_passes (sat_name,pass_start,pass_end,max_elev) VALUES (\"$sat_name\",$epoch_date,$epoch_date,0);" if [[ -f "$FINALPATH/$passname-MSA.jpg" ]]; then - sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,1);" + # MSA requires a daylight pass and daylight pass is a column of decoded_passes so this is the way to grab them + sqlite3 "${RAMFS_AUDIO}/panel.db" "INSERT INTO decoded_passes (pass_start, file_path, daylight_pass, is_noaa) VALUES ($epoch_date,\"$passname\",1,1);" else - sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",0,1);" + sqlite3 "${RAMFS_AUDIO}/panel.db" "INSERT INTO decoded_passes (pass_start, file_path, daylight_pass, is_noaa) VALUES ($epoch_date,\"$passname\",0,1);" fi fi + + # Move the database file to its final destination mv "${RAMFS_AUDIO}/panel.db" "$DB_PATH" echo "Done." echo "" From d235875b72a502b0515ac8215b3f4d527e518330 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Mon, 28 Sep 2020 21:22:21 -0300 Subject: [PATCH 19/57] add a nginx rule to rewrite the old yyyy/mm/dd paths to the new /images/ path --- templates/nginx.cfg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/nginx.cfg b/templates/nginx.cfg index 7e5979a..d1dcfe5 100644 --- a/templates/nginx.cfg +++ b/templates/nginx.cfg @@ -14,4 +14,7 @@ server { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; } + + # Rewrite the old path yyyy/mm/dd/ to /images/ + rewrite "^/image/\d{4}/\d{2}/\d{2}/(.+)$" /images/$1 permanent } From 1519489c1faab74551eaa23e78d2412434ce11fa Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Mon, 28 Sep 2020 21:23:03 -0300 Subject: [PATCH 20/57] wrong var for epoch --- schedule_meteor.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/schedule_meteor.sh b/schedule_meteor.sh index f8541c0..a373bea 100755 --- a/schedule_meteor.sh +++ b/schedule_meteor.sh @@ -18,8 +18,7 @@ while [ "$(date --date="@${var2}" +%D)" = "$(date +%D)" ]; do var3=$(echo "$START_TIME" | cut -d " " -f 2 | cut -d ":" -f 3) TIMER=$(expr "${var2}" - "${var1}" + "${var3}") OUTDATE=$(date --date="TZ=\"UTC\" ${START_TIME}" +%Y%m%d-%H%M%S) - PASS_START=$(expr "$5" + 90) - SUN_ELEV=$(python3 "$NOAA_HOME"/sun.py "$PASS_START") + SUN_ELEV=$(python3 "$NOAA_HOME"/sun.py "$var1") if [ "${MAXELEV}" -gt "${METEOR_MIN_ELEV}" ] && [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then log "Pass is above ${METEOR_MIN_ELEV}, that is OK for me" "INFO" From 71043c5c73edf4e8dcfbcea603bfaaf0e54af346 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Mon, 28 Sep 2020 21:24:35 -0300 Subject: [PATCH 21/57] move database schema to templates folder --- migrate_data.sh | 2 +- panel.sql => templates/webpanel_schema.sql | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename panel.sql => templates/webpanel_schema.sql (100%) diff --git a/migrate_data.sh b/migrate_data.sh index f9501ef..f8b84f7 100644 --- a/migrate_data.sh +++ b/migrate_data.sh @@ -23,7 +23,7 @@ DB_PATH="${NOAA_HOME}/panel.db" # operations are done over the RAMFS # partition cd "${RAMFS_AUDIO}" || exit 1 - sqlite3 < "${NOAA_HOME}/panel.sql" + sqlite3 < "${NOAA_HOME}/templates/webpanel_schema.sql" ) diff --git a/panel.sql b/templates/webpanel_schema.sql similarity index 100% rename from panel.sql rename to templates/webpanel_schema.sql From 347695df49ac58eca90fc42a83e39bfdf4f5c8d2 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 13:56:24 -0300 Subject: [PATCH 22/57] enable meteor m2 night passes --- receive_meteor.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 2383b78..0b248a5 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -5,6 +5,10 @@ . "$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 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" @@ -39,17 +43,19 @@ medet_arm "${METEOR_OUTPUT}/${3}.qpsk" "${METEOR_OUTPUT}/${3}" -cd 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}/images/${3}-122.jpg" + if [ "${SUN_ELEV}" -lt "${SUN_MIN_ELEV}" ]; then + log "I got a successful ${3}.dec file. Decoding APID 68" "INFO" + medet_arm "${METEOR_OUTPUT}/${3}.dec" "${METEOR_OUTPUT}/${3}-122" -r 68 -g 68 -b 68 -d + rm "${METEOR_OUTPUT}/${3}-122.bmp" + else + 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 + rm "${METEOR_OUTPUT}/${3}-122.bmp" + rm "${METEOR_OUTPUT}/${3}.bmp" + fi log "Rectifying image to adjust aspect ratio" "INFO" - 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}/images/${3}-122.jpg" + convert "${METEOR_OUTPUT}/${3}-122.bmp" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.jpg" + python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${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 From 5b9ef0925db11608e56d6584a0711603f5d8a3ee Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 13:59:39 -0300 Subject: [PATCH 23/57] Tidy-up if block --- receive_meteor.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 0b248a5..18211e9 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -43,19 +43,21 @@ medet_arm "${METEOR_OUTPUT}/${3}.qpsk" "${METEOR_OUTPUT}/${3}" -cd rm "${METEOR_OUTPUT}/${3}.qpsk" if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then + if [ "${SUN_ELEV}" -lt "${SUN_MIN_ELEV}" ]; then log "I got a successful ${3}.dec file. Decoding APID 68" "INFO" medet_arm "${METEOR_OUTPUT}/${3}.dec" "${METEOR_OUTPUT}/${3}-122" -r 68 -g 68 -b 68 -d - rm "${METEOR_OUTPUT}/${3}-122.bmp" else 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 - rm "${METEOR_OUTPUT}/${3}-122.bmp" - rm "${METEOR_OUTPUT}/${3}.bmp" fi + log "Rectifying image to adjust aspect ratio" "INFO" - convert "${METEOR_OUTPUT}/${3}-122.bmp" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.jpg" - python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.jpg" + convert "${METEOR_OUTPUT}/${3}-122.bmp" "${NOAA_OUTPUT}/images/${3}-122.jpg" + python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.jpg" + rm "${METEOR_OUTPUT}/${3}-122.bmp" + rm "${METEOR_OUTPUT}/${3}.bmp" + 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 From 6f72416a02f0999e8a55f44c2d6f863ba526dba0 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 14:02:17 -0300 Subject: [PATCH 24/57] Rectify meteor night passes --- rectify.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/rectify.py b/rectify.py index 1b95e82..c20ba43 100755 --- a/rectify.py +++ b/rectify.py @@ -73,11 +73,16 @@ def wthread(rectified_width, corr, endrow, startrow): # Linearly interpolate for i in range(delta): - interp_r = int((start_px[0]*(delta-i) + end_px[0]*i) / delta) - interp_g = int((start_px[1]*(delta-i) + end_px[1]*i) / delta) - interp_b = int((start_px[2]*(delta-i) + end_px[2]*i) / delta) - - rectified_pixels[cur_col, row] = (interp_r, interp_g, interp_b) + # For night passes of Meteor the image is just gray level and + # start_px and end_px being an int instead of a tuple + if type(start_px) != int: + interp_r = int((start_px[0]*(delta-i) + end_px[0]*i) / delta) + interp_g = int((start_px[1]*(delta-i) + end_px[1]*i) / delta) + interp_b = int((start_px[2]*(delta-i) + end_px[2]*i) / delta) + rectified_pixels[cur_col,row] = (interp_r, interp_g, interp_b) + else: + interp = int((start_px*(delta-i) + end_px*i) / delta) + rectified_pixels[cur_col,row] = interp cur_col += 1 start_px = end_px @@ -94,11 +99,16 @@ def wthread(rectified_width, corr, endrow, startrow): # Linearly interpolate for i in range(delta): - interp_r = int((start_px[0]*(delta-i) + end_px[0]*i) / delta) - interp_g = int((start_px[1]*(delta-i) + end_px[1]*i) / delta) - interp_b = int((start_px[2]*(delta-i) + end_px[2]*i) / delta) - - rectified_pixels[cur_col, row] = (interp_r, interp_g, interp_b) + # For night passes of Meteor the image is just gray level and + # start_px and end_px being an int instead of a tuple + if type(start_px) != int: + interp_r = int((start_px[0]*(delta-i) + end_px[0]*i) / delta) + interp_g = int((start_px[1]*(delta-i) + end_px[1]*i) / delta) + interp_b = int((start_px[2]*(delta-i) + end_px[2]*i) / delta) + rectified_pixels[cur_col,row] = (interp_r, interp_g, interp_b) + else: + interp = int((start_px*(delta-i) + end_px*i) / delta) + rectified_pixels[cur_col,row] = interp cur_col -= 1 start_px = end_px From 5370e03f01729c7f505b74960152babb54d43cd2 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 16:57:00 -0300 Subject: [PATCH 25/57] Rectify: save one step --- receive_meteor.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 18211e9..5e31cd0 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -53,8 +53,7 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then fi log "Rectifying image to adjust aspect ratio" "INFO" - convert "${METEOR_OUTPUT}/${3}-122.bmp" "${NOAA_OUTPUT}/images/${3}-122.jpg" - python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.jpg" + python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.bmp" rm "${METEOR_OUTPUT}/${3}-122.bmp" rm "${METEOR_OUTPUT}/${3}.bmp" From 9a767a6e54a800c5875a600739b5ec00ac0ad79e Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 17:26:11 -0300 Subject: [PATCH 26/57] add install steps for webpanel version --- install.sh | 15 +++++++++------ migrate_data.sh | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 812e9f6..5bc4eb0 100755 --- a/install.sh +++ b/install.sh @@ -62,6 +62,14 @@ sudo apt install -yq predict \ sudo pip3 install numpy ephem tweepy Pillow log_done "Packages installed" +### Create the database schema +if [ -e "$HOME/raspberry-noaa/panel.db" ]; then + log_done "Database already created" +else + sqlite3 "panel.db" < "templates/webpanel_schema.sql" + log_done "Database schema created" +fi + ### Blacklist DVB modules if [ -e /etc/modprobe.d/rtlsdr.conf ]; then log_done "DVB modules were already blacklisted" @@ -176,12 +184,7 @@ sudo cp templates/nginx.cfg /etc/nginx/sites-enabled/default sudo chmod 775 /var/www/wx ) sudo systemctl restart nginx -if [ ! -e /var/www/wx/index.html ]; then - sudo cp templates/index.html /var/www/wx/index.html -fi -if [ ! -e /var/www/wx/logo-small.png ]; then - sudo cp templates/logo-small.png /var/www/wx/logo-small.png -fi +cp -r "templates/webpanel/*" "/var/www/wx/" log_done "Nginx configured" ### Setup ramFS diff --git a/migrate_data.sh b/migrate_data.sh index f8b84f7..a2d92ed 100644 --- a/migrate_data.sh +++ b/migrate_data.sh @@ -23,7 +23,7 @@ DB_PATH="${NOAA_HOME}/panel.db" # operations are done over the RAMFS # partition cd "${RAMFS_AUDIO}" || exit 1 - sqlite3 < "${NOAA_HOME}/templates/webpanel_schema.sql" + sqlite3 "$DB_PATH" < "${NOAA_HOME}/templates/webpanel_schema.sql" ) From 1ef4c6ae910d41e8d534f2fe98254e5eb56fbca8 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 17:26:43 -0300 Subject: [PATCH 27/57] add webpanel files --- templates/webpanel/Config.php | 7 ++ templates/webpanel/Controller/C_predict.php | 6 ++ .../webpanel/Controller/C_showDetail.php | 8 ++ .../webpanel/Controller/C_showLastImage.php | 6 ++ .../webpanel/Controller/C_showLastImages.php | 11 ++ templates/webpanel/Controller/index.html | 0 templates/webpanel/Model/Conn.php | 74 +++++++++++++ templates/webpanel/Model/index.html | 0 templates/webpanel/Views/V_viewDetail.php | 23 ++++ templates/webpanel/Views/V_viewLastImage.php | 24 +++++ templates/webpanel/Views/V_viewLastImages.php | 42 ++++++++ templates/webpanel/Views/V_viewPasses.php | 24 +++++ templates/webpanel/Views/index.html | 0 templates/webpanel/detail.php | 7 ++ templates/webpanel/footer.php | 6 ++ templates/webpanel/header.php | 27 +++++ templates/webpanel/index.php | 7 ++ templates/webpanel/language/en.php | 15 +++ templates/webpanel/language/es.php | 15 +++ templates/webpanel/logo-small.png | Bin 0 -> 16850 bytes templates/webpanel/passes.php | 5 + templates/webpanel/style.css | 99 ++++++++++++++++++ 22 files changed, 406 insertions(+) create mode 100644 templates/webpanel/Config.php create mode 100644 templates/webpanel/Controller/C_predict.php create mode 100644 templates/webpanel/Controller/C_showDetail.php create mode 100644 templates/webpanel/Controller/C_showLastImage.php create mode 100644 templates/webpanel/Controller/C_showLastImages.php create mode 100644 templates/webpanel/Controller/index.html create mode 100644 templates/webpanel/Model/Conn.php create mode 100644 templates/webpanel/Model/index.html create mode 100644 templates/webpanel/Views/V_viewDetail.php create mode 100644 templates/webpanel/Views/V_viewLastImage.php create mode 100644 templates/webpanel/Views/V_viewLastImages.php create mode 100644 templates/webpanel/Views/V_viewPasses.php create mode 100644 templates/webpanel/Views/index.html create mode 100644 templates/webpanel/detail.php create mode 100644 templates/webpanel/footer.php create mode 100644 templates/webpanel/header.php create mode 100644 templates/webpanel/index.php create mode 100644 templates/webpanel/language/en.php create mode 100644 templates/webpanel/language/es.php create mode 100755 templates/webpanel/logo-small.png create mode 100644 templates/webpanel/passes.php create mode 100644 templates/webpanel/style.css diff --git a/templates/webpanel/Config.php b/templates/webpanel/Config.php new file mode 100644 index 0000000..2279883 --- /dev/null +++ b/templates/webpanel/Config.php @@ -0,0 +1,7 @@ + '/images/', + 'img_per_page' => 12, + 'lang' => 'es' +); +?> diff --git a/templates/webpanel/Controller/C_predict.php b/templates/webpanel/Controller/C_predict.php new file mode 100644 index 0000000..f5b519e --- /dev/null +++ b/templates/webpanel/Controller/C_predict.php @@ -0,0 +1,6 @@ +getPasses(); + require('Views/V_viewPasses.php'); +?> diff --git a/templates/webpanel/Controller/C_showDetail.php b/templates/webpanel/Controller/C_showDetail.php new file mode 100644 index 0000000..13b378c --- /dev/null +++ b/templates/webpanel/Controller/C_showDetail.php @@ -0,0 +1,8 @@ +getEnhacements($pass_id); + $path = $con->getPath($pass_id); + require('Views/V_viewDetail.php'); +?> diff --git a/templates/webpanel/Controller/C_showLastImage.php b/templates/webpanel/Controller/C_showLastImage.php new file mode 100644 index 0000000..83e6bd6 --- /dev/null +++ b/templates/webpanel/Controller/C_showLastImage.php @@ -0,0 +1,6 @@ +getLastImage(); + require('Views/V_viewLastImage.php'); +?> diff --git a/templates/webpanel/Controller/C_showLastImages.php b/templates/webpanel/Controller/C_showLastImages.php new file mode 100644 index 0000000..80084ce --- /dev/null +++ b/templates/webpanel/Controller/C_showLastImages.php @@ -0,0 +1,11 @@ +img_per_page; + $page_count = $con->totalPages($img_per_page); + if ($page < 1) $page = 1; + if ($page > $page_count) $page = $page_count; + $images = $con->getImages($page, $img_per_page); + require('Views/V_viewLastImages.php'); +?> diff --git a/templates/webpanel/Controller/index.html b/templates/webpanel/Controller/index.html new file mode 100644 index 0000000..e69de29 diff --git a/templates/webpanel/Model/Conn.php b/templates/webpanel/Model/Conn.php new file mode 100644 index 0000000..b60fb51 --- /dev/null +++ b/templates/webpanel/Model/Conn.php @@ -0,0 +1,74 @@ +con = new SQLite3("/home/pi/raspberry-noaa/panel.db"); + } + + public function getPasses() { + $today = strtotime(date('Y-m-d', time())); + $query = $this->con->query("SELECT sat_name, is_active, + pass_start, pass_end, + max_elev FROM predict_passes + WHERE (pass_start > $today) ORDER BY + pass_start ASC;"); + $passes = []; + $i = 0; + while($row = $query->fetchArray()){ + $passes[$i] = $row; + $i++; + } + return $passes; + } + + public function totalPages($img_per_page) { + $total_pages = $this->con->querySingle("SELECT count() from decoded_passes;"); + return ceil($total_pages/$img_per_page); + } + + public function getImages($page, $img_per_page) { + $query = $this->con->prepare("SELECT decoded_passes.id, predict_passes.pass_start, + file_path, is_noaa, predict_passes.sat_name, predict_passes.max_elev + FROM decoded_passes INNER JOIN predict_passes + ON predict_passes.pass_start = decoded_passes.pass_start + ORDER BY decoded_passes.pass_start DESC LIMIT ? OFFSET ?;"); + $query->bindValue(1, $img_per_page); + $query->bindValue(2, $img_per_page * ($page-1)); + $result = $query->execute(); + $images = []; + $i = 0; + while($row = $result->fetchArray()){ + $images[$i] = $row; + $i++; + } + return $images; + } + + public function getEnhacements($id) { + $query = $this->con->prepare('SELECT daylight_pass, is_noaa + FROM decoded_passes WHERE id = ?;'); + $query->bindValue(1, $id); + $result = $query->execute(); + $pass = $result->fetchArray(); + if ($pass['is_noaa'] == 0) { + $enhacements = ['-122-rectified.jpg']; + } else { + if ($pass['daylight_pass'] == 1) { + $enhacements = ['-ZA.jpg','-MCIR.jpg','-MCIR-precip.jpg','-MSA.jpg','-MSA-precip.jpg','-HVC.jpg','-HVC-precip.jpg','-HVCT.jpg','-HVCT-precip.jpg']; + } else { + $enhacements = ['-ZA.jpg','-MCIR.jpg','-MCIR-precip.jpg']; + } + } + return $enhacements; + } + + public function getPath($id) { + $query = $this->con->prepare('SELECT file_path FROM decoded_passes + WHERE id = ?;'); + $query->bindValue(1, $id); + $result = $query->execute(); + $image = $result->fetchArray(); + return $image['file_path']; + } + } +?> diff --git a/templates/webpanel/Model/index.html b/templates/webpanel/Model/index.html new file mode 100644 index 0000000..e69de29 diff --git a/templates/webpanel/Views/V_viewDetail.php b/templates/webpanel/Views/V_viewDetail.php new file mode 100644 index 0000000..2d457c2 --- /dev/null +++ b/templates/webpanel/Views/V_viewDetail.php @@ -0,0 +1,23 @@ +
+ + base_url; + foreach ($enhacements as $enhacement) { + if($row_count%3==0) { + echo ""; + $col_count=1; + } + echo ""; + } + $row_count++; + $col_count++; + } + ?> +
"; + if($col_count==3) { + echo "
+
+ + diff --git a/templates/webpanel/Views/V_viewLastImage.php b/templates/webpanel/Views/V_viewLastImage.php new file mode 100644 index 0000000..57cf7e5 --- /dev/null +++ b/templates/webpanel/Views/V_viewLastImage.php @@ -0,0 +1,24 @@ + + base_url; + foreach ($images as $image) { + if($row_count%3==0) { + echo ""; + $col_count=1; + } + echo ""; + if($col_count==3) { + echo ""; + } + $row_count++; + $col_count++; + } + ?> +
"; + echo "
  • ". $image['sat_name'] ."
  • "; + echo "
  • ". date('d/m/Y H:i:s', $image['pass_start']) ."
+ + + diff --git a/templates/webpanel/Views/V_viewLastImages.php b/templates/webpanel/Views/V_viewLastImages.php new file mode 100644 index 0000000..81f187d --- /dev/null +++ b/templates/webpanel/Views/V_viewLastImages.php @@ -0,0 +1,42 @@ +
+ + 1) { + echo ""; + } else { + echo ""; + } + echo ""; + if ($page < $page_count) { + echo ""; + } else { + echo ""; + } + $row_count=0; + $col_count=0; + $baseurl = $configs->base_url; + foreach ($images as $image) { + if($row_count%3==0) { + echo ""; + $col_count=1; + } + if ($image['is_noaa'] == true) { + $ending = "-MCIR.jpg"; + } else { + $ending = "-122-rectified.jpg"; + } + echo ""; + if($col_count==3) { + echo ""; + } + $row_count++; + $col_count++; + } + ?> +
" . $lang['prev'] . "
" . $lang['page'] . " $page " . $lang['of'] . " $page_count" . $lang['next'] . "
"; + echo "
  • ". $image['sat_name'] ."
  • "; + echo "
  • " . $lang['elev'] . ": ". $image['max_elev'] ."°
  • "; + echo "
  • ". date('d/m/Y H:i:s', $image['pass_start']) ."
+
+ + diff --git a/templates/webpanel/Views/V_viewPasses.php b/templates/webpanel/Views/V_viewPasses.php new file mode 100644 index 0000000..cf8cd2b --- /dev/null +++ b/templates/webpanel/Views/V_viewPasses.php @@ -0,0 +1,24 @@ +
+ + + + + + + + "; + } else { + echo ""; + } + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> +
". $pass['sat_name'] ."". date('H:i:s', $pass['pass_start']) ."". date('H:i:s', $pass['pass_end']) ."". $pass['max_elev'] ."
+
diff --git a/templates/webpanel/Views/index.html b/templates/webpanel/Views/index.html new file mode 100644 index 0000000..e69de29 diff --git a/templates/webpanel/detail.php b/templates/webpanel/detail.php new file mode 100644 index 0000000..a11d8d6 --- /dev/null +++ b/templates/webpanel/detail.php @@ -0,0 +1,7 @@ + diff --git a/templates/webpanel/footer.php b/templates/webpanel/footer.php new file mode 100644 index 0000000..02bc661 --- /dev/null +++ b/templates/webpanel/footer.php @@ -0,0 +1,6 @@ + +
+ +
+ + diff --git a/templates/webpanel/header.php b/templates/webpanel/header.php new file mode 100644 index 0000000..5efac7e --- /dev/null +++ b/templates/webpanel/header.php @@ -0,0 +1,27 @@ +lang; + include_once('language/' . $lang . '.php'); +?> + + + + + + + + <?= isset($PageTitle) ? $PageTitle : "Raspberry NOAA"?> + + + +
+ + diff --git a/templates/webpanel/index.php b/templates/webpanel/index.php new file mode 100644 index 0000000..ddaa13c --- /dev/null +++ b/templates/webpanel/index.php @@ -0,0 +1,7 @@ + diff --git a/templates/webpanel/language/en.php b/templates/webpanel/language/en.php new file mode 100644 index 0000000..5373e27 --- /dev/null +++ b/templates/webpanel/language/en.php @@ -0,0 +1,15 @@ + "Passes", + "satellite" => "Satellite", + "images" => "Images", + "pass_start" => "Pass start", + "pass_end" => "Pass end", + "max_elev" => "Max elevation", + "elev" => "Elevation", + "page" => "Page", + "of" => "of", + "prev" => "Prev", + "next" => "Next", +); +?> diff --git a/templates/webpanel/language/es.php b/templates/webpanel/language/es.php new file mode 100644 index 0000000..0b4e507 --- /dev/null +++ b/templates/webpanel/language/es.php @@ -0,0 +1,15 @@ + "Pasadas", + "satellite" => "Satélite", + "images" => "Imagenes", + "pass_start" => "Inicio", + "pass_end" => "Fin", + "max_elev" => "Elevación", + "elev" => "Elevación", + "page" => "Página", + "of" => "de", + "prev" => "Anterior", + "next" => "Siguiente", +); +?> diff --git a/templates/webpanel/logo-small.png b/templates/webpanel/logo-small.png new file mode 100755 index 0000000000000000000000000000000000000000..5ec241b66a9b6b73e41ef0eaa83f3e4846cec258 GIT binary patch literal 16850 zcmXtg16*Wp*mkyUY}o9rHfu8{+qPYs?KWexZM(MGY}Zb%Z)04&8!PeE(*vXv5(Zw?RQh*2o zf&xNDLR8Hw=RDUlLtnk)Q`q*xh<|oAb03(@d9B7TfoaRnXs@OnI4lp}w4}yPTu*rYD=O zoGYJ|jn?1fi2W>}TzI6|SU4kE3|I|FTX@p8pZgdWGQVjzSwhDkV3dg+_(kv{p_7bX zpMGvT@qatk;ycjdMC>sR+z1(XcZ0T>?Ijp^fc^vFu*ROf+bi<nW2oLhUsh7Zr7 ziF|>_8KN4xjSp<6-QU2ieqjGne{|zJJj4zx8WqJF)(1ikN;OJgAe0xwW-m-T`{oDh zZrR>rO+W138tuhRb+zM+YwrwM`WMZ}x&vsxHcfJZhT zS4~+oGS@@c9iKpjg1U1cQi81I%Z+25zvuX2--=e-DdSr_ zls*i=1Q`-iq13R_pFHCS#f3k#mY4|11q}5v3<*w}KKi*Ng>e9m7yV`+eLV)-PtUf*Y)8zP@YE&>94d&E@9NC6A)hbeS4?tJ-NAy z{QWf8!U&BG&5Lo9CszdOjSiA96K4K~rN5zn3;_Yp2rCE&89IHtL}u6PRR;fc+!gIT z`Q`z}CgeLzu^!P%vuM8WplONB0QBQmine(PD7LohzWG+I1*JrEXb=|0 zyYYRMzJrk$uAH|p!{#>X^GqYKD|83#9i|t5phbwNoo&;T5f@PVI~bGQ_;Kw4=<#to zgu10cn}4abi~HeRjPm=}=#(YxQJ0RRgB>3&kHb;jHq_MN@wYZq8WW*%yB+eOD}ndn zQ)p`_#HBCF$Ru(U?CIArjTcxq788$A^?i(kJ0<1;Q5kZlvF-(LT8f8xOU1PY zK*!4DYx8kFiUx{`2j}&R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5BmKp?{j7QJ*-t-3Xn!#kOiVm?eq>iy=tn2lK+h{d%g;U86prA>hU3BwgAYPe zzk%_yZ82p7sC7o|l^YXuTbGHOEoigSqqNwPpSh0u|55}!o#kv34Y%CZK!>WIPS&4o z&6lU54mK>`g*`u5E#TqiZPi!gD{5p*bJl1Y z=wf_L-SP6TY@@d)#&95;NB(u)m7bn=&(Z`6Lo&)e_uc(a)0y zCipC!*W`CL95+qouah>hj|!ua{3)777Abjxq*2dKg>)IGw-A0q>*?lVx{^=6my)WK zpLkSu0a!rS4oHAMC$VTnI&1c~!*AB#R`V;v*(FME1Nh_lvqXQe>& zsjEZvr&oh$*96<>v+^*a;{=K1`>z~Zt2$!evSVw)bA}-Tpj?tz`Rp5tQ|JC-c#)J2 zM@n5C_mJY>QG%UQpWPOBMG69F2FB=fU5+e!B>R^OE3>74+a4y|qtDA7rdNu)`)xOd zg6op$bTCK>>9P|>QELQ1*GuV7y2>r6AKBO3FniPt33r}dwJzdewbOn+r4CASWxLZwIBEhE<#p^DsrEksngC`0^?&wqmY9t( z*N@)bz=mYkQ>g4v;R&F0%aUp+a|mB5vhQrHZ>ZMWTVgiGT$jRIBDbpNJuPSt%4RAo zz+XfXbV$@WG@A{5o%%U4UyC@4vBYeQ`5%Zl>mSPA<0$tPL^cQ-2I)k#6=4m~hO&T= tMVUsJ1jazd1wBpB`5`g1=lr#b_Ft7qH) diff --git a/templates/webpanel/style.css b/templates/webpanel/style.css new file mode 100644 index 0000000..e17a0bb --- /dev/null +++ b/templates/webpanel/style.css @@ -0,0 +1,99 @@ +body { + margin: 0; + font-family: Arial, Helvetica, sans-serif; +} + +.container { + margin: 20px auto; + max-width: 800px; +} + +.topnav { + overflow: hidden; + background-color: #333; +} + +.topnav a { + float: left; + color: #f2f2f2; + text-align: center; + padding: 14px 16px; + text-decoration: none; + font-size: 17px; +} + +.topnav a:hover { + background-color: #ddd; + color: black; +} + +.topnav a.active { + background-color: #4CAF50; + color: white; +} + +#passes { + font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; + border-collapse: collapse; + max-width: 500px; + width: 100%; + margin: auto; +} + +#passes.img-grid { + max-width: 700px; +} + +#passes td, +#passes th { + border: 1px solid #ddd; + padding: 8px; +} + +#passes tr:nth-child(even) { + background-color: #f2f2f2; +} + + +/* #passes tr:hover {background-color: #ddd;} */ + +#passes th { + padding-top: 12px; + padding-bottom: 12px; + background-color: #4CAF50; + text-align: center; + color: white; +} + +#passes tr.inactive { + color: lightgray; +} + +#satimg { + max-width: 200px; + max-height: 200px; + width: 100%; +} + +#satimgdiv { + width: 100%; + height: 100%; + max-width: 200px; + background-color: antiquewhite; + /* margin: 10px; */ + display: inline-block; + vertical-align: middle; + text-align: center; +} + +footer { + /* position: absolute; */ + margin: 20px; + bottom: 0; + max-width: 100%; + text-align: center; +} + +img.img-footer { + max-width: 100%; +} \ No newline at end of file From 6f2765e756bdea12a6795f43510a35a2f269bfba Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 19:18:51 -0300 Subject: [PATCH 28/57] typo --- templates/nginx.cfg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/nginx.cfg b/templates/nginx.cfg index d1dcfe5..151018a 100644 --- a/templates/nginx.cfg +++ b/templates/nginx.cfg @@ -11,10 +11,10 @@ server { } location ~ \.php$ { - include snippets/fastcgi-php.conf; - fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; } # Rewrite the old path yyyy/mm/dd/ to /images/ - rewrite "^/image/\d{4}/\d{2}/\d{2}/(.+)$" /images/$1 permanent + rewrite "^/image/\d{4}/\d{2}/\d{2}/(.+)$" /images/$1 permanent; } From d24da8aea202f4f2c12e940332e20b6eb0345dd9 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 19:30:10 -0300 Subject: [PATCH 29/57] chgrp to www-data, launch scheduler --- install.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 5bc4eb0..d070169 100755 --- a/install.sh +++ b/install.sh @@ -184,7 +184,8 @@ sudo cp templates/nginx.cfg /etc/nginx/sites-enabled/default sudo chmod 775 /var/www/wx ) sudo systemctl restart nginx -cp -r "templates/webpanel/*" "/var/www/wx/" +sudo cp -rp templates/webpanel/* /var/www/wx/ + log_done "Nginx configured" ### Setup ramFS @@ -231,8 +232,10 @@ sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g" "$HOME/.wxtoi sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/$(echo "$lon * -1" | bc)/g" "$HOME/.predict/predict.qth" sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g;s/change_tz/$(echo "$timezone * -1" | bc)/g" "sun.py" -# Running WXTOIMG to have the user accept the licensing agreement -wxtoimg +### Launch scheduler +newgrp www-data << END + /home/pi/raspberry-noaa/schedule.sh +END success "Install done! Double check your $HOME/.noaa.conf settings" @@ -240,3 +243,6 @@ echo " If you want to post your images to Twitter, please setup your Twitter credentials on $HOME/.tweepy.conf " + +### Running WXTOIMG to have the user accept the licensing agreement +wxtoimg From 0755fc4c30454dcafd3e7aba3ad457631507d032 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 20:27:40 -0300 Subject: [PATCH 30/57] create thumb dir --- common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common.sh b/common.sh index a008ff0..c19ccca 100755 --- a/common.sh +++ b/common.sh @@ -48,8 +48,8 @@ if [ ! -d "${RAMFS_AUDIO}/audio/" ]; then mkdir -m 775 -p "${RAMFS_AUDIO}/audio/" fi -if [ ! -d "${NOAA_OUTPUT}/images/" ]; then - mkdir -m 775 -p "${NOAA_OUTPUT}/images/" +if [ ! -d "${NOAA_OUTPUT}/images/thumb" ]; then + mkdir -m 775 -p "${NOAA_OUTPUT}/images/thumb" fi if [ ! -d "${NOAA_HOME}/map/" ]; then From e6ad619cfa56163d5952a5a9c1de033dc08432ea Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 21:05:18 -0300 Subject: [PATCH 31/57] make more space on ramfs partition for meteor passes --- templates/fstab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/fstab b/templates/fstab index dbccb3a..023fb81 100644 --- a/templates/fstab +++ b/templates/fstab @@ -1 +1 @@ -tmpfs /var/ramfs tmpfs nodev,nosuid,size=100M 0 0 +tmpfs /var/ramfs tmpfs nodev,nosuid,size=400M 0 0 From 7a8f63557cbecec0891c520db74f4209a3f544c8 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 22:04:54 -0300 Subject: [PATCH 32/57] fix image path --- templates/webpanel/Views/V_viewDetail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/webpanel/Views/V_viewDetail.php b/templates/webpanel/Views/V_viewDetail.php index 2d457c2..15172e8 100644 --- a/templates/webpanel/Views/V_viewDetail.php +++ b/templates/webpanel/Views/V_viewDetail.php @@ -9,7 +9,7 @@ echo ""; $col_count=1; } - echo "
"; + echo "
"; if($col_count==3) { echo ""; } From d342c86e900fe9d01763f1df3a728fc18020dd59 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 22:06:38 -0300 Subject: [PATCH 33/57] replace shebang --- schedule_iss.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schedule_iss.sh b/schedule_iss.sh index 67e4b16..8267a0f 100755 --- a/schedule_iss.sh +++ b/schedule_iss.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ## debug # set -x From 991657fd5089c31372e3c5603df0bf33c63f4bfa Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 22:26:04 -0300 Subject: [PATCH 34/57] fix image path --- receive_meteor.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 5e31cd0..816a40f 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -46,10 +46,10 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then if [ "${SUN_ELEV}" -lt "${SUN_MIN_ELEV}" ]; then log "I got a successful ${3}.dec file. Decoding APID 68" "INFO" - medet_arm "${METEOR_OUTPUT}/${3}.dec" "${METEOR_OUTPUT}/${3}-122" -r 68 -g 68 -b 68 -d + medet_arm "${METEOR_OUTPUT}/${3}.dec" "${NOAA_OUTPUT}/images/${3}-122" -r 68 -g 68 -b 68 -d else 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 + medet_arm "${METEOR_OUTPUT}/${3}.dec" "${NOAA_OUTPUT}/images/${3}-122" -r 65 -g 65 -b 64 -d fi log "Rectifying image to adjust aspect ratio" "INFO" From 35c76cf0f833f05b109b6822d5d5b9ea22197f73 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 22:29:43 -0300 Subject: [PATCH 35/57] add thumb --- receive_meteor.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/receive_meteor.sh b/receive_meteor.sh index 816a40f..5f3a019 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -54,6 +54,7 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then log "Rectifying image to adjust aspect ratio" "INFO" python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.bmp" + /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-rectified.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-rectified.jpg" rm "${METEOR_OUTPUT}/${3}-122.bmp" rm "${METEOR_OUTPUT}/${3}.bmp" From b62d1e3d1f214b1fe6b245ab76fa000fe1c4f6dd Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 4 Oct 2020 11:05:38 -0300 Subject: [PATCH 36/57] fix path --- receive_meteor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 5f3a019..8a99d43 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -54,7 +54,7 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then log "Rectifying image to adjust aspect ratio" "INFO" python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.bmp" - /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-rectified.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-rectified.jpg" + /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-122-rectified.jpg" rm "${METEOR_OUTPUT}/${3}-122.bmp" rm "${METEOR_OUTPUT}/${3}.bmp" From e98a1a6549bae1a86835c21742db254f42f3de73 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 4 Oct 2020 11:28:21 -0300 Subject: [PATCH 37/57] fix path --- receive_meteor.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 8a99d43..6178cd9 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -56,7 +56,6 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.bmp" /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-122-rectified.jpg" rm "${METEOR_OUTPUT}/${3}-122.bmp" - rm "${METEOR_OUTPUT}/${3}.bmp" 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;") From 65ccd5c3a72c9fb93903bed71cc9e1c7f78dcd97 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 4 Oct 2020 11:30:59 -0300 Subject: [PATCH 38/57] fix path --- receive_meteor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 6178cd9..660b81c 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -55,7 +55,7 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then log "Rectifying image to adjust aspect ratio" "INFO" python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.bmp" /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-122-rectified.jpg" - rm "${METEOR_OUTPUT}/${3}-122.bmp" + rm "${METEOR_OUTPUT}/${3}.bmp" 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;") From 3122671bb8c339b9db5645805d163ae085c2c057 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 4 Oct 2020 11:51:23 -0300 Subject: [PATCH 39/57] fix path for thumb --- templates/webpanel/Views/V_viewLastImage.php | 2 +- templates/webpanel/Views/V_viewLastImages.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/webpanel/Views/V_viewLastImage.php b/templates/webpanel/Views/V_viewLastImage.php index 57cf7e5..66766bb 100644 --- a/templates/webpanel/Views/V_viewLastImage.php +++ b/templates/webpanel/Views/V_viewLastImage.php @@ -8,7 +8,7 @@ echo ""; $col_count=1; } - echo "
"; + echo "
"; echo "
  • ". $image['sat_name'] ."
  • "; echo "
  • ". date('d/m/Y H:i:s', $image['pass_start']) ."
"; if($col_count==3) { diff --git a/templates/webpanel/Views/V_viewLastImages.php b/templates/webpanel/Views/V_viewLastImages.php index 81f187d..c17d4bb 100644 --- a/templates/webpanel/Views/V_viewLastImages.php +++ b/templates/webpanel/Views/V_viewLastImages.php @@ -25,7 +25,7 @@ } else { $ending = "-122-rectified.jpg"; } - echo "
"; + echo "
"; echo "
  • ". $image['sat_name'] ."
  • "; echo "
  • " . $lang['elev'] . ": ". $image['max_elev'] ."°
  • "; echo "
  • ". date('d/m/Y H:i:s', $image['pass_start']) ."
"; From 72f43265b5b929865c3d9696964cb06c9850f799 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 4 Oct 2020 13:13:21 -0300 Subject: [PATCH 40/57] disable ramfs for meteor passes on <2Gi ram systems --- install.sh | 4 ++++ receive_meteor.sh | 7 +++++++ templates/fstab | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index d070169..a4d9c08 100755 --- a/install.sh +++ b/install.sh @@ -189,6 +189,10 @@ sudo cp -rp templates/webpanel/* /var/www/wx/ log_done "Nginx configured" ### Setup ramFS +SYSTEM_MEMORY=$(free -m | awk '/^Mem:/{print $2}') +if [ "$SYSTEM_MEMORY" -lt 2000 ]; then + sed -i -e "s/1000M/200M/g" templates/fstab +fi set +e cat /etc/fstab | grep -q "ramfs" if [ $? -eq 0 ]; then diff --git a/receive_meteor.sh b/receive_meteor.sh index 660b81c..3523af8 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -5,6 +5,13 @@ . "$HOME/.tweepy.conf" . "$NOAA_HOME/common.sh" + +SYSTEM_MEMORY=$(free -m | awk '/^Mem:/{print $2}') +if [ "$SYSTEM_MEMORY" -lt 2000 ]; then + log "The system doesn't have enough space to store a Meteor pass on RAM" "INFO" + RAMFS_AUDIO="${METEOR_OUTPUT}" +fi + ## pass start timestamp and sun elevation PASS_START=$(expr "$5" + 90) SUN_ELEV=$(python3 "$NOAA_HOME"/sun.py "$PASS_START") diff --git a/templates/fstab b/templates/fstab index 023fb81..d76b2c0 100644 --- a/templates/fstab +++ b/templates/fstab @@ -1 +1 @@ -tmpfs /var/ramfs tmpfs nodev,nosuid,size=400M 0 0 +tmpfs /var/ramfs tmpfs nodev,nosuid,size=1000M 0 0 From 574178c784e46101cbb9479087a4f0c2799a408b Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 4 Oct 2020 18:33:24 -0300 Subject: [PATCH 41/57] Enable meteor m2 night passes --- schedule_meteor.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/schedule_meteor.sh b/schedule_meteor.sh index a373bea..20ca9d4 100755 --- a/schedule_meteor.sh +++ b/schedule_meteor.sh @@ -18,9 +18,8 @@ while [ "$(date --date="@${var2}" +%D)" = "$(date +%D)" ]; do var3=$(echo "$START_TIME" | cut -d " " -f 2 | cut -d ":" -f 3) TIMER=$(expr "${var2}" - "${var1}" + "${var3}") OUTDATE=$(date --date="TZ=\"UTC\" ${START_TIME}" +%Y%m%d-%H%M%S) - SUN_ELEV=$(python3 "$NOAA_HOME"/sun.py "$var1") - if [ "${MAXELEV}" -gt "${METEOR_MIN_ELEV}" ] && [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then + if [ "${MAXELEV}" -gt "${METEOR_MIN_ELEV}" ]; then log "Pass is above ${METEOR_MIN_ELEV}, that is OK for me" "INFO" SATNAME=$(echo "$1" | sed "s/ //g") echo "${SATNAME}" "${OUTDATE}" "$MAXELEV" From d07152410e8269319b8e160b5c34f94bc043c34f Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 4 Oct 2020 19:37:10 -0300 Subject: [PATCH 42/57] Enable image enhancement --- receive_meteor.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/receive_meteor.sh b/receive_meteor.sh index 3523af8..5117f50 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -61,6 +61,7 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then log "Rectifying image to adjust aspect ratio" "INFO" python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.bmp" + convert "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" -channel rgb -normalize "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-122-rectified.jpg" rm "${METEOR_OUTPUT}/${3}.bmp" From 27c79caf1359825fd48c66188a9f3b8ecef2a09c Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 4 Oct 2020 19:53:20 -0300 Subject: [PATCH 43/57] Turn upside down night passes --- receive_meteor.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/receive_meteor.sh b/receive_meteor.sh index 5117f50..78dfb29 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -54,6 +54,7 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then if [ "${SUN_ELEV}" -lt "${SUN_MIN_ELEV}" ]; then log "I got a successful ${3}.dec file. Decoding APID 68" "INFO" medet_arm "${METEOR_OUTPUT}/${3}.dec" "${NOAA_OUTPUT}/images/${3}-122" -r 68 -g 68 -b 68 -d + /usr/bin/convert -rotate 180 "${NOAA_OUTPUT}/images/${3}-122.bmp" "${NOAA_OUTPUT}/images/${3}-122.bmp" else log "I got a successful ${3}.dec file. Creating false color image" "INFO" medet_arm "${METEOR_OUTPUT}/${3}.dec" "${NOAA_OUTPUT}/images/${3}-122" -r 65 -g 65 -b 64 -d From 197a848cda6f4a5ff612c97d5b899c9b37a6f66c Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Tue, 6 Oct 2020 10:31:17 -0300 Subject: [PATCH 44/57] Enable meteor m2 night passes --- schedule_meteor.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/schedule_meteor.sh b/schedule_meteor.sh index 20ca9d4..1449f7e 100755 --- a/schedule_meteor.sh +++ b/schedule_meteor.sh @@ -19,14 +19,10 @@ while [ "$(date --date="@${var2}" +%D)" = "$(date +%D)" ]; do TIMER=$(expr "${var2}" - "${var1}" + "${var3}") OUTDATE=$(date --date="TZ=\"UTC\" ${START_TIME}" +%Y%m%d-%H%M%S) - if [ "${MAXELEV}" -gt "${METEOR_MIN_ELEV}" ]; then - log "Pass is above ${METEOR_MIN_ELEV}, that is OK for me" "INFO" - SATNAME=$(echo "$1" | sed "s/ //g") - echo "${SATNAME}" "${OUTDATE}" "$MAXELEV" - echo "${NOAA_HOME}/receive_meteor.sh \"${1}\" $2 ${SATNAME}${OUTDATE} "${NOAA_HOME}"/predict/weather.tle \ -${var1} ${TIMER} ${MAXELEV}" | at "$(date --date="TZ=\"UTC\" ${START_TIME}" +"%H:%M %D")" - sqlite3 /home/pi/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev,is_active) values (\"$SATNAME\",$var1,$var2,$MAXELEV,1);" - fi + SATNAME=$(echo "$1" | sed "s/ //g") + echo "${SATNAME}" "${OUTDATE}" "$MAXELEV" + echo "${NOAA_HOME}/receive_meteor.sh \"${1}\" $2 ${SATNAME}${OUTDATE} "${NOAA_HOME}"/predict/weather.tle ${var1} ${TIMER} ${MAXELEV}" | at "$(date --date="TZ=\"UTC\" ${START_TIME}" +"%H:%M %D")" + sqlite3 /home/pi/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev,is_active) values (\"$SATNAME\",$var1,$var2,$MAXELEV,1);" NEXTPREDICT=$(expr "${var2}" + 60) PREDICTION_START=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | head -1) PREDICTION_END=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | tail -1) From effedb66ccf1496a3656df4d59b4adf341ae0e43 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Tue, 6 Oct 2020 10:32:58 -0300 Subject: [PATCH 45/57] Revert "Enable meteor m2 night passes" This reverts commit 197a848cda6f4a5ff612c97d5b899c9b37a6f66c. --- schedule_meteor.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/schedule_meteor.sh b/schedule_meteor.sh index 1449f7e..20ca9d4 100755 --- a/schedule_meteor.sh +++ b/schedule_meteor.sh @@ -19,10 +19,14 @@ while [ "$(date --date="@${var2}" +%D)" = "$(date +%D)" ]; do TIMER=$(expr "${var2}" - "${var1}" + "${var3}") OUTDATE=$(date --date="TZ=\"UTC\" ${START_TIME}" +%Y%m%d-%H%M%S) - SATNAME=$(echo "$1" | sed "s/ //g") - echo "${SATNAME}" "${OUTDATE}" "$MAXELEV" - echo "${NOAA_HOME}/receive_meteor.sh \"${1}\" $2 ${SATNAME}${OUTDATE} "${NOAA_HOME}"/predict/weather.tle ${var1} ${TIMER} ${MAXELEV}" | at "$(date --date="TZ=\"UTC\" ${START_TIME}" +"%H:%M %D")" - sqlite3 /home/pi/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev,is_active) values (\"$SATNAME\",$var1,$var2,$MAXELEV,1);" + if [ "${MAXELEV}" -gt "${METEOR_MIN_ELEV}" ]; then + log "Pass is above ${METEOR_MIN_ELEV}, that is OK for me" "INFO" + SATNAME=$(echo "$1" | sed "s/ //g") + echo "${SATNAME}" "${OUTDATE}" "$MAXELEV" + echo "${NOAA_HOME}/receive_meteor.sh \"${1}\" $2 ${SATNAME}${OUTDATE} "${NOAA_HOME}"/predict/weather.tle \ +${var1} ${TIMER} ${MAXELEV}" | at "$(date --date="TZ=\"UTC\" ${START_TIME}" +"%H:%M %D")" + sqlite3 /home/pi/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev,is_active) values (\"$SATNAME\",$var1,$var2,$MAXELEV,1);" + fi NEXTPREDICT=$(expr "${var2}" + 60) PREDICTION_START=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | head -1) PREDICTION_END=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | tail -1) From 27d4eb27762c0c1435aa1d4180f707c1dcff4aa9 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Fri, 16 Oct 2020 11:33:32 -0300 Subject: [PATCH 46/57] toggle image flip for meteor night passes --- receive_meteor.sh | 11 +++++++++-- rectify.py | 2 +- templates/noaa.conf | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 78dfb29..97d61c8 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -12,6 +12,13 @@ if [ "$SYSTEM_MEMORY" -lt 2000 ]; then RAMFS_AUDIO="${METEOR_OUTPUT}" fi +if [ "$FLIP_METEOR_IMG" == "true" ]; then + log "I'll flip this image pass because FLIP_METEOR_IMG is set to true" "INFO" + FLIP="-rotate 180" +else + FLIP="" +fi + ## pass start timestamp and sun elevation PASS_START=$(expr "$5" + 90) SUN_ELEV=$(python3 "$NOAA_HOME"/sun.py "$PASS_START") @@ -54,7 +61,7 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then if [ "${SUN_ELEV}" -lt "${SUN_MIN_ELEV}" ]; then log "I got a successful ${3}.dec file. Decoding APID 68" "INFO" medet_arm "${METEOR_OUTPUT}/${3}.dec" "${NOAA_OUTPUT}/images/${3}-122" -r 68 -g 68 -b 68 -d - /usr/bin/convert -rotate 180 "${NOAA_OUTPUT}/images/${3}-122.bmp" "${NOAA_OUTPUT}/images/${3}-122.bmp" + /usr/bin/convert $FLIP "${NOAA_OUTPUT}/images/${3}-122.bmp" "${NOAA_OUTPUT}/images/${3}-122.bmp" else log "I got a successful ${3}.dec file. Creating false color image" "INFO" medet_arm "${METEOR_OUTPUT}/${3}.dec" "${NOAA_OUTPUT}/images/${3}-122" -r 65 -g 65 -b 64 -d @@ -62,7 +69,7 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then log "Rectifying image to adjust aspect ratio" "INFO" python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.bmp" - convert "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" -channel rgb -normalize "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" + convert "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" -channel rgb -normalize -undercolor black -fill yellow -pointsize 60 -annotate +20+40 "${1} ${START_DATE} Elev: $7°" "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-122-rectified.jpg" rm "${METEOR_OUTPUT}/${3}.bmp" diff --git a/rectify.py b/rectify.py index c20ba43..042870d 100755 --- a/rectify.py +++ b/rectify.py @@ -8,7 +8,7 @@ from math import atan,sin,cos,sqrt,tan,acos,ceil from PIL import Image EARTH_RADIUS = 6371.0 -SAT_HEIGHT = 822.5 +SAT_HEIGHT = 830.0 SAT_ORBIT_RADIUS = EARTH_RADIUS + SAT_HEIGHT SWATH_KM = 2800.0 THETA_C = SWATH_KM / EARTH_RADIUS diff --git a/templates/noaa.conf b/templates/noaa.conf index fd188d1..1a34fb0 100644 --- a/templates/noaa.conf +++ b/templates/noaa.conf @@ -9,4 +9,5 @@ LOG_LEVEL=DEBUG LAT=change_latitude LON=change_longitude BIAS_TEE="enable_bias_tee" -DELETE_AUDIO=true +DELETE_AUDIO="true" +FLIP_METEOR_IMG="true" From db6c5c70d8e396da269ebcf1ac57357f0d929fea Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Fri, 16 Oct 2020 11:34:59 -0300 Subject: [PATCH 47/57] toggle image flip for meteor night passes --- receive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receive.sh b/receive.sh index 875db59..5b6a94d 100755 --- a/receive.sh +++ b/receive.sh @@ -41,7 +41,7 @@ log "Bulding pass map" "INFO" 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}/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 -quality 90 -format jpg "${NOAA_OUTPUT}/images/${3}-$i.jpg" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} $i ${START_DATE}Elev: $7°" "${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 From 8660137bc7a6f6d1878b1ef5b0ab3972d6ad1cbe Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Fri, 16 Oct 2020 11:36:35 -0300 Subject: [PATCH 48/57] pick bugfix on timezone --- sun.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sun.py b/sun.py index 3454b29..cdd87e8 100755 --- a/sun.py +++ b/sun.py @@ -2,8 +2,8 @@ import ephem import time import sys -timezone = change_tz -date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(sys.argv[1])+(timezone*60*60))) +timezone = change_tz + time.localtime().tm_isdst +date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(sys.argv[1])-(timezone*60*60))) obs=ephem.Observer() obs.lat='change_latitude' From 3155071ec3f32b9c0ad7da3b1b708656575deac0 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Fri, 16 Oct 2020 11:40:55 -0300 Subject: [PATCH 49/57] fix indent, fix path on delete --- receive_meteor.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 97d61c8..ea939f6 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -25,8 +25,8 @@ SUN_ELEV=$(python3 "$NOAA_HOME"/sun.py "$PASS_START") 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" - pkill -9 -f rtl_fm + log "There is an already running rtl_fm instance but I dont care for now, I prefer this pass" "INFO" + pkill -9 -f rtl_fm fi # $1 = Satellite Name @@ -47,7 +47,7 @@ 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" + log "Moving audio files out to the SD card" "INFO" mv "${RAMFS_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/audio/${3}.wav" fi @@ -71,7 +71,7 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.bmp" convert "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" -channel rgb -normalize -undercolor black -fill yellow -pointsize 60 -annotate +20+40 "${1} ${START_DATE} Elev: $7°" "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-122-rectified.jpg" - rm "${METEOR_OUTPUT}/${3}.bmp" + rm "${NOAA_OUTPUT}/images/${3}-122.bmp" 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;") From c4799973750cdd47cf9da20705ce83475e3039b9 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Fri, 16 Oct 2020 17:09:03 -0300 Subject: [PATCH 50/57] Disable ppm correction --- receive.sh | 2 +- receive_meteor.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/receive.sh b/receive.sh index 5b6a94d..de1a3a3 100755 --- a/receive.sh +++ b/receive.sh @@ -26,7 +26,7 @@ fi # $7 = Satellite max elevation 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 +timeout "${6}" /usr/local/bin/rtl_fm ${BIAS_TEE} -f "${2}"M -s 60k -g 50 -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 [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then ENHANCEMENTS="ZA MCIR MCIR-precip MSA MSA-precip HVC-precip HVCT-precip HVC HVCT" diff --git a/receive_meteor.sh b/receive_meteor.sh index ea939f6..8c4fc2d 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -38,7 +38,7 @@ fi # $7 = Satellite max elevation log "Starting rtl_fm record" "INFO" -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 +timeout "${6}" /usr/local/bin/rtl_fm ${BIAS_TEE} -M raw -f "${2}"M -s 288k -g 48 | sox -t raw -r 288k -c 2 -b 16 -e s - -t wav "${RAMFS_AUDIO}/audio/${3}.wav" rate 96k log "Demodulation in progress (QPSK)" "INFO" meteor_demod -B -o "${METEOR_OUTPUT}/${3}.qpsk" "${RAMFS_AUDIO}/audio/${3}.wav" From 698a85dd9d74d749357b7d93345727a6516f0962 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Fri, 16 Oct 2020 18:33:49 -0300 Subject: [PATCH 51/57] add missing rm's --- common.sh | 5 ----- receive.sh | 3 +++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/common.sh b/common.sh index c19ccca..a9567a1 100755 --- a/common.sh +++ b/common.sh @@ -35,11 +35,6 @@ if [ ! -d "${NOAA_OUTPUT}/audio/" ]; then mkdir -m 775 -p "${NOAA_OUTPUT}/audio/" fi - -if [ ! -d "${METEOR_OUTPUT}" ]; then - mkdir -m 775 -p "${METEOR_OUTPUT}" -fi - if [ ! -d "${METEOR_OUTPUT}/audio/" ]; then mkdir -m 775 -p "${METEOR_OUTPUT}/audio/" fi diff --git a/receive.sh b/receive.sh index de1a3a3..daf39e7 100755 --- a/receive.sh +++ b/receive.sh @@ -44,6 +44,9 @@ for i in $ENHANCEMENTS; do /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}Elev: $7°" "${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 + +rm "${NOAA_HOME}/map/${3}-map.png" + 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 From 52fd5b749a8e48f3cad0a162a4426bb87a892d34 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 17 Oct 2020 08:35:30 -0300 Subject: [PATCH 52/57] negrate b/w pass --- receive_meteor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 8c4fc2d..80f9590 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -61,7 +61,7 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then if [ "${SUN_ELEV}" -lt "${SUN_MIN_ELEV}" ]; then log "I got a successful ${3}.dec file. Decoding APID 68" "INFO" medet_arm "${METEOR_OUTPUT}/${3}.dec" "${NOAA_OUTPUT}/images/${3}-122" -r 68 -g 68 -b 68 -d - /usr/bin/convert $FLIP "${NOAA_OUTPUT}/images/${3}-122.bmp" "${NOAA_OUTPUT}/images/${3}-122.bmp" + /usr/bin/convert $FLIP -negate "${NOAA_OUTPUT}/images/${3}-122.bmp" "${NOAA_OUTPUT}/images/${3}-122.bmp" else log "I got a successful ${3}.dec file. Creating false color image" "INFO" medet_arm "${METEOR_OUTPUT}/${3}.dec" "${NOAA_OUTPUT}/images/${3}-122" -r 65 -g 65 -b 64 -d From 9758e1a77b14cff10d7a19ef53e5a81e3d391b99 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sun, 18 Oct 2020 18:33:52 -0300 Subject: [PATCH 53/57] receive: add whitespace --- receive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receive.sh b/receive.sh index daf39e7..dbe62d2 100755 --- a/receive.sh +++ b/receive.sh @@ -41,7 +41,7 @@ log "Bulding pass map" "INFO" 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}/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}Elev: $7°" "${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} Elev: $7°" "${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 From 13bf3be6f8776ecbbfedb74948e27fa61eef3dfd Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Tue, 20 Oct 2020 10:10:10 -0300 Subject: [PATCH 54/57] remove files --- receive_meteor.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/receive_meteor.sh b/receive_meteor.sh index 80f9590..54a013b 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -72,6 +72,8 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then convert "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" -channel rgb -normalize -undercolor black -fill yellow -pointsize 60 -annotate +20+40 "${1} ${START_DATE} Elev: $7°" "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-122-rectified.jpg" rm "${NOAA_OUTPUT}/images/${3}-122.bmp" + rm "${METEOR_OUTPUT}/${3}.bmp" + rm "${METEOR_OUTPUT}/${3}.dec" 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;") From c1d876e328d1da3503d3aba08ede122f0a431fac Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Tue, 20 Oct 2020 10:11:24 -0300 Subject: [PATCH 55/57] move annotation --- receive_meteor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 54a013b..8bcc521 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -69,7 +69,7 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then log "Rectifying image to adjust aspect ratio" "INFO" python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.bmp" - convert "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" -channel rgb -normalize -undercolor black -fill yellow -pointsize 60 -annotate +20+40 "${1} ${START_DATE} Elev: $7°" "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" + convert "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" -channel rgb -normalize -undercolor black -fill yellow -pointsize 60 -annotate +20+60 "${1} ${START_DATE} Elev: $7°" "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg" "${NOAA_OUTPUT}/images/thumb/${3}-122-rectified.jpg" rm "${NOAA_OUTPUT}/images/${3}-122.bmp" rm "${METEOR_OUTPUT}/${3}.bmp" From e824bcceb5bcfb79b7193a004ae16955bcf5de16 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Fri, 6 Nov 2020 19:30:03 -0300 Subject: [PATCH 56/57] migration: check if there is enough free space --- migrate_data.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/migrate_data.sh b/migrate_data.sh index a2d92ed..d7f3b08 100644 --- a/migrate_data.sh +++ b/migrate_data.sh @@ -5,9 +5,23 @@ . "$HOME/.tweepy.conf" . "$NOAA_HOME/common.sh" + +# Free disk space +FREE_DISK="$(df | grep "/dev/root" | awk {'print $3'})" + # This is the original path where images were stored BASEPATH="/var/www/wx/image" +# Size of the old images folder +IMAGEPATH_SIZE="$(du -s $BASEPATH | awk {'print $1'})" + +SPACE_NEEDED="$((IMAGEPATH_SIZE * 2))" + +if [ "$SPACE_NEEDED" -gt "$FREE_DISK" ]; then + echo "You need more free space" + exit 1 +fi + # This is the destination path (AKA the new path) FINALPATH="/var/www/wx/images" From 5d3f1354b2e076550ad375c2df2f41b76621c471 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Fri, 6 Nov 2020 19:33:12 -0300 Subject: [PATCH 57/57] web_panel: install requirements for web panel --- INSTALL.md | 15 ++++++++++++++- README.md | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 8dd93b8..7e764cc 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -11,6 +11,7 @@ - [Install the default configuration files](#install-the-default-configuration-files) - [Install Meteor software](#install-meteor-software) - [Setup Nginx](#setup-nginx) + - [Setup Database](#setup-database) - [Setup RamFS](#setup-ramfs) - [Cron the scheduling job](#cron-the-scheduling-job) - [Set your Twitter credentials](#set-your-twitter-credentials) @@ -60,7 +61,13 @@ sudo apt install -yq predict \ python3-pip \ imagemagick \ libxft-dev \ - libxft2 + libxft2 \ + libjpeg9 \ + libjpeg9-dev \ + socat \ + php7.2-fpm \ + php7.2-sqlite \ + sqlite3 ``` ``` @@ -145,6 +152,12 @@ sudo chmod 775 /var/www/wx sudo cp templates/index.html /var/www/wx/index.html sudo cp templates/logo-small.png /var/www/wx/logo-small.png sudo systemctl restart nginx +sudo cp -rp templates/webpanel/* /var/www/wx/ +``` + +### Setup Database +``` +sqlite3 "panel.db" < "templates/webpanel_schema.sql" ``` ### Setup RamFS diff --git a/README.md b/README.md index cb70562..2ea1034 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Most of the code and setup stolen from: [Instructables](https://www.instructables.com/id/Raspberry-Pi-NOAA-Weather-Satellite-Receiver/) ## New Features! + - A webpanel! - [Meteor M2 full decoding!](METEOR.md) - Nginx webserver to show images - Timestamp and satellite name overlay on every image