From 7f6a815b246381602bf1693e030874d22354f9f3 Mon Sep 17 00:00:00 2001 From: Nico Rey Date: Sat, 3 Oct 2020 13:39:59 -0300 Subject: [PATCH] enable meteor m2 night passes --- receive_meteor.sh | 22 ++++++++++++++++------ rectify.py | 30 ++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/receive_meteor.sh b/receive_meteor.sh index 52d99d1..ee81fa4 100755 --- a/receive_meteor.sh +++ b/receive_meteor.sh @@ -9,11 +9,6 @@ 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" @@ -49,7 +44,22 @@ 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" + 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 65 -g 65 -b 68 -s -d + convert "${METEOR_OUTPUT}/${3}-122_0.bmp" "${NOAA_OUTPUT}/images/${3}-122.jpg" + python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.jpg" + rm "${METEOR_OUTPUT}/${3}-122_1.bmp" + rm "${METEOR_OUTPUT}/${3}-122_2.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 + convert "${METEOR_OUTPUT}/${3}-122.bmp" "${NOAA_OUTPUT}/images/${3}-122.jpg" + rm "${METEOR_OUTPUT}/${3}-122.bmp" + rm "${METEOR_OUTPUT}/${3}.bmp" + log "Rectifying image to adjust aspect ratio" "INFO" + python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/images/${3}-122.jpg" + fi 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" log "Rectifying image to adjust aspect ratio" "INFO" 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