From af1772fb2ac8db499e60c1fac338e42b913e24e6 Mon Sep 17 00:00:00 2001 From: mihajlo2003petkovic Date: Wed, 14 Oct 2020 22:41:30 +0200 Subject: [PATCH 1/6] Invert nighttime Meteor M2 images. I've added piece of code to invert Meteor M2 images from nighttime pases (APID68 from IR sensor) so that clouds appear white and not black, text overlay (satellite name, timestamp and elevation) on Meteor M2 images like NOAA have, and deleting all intermediate images. --- receive_meteor.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 1201c84..8276199 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -54,23 +54,29 @@ 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}/image/${FOLDER_DATE}/${3}-122" -r 68 -g 68 -b 68 -d - /usr/bin/convert -rotate 180 "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.bmp" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.bmp" + medet_arm "${METEOR_OUTPUT}/${3}.dec" "${METEOR_OUTPUT}/${3}-122" -r 68 -g 68 -b 68 -d + convert "${METEOR_OUTPUT}/${3}-122.bmp" -channel RGB -negate "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.png" else log "I got a successful ${3}.dec file. Creating false color image" "INFO" - medet_arm "${METEOR_OUTPUT}/${3}.dec" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122" -r 65 -g 65 -b 64 -d + 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.png" fi - log "Rectifying image to adjust aspect ratio" "INFO" - python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.bmp" - convert "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified.jpg" -channel rgb -normalize "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified.jpg" - rm "${METEOR_OUTPUT}/${3}.bmp" - rm "${METEOR_OUTPUT}/${3}-122.bmp" - + python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.png" + convert "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified.png" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} ${START_DATE} Elevation: $7°" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified-text.png" 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}" "$7°" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified-text.png" fi + rm "${METEOR_OUTPUT}/${3}.bmp" + rm "${METEOR_OUTPUT}/${3}-122.bmp" + rm "${METEOR_OUTPUT}/${3}-122.png" + rm "${METEOR_OUTPUT}/${3}.dec" + rm "${METEOR_OUTPUT}/${3}-122.png" + rm "${METEOR_OUTPUT}/${3}-122-rectified.png" + rm "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.png" + rm "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified.png" + #rm "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified-text.png" else log "Decoding failed, either a bad pass/low SNR or a software problem" "ERROR" fi From f3e950d7d14627e96ed008c9a0015bfd22593d60 Mon Sep 17 00:00:00 2001 From: mihajlo2003petkovic Date: Wed, 14 Oct 2020 22:42:11 +0200 Subject: [PATCH 2/6] Update receive_meteor.sh --- receive_meteor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 8276199..ebbca7a 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -66,7 +66,7 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then convert "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified.png" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} ${START_DATE} Elevation: $7°" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified-text.png" if [ -n "$CONSUMER_KEY" ]; then log "Posting to Twitter" "INFO" - python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE}" "$7°" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified-text.png" + python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE}" "$7°" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified-text.png" fi rm "${METEOR_OUTPUT}/${3}.bmp" rm "${METEOR_OUTPUT}/${3}-122.bmp" From 123bd1b920ef78a393227aa6889157846e4e26e2 Mon Sep 17 00:00:00 2001 From: mihajlo2003petkovic Date: Wed, 14 Oct 2020 22:48:33 +0200 Subject: [PATCH 3/6] Added elevation on overlay and changed JPG to PNG I've added elevation on text overlay, changed all images from JPG to PNG in order to preserve whole resolution and added code to remove map image for overlay. --- receive.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/receive.sh b/receive.sh index 11dcdb1..2259f1a 100755 --- a/receive.sh +++ b/receive.sh @@ -42,18 +42,20 @@ 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/${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" "${RAMFS_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-$i.png" + /usr/bin/convert "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-$i.png" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} $i ${START_DATE} Elevation: $7°" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-$i.png" 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" + python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE}" "$7" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MCIR-precip.png" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MSA-precip.png" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-HVC-precip.png" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-HVCT-precip.png" 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" + python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE}" "$7" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MCIR-precip.png" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MCIR.png" fi fi +rm "${NOAA_HOME}/map/${3}-map.png" + if [ "$DELETE_AUDIO" = true ]; then log "Deleting audio files" "INFO" rm "${RAMFS_AUDIO}/audio/${3}.wav" From 06fd3cb3f1cfefdeaaad2e35e99e9741b0b83b89 Mon Sep 17 00:00:00 2001 From: mihajlo2003petkovic Date: Wed, 14 Oct 2020 22:52:12 +0200 Subject: [PATCH 4/6] Update receive_meteor.sh --- receive_meteor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index ebbca7a..cd77450 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -66,7 +66,7 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then convert "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified.png" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} ${START_DATE} Elevation: $7°" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified-text.png" if [ -n "$CONSUMER_KEY" ]; then log "Posting to Twitter" "INFO" - python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE}" "$7°" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified-text.png" + 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.png" fi rm "${METEOR_OUTPUT}/${3}.bmp" rm "${METEOR_OUTPUT}/${3}-122.bmp" From 4f568b3141f75e23ffd4d66727345ca7f1598a67 Mon Sep 17 00:00:00 2001 From: mihajlo2003petkovic Date: Wed, 14 Oct 2020 22:56:14 +0200 Subject: [PATCH 5/6] Bugs fixed. I've experienced issue when I put in +2 timezone, the script calculates sun elevation for -2 timezone so i changed plus to minus in time.localtime function. Also added support for Daylight saving time. --- 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 537101b95ad8fa6b4e6c7a2db0d73f8eaa120dfc Mon Sep 17 00:00:00 2001 From: mihajlo2003petkovic Date: Wed, 14 Oct 2020 23:00:33 +0200 Subject: [PATCH 6/6] Changed JPG to PNG and satellite height I've changed the last line which saves the image from JPG format to PNG in order to be compatible with receive_meteor.sh script. I've also changed satellite height to 830 km since according to https://www.n2yo.com/satellite/?s=40069 perigee is 826.8 km, and apogee is 833.6 km as of 14 October 2020. --- rectify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rectify.py b/rectify.py index c20ba43..5239c92 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 @@ -180,4 +180,4 @@ if __name__ == "__main__": # It's a dead pool now p.join() - rectified_img.save(out_fname + ".jpg", "JPEG", quality=90) + rectified_img.save(out_fname + ".png", "PNG")