Skip to content

Commit

Permalink
Merge 7e45058 into 5eebc9d
Browse files Browse the repository at this point in the history
  • Loading branch information
cdeline committed May 12, 2020
2 parents 5eebc9d + 7e45058 commit 4e1c8e8
Show file tree
Hide file tree
Showing 21 changed files with 468 additions and 258 deletions.
561 changes: 336 additions & 225 deletions bifacial_radiance/main.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bifacial_radiance/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def runModelChain(simulationParamsDict, sceneParamsDict, timeControlParamsDict=N
# Timestamp range selection
if simulationParamsDict["timeIndexSimulation"]: # fixed tilt timestamp range
for timeindex in range(timeControlParamsDict['timeindexstart'], timeControlParamsDict['timeindexend']):
demo.gendaylit(metdata, timeindex) # Noon, June 17th
demo.gendaylit(metdata=metdata, timeindex=timeindex) # Noon, June 17th
# makeOct combines all of the ground, sky and object files into a .oct file.
octfile = demo.makeOct(demo.getfilelist())
# return an analysis object including the scan dimensions for back irradiance
Expand Down
36 changes: 36 additions & 0 deletions docs/sphinx/source/whatsnew/v0.3.3.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. _whatsnew_0333:

v0.3.3.3 (X / X / 2020)
--------------------------
Release of new version including RGB and time-series albedo options


Enhancements
~~~~~~~~~~~~
*
API Changes
~~~~~~~~~~~
* Input changed to py:class:`~bifacial_radiance.RadianceObj.gendaylit`, now making metdata an optional input.


Bug fixes
~~~~~~~~~
*

Testing
~~~~~~~
* Added pytesting to py:class:`~bifacial_radiance.GroundObj`


Documentation
~~~~~~~~~~~~~~


Contributors
~~~~~~~~~~~~
* Chris Deline (:ghuser:`cdeline`)
* Silvana Ayala (:ghuser:`shirubana`)




4 changes: 2 additions & 2 deletions docs/tutorials/(development) Glass Test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"demo.setGround(0.30) # This prints available materials.\n",
"epwfile = demo.getEPW(lat = 37.5, lon = -77.6) # This location corresponds to Richmond, VA.\n",
"metdata = demo.readWeatherFile(epwfile) \n",
"demo.gendaylit(metdata,8) # Noon, June 17th (timepoint # 4020)\\\n"
"demo.gendaylit(8) # Noon, June 17th (timepoint # 4020)\\\n"
]
},
{
Expand Down Expand Up @@ -599,7 +599,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/(development) Glass Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
demo.setGround(0.30) # This prints available materials.
epwfile = demo.getEPW(lat = 37.5, lon = -77.6) # This location corresponds to Richmond, VA.
metdata = demo.readWeatherFile(epwfile)
demo.gendaylit(metdata,8) # Noon, June 17th (timepoint # 4020)\
demo.gendaylit(8) # Noon, June 17th (timepoint # 4020)\


# In[16]:
Expand Down
10 changes: 5 additions & 5 deletions docs/tutorials/(development) Sensor Position Sanity Check.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
"demo.setGround(albedo) \n",
"epwfile = demo.getEPW(lat = lat, lon = lon) \n",
"metdata = demo.readWeatherFile(weatherFile = epwfile)\n",
"demo.gendaylit(metdata,timeindex) \n",
"demo.gendaylit(timeindex) \n",
"mymodule = demo.makeModule(name=moduletype, x=x, y=y)\n",
"sceneDict = {'gcr': gcr,'hub_height':hub_height, 'tilt': 90, 'azimuth': 180, 'nMods':nMods, 'nRows': nRows} \n",
"scene = demo.makeScene(moduletype,sceneDict)\n",
Expand Down Expand Up @@ -695,7 +695,7 @@
"demo.setGround(albedo) \n",
"epwfile = demo.getEPW(lat = lat, lon = lon) \n",
"metdata = demo.readWeatherFile(weatherFile = epwfile)\n",
"demo.gendaylit(metdata,timeindex) \n",
"demo.gendaylit(timeindex) \n",
"mymodule = demo.makeModule(name=moduletype, x=x, y=y)\n",
"sceneDict = {'gcr': gcr,'hub_height':hub_height, 'tilt': 90, 'azimuth': 90, 'nMods':nMods, 'nRows': nRows} \n",
"scene = demo.makeScene(moduletype,sceneDict)\n",
Expand Down Expand Up @@ -1186,7 +1186,7 @@
"demo.setGround(albedo) \n",
"epwfile = demo.getEPW(lat = lat, lon = lon) \n",
"metdata = demo.readWeatherFile(weatherFile = epwfile)\n",
"demo.gendaylit(metdata,timeindex) \n",
"demo.gendaylit(timeindex) \n",
"mymodule = demo.makeModule(name=moduletype, x=x, y=y)\n",
"sceneDict = {'gcr': gcr,'hub_height':hub_height, 'tilt': 75, 'azimuth': 90, 'nMods':nMods, 'nRows': nRows} \n",
"scene = demo.makeScene(moduletype,sceneDict)\n",
Expand Down Expand Up @@ -1337,7 +1337,7 @@
"demo.setGround(albedo) \n",
"epwfile = demo.getEPW(lat = lat, lon = lon) \n",
"metdata = demo.readWeatherFile(weatherFile = epwfile)\n",
"demo.gendaylit(metdata,timeindex) \n",
"demo.gendaylit(timeindex) \n",
"mymodule = demo.makeModule(name=moduletype, x=0.001, y=y)\n",
"sceneDict = {'gcr': gcr,'hub_height':hub_height, 'tilt': 45, 'azimuth': 135, 'nMods':nMods, 'nRows': nRows} \n",
"scene = demo.makeScene(moduletype,sceneDict)\n",
Expand Down Expand Up @@ -1562,7 +1562,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/(development) Sensor Position Sanity Check.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
demo.setGround(albedo)
epwfile = demo.getEPW(lat = lat, lon = lon)
metdata = demo.readWeatherFile(weatherFile = epwfile)
demo.gendaylit(metdata,timeindex)
demo.gendaylit(timeindex)
mymodule = demo.makeModule(name=moduletype, x=x, y=y)
sceneDict = {'gcr': gcr,'hub_height':hub_height, 'tilt': 90, 'azimuth': 180, 'nMods':nMods, 'nRows': nRows}
scene = demo.makeScene(moduletype,sceneDict)
Expand Down Expand Up @@ -116,7 +116,7 @@
demo.setGround(albedo)
epwfile = demo.getEPW(lat = lat, lon = lon)
metdata = demo.readWeatherFile(weatherFile = epwfile)
demo.gendaylit(metdata,timeindex)
demo.gendaylit(timeindex)
mymodule = demo.makeModule(name=moduletype, x=x, y=y)
sceneDict = {'gcr': gcr,'hub_height':hub_height, 'tilt': 90, 'azimuth': 90, 'nMods':nMods, 'nRows': nRows}
scene = demo.makeScene(moduletype,sceneDict)
Expand Down Expand Up @@ -179,7 +179,7 @@
demo.setGround(albedo)
epwfile = demo.getEPW(lat = lat, lon = lon)
metdata = demo.readWeatherFile(weatherFile = epwfile)
demo.gendaylit(metdata,timeindex)
demo.gendaylit(timeindex)
mymodule = demo.makeModule(name=moduletype, x=x, y=y)
sceneDict = {'gcr': gcr,'hub_height':hub_height, 'tilt': 75, 'azimuth': 90, 'nMods':nMods, 'nRows': nRows}
scene = demo.makeScene(moduletype,sceneDict)
Expand All @@ -200,7 +200,7 @@
demo.setGround(albedo)
epwfile = demo.getEPW(lat = lat, lon = lon)
metdata = demo.readWeatherFile(weatherFile = epwfile)
demo.gendaylit(metdata,timeindex)
demo.gendaylit(timeindex)
mymodule = demo.makeModule(name=moduletype, x=0.001, y=y)
sceneDict = {'gcr': gcr,'hub_height':hub_height, 'tilt': 45, 'azimuth': 135, 'nMods':nMods, 'nRows': nRows}
scene = demo.makeScene(moduletype,sceneDict)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
"if fullYear:\n",
" demo.genCumSky(demo.epwfile) # entire year.\n",
"else:\n",
" demo.gendaylit(metdata,4020) # Noon, June 17th (timepoint # 4020)"
" demo.gendaylit(4020) # Noon, June 17th (timepoint # 4020)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
if fullYear:
demo.genCumSky(demo.epwfile) # entire year.
else:
demo.gendaylit(metdata,4020) # Noon, June 17th (timepoint # 4020)
demo.gendaylit(4020) # Noon, June 17th (timepoint # 4020)


# The method gencumSky calculates the hourly radiance of the sky hemisphere by dividing it into 145 patches. Then it adds those hourly values to generate one single <b> cumulative sky</b>. Here is a visualization of this patched hemisphere for Richmond, VA, US. Can you deduce from the radiance values of each patch which way is North?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"demo.setGround(albedo) # input albedo number or material name like 'concrete'. To see options, run this without any input.\n",
"epwfile = demo.getEPW(lat, lon) # NJ lat/lon 40.0583° N, 74.4057\n",
"metdata = demo.readEPW(epwfile) # read in the EPW weather data from above\n",
"demo.gendaylit(metdata,4020) # Use this to simulate only one hour at a time. \n",
"demo.gendaylit(4020) # Use this to simulate only one hour at a time. \n",
"# This allows you to \"view\" the scene on RVU (see instructions below)\n",
"# timestam 4020 : Noon, June 17th.\n",
"#demo.genCumSky(demo.epwfile) # Use this instead of gendaylit to simulate the whole year\n",
Expand Down Expand Up @@ -500,7 +500,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
demo.setGround(albedo) # input albedo number or material name like 'concrete'. To see options, run this without any input.
epwfile = demo.getEPW(lat, lon) # NJ lat/lon 40.0583° N, 74.4057
metdata = demo.readEPW(epwfile) # read in the EPW weather data from above
demo.gendaylit(metdata,4020) # Use this to simulate only one hour at a time.
demo.gendaylit(4020) # Use this to simulate only one hour at a time.
# This allows you to "view" the scene on RVU (see instructions below)
# timestam 4020 : Noon, June 17th.
#demo.genCumSky(demo.epwfile) # Use this instead of gendaylit to simulate the whole year
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
"demo.setGround(albedo) # input albedo number or material name like 'concrete'. To see options, run this without any input.\n",
"epwfile = demo.getEPW(lat,lon) # pull TMY data for any global lat/lon\n",
"metdata = demo.readEPW(epwfile) # read in the EPW weather data from above\n",
"demo.gendaylit(metdata,timestamp) # Noon, June 17th"
"demo.gendaylit(timestamp) # Noon, June 17th"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
demo.setGround(albedo) # input albedo number or material name like 'concrete'. To see options, run this without any input.
epwfile = demo.getEPW(lat,lon) # pull TMY data for any global lat/lon
metdata = demo.readEPW(epwfile) # read in the EPW weather data from above
demo.gendaylit(metdata,timestamp) # Noon, June 17th
demo.gendaylit(timestamp) # Noon, June 17th


# <a id='step4'></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"demo.setGround(albedo) # input albedo number or material name like 'concrete'. To see options, run this without any input.\n",
"epwfile = demo.getEPW(40.0583,-74.4057) # NJ lat/lon 40.0583° N, 74.4057\n",
"metdata = demo.readEPW(epwfile) # read in the EPW weather data from above\n",
"demo.gendaylit(metdata,4020) # Use this to simulate only one hour at a time. \n",
"demo.gendaylit(4020) # Use this to simulate only one hour at a time. \n",
"# This allows you to \"view\" the scene on RVU (see instructions below)\n",
"# timestam 4020 : Noon, June 17th.\n",
"#demo.genCumSky(demo.epwfile) # Use this instead of gendaylit to simulate the whole year\n",
Expand Down Expand Up @@ -462,7 +462,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
demo.setGround(albedo) # input albedo number or material name like 'concrete'. To see options, run this without any input.
epwfile = demo.getEPW(40.0583,-74.4057) # NJ lat/lon 40.0583° N, 74.4057
metdata = demo.readEPW(epwfile) # read in the EPW weather data from above
demo.gendaylit(metdata,4020) # Use this to simulate only one hour at a time.
demo.gendaylit(4020) # Use this to simulate only one hour at a time.
# This allows you to "view" the scene on RVU (see instructions below)
# timestam 4020 : Noon, June 17th.
#demo.genCumSky(demo.epwfile) # Use this instead of gendaylit to simulate the whole year
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"epwfile = demo.getEPW(lat = 37.5, lon = -77.6) \n",
"metdata = demo.readWeatherFile('EPWs\\\\USA_VA_Richmond.Intl.AP.724010_TMY.epw') \n",
"fullYear = True\n",
"demo.gendaylit(metdata,4020) # Noon, June 17th . # Gencumsky could be used too.\n",
"demo.gendaylit(4020) # Noon, June 17th . # Gencumsky could be used too.\n",
"module_type = 'Prism Solar Bi60 landscape' \n",
"demo.makeModule(name=module_type,y=1,x=1.7)\n",
"sceneDict = {'tilt':10,'pitch':1.5,'clearance_height':0.2,'azimuth':180, 'nMods': 5, 'nRows': 2, 'appendRadfile':True} \n",
Expand Down Expand Up @@ -538,7 +538,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
epwfile = demo.getEPW(lat = 37.5, lon = -77.6)
metdata = demo.readWeatherFile('EPWs\\USA_VA_Richmond.Intl.AP.724010_TMY.epw')
fullYear = True
demo.gendaylit(metdata,4020) # Noon, June 17th . # Gencumsky could be used too.
demo.gendaylit(4020) # Noon, June 17th . # Gencumsky could be used too.
module_type = 'Prism Solar Bi60 landscape'
demo.makeModule(name=module_type,y=1,x=1.7)
sceneDict = {'tilt':10,'pitch':1.5,'clearance_height':0.2,'azimuth':180, 'nMods': 5, 'nRows': 2, 'appendRadfile':True}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#
# This will generate the results over which we will perform the mismatch analysis. Here we are doing only 1 day to make this 'fater'.

# In[ ]:
# In[6]:


import bifacial_radiance
Expand Down Expand Up @@ -73,7 +73,7 @@

# Analysis parmaeters
startdate = '11/06'
enddate = '11/06'
enddate = '11/07'
sensorsy = 12

demo = bifacial_radiance.RadianceObj(simulationName, path=testfolder)
Expand Down Expand Up @@ -112,7 +112,7 @@
# - Upsample
#

# In[1]:
# In[7]:


resultfolder = os.path.join(testfolder, 'results')
Expand Down
6 changes: 3 additions & 3 deletions tests/test_bifacial_radiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_RadianceObj_fixed_tilt_end_to_end():
if fullYear:
demo.genCumSky(demo.epwfile) # entire year.
else:
demo.gendaylit(metdata,4020) # Noon, June 17th
demo.gendaylit(timeindex=4020, metdata=metdata) # Noon, June 17th
# create a scene using panels in landscape at 10 deg tilt, 1.5m pitch. 0.2 m ground clearance
sceneDict = {'tilt':10,'pitch':1.5,'height':0.2, 'nMods':10, 'nRows':3}
demo.makeModule(name='test',y=0.95,x=1.59, xgap=0)
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_RadianceObj_high_azimuth_angle_end_to_end():
if fullYear:
demo.genCumSky(demo.epwfile) # entire year. # Don't know how to test this yet in pytest...
else:
demo.gendaylit(metdata,4020) # Noon, June 17th
demo.gendaylit(metdata=metdata,timeindex=4020) # Noon, June 17th
# create a scene using panels in landscape at 10 deg tilt, 1.5m pitch. 0.2 m ground clearance
sceneDict = {'tilt':10,'pitch':1.5,'height':0.2,'azimuth':30, 'nMods':10, 'nRows':3}
moduleDict = demo.makeModule(name='test',y=0.95,x=1.59, xgap=0)
Expand Down Expand Up @@ -317,7 +317,7 @@ def test_SingleModule_end_to_end():
demo = bifacial_radiance.RadianceObj(name) # Create a RadianceObj 'object'
demo.setGround('litesoil')
metdata = demo.readEPW(epwfile= MET_FILENAME)
demo.gendaylit(metdata,4020,debug=True) # 1pm, June 17th
demo.gendaylit(timeindex=4020, metdata=metdata, debug=True) # 1pm, June 17th
# create a scene using panels in landscape at 10 deg tilt, 1.5m pitch. 0.2 m ground clearance
tilt=demo.getSingleTimestampTrackerAngle(metdata=metdata, timeindex=4020, gcr=0.33)
assert tilt == pytest.approx(-6.7, abs = 0.4)
Expand Down
63 changes: 63 additions & 0 deletions tests/test_groundobj.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
"""
Created 2/19/19
@author: cdeline
Using pytest to create unit tests for GroundObj
to run unit tests, run pytest from the command line in the bifacial_radiance directory
"""

import bifacial_radiance
import os, pytest
import numpy as np

# try navigating to tests directory so tests run from here.
try:
os.chdir('tests')
except:
pass

# also test a dummy TMY3 Boulder file in /tests/
MET_FILENAME = 'USA_CO_Boulder.724699_TMY2.epw'
MET_FILENAME2 = '724666TYA.CSV'
# return albedo values in GroundObj
def _groundtest(groundobj):
if type(groundobj) != bifacial_radiance.main.GroundObj:
raise TypeError('bifacial_radiance.GroundObj not passed')

return(groundobj.Rrefl, groundobj.Grefl, groundobj.Brefl, groundobj.ReflAvg)


def test_albedo_cases_orig():
# test 'litesoil', constant albedo
ground = bifacial_radiance.GroundObj('litesoil')
testvals_litesoil = ([.29], [.187], [.163], [.213])
np.testing.assert_allclose(_groundtest(ground), testvals_litesoil, atol=.001)

ground = bifacial_radiance.GroundObj(0.2)
testvals_const = ([.2], [.2], [.2], [.2])
np.testing.assert_allclose(_groundtest(ground), testvals_const, atol=.001)

def test_albedo_tmy3():
# test 1xN albedo array
demo = bifacial_radiance.RadianceObj(name = 'test')
demo.readWeatherFile(MET_FILENAME2)
demo.setGround(demo.metdata.albedo)
assert demo.ground.Rrefl.__len__() == 8760
assert demo.ground.ReflAvg.__len__() == 8760

def test_RGB_timeseries():
# test 3xN albedo array with two timesteps
albedo = np.array([[0.2, 0.3, 0.4], [0.12, 0.13, 0.26]]) # 2 RGB Albedo
ground = bifacial_radiance.GroundObj(albedo)
testval = _groundtest(ground)
testvals_const = ([[.2,.12], [.3, .13], [.4, .26], [.3,.17]])
np.testing.assert_allclose(testval, testvals_const)

# test 4xN albedo array which should be trimmed and raise a warning
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)

0 comments on commit 4e1c8e8

Please sign in to comment.