Skip to content

Commit

Permalink
DNI and DHI to results.... maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
shirubana committed Aug 4, 2022
1 parent 5de3b37 commit f75212c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bifacial_radiance/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def _exportTrackerDict(trackerdict, savefile, reindex=False, monthlyyearly=False
print("Exporting TrackerDict")

# convert trackerdict into dataframe
d = df.from_dict(trackerdict,orient='index',columns=['dhi','ghi', 'temp_air',
d = df.from_dict(trackerdict,orient='index',columns=['dni','dhi','ghi', 'temp_air',
'wind_speed', 'theta','surf_tilt','surf_azm',
'clearance_height',
# Not including the whole distribution because these are not clean..
Expand Down
20 changes: 16 additions & 4 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,9 @@ def calculateResults(self, CECMod=None, glassglass=False, bifacialityfactor=None
rowWanted = []
modWanted = []
keys_all = []
dni = []
dhi = []
ghi = []

for key in keys:
for row_mod in trackerdict[key]['Results']: # loop over multiple row & module in trackerDict['Results']
Expand All @@ -2717,6 +2720,9 @@ def calculateResults(self, CECMod=None, glassglass=False, bifacialityfactor=None
if self.cumulativesky is False:
temp_air.append(trackerdict[key]['temp_air'])
wind_speed.append(trackerdict[key]['wind_speed'])
dni.append(trackerdict[key]['dni'])
dhi.append(trackerdict[key]['dhi'])
ghi.append(trackerdict[key]['ghi'])

# trackerdict[key]['effective_irradiance'] = eff_irrad

Expand All @@ -2738,11 +2744,13 @@ def calculateResults(self, CECMod=None, glassglass=False, bifacialityfactor=None
modfilter2 = db.index.str.startswith('Pr') & db.index.str.endswith('BHC72-400')
CECMod = db[modfilter2]

kwargs = {'dni': dni, 'dhi': dhi, 'ghi': ghi}

results = performance.calculateResults(CECMod=CECMod, results=data,
wind_speed = data['wind_speed'],
temp_air=data['temp_air'],
bifacialityfactor=bifacialityfactor,
CECMod2=CECMod2)
CECMod2=CECMod2, **kwargs)

ii = 0
# Update tracker dict now!
Expand Down Expand Up @@ -3585,6 +3593,7 @@ def _set1axis(self, azimuth=180, limit_angle=45, angledelta=None,
'surf_azm':self.surface_azimuth[i],
'surf_tilt':self.surface_tilt[i],
'theta':self.tracker_theta[i],
'dni':self.dni[i],
'ghi':self.ghi[i],
'dhi':self.dhi[i],
'temp_air':self.temp_air[i],
Expand Down Expand Up @@ -3746,22 +3755,25 @@ def _makeTrackerCSV(self, theta_list, trackingdata):
trackerdict[theta]['count'] = datetimetemp.__len__()
#Create new temp csv file with zero values for all times not equal to datetimetemp
# write 8760 2-column csv: GHI,DHI
dni_temp = []
ghi_temp = []
dhi_temp = []
for g, d, time in zip(self.ghi, self.dhi,
for g, d, dn, time in zip(self.ghi, self.dhi, self.dni,
dt.strftime('%Y-%m-%d %H:%M:%S')):

# is this time included in a particular theta_round angle?
if time in datetimetemp:
ghi_temp.append(g)
dhi_temp.append(d)
dni_temp.append(dn)
else:
# mask out irradiance at this time, since it
# belongs to a different bin
ghi_temp.append(0.0)
dhi_temp.append(0.0)
dni_temp.append(0.0)
# save in 2-column GHI,DHI format for gencumulativesky -G
savedata = pd.DataFrame({'GHI':ghi_temp, 'DHI':dhi_temp},
savedata = pd.DataFrame({'DNI': dni_temp, 'GHI':ghi_temp, 'DHI':dhi_temp},
index = self.datetime).tz_localize(None)
# Fill partial year. Requires 2021 measurement year.
savedata = _subhourlydatatoGencumskyformat(savedata,
Expand All @@ -3773,7 +3785,7 @@ def _makeTrackerCSV(self, theta_list, trackingdata):
index=False,
header=False,
sep=' ',
columns=['GHI','DHI'])
columns=['DNI','GHI','DHI'])


return trackerdict
Expand Down
12 changes: 10 additions & 2 deletions bifacial_radiance/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def _cleanDataFrameResults(mattype, rearMat, Wm2Front, Wm2Back, fillcleanedSenso

def calculateResults(CECMod, csvfile=None, results=None,
temp_air=None, wind_speed=1, temp_cell=None, glassglass=False,
bifacialityfactor=1.0, CECMod2=None, fillcleanedSensors=False):
bifacialityfactor=1.0, CECMod2=None, fillcleanedSensors=False, **kwargs):
'''
Calculate Performance and Mismatch for timestamped data. This routine
Expand Down Expand Up @@ -339,7 +339,15 @@ def calculateResults(CECMod, csvfile=None, results=None,
dfst['BGE'] = (dfst['Pout_raw']-dfst['Pout_Gfront'])*100/dfst['Pout_Gfront']
dfst['Mismatch'] = mismatch.mismatch_fit3(POA.T)
dfst['Pout'] = dfst['Pout_raw']*(1-dfst['Mismatch']/100)

dfst['Wind Speed'] = wind_speed
if "dni" in kwargs:
dfst['DNI'] = kwargs['dni']
if "dhi" in kwargs:
dfst['DHI'] = kwargs['dhi']
if "ghi" in kwargs:
dfst['GHI'] = kwargs['ghi']
dfst['Wind Speed'] = wind_speed

return dfst


Expand Down
4 changes: 2 additions & 2 deletions tests/simulation3.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ customObject = C:\Users\sayala\Documents\GitHub\bifacial_radiance\tests\customFi

[timeControlParamsDict]
starttime = 06_17_13
endtime = 06_17_13
endtime = 06_17_14

[moduleParamsDict]
bifi = 0.9
Expand All @@ -47,7 +47,7 @@ customtext = !xform -rz 0 C:\Users\sayala\Documents\GitHub\bifacial_radiance\tes
[analysisParamsDict]
sensorsy = [1,9]
sensorsx = [1,1]
modWanted = 2
modWanted = [2,3]
rowWanted = 1

[cellLevelModuleParamsDict]
Expand Down

0 comments on commit f75212c

Please sign in to comment.