Ejemplo n.º 1
0
def calc_sunrise(lat, lon, doy, date):
    date = date.replace(hour=0)
    sun = Sun()
    coords = {'longitude': lon, 'latitude': lat}
    sunr_dec = sun.getSunriseTime(coords, date=date)['decimal']
    suns_dec = sun.getSunsetTime(coords, date=date)['decimal']
    sunr_dec *= 60
    suns_dec *= 60
    sunrise = date + pd.to_timedelta(sunr_dec, unit='m')
    sunset = date + pd.to_timedelta(suns_dec, unit='m')
    return sunrise, sunset
Ejemplo n.º 2
0
    #    GPIO.cleanup()
    debug("stopped")
    return


def debug(x):
    print(x)
    return


# This is the start of the main program

coords = {'longitude': 0.34, 'latitude': 51.1}
sun = Sun()

print sun.getSunriseTime(coords)
# Sunrise time UTC (decimal, 24 hour format)
push("hi")
print sun.getSunriseTime(coords)['hr']
print sun.getSunriseTime(coords)['min']

print sun.getSunsetTime(coords)['hr']
print sun.getSunsetTime(coords)['min']

GPIO.setmode(GPIO.BOARD)
PIR_PIN = 26
GPIO.setup(PIR_PIN, GPIO.IN)

print howfar()

try:
Ejemplo n.º 3
0
        wlan.ifconfig()[0]))  # get the interface's IP/netmask/gw/DNS addresses
    print("RSSI {}".format(wlan.status('rssi')))
except:
    pass

#update RCT time form network
ntptime.host = 'pool.ntp.org'
#ntptime.settime()
now = float("{}.{}".format(localtime()[3], localtime()[4]))
print("time: {}".format(localtime()))

#calculate sunrise/sunset time
coords = {'longitude': 2.107, 'latitude': 44.584}
sun = Sun()
# Sunrise time UTC (decimal, 24 hour format)
sunrise = sun.getSunriseTime(coords)['decimal']
print("Sunrise (UTC decimal) : {}".format(sunrise))
# Sunset time UTC (decimal, 24 hour format)
sunset = sun.getSunsetTime(coords)['decimal']
print("Sunset (UTC decimal): {}".format(sunset))

#scheduling

stepPin = PWM(Pin(STEP_PIN), freq=0, duty=32)
stopTim = Timer(1)
dirPin = Pin(DIR_PIN, Pin.OUT)

#override now variable for testing
now = 7.45

Ejemplo n.º 4
0
def getSunriseTime(longitude, latitude):
    from sun import Sun
    coords = {'longitude': longitude, 'latitude': latitude}
    sun = Sun()
    sunset = sun.getSunriseTime(coords)
    return utc2local_time(sunset['hr'], sunset['min'])