Esempio n. 1
0
	def testGetPosition(self):
		az, al = solar.get_position(-43, 172, TestApi.test_when)
		self.assertAlmostEqual(az, -230.4936927)
		self.assertAlmostEqual(al, 63.0945557)

		# From Greenwich
		az, al = solar.get_position(51.4826, 0, TestApi.test_when)
		self.assertAlmostEqual(az, -153.0476242)
		self.assertAlmostEqual(al, -59.8384205)
Esempio n. 2
0
    def testGetPosition(self):
        az, al = solar.get_position(59.6365662, 12.5350953, TestApi.test_when)
        self.assertAlmostEqual(az, 357.1431414)
        self.assertAlmostEqual(al, -53.7672217)

        az, al = solar.get_position(-43, 172, TestApi.test_when)
        self.assertAlmostEqual(az, 50.50035708)
        self.assertAlmostEqual(al, 63.0922036)

        # From Greenwich
        az, al = solar.get_position(51.4826, 0, TestApi.test_when)
        self.assertAlmostEqual(az, 333.04037976)
        self.assertAlmostEqual(al, -59.83724345)
Esempio n. 3
0
	def testGetPosition(self):
		az, al = solar.get_position(59.6365662,12.5350953, TestApi.test_when)
		self.assertAlmostEqual(az, 357.1431475)
		self.assertAlmostEqual(al, -53.7672218)

		az, al = solar.get_position(-43, 172, TestApi.test_when)
		self.assertAlmostEqual(az, 50.5003507)
		self.assertAlmostEqual(al, 63.0922058)

		# From Greenwich
		az, al = solar.get_position(51.4826, 0, TestApi.test_when)
		self.assertAlmostEqual(az, 333.0403866)
		self.assertAlmostEqual(al, -59.8372445)
Esempio n. 4
0
 def position(self, time):
     """
     :return: position of the sun, as `IncidenceAngle` object
     """
     with warnings.catch_warnings():
         warnings.filterwarnings(
             'ignore', "I don't know about leap seconds after 2017")
         az, el = get_position(self.latitude, self.longitude, time,
                               self.elevation)
     return IncidenceAngle(az, el)
Esempio n. 5
0
    def getSunPosData(self):
        # in case quadra not functioning
        import pytz

        tz = pytz.timezone('Europe/Berlin')
        date = datetime.now(tz)

        latitude_deg = 51.05667 # positive in the northern hemisphere (Drongen 51.05)
        longitude_deg = 3.66410 # negative reckoning west from prime meridian in Greenwich, England (Drongen
                                # 3.66)

        from pysolar.solar import get_position
        from pysolar.radiation import get_radiation_direct   
        sun_azimuth, sun_altitude = get_position(latitude_deg, longitude_deg, date,elevation=4)
        expectedRad = get_radiation_direct(date, latitude_deg)
        return sun_azimuth, sun_altitude ,expectedRad
Esempio n. 6
0
File: sif.py Progetto: silmae/SIF
def sun_positions(location_info, utc_times):
    """Get sun positions (azimuth, altitude) given a place and set of times
    
    Parameters
    ----------
    location_info : dict-like
        Dictionary with the keys
            'latitude_deg',
            'longitude_deg',
            and 'elevation' (optional, in meters)
    utc_times : list-like
        List of UTC datetime objects to get sun positions for.
    
    Returns
    -------
    numpy.ndarray
        N x 2 array of sun azimuths and altitudes in degrees.
    """

    from pysolar.solar import get_position

    return np.array([get_position(**location_info, when=t) for t in utc_times])
 def test_solar_get_position_raise_error(self):
     with self.assertRaises(NoTimeZoneInfoError):
         solar.get_position(self.lat, self.lon, self.unaware)
    def test_solar_get_position_no_error(self):
        try:
            solar.get_position(self.lat, self.lon, self.aware)
        except NoTimeZoneInfoError:
            self.fail("""'NoTimeZoneInfoError' should not be raised \
as 'datetime' object is tz-aware.""")
Esempio n. 9
0
    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)
    azicos = np.cos(azi)
    Zr = np.array([[azicos, azisin, 0], [-azisin, azicos, 0], [0, 0, 1]])
    return Zr.dot(Xr)


roofvec = get_vector(ROOFALT, ROOFAZI)

srs = []
for minutes in range(60 * 24 * 3):
    rec = dict()
    if minutes % (60 * 24) == 0:
        print(f"Day {int(minutes / (60 * 24)) + 1}")
    dmins = datetime.timedelta(minutes=minutes)
    fdate = starttime + dmins
    azi, alt = solar.get_position(*LATLON, fdate)

    dotp = roofvec.dot(get_vector(alt, azi))
    sr = Solarrec(fdate, azi, alt, dotp, ROOFAZI, ROOFALT)
    srs.append(sr)
    # print(f"{fdate.hour - 5:02d}:{fdate.minute:02d}, {alt=:7.4f}, {azi=:7.4f}, {dotp=:8.5f}")

sdf = pd.DataFrame.from_records(srs, columns=Solarrec._fields, index='fdate')

pass
# Some things to try:
# sdf[(sdf['dotp'] > 0) & (sdf['alt'] > 0)].loc['2021-08', 'dotp'].mean()
Esempio n. 10
0
    def is_active(self):
        time = datetime.datetime.now(datetime.timezone.utc)
        az, alt = solar.get_position(self.lat, self.lon, time)

        return alt <= self.max_alt or self.min_az <= az <= self.max_az