Exemplo n.º 1
0
    def test_position_exception(self):
        s, eff = 0, 0
        lat, lng, h = 0, 0, 0
        v = array([0, 0, -1])
        d = datetime(2019, 1, 21, 12, 0)

        sp = solar_panel(s, eff, id_name=None)
        sp.set_orientation(v)
        sp.set_datetime(d)

        with self.assertRaises(ValueError):
            sp.set_position(-91, lng, h)  # latitude exceeds range
            sp.power()

        with self.assertRaises(ValueError):
            sp.set_position(90.1, lng, h)  # latitude exceeds range
            sp.power()

        with self.assertRaises(TypeError):
            sp.set_position('1', lng, h)  # wrong latitude type
            sp.power()

        with self.assertRaises(ValueError):
            sp.set_position(lat, lng, -1)  # altitude exceeds range
            sp.power()

        with self.assertRaises(TypeError):
            sp.set_position(lat, lng, '21')  # altitude wrong type
            sp.power()
Exemplo n.º 2
0
    def test_zero_efficiency(self):
        s, eff = 1, 0
        lat, lng, h = 0, 0, 0
        v = array([0, 0, -1])
        d = datetime(2019, 1, 21, 12, 0)

        sp = solar_panel(s, eff)
        sp.set_position(lat, lng, h)
        sp.set_orientation(v)
        sp.set_datetime(d)
        self.assertAlmostEqual(sp.power(), 0)
Exemplo n.º 3
0
    def test_null_surface(self):
        s, eff = 0, 0.5
        lat, lng, h = 0, 0, 0
        v = array([0, 0, -1])
        d = datetime(2019, 1, 21, 12, 0)

        sp = solar_panel(s, eff)
        sp.set_position(lat, lng, h)
        sp.set_orientation(v)
        sp.set_datetime(d)
        self.assertAlmostEqual(sp.power(), 0)
Exemplo n.º 4
0
    def test_upside_down(self):
        s, eff = 1, 0.3
        lat, lng, h = 0, 0, 0
        v = array([0, 0, 1])  # upside down
        d = datetime(2019, 1, 21, 12, 0)

        sp = solar_panel(s, eff)
        sp.set_position(lat, lng, h)
        sp.set_orientation(v)
        sp.set_datetime(d)
        self.assertAlmostEqual(sp.power(), 0)
Exemplo n.º 5
0
    def test_datetime_exception(self):
        s, eff = 0, 0
        lat, lng, h = 0, 0, 0
        v = array([0, 0, -1])

        sp = solar_panel(s, eff)
        sp.set_position(lat, lng, h)
        sp.set_orientation(v)

        with self.assertRaises(TypeError):
            sp.set_datetime('a')  # wrong type
            sp.power()
Exemplo n.º 6
0
    def test_orientation_exception(self):
        s, eff = 0, 0
        lat, lng, h = 0, 0, 0
        d = datetime(2019, 1, 21, 12, 0)

        sp = solar_panel(s, eff, 'panel1')
        sp.set_position(lat, lng, h)
        sp.set_datetime(d)

        with self.assertRaises(ValueError):
            sp.set_orientation(1)  # wrong type
            sp.power()
Exemplo n.º 7
0
    def test_pointing_opposite_direction(self):
        # panel points west in the morning
        s, eff = 1, 0.3
        lat, lng, h = 0, 0, 0
        v = array([0, -1, 0])  # west
        d = datetime(2019, 8, 1, 10, 0)

        sp = solar_panel(s, eff)
        sp.set_position(lat, lng, h)
        sp.set_orientation(v)
        sp.set_datetime(d)
        self.assertAlmostEqual(sp.power(), 0)

        # panel points east in the afternoon
        s, eff = 1, 0.3
        lat, lng, h = 0, 0, 0
        v = array([0, 1, 0])  # east
        d = datetime(2019, 8, 1, 18, 0)

        sp = solar_panel(s, eff)
        sp.set_position(lat, lng, h)
        sp.set_orientation(v)
        sp.set_datetime(d)
        self.assertAlmostEqual(sp.power(), 0)
Exemplo n.º 8
0
    def test_permanent_darkness(self):
        # north hemisphere
        s, eff = 1, 0.3
        lat, lng, h = 80, 0, 0
        v = array([0, 0, -1])
        d = datetime(2019, 1, 15, 12, 0)  # Jan 15

        sp = solar_panel(s, eff)
        sp.set_position(lat, lng, h)
        sp.set_orientation(v)
        sp.set_datetime(d)
        self.assertAlmostEqual(sp.power(), 0)

        # south hemisphere
        s, eff = 1, 0.3
        lat, lng, h = -85, 0, 0
        v = array([0, 0, -1])
        d = datetime(2019, 7, 1, 12, 0)  # Jul 1

        sp = solar_panel(s, eff)
        sp.set_position(lat, lng, h)
        sp.set_orientation(v)
        sp.set_datetime(d)
        self.assertAlmostEqual(sp.power(), 0)
Exemplo n.º 9
0
    def test_night(self):
        s, eff = 1, 0.3
        lat, lng, h = 0, 0, 0
        v = array([0, 0, -1])

        sp = solar_panel(s, eff)
        sp.set_position(lat, lng, h)
        sp.set_orientation(v)

        d = datetime(2019, 1, 21, 22, 15)
        sp.set_datetime(d)
        self.assertAlmostEqual(sp.power(), 0)

        d = datetime(2019, 7, 21, 0, 0)
        sp.set_datetime(d)
        self.assertAlmostEqual(sp.power(), 0)

        d = datetime(2019, 11, 1, 3, 40)
        sp.set_datetime(d)
        self.assertAlmostEqual(sp.power(), 0)

        d = datetime(2019, 4, 12, 5, 0)
        sp.set_datetime(d)
        self.assertAlmostEqual(sp.power(), 0)
Exemplo n.º 10
0
locale.setlocale(locale.LC_ALL, '')

# initialize location
# Ahrensburg
lat = 53.67
lon = 10.24

# initialize figures
plt.rcParams['toolbar'] = 'None'
plt.style.use('dark_background')
plt.rcParams['axes.linewidth'] = 0.1
fig = plt.figure(" ", figsize=(19.88910891089109, 10.28095238095238))
fig.set_tight_layout(False)

# initialize solar panel
panel = solar_panel(1, 0.2, id_name='NYC_xmas')  # surface, efficiency and name
panel.set_orientation(np.array([0, 0, -1]))  # upwards
panel.set_position(lat, lon, 0)  # NYC latitude, longitude, altitude
panel.set_datetime(dt.datetime(2019, 12, 25, 13, 15))  # Christmas Day!
panel.power()

y=0.48
#y=0.415
x=0.03564904697110492
dx=0.4181903129732449/244
startHour=-9
size=0.05
ax421a = plt.subplot2grid((4, 2), (0, 0), rowspan=2)  # Weather data text
ax421b = fig.add_axes([0.25, 0.8, 0.2, 0.2], anchor='NE', zorder=-1) # weather symbol
ax421c = fig.add_axes([dx*(startHour+24), y, size, size], anchor='NE', zorder=1) # weather symbol
ax421d = fig.add_axes([dx*(startHour+48), y, size, size], anchor='NE', zorder=1) # weather symbol