Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
Added sun.py to calculate sun elevation and select desired enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico Rey committed Sep 15, 2018
1 parent dbc8924 commit e21abc6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
26 changes: 17 additions & 9 deletions receive.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

## debug
#set -x
# set -x

. ~/.noaa.conf

Expand Down Expand Up @@ -46,16 +46,24 @@ START_DATE=$(date '+%d-%m-%Y %H:%M')
timeout "${6}" rtl_fm -f "${2}"M -s 60k -g 50 -p 55 -E wav -E deemp -F 9 - | sox -t raw -e signed -c 1 -b 16 -r 60000 - ${NOAA_OUTPUT}/audio/"${3}".wav rate 11025

PASS_START=$(expr "$5" + 90)

SUN_ELEV=$(python2 sun.py $PASS_START)

if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then
ENHANCEMENTS="ZA MCIR MCIR-precip MSA MSA-precip HVC-precip HVCT-precip HVC HVCT"
else
ENHANCEMENTS="ZA MCIR MCIR-precip"
fi

/usr/local/bin/wxmap -T "${1}" -H "${4}" -p 0 -l 0 -o "${PASS_START}" ${NOAA_HOME}/map/"${3}"-map.png
for i in ZA MCIR MCIR-precip MSA MSA-precip HVC-precip HVCT-precip HVC HVCT; do
/usr/local/bin/wxtoimg -o -m ${NOAA_HOME}/map/"${3}"-map.png -e $i ${NOAA_OUTPUT}/audio/"${3}".wav ${NOAA_OUTPUT}/image/"${3}"-$i.png
/usr/bin/convert ${NOAA_OUTPUT}/image/"${3}"-$i.png -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} $i ${START_DATE}" ${NOAA_OUTPUT}/image/"${3}"-$i.png
for i in $ENHANCEMENTS; do
/usr/local/bin/wxtoimg -o -m ${NOAA_HOME}/map/"${3}"-map.png -e $i ${NOAA_OUTPUT}/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/gdrive upload --parent 1gehY-0iYkNSkBU9RCDsSTexRaQ_ukN0A ${NOAA_OUTPUT}/image/"${3}"-$i.jpg
done

ECLIPSED=$(identify -ping -format "%[fx:w]" /usr/share/html/image/$3-MSA.png)
if [ "$ECLIPSED" -gt 1041 ]; then
python2 ${NOAA_HOME}/post.py "$1 ${START_DATE}" ${NOAA_OUTPUT}/image/$3-MCIR-precip.png ${NOAA_OUTPUT}/image/$3-MCIR.png
if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then
python2 ${NOAA_HOME}/post.py "$1 ${START_DATE}" ${NOAA_OUTPUT}/image/$3-MCIR-precip.jpg ${NOAA_OUTPUT}/image/$3-MSA-precip.jpg ${NOAA_OUTPUT}/image/$3-HVC-precip.jpg ${NOAA_OUTPUT}/image/$3-HVCT.jpg
else
python2 ${NOAA_HOME}/post.py "$1 ${START_DATE}" ${NOAA_OUTPUT}/image/$3-MCIR-precip.png ${NOAA_OUTPUT}/image/$3-MSA-precip.png ${NOAA_OUTPUT}/image/$3-HVC-precip.png ${NOAA_OUTPUT}/image/$3-HVCT.png
python2 ${NOAA_HOME}/post.py "$1 ${START_DATE}" ${NOAA_OUTPUT}/image/$3-MCIR-precip.jpg ${NOAA_OUTPUT}/image/$3-MCIR.jpg
fi

16 changes: 16 additions & 0 deletions sun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python2
import ephem
import time
import sys

date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(sys.argv[1])+3*60*60))

obs=ephem.Observer()
obs.lat=''
obs.long=''
obs.date = date

sun = ephem.Sun(obs)
sun.compute(obs)
sun_angle = float(sun.alt) * 57.2957795 # Rad to deg
print int(sun_angle)

0 comments on commit e21abc6

Please sign in to comment.