Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/NREL/main' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
cdeline committed Oct 2, 2024
2 parents 030daf3 + 75aae25 commit d4adec9
Show file tree
Hide file tree
Showing 11 changed files with 9,087 additions and 1,064 deletions.
11 changes: 9 additions & 2 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,12 +970,12 @@ def readWeatherFile(self, weatherFile=None, starttime=None,
if source.lower() =='epw':
if label is None:
label = 'right'
metdata, metadata = self._readEPW(weatherFile, label=label)
metdata, metadata = self._readEPW(weatherFile, label=label, coerce_year=coerce_year)

if source.lower() =='tmy3':
if label is None:
label = 'right'
metdata, metadata = self._readTMY(weatherFile, label=label)
metdata, metadata = self._readTMY(weatherFile, label=label, coerce_year=coerce_year)

if source.lower() =='sam':
if label is None:
Expand Down Expand Up @@ -1525,7 +1525,14 @@ def _readEPW(self, epwfile=None, label = 'right', coerce_year=None):
coerce_year=coerce_year) #pvlib>0.6.1
#pvlib uses -1hr offset that needs to be un-done.
tmydata.index = tmydata.index+pd.Timedelta(hours=1)
# need to check for leap year here and add a day just in case
# use indices to check for a leap day and advance it to March 1st
leapday = (tmydata.index.month == 2) & (tmydata.index.day == 29)
index2 = tmydata.index.to_series()
index2.loc[leapday] += datetime.timedelta(days=1)
tmydata.set_index(index2, inplace=True)


