def test_degsin(): """py.test for degcos""" data = ((30, 0.5), # deg, thesin ) for deg, thesin in data: result = clearskyrad.degsin(deg) assert almostequal(result, thesin) == True
def test_diffusehorizontal(): """py.test for diffusehorizontal""" data = ((0.289, 2.641, 90, 21, 100.490533), # taub, taud, alt, daynum, Eb ) for taub, taud, alt, daynum, Eb in data: result = clearskyrad.diffusehorizontal(taub, taud, alt, daynum=daynum) assert almostequal(result, Eb)
def test_degcos(): """py.test for degcos""" data = ((60, 0.5), # deg, thecos ) for deg, thecos in data: result = clearskyrad.degcos(deg) assert almostequal(result, thecos) == True
def test_directnormal(): """py.test for directnormal""" data = ((0.289, 2.641, 90, 21, 1056.136599), # taub, taud, alt, daynum, Eb ) for taub, taud, alt, daynum, Eb in data: result = clearskyrad.directnormal(taub, taud, alt, daynum) assert almostequal(result, Eb, places=5)
def test_getad(): """py.test for getad""" data = ((0.289, 2.641, -0.335194893), # taub, taud, thead ) for taub, taud, thead in data: result = clearskyrad.getad(taub, taud) assert almostequal(result, thead)
def test_getab(): """py.test for getab""" data = ((0.289, 2.641, 0.652079204), # taub, taud, theab ) for taub, taud, theab in data: result = clearskyrad.getab(taub, taud) assert almostequal(result, theab)
def test_diffhoriz_inner(): """py.test for diffhoriz_inner""" data = ((1409.962705, 2.641, 0.999711992, -0.335194893, 100.490533,), # E0, taud, m, ad, Ed ) for E0, taud, m, ad, Ed in data: result = clearskyrad.diffhoriz_inner(E0, taud, m, ad) assert almostequal(result, Ed, places=6)
def test_directnormal_inner(): """py.test for directnormal_inner""" data = ((1409.962705, 0.289, 0.999711992, 0.652079204, 1056.136599), # E0, taub, m, ab, Eb ) for E0, taub, m, ab, Eb in data: result = clearskyrad.directnormal_inner(E0, taub, m, ab) assert almostequal(result, Eb, places=6)
def test_airmass(): """py.test for airmass""" data = ((30, 1.9942928525), # alt, theairmass (45, 1.412595252), # alt, theairmass (60, 1.1539922334), # alt, theairmass (90, 0.9997119919), # alt, theairmass ) for alt, theairmass in data: result = clearskyrad.airmass(alt) assert almostequal(result, theairmass)
def test_ETradiation(): """py.test for ETradiation""" data = ((21, 1410), # daynum, radiation (52, 1397), # daynum, radiation (80, 1378), # daynum, radiation (111, 1354), # daynum, radiation (141, 1334), # daynum, radiation (172, 1323), # daynum, radiation (202, 1324), # daynum, radiation (233, 1336), # daynum, radiation (264, 1357), # daynum, radiation (294, 1380), # daynum, radiation (325, 1400), # daynum, radiation (355, 1411), # daynum, radiation ) for daynum, radiation in data: result = clearskyrad.ETradiation(daynum=daynum) assert almostequal(result, radiation, places=0) == True from datetime import datetime as dt data = ((dt(2013, 1, 21), 1410), # thedate, radiation (dt(2013, 2, 21), 1397), # thedate, radiation (dt(2013, 3, 21), 1378), # thedate, radiation (dt(2013, 4, 21), 1354), # thedate, radiations (dt(2013, 5, 21), 1334), # thedate, radiation (dt(2013, 6, 21), 1323), # thedate, radiation (dt(2013, 7, 21), 1324), # thedate, radiation (dt(2013, 8, 21), 1336), # thedate, radiation (dt(2013, 9, 21), 1357), # thedate, radiation (dt(2013, 10, 21), 1380), # thedate, radiation (dt(2013, 11, 21), 1400), # thedate, radiation (dt(2013, 12, 21), 1411), # thedate, radiation ) for thedate, radiation in data: result = clearskyrad.ETradiation(thedate=thedate) # print result, radiation assert almostequal(result, radiation, places=0) == True
def test_comfort_matrix(): """py.test for comfort_matrix""" data = (# ([[22,27], # [23,28], # [30,32], # [32,30], # [28,23], # [27,22]], # comfort.comfort, # 1,1, # #- # [[22,27,24,28.74,1.74], # [23,28,25,29.05,1.05], # [30,32,28.33333333,30.08333333,-1.916666667], # [32,30,30,30.6,0.6], # [28,23,29,30.29,7.29], # [27,22,25.66666667,29.25666667,7.256666667]]), # inmat, comfunc, upspan, downspan, outmat ([[22,27], [23,28], [30,32], [32,30], [28,23], [27,22]], comfort.comfortET, 1,1, #- [[22.0, 27.0, 24.0, 28.52, 1.52], [23.0, 28.0, 25.0, 28.774999999999999, 0.77500000000000002], [30.0, 32.0, 28.333333329999999, 29.625, -2.375], [32.0, 30.0, 30.0, 30.050000000000001, 0.050000000000000003], [28.0, 23.0, 29.0, 29.795000000000002, 6.7949999999999999], [27.0, 22.0, 25.666666670000001, 28.945, 6.9450000000000003]]), # inmat, comfunc, upspan, downspan, outmat ) for inmat, comfunc, upspan, downspan, outmat in data: result = comfort.comfort_matrix(inmat, comfunc, upspan, downspan) for row1, row2 in zip(result, outmat): for c1, c2 in zip(row1, row2): assert almostequal(c1, c2)