From b6d7e799cc66fb92d0a7ecd6e75e43352e6d58b1 Mon Sep 17 00:00:00 2001 From: Pascal Date: Mon, 8 Feb 2021 23:03:44 +0100 Subject: [PATCH] Fixed sun template --- common.sh | 2 +- install.sh | 1 + templates/sun.py | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 templates/sun.py diff --git a/common.sh b/common.sh index 3288d4d..2d03581 100755 --- a/common.sh +++ b/common.sh @@ -1,4 +1,4 @@ -##!/bin/bash +#!/bin/bash ## debug # set -x diff --git a/install.sh b/install.sh index 1603383..4a69f49 100755 --- a/install.sh +++ b/install.sh @@ -286,6 +286,7 @@ else log_done "pd120_decoder installed" fi +cp templates/sun.py . success "Install (almost) done!" diff --git a/templates/sun.py b/templates/sun.py new file mode 100755 index 0000000..cdd87e8 --- /dev/null +++ b/templates/sun.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +import ephem +import time +import sys +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' +obs.long='change_longitude' +obs.date = date + +sun = ephem.Sun(obs) +sun.compute(obs) +sun_angle = float(sun.alt) * 57.2957795 # Rad to deg +print(int(sun_angle))