Skip to content

Commit

Permalink
fixes #441. Changed how the metadata is indexed in gendaylit1axis - n…
Browse files Browse the repository at this point in the history
…ow key off the timestamp instead of assuming the two indices have the same integer index.
  • Loading branch information
cdeline committed Sep 24, 2024
1 parent 46d3c4c commit 324253f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1831,22 +1831,23 @@ def gendaylit1axis(self, metdata=None, trackerdict=None, startdate=None,
count = 0 # counter to get number of skyfiles created, just for giggles

trackerdict2={}
for i in range(0, len(trackerdict.keys())):
#for i in range(0, len(trackerdict.keys())):
for key in trackerdict.keys():
time_target = pd.to_datetime(key, format="%Y-%m-%d_%H%M").tz_localize(int(self.metdata.timezone*3600))
try:
time = metdata.datetime[i]
i = metdata.datetime.index(time_target)
except IndexError: #out of range error
break #
#filename = str(time)[5:-12].replace('-','_').replace(' ','_')
filename = time.strftime('%Y-%m-%d_%H%M')
self.name = filename
self.name = key

#check for GHI > 0
#if metdata.ghi[i] > 0:
if (metdata.ghi[i] > 0) & (~np.isnan(metdata.tracker_theta[i])):
skyfile = self.gendaylit(metdata=metdata,timeindex=i, debug=debug)
skyfile = self.gendaylit(metdata=metdata, timeindex=i, debug=debug)
# trackerdict2 reduces the dict to only the range specified.
trackerdict2[filename] = trackerdict[filename]
trackerdict2[filename]['skyfile'] = skyfile
trackerdict2[key] = trackerdict[key]
trackerdict2[key]['skyfile'] = skyfile
count +=1

print('Created {} skyfiles in /skies/'.format(count))
Expand Down
1 change: 1 addition & 0 deletions docs/sphinx/source/whatsnew/pending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Enhancements

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`)

Documentation
Expand Down

0 comments on commit 324253f

Please sign in to comment.