# rename different field parameters to match output from
# pvlib.tmy.readtmy: DNI, DHI, DryBulb, Wspd
tmydata.rename(columns={'dni':'DNI',
Expand Down
1 change: 1 addition & 0 deletions docs/sphinx/source/whatsnew/v0.4.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Bug fixes
* Fixed a major error with indexing the irradiance conditions with :py:func:`~bifacial_radiance.RadianceObj.gendaylit1axis`. This could result in the trackerdict entry being mismatched from the metdata resource. (:issue:`441`)
* versioning with setuptools_scm- set fallback_version to bifirad v0.4.3 to prevent crashes if git is not present (:issue:`535`)(:pull:`539`)
* :py:func:`bifacial_radiance.load.readconfigurationinputfile` now properly handles loading moduleObj parameters from .ini files: `glass`, `glassEdge`, `frameParamsDict`, `omegaParamsDict` (:pull:`551`)
* Fixed a leap year bug in :py:func:`~bifacial_radiance.RadianceObj.readWeatherFile` that crashed if epwfiles are loaded that include leap year data (like Feb. 28 2020). (:issue:`552`)

Documentation
~~~~~~~~~~~~~~
Expand Down
507 changes: 24 additions & 483 deletions docs/tutorials/18 - AgriPV - Coffee Plantation with Tree Modeling.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#
# While we have HPC scripts to do the below simulation, this journals runs all of the above so it might take some time, as there are 109 combinations of parameters explored

# In[7]:
# In[ ]:


import bifacial_radiance
Expand All @@ -64,7 +64,7 @@
import pandas as pd


# In[8]:
# In[ ]:


testfolder = str(Path().resolve().parent.parent / 'bifacial_radiance' / 'TEMP' / 'Tutorial_18')
Expand All @@ -76,7 +76,7 @@

# ## General Parameters and Variables

# In[9]:
# In[ ]:


lat = 18.202142
Expand All @@ -99,12 +99,12 @@
nMods = 20
nRows = 7
numpanels = 1
moduletype = 'test-module'
module_name = 'test-module'
hpc = False
sim_general_name = 'tutorial_18'


# In[10]:
# In[ ]:


if not os.path.exists(os.path.join(testfolder, 'EPWs')):
Expand All @@ -118,7 +118,7 @@

# ## 1. Loop to Raytrace and sample irradiance at where Three would be located

# In[15]:
# In[ ]:


demo = bifacial_radiance.RadianceObj(sim_general_name,str(testfolder))
Expand Down Expand Up @@ -152,9 +152,10 @@
coffeeplant_x = (x+xgap)/2
coffeeplant_y = pitch/2

demo.makeModule(name=moduletype, x=x, y=y, xgap = xgap)
sceneDict = {'tilt':tilt,'pitch':pitch,'clearance_height':clearance_height,'azimuth':azimuth, 'nMods': nMods, 'nRows': nRows}
scene = demo.makeScene(moduletype=moduletype,sceneDict=sceneDict, radname = sim_name)
demo.makeModule(name=module_name, x=x, y=y, xgap = xgap)
sceneDict = {'tilt':tilt, 'pitch':pitch, 'clearance_height':clearance_height, 'azimuth':azimuth,
'nMods': nMods, 'nRows':nRows}
scene = demo.makeScene(module=module_name, sceneDict=sceneDict, radname=sim_name)
octfile = demo.makeOct(octname = demo.basename )
analysis = bifacial_radiance.AnalysisObj(octfile=octfile, name=sim_name)

Expand All @@ -180,13 +181,13 @@

# ### Option 1: Raytrace of Empty Field

# In[13]:
# In[ ]:


sim_name = 'EMPTY'
demo.makeModule(name=moduletype, x=0.001, y=0.001, xgap = 0)
demo.makeModule(name=module_name, x=0.001, y=0.001, xgap = 0)
sceneDict = {'tilt':0,'pitch':2,'clearance_height':0.005,'azimuth':180, 'nMods': 1, 'nRows': 1}
scene = demo.makeScene(moduletype=moduletype,sceneDict=sceneDict, radname = sim_name)
scene = demo.makeScene(module=module_name,sceneDict=sceneDict, radname = sim_name)
octfile = demo.makeOct(octname = demo.basename)
analysis = bifacial_radiance.AnalysisObj(octfile=octfile, name=sim_name)
frontscan, backscan = analysis.moduleAnalysis(scene=scene, sensorsy=1)
Expand All @@ -205,12 +206,11 @@
print("YEARLY TOTAL Wh/m2:", puerto_rico_Year)



# <a id='step2b'></a>

# ### Option 2: Weather File

# In[14]:
# In[ ]:


# Indexes for start of each month of interest in TMY3 8760 hours file
Expand Down Expand Up @@ -410,9 +410,9 @@
coffeeplant_x = (x+xgap)/2
coffeeplant_y = pitch

demo.makeModule(name=moduletype, x=x, y=y, xgap = xgap)
demo.makeModule(name=module_name, x=x, y=y, xgap = xgap)
sceneDict = {'tilt':tilt,'pitch':pitch,'clearance_height':clearance_height,'azimuth':azimuth, 'nMods': nMods, 'nRows': nRows}
scene = demo.makeScene(moduletype=moduletype,sceneDict=sceneDict, radname = sim_name)
scene = demo.makeScene(module=module_name,sceneDict=sceneDict, radname = sim_name)

# Appending the Trees here
text = ''
Expand Down Expand Up @@ -511,9 +511,9 @@
coffeeplant_y = pitch

demo.gendaylit(4020)
demo.makeModule(name=moduletype, x=x, y=y, xgap = xgap)
demo.makeModule(name=module_name, x=x, y=y, xgap = xgap)
sceneDict = {'tilt':tilt,'pitch':pitch,'clearance_height':clearance_height,'azimuth':azimuth, 'nMods': nMods, 'nRows': nRows}
scene = demo.makeScene(moduletype=moduletype,sceneDict=sceneDict, radname = sim_name)
scene = demo.makeScene(module=module_name,sceneDict=sceneDict, radname = sim_name)


for ii in range(0,3):
Expand Down
Loading

0 comments on commit d4adec9

Please sign in to comment.