Exemple #1
0
def test_Astral_SolarAzimuthWithTimezone():
    dd = Astral()
    location = dd['Jubail']

    dt = datetime.datetime(2015, 2, 4, 9, 0, 0, tzinfo=location.tz)
    azimuth = dd.solar_azimuth(dt, location.latitude, location.longitude)
    assert float_almost_equal(azimuth, 129.02, 0.1)
Exemple #2
0
def testAzimuth():
    city_name = "Jubail"

    dd = Astral()
    city = dd[city_name]
    print("Latitude: %f, Longitude: %f" % (city.latitude, city.longitude))

    dt = datetime.datetime.now(tz=city.tz)
    print("Date & time: %s" % dt)
    print("Date & time (UTC): %s" % dt.astimezone(pytz.utc))
    print("Azimuth: %.02f" % dd.solar_azimuth(dt, city.latitude, city.longitude))
Exemple #3
0
def test_Astral_SolarAzimuth():
    a = Astral()
    l = a['London']

    test_data = {
        datetime.datetime(2015, 12, 14, 11, 0, 0, tzinfo=pytz.UTC): 167,
        datetime.datetime(2015, 12, 14, 20, 1, 0): 279,
    }

    for dt, angle1 in test_data.items():
        angle2 = a.solar_azimuth(dt, l.latitude, l.longitude)
        assert float_almost_equal(angle1, angle2)
Exemple #4
0
def test_Astral_SolarAzimuth():
    dd = Astral()
    dt = datetime.datetime(2015, 2, 3, 9, 0, 0, tzinfo=pytz.UTC)

    azimuth = dd.solar_azimuth(dt, 51.5, -0.12)
    assert float_almost_equal(azimuth, 133.162, 0.1)
Exemple #5
0
data['/Pv/W'] = float(data['/Pv/V']) * float(data['/Pv/I'])

# Calculate solar Data
solar = Astral()
solar.solar_depression = 'civil'
#l = Location()
#l.name = 'Wohnwagen'
#l.latitude = latitude
#l.longitude = longitude
#l.timezone = 'Europe/Berlin'
#l.elevation = 0
#sun = l.sun()

#data['sunrise'] = str(sun['sunrise'])
#data['sunset'] = str(sun['sunset'])
data['azimuth'] = solar.solar_azimuth(dateandtime, latitude, longitude)
data['elevation'] = solar.solar_elevation(dateandtime, latitude, longitude)
if data['elevation'] < 0:
	data['elevation'] = 0
data['zenith'] = solar.solar_zenith(dateandtime, latitude, longitude)

# Set up a client for InfluxDB
dbclient = InfluxDBClient(config[influx_server]['host'], config[influx_server]['port'], config[influx_server]['username'], config[influx_server]['password'], config[influx_server]['database'])

json_body = [{
	"measurement": "power",
	"fields": {
		"pv_w": float(data['/Pv/W']),
		"pv_v": float(data['/Pv/V']),
		"pv_a": float(data['/Pv/I']),
		"pv_state": float(data['/State']),
Exemple #6
0
    # Convert angular measurements to radians
    azRad, elevRad = (360. - az + 90.)*np.pi/180., (90.-elev)*np.pi/180.
    Sx, Sy = calcFiniteSlopes(elevGrid, dx)  # Calculate slope in X and Y directions

    AspectRad = np.arctan2(Sy, Sx) # Angle of aspect
    SmagRad = np.arctan(np.sqrt(Sx**2. + Sy**2.))  # magnitude of slope in radians

    return (((np.cos(elevRad) * np.cos(SmagRad)) + (np.sin(elevRad)* np.sin(SmagRad) * np.cos(azRad - AspectRad))))*255

a = Astral()
Latitude = 47.074531
longitude = 12.846210

b = datetime.datetime(2015,10,3,7,30)

c= a.solar_azimuth(b,Latitude,longitude)
d= a.solar_elevation(b,Latitude,longitude)
print d, a.solar_zenith(b, Latitude, longitude)

print c

headinfo,dtm = ascii.read_ascii("C:\Master\settings/vernagtferner14-16/dgm_vernagtferner.txt")

test = calcHillshade(dtm,headinfo[-2],c,d)
print np.min(test), np.max(test)


plt.imshow(test, cmap="Greys")
plt.show()
ascii.write_ascii("test.asc",headinfo,test,format="%i")