Skip to content

Commit

Permalink
more groundObj pytests
Browse files Browse the repository at this point in the history
  • Loading branch information
cdeline committed Oct 14, 2024
1 parent 69b3d65 commit 2980a91
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
15 changes: 8 additions & 7 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2747,8 +2747,8 @@ def __init__(self, materialOrAlbedo=None, material_file=None, silent=False):
f'{self._nonzeromean(self.ReflAvg):0.3f} avg\n'
f'{self.ReflAvg[self.ReflAvg != 0].__len__()} nonzero albedo values.')
except IndexError as e:
print('albedo.shape should be 3 column (N x 3)')
raise e
raise Exception('albedo.shape needs to be 3 column (N x 3)')


def printGroundMaterials(self, materialString=None):
"""
Expand Down Expand Up @@ -4151,11 +4151,12 @@ def _checkSensors(sensors):
else:
print ("Module's z not set on sceneDict internal dictionary. Setting to default")
modulez = 0.02

if frontsurfaceoffset is None:
frontsurfaceoffset = 0.001
if backsurfaceoffset is None:
backsurfaceoffset = 0.001

# cdeline 20241014 remove this check - extraneous
#if frontsurfaceoffset is None:
# frontsurfaceoffset = 0.001
#if backsurfaceoffset is None:
# backsurfaceoffset = 0.001

# The Sensor routine below needs a "hub-height", not a clearance height.
# The below complicated check checks to see if height (deprecated) is passed,
Expand Down
4 changes: 2 additions & 2 deletions tests/ini_cell_level_module.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ clearance_height = 0.8
hub_height = 0.9

[timeControlParamsDict]
starttime: 06_21_11_00
endtime: 06_21_12_00
starttime: 06_21_11
endtime: 06_21_12

[moduleParamsDict]
numpanels = 2
Expand Down
4 changes: 2 additions & 2 deletions tests/ini_soltec.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ latitude: 37.5
longitude: -77.6

[timeControlParamsDict]
starttime: 06_21_12_00
endtime: 06_21_12_00
starttime: 06_21_12
endtime: 06_21_12

[sceneParamsDict]
gcrorpitch: pitch
Expand Down
1 change: 1 addition & 0 deletions tests/test_bifacial_radiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,4 +605,5 @@ def test_raypath():

os.environ['RAYPATH'] = raypath0



10 changes: 9 additions & 1 deletion tests/test_groundobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,19 @@ def test_RGB_timeseries():
albedo_bad = np.array([[0.2, 0.3, 0.4, 0.5], [0.12, 0.13, 0.26, 0.5]]) # invalid
ground = pytest.warns(UserWarning, bifacial_radiance.GroundObj, albedo_bad)
np.testing.assert_allclose(_groundtest(ground), testvals_const)
with pytest.raises(Exception):
temp = bifacial_radiance.GroundObj(np.array([[.1,.2],[.1,.2]]))

def test_printGroundMaterials():
ground = bifacial_radiance.GroundObj('litesoil')
assert ground.printGroundMaterials()[1] == 'litesoil'

def test_albedo_greaterthan_one():
ground = bifacial_radiance.GroundObj(2)
assert ground.ReflAvg[0] == 1
assert ground.ReflAvg[0] == 1

def test_repr_and_normval():
ground = bifacial_radiance.GroundObj()
groundstr = ground.__repr__()
ground = bifacial_radiance.GroundObj([0.1, 0.2])
assert ground.normval == pytest.approx([0.10034, 0.20068])

0 comments on commit 2980a91

Please sign in to comment.