Skip to content

Commit

Permalink
Merge pull request #381 from NREL/369_main_updates
Browse files Browse the repository at this point in the history
GUI default value bug fix and pandas deprecation errors
  • Loading branch information
cdeline authored Feb 10, 2022
2 parents 8470659 + ac790b8 commit cf5ae46
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
54 changes: 29 additions & 25 deletions bifacial_radiance/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,12 @@ def read_valuesfromGUI():
if limitangle is not None: trackingParamsDict['limit_angle'] = limitangle
if angledelta is not None: trackingParamsDict['angle_delta'] = angledelta

if diameter is not None: torquetubeParamsDict['diameter'] = diameter
if tubeType is not None: torquetubeParamsDict['tubetype'] = tubeType

if torqueTubeMaterial is not None: torquetubeParamsDict['material'] = torqueTubeMaterial
if invisible: torquetubeParamsDict['visible'] = False
if torqueTube:
if diameter is not None: torquetubeParamsDict['diameter'] = diameter
if tubeType is not None: torquetubeParamsDict['tubetype'] = tubeType

if torqueTubeMaterial is not None: torquetubeParamsDict['material'] = torqueTubeMaterial
if invisible: torquetubeParamsDict['visible'] = False

if sensorsy is not None: analysisParamsDict['sensorsy'] = sensorsy
if modWanted is not None: analysisParamsDict['modWanted'] = modWanted
Expand Down Expand Up @@ -403,11 +404,7 @@ def setDefaultValues():
entry_angledelta.insert(0,"5")
entry_axis_azimuth.insert(0,"180")
entry_azimuth.insert(0,"180")
#A="" # TEST OF EMPTY INPUT
#entry_azimuth.insert(0,A)
entry_bifi.insert(0,"0.9")
entry_clearanceheight.insert(0,"0.8")
entry_diameter.insert(0,"0.1")
entry_endtime.insert(0,"06_21_12")
entry_epwfile.insert(0, r"EPWs\\USA_VA_Richmond.Intl.AP.724010_TMY.epw") #FIX
entry_gcr.insert(0,"0.35")
Expand All @@ -416,21 +413,24 @@ def setDefaultValues():
entry_hubheight.insert(0,"0.9")
entry_inputvariablefile.insert(0, "BB") #FIX
entry_limitangle.insert(0,"60")
entry_moduletype.insert(0,"Prism Solar Bi60")
entry_modWanted.insert(0,"") #was 10
entry_nMods.insert(0,"20")
entry_nRows.insert(0,"7")
entry_numberofPanels.insert(0,"2")
entry_numcellsx.insert(0,"12")
entry_numcellsy.insert(0,"6")
entry_pitch.insert(0,"10")
entry_rowWanted.insert(0,"") #was 3
entry_sensorsy.insert(0,"9")
entry_sensorsy.insert(0,"10")
entry_simulation.insert(0,"Demo1")
entry_starttime.insert(0,"06_21_12")
#entry_testfolder.insert(0, os.getcwd())
entry_testfolder.insert(0, TEMP_PATH)
entry_tilt.insert(0,"10")

# Module parameters - populate by loading first module in module.json
"""
entry_bifi.insert(0,"0.9")
entry_numberofPanels.insert(0,"2")
entry_numcellsx.insert(0,"12")
entry_numcellsy.insert(0,"6")
entry_diameter.insert(0,"0.1")
entry_x.insert(0,"0.98")
entry_xcell.insert(0,"0.15")
entry_xcellgap.insert(0,"0.01")
Expand All @@ -440,6 +440,9 @@ def setDefaultValues():
entry_xgap.insert(0,"0.05")
entry_ygap.insert(0,"0.15")
entry_zgap.insert(0,"0.10")
"""



def activateAllEntries():
entry_albedo.config(state='normal')
Expand Down Expand Up @@ -1293,7 +1296,7 @@ def showModule(noprint=False):
print('Empty module dictionary - returning')
return

moduletype = 'test'
moduletype = 'test-module'
print('Creating test module')

# need to first create a dummy SceneObj to create the module .rad
Expand All @@ -1302,15 +1305,16 @@ def showModule(noprint=False):

# create the kwargs for makeModule
cellModuleParams = (P[7] if P[0]['cellLevelModule'] else None)
kwargs = {'name':moduletype, 'torquetube':P[0]['torqueTube'],
'numpanels':P[3]['numpanels'], 'x':P[3]['x'],
'y':P[3]['y'], 'xgap':P[3]['xgap'], 'ygap':P[3]['ygap'],
'zgap':P[3]['zgap'], 'diameter':P[5]['diameter'],
'tubetype':P[5]['tubetype'], 'material':P[5]['torqueTubeMaterial'],
'cellModule':cellModuleParams}
kwargs = {'name':moduletype, 'numpanels':P[3]['numpanels'],
'x':P[3]['x'],'y':P[3]['y'], 'xgap':P[3]['xgap'],
'ygap':P[3]['ygap'],'zgap':P[3]['zgap']}

# Run makeModule with the above kwarg dictionary
module = demo.makeModule(**kwargs)
if cellModuleParams: module.addCellModule(**cellModuleParams)
if P[5]:
print(f'P5: {P[5]}')
module.addTorquetube(**P[5])

if noprint is False:
# show module
Expand Down Expand Up @@ -1406,7 +1410,7 @@ def enable_cellModule(d):
entry_ycellgap.insert(0,str(d['cellModule']['ycellgap']))



key = entry_modulename_value.get() # what is the value selected?
#print(key + ' selected')
if key != '': # '' not a dict key
Expand Down Expand Up @@ -1647,10 +1651,10 @@ def clearAllValuesButton():
buttonImage = Button(imagevariables_frame, image=image_fixed)
buttonImage.grid(row=0, columnspan=4, sticky=W)

#setDefaultValues()
setDefaults()
# setDefaultValues()
setdefaultGray()
entry_modulename.event_generate('<<ComboboxSelected>>') # populate module params


# root.title("Bifacial_Radiance | v. 0_2_5")

Expand Down
9 changes: 6 additions & 3 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,13 @@ def _subhourlydatatoGencumskyformat(gencumskydata, label='right'):
if any(gencumskydata.index.isin([padstart])):
print("Data starts on Jan. 01")
else:
gencumskydata=gencumskydata.append(pd.DataFrame(index=[padstart]))
#gencumskydata=gencumskydata.append(pd.DataFrame(index=[padstart]))
gencumskydata=pd.concat([gencumskydata,pd.DataFrame(index=[padstart])])
if any(gencumskydata.index.isin([padend])):
print("Data ends on Dec. 31st")
else:
gencumskydata=gencumskydata.append(pd.DataFrame(index=[padend]))
#gencumskydata=gencumskydata.append(pd.DataFrame(index=[padend]))
gencumskydata=pd.concat([gencumskydata, pd.DataFrame(index=[padend])])
gencumskydata.loc[padstart]=0
gencumskydata.loc[padend]=0
gencumskydata=gencumskydata.sort_index()
Expand Down Expand Up @@ -729,7 +731,8 @@ def _returnEPWnames():
lontemp = location['geometry']['coordinates'][0]
lattemp = location['geometry']['coordinates'][1]
dftemp = pd.DataFrame({'url':[url], 'lat':[lattemp], 'lon':[lontemp], 'name':[name]})
df = df.append(dftemp, ignore_index=True)
#df = df.append(dftemp, ignore_index=True)
df = pd.concat([df, dftemp], ignore_index=True)
return df

def _findClosestEPW(lat, lon, df):
Expand Down

0 comments on commit cf5ae46

Please sign in to comment.