def test_scalar_with_numpy(): pysolar.use_numpy() lat = 50.63 lon = 3.05 time = datetime(2018, 5, 8, 12, 0, 0, tzinfo=pytz.UTC) print(solar.get_altitude(lat, lon, time)) print(solar.get_azimuth(lat, lon, time))
def test_numpy(): """ get_altitude and get_azimuth, with lat, lon and date arrays """ pysolar.use_numpy() lat = np.array([45., 40.]) lon = np.array([3., 4.]) time = np.array(['2018-05-08T12:15:00', '2018-05-08T15:00:00'], dtype='datetime64') print(solar.get_altitude_fast(lat, lon, time)) print(solar.get_azimuth_fast(lat, lon, time))
def test_with_fixed_position(): """ get_altitude and get_azimuth, with scalar position """ pysolar.use_numpy() lat = 50. lon = 3. time = np.array(['2018-05-08T12:15:00', '2018-05-08T15:00:00'], dtype='datetime64') print(solar.get_altitude_fast(lat, lon, time)) print(solar.get_azimuth_fast(lat, lon, time))
def test_with_fixed_time(): """ get_altitude and get_azimuth, with scalar date """ pysolar.use_numpy() lat = np.array([45., 40.]) lon = np.array([3., 4.]) time = datetime(2018, 5, 8, 12, 0, 0, tzinfo=pytz.UTC) print(solar.get_altitude(lat, lon, time)) print(solar.get_azimuth(lat, lon, time)) print(solar.get_altitude_fast(lat, lon, time)) print(solar.get_azimuth_fast(lat, lon, time))
def test_numpy_radiation(): """ get_radiation_direct with lat, lon, and date as arrays """ pysolar.use_numpy() lat = np.array([45., 40., 40.]) lon = np.array([3., 4., 3.]) time = np.array([ '2018-05-08T12:15:00', '2018-05-08T15:00:00', '2018-05-08T03:00:00', ], dtype='datetime64') altitude = solar.get_altitude_fast(lat, lon, time) rad_results = radiation.get_radiation_direct(time, altitude) assert rad_results[2] == 0 print(rad_results)
from collections import namedtuple import datetime import numpy as np import pandas as pd import pysolar import pysolar.solar as solar Solarrec = namedtuple('Solarrec', 'fdate azi alt dotp roofazi roofalt') columns = 'fdate azi alt dotp roofazi roofalt'.split() pysolar.use_numpy() starttime = datetime.datetime.fromisoformat('2021-03-12T00:00:00+00:00') ROOFALT = 90 - 15.0 # ROOFALT = 90 - 17.7 # ROOFAZI = 126 # ROOFAZI = 131 ROOFAZI = 139.38 # Measured by sun position # ROOFAZI = 150 LATLON = [43.752047, -73.275785] def get_vector(alt, azi): """Calculate unit vector (from [0, 0, 1]) for a given altitude and azimuth """ alt, azi = np.radians([alt, azi]) Xr = np.array([0, -np.cos(alt), np.sin(alt)]) azisin = np.sin(azi)