bifacial-radiance 0.5.1__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. bifacial_radiance/HPCScripts/BasicSimulations/addNewModule.py +15 -0
  2. bifacial_radiance/HPCScripts/BasicSimulations/dask_on_node.sh +11 -0
  3. bifacial_radiance/HPCScripts/BasicSimulations/run_sbatch.sbatch +51 -0
  4. bifacial_radiance/HPCScripts/BasicSimulations/simulate_fixedtilt_gencumsky.py +110 -0
  5. bifacial_radiance/HPCScripts/BasicSimulations/simulate_fixedtilt_gendaylit.py +102 -0
  6. bifacial_radiance/HPCScripts/BasicSimulations/simulate_tracking_gendaylit.py +126 -0
  7. bifacial_radiance/HPCScripts/Other Examples (unorganized)/PuertoRico.py +168 -0
  8. bifacial_radiance/HPCScripts/Other Examples (unorganized)/PuertoRico_2.py +166 -0
  9. bifacial_radiance/HPCScripts/Other Examples (unorganized)/PuertoRico_Original.py +195 -0
  10. bifacial_radiance/HPCScripts/Other Examples (unorganized)/basic_module_sampling.py +154 -0
  11. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_B.py +162 -0
  12. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_Cases.py +122 -0
  13. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_CasesMonth.py +142 -0
  14. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_PRNew.py +91 -0
  15. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_PRNewP2.py +95 -0
  16. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_TreeResults.py +108 -0
  17. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_basic_module_sampling.py +103 -0
  18. bifacial_radiance/HPCScripts/Other Examples (unorganized)/simulate_JackHourly.py +160 -0
  19. bifacial_radiance/HPCScripts/Other Examples (unorganized)/simulate_improvedArray_Oct2127.py +623 -0
  20. bifacial_radiance/TEMP/.gitignore +4 -0
  21. bifacial_radiance/__init__.py +24 -0
  22. bifacial_radiance/data/CEC Modules.csv +16860 -0
  23. bifacial_radiance/data/default.ini +65 -0
  24. bifacial_radiance/data/falsecolor.exe +0 -0
  25. bifacial_radiance/data/gencumsky/License.txt +54 -0
  26. bifacial_radiance/data/gencumsky/Makefile +17 -0
  27. bifacial_radiance/data/gencumsky/README.txt +9 -0
  28. bifacial_radiance/data/gencumsky/Solar Irradiation Modelling.doc +0 -0
  29. bifacial_radiance/data/gencumsky/Sun.cpp +118 -0
  30. bifacial_radiance/data/gencumsky/Sun.h +45 -0
  31. bifacial_radiance/data/gencumsky/average_val.awk +3 -0
  32. bifacial_radiance/data/gencumsky/cPerezSkyModel.cpp +238 -0
  33. bifacial_radiance/data/gencumsky/cPerezSkyModel.h +57 -0
  34. bifacial_radiance/data/gencumsky/cSkyVault.cpp +536 -0
  35. bifacial_radiance/data/gencumsky/cSkyVault.h +86 -0
  36. bifacial_radiance/data/gencumsky/climateFile.cpp +312 -0
  37. bifacial_radiance/data/gencumsky/climateFile.h +37 -0
  38. bifacial_radiance/data/gencumsky/cumulative.cal +177 -0
  39. bifacial_radiance/data/gencumsky/cumulative.rad +14 -0
  40. bifacial_radiance/data/gencumsky/cumulativesky_rotated.rad +2 -0
  41. bifacial_radiance/data/gencumsky/gencumulativesky +0 -0
  42. bifacial_radiance/data/gencumsky/gencumulativesky.cpp +269 -0
  43. bifacial_radiance/data/gencumsky/make_gencumskyexe.py +107 -0
  44. bifacial_radiance/data/gencumsky/paths.h +62 -0
  45. bifacial_radiance/data/gencumulativesky +0 -0
  46. bifacial_radiance/data/gencumulativesky.exe +0 -0
  47. bifacial_radiance/data/ground.rad +83 -0
  48. bifacial_radiance/data/module.json +103 -0
  49. bifacial_radiance/gui.py +1696 -0
  50. bifacial_radiance/images/fig1_fixed_small.gif +0 -0
  51. bifacial_radiance/images/fig2_tracked_small.gif +0 -0
  52. bifacial_radiance/load.py +1156 -0
  53. bifacial_radiance/main.py +5673 -0
  54. bifacial_radiance/mismatch.py +461 -0
  55. bifacial_radiance/modelchain.py +299 -0
  56. bifacial_radiance/module.py +1427 -0
  57. bifacial_radiance/performance.py +466 -0
  58. bifacial_radiance/spectral_utils.py +555 -0
  59. bifacial_radiance-0.5.1.dist-info/METADATA +129 -0
  60. bifacial_radiance-0.5.1.dist-info/RECORD +63 -0
  61. bifacial_radiance-0.5.1.dist-info/WHEEL +6 -0
  62. bifacial_radiance-0.5.1.dist-info/licenses/LICENSE +30 -0
  63. bifacial_radiance-0.5.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1696 @@
1
+ '''
2
+ Saving and reading data from a config.ini file.
3
+ '''
4
+ import os
5
+ try:
6
+ import tkinter as tk
7
+ from tkinter import ttk
8
+ except:
9
+ import Tkinter as tk
10
+ import ttk
11
+
12
+ import bifacial_radiance
13
+ import warnings
14
+
15
+ # aliases for Tkinter functions
16
+ END = tk.END
17
+ W = tk.W
18
+ Entry = tk.Entry
19
+ Button = tk.Button
20
+ Radiobutton = tk.Radiobutton
21
+ IntVar = tk.IntVar
22
+ PhotoImage = tk.PhotoImage
23
+
24
+ #global DATA_PATH # path to data files including module.json. Global context
25
+ DATA_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), 'data'))
26
+ IMAGE_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), 'images'))
27
+ TEMP_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), 'TEMP'))
28
+
29
+ class Window(tk.Tk):
30
+ def __init__(self):
31
+ tk.Tk.__init__(self)
32
+ self.geometry("950x800")
33
+
34
+ yscroll = tk.Scrollbar(self, orient=tk.VERTICAL)
35
+ xscroll = tk.Scrollbar(self, orient=tk.HORIZONTAL)
36
+ yscroll.pack(side=tk.RIGHT, fill=tk.Y)
37
+ xscroll.pack(side=tk.BOTTOM, fill=tk.X)
38
+
39
+ self.canvas = tk.Canvas(self)
40
+ self.canvas.pack(fill=tk.BOTH, expand=True)
41
+ self.canvas['yscrollcommand'] = yscroll.set
42
+ self.canvas['xscrollcommand'] = xscroll.set
43
+ yscroll['command'] = self.canvas.yview
44
+ xscroll['command'] = self.canvas.xview
45
+
46
+ frame = tk.Frame(self.canvas)
47
+ self.canvas.create_window(4, 4, window=frame, anchor='nw') # Canvas equivalent of pack()
48
+ frame.bind("<Configure>", self._on_frame_configure)
49
+
50
+ def select_testfolder():
51
+ """ select folder to save Radiance structure to
52
+ """
53
+ msg = 'Select Folder for BifacialRadiance project'
54
+ dirname = bifacial_radiance.main._interactive_directory(msg)
55
+ entry_testfolder.delete(0, END)
56
+ entry_testfolder.insert(0, dirname)
57
+
58
+ def select_local_weatherfile():
59
+ """ select local weatherfile
60
+ """
61
+ msg = 'Select EPW or TMY .csv file'
62
+ filename = bifacial_radiance.main._interactive_load(msg)
63
+ entry_epwfile.delete(0, END)
64
+ entry_epwfile.insert(0, filename)
65
+
66
+ def select_inputvariablefile():
67
+ """ select input parameter .ini file
68
+ """
69
+ msg = 'Select simulation .ini file to save or load'
70
+
71
+ """
72
+ from tkinter import filedialog
73
+ root = tk.Tk()
74
+ root.withdraw() #Start interactive file input
75
+ root.attributes("-topmost", True) #Bring window into foreground
76
+ return filedialog.askopenfilename(parent=root, title=title) #initialdir = data_dir
77
+ """
78
+
79
+ variablefile = bifacial_radiance.main._interactive_load(msg)
80
+
81
+ entry_inputvariablefile.delete(0, END)
82
+ entry_inputvariablefile.insert(0, variablefile)
83
+ pass
84
+
85
+ def read_valuesfromGUI():
86
+ '''
87
+ List of all the variables read:
88
+
89
+ testfolder, weatherfile, weatherinputMode, simulation,
90
+ moduletype, rewriteModule, cellLevelModule, axisofrotationTorqueTube,
91
+ torqueTube, fixedortracking, cumulativesky,
92
+ selectTimes, lat, lon,
93
+ entry_starttime, entry_endtime,
94
+ numberofPanels, x, y, bifi, xgap, ygap, zgap,
95
+ GCRorPitch, gcr, pitch, albedo, nMods, nRows, azimuth, tilt,
96
+ clearanceheight, hubheight, axis_azimuth, backtrack, limitangle, angledelta,
97
+ diameter, tubeType, torqueTubeMaterial, sensorsy, modWanted, rowWanted,
98
+ numcellsx, numcellsy, xcell, ycell, xcellgap, ycellgap,
99
+
100
+
101
+ '''
102
+
103
+
104
+ testfolder, weatherfile, weatherinputMode, simulation,\
105
+ moduletype, rewriteModule, cellLevelModule, axisofrotationTorqueTube,\
106
+ torqueTube, fixedortracking, cumulativesky,\
107
+ selectTimes, lat, lon, \
108
+ endtime, starttime, \
109
+ numberofPanels, x, y, bifi, xgap, ygap, zgap, \
110
+ GCRorPitch, gcr, pitch, albedo, nMods, nRows, azimuth, tilt,\
111
+ clearanceheight, hubheight, axis_azimuth, backtrack, limitangle, angledelta,\
112
+ diameter, tubeType, torqueTubeMaterial, sensorsy, modWanted, rowWanted,\
113
+ numcellsx, numcellsy, xcell, ycell, xcellgap, ycellgap, invisible = \
114
+ None, None, None, None, None, None, None, None, None, None, \
115
+ None, None, None, None, None, None, None, None, None, None, \
116
+ None, None, None, None, None, None, None, None, None, None, \
117
+ None, None, None, None, None, None, None, None, None, None, \
118
+ None, None, None, None, None, None, None, None, None, None
119
+
120
+
121
+ try: inputvariablefile = entry_inputvariablefile.get()
122
+ except: inputvariablefile = os.path.join('data','default.ini')
123
+
124
+ # Initializing
125
+ selectTimes = False
126
+ if rb_fixedortracking.get() == 0:
127
+ fixedortracking=False # False, fixed. Fixed, Cumulative Sky Yearly
128
+ cumulativesky = True
129
+ if rb_fixedortracking.get() == 1:
130
+ fixedortracking=False # True, 'tracking' Fixed, Cumulative Sky with Start/End
131
+ cumulativesky = True
132
+ selectTimes = True #TODO: check this out. new 8/20/19
133
+ if rb_fixedortracking.get() == 2:
134
+ fixedortracking=False # True, 'tracking' Fixed, Hourly with Start/End times
135
+ cumulativesky = False
136
+ selectTimes = True
137
+ if rb_fixedortracking.get() == 3:
138
+ fixedortracking=False # True, 'tracking' Fixed, Hourly for the Whole Year
139
+ cumulativesky = False
140
+ if rb_fixedortracking.get() == 4:
141
+ fixedortracking=True # True, 'tracking' Tracking, Cumulative Sky Yearly
142
+ cumulativesky = True
143
+ if rb_fixedortracking.get() == 5:
144
+ fixedortracking=True # True, 'tracking' Tracking, Hourly with Start/End times
145
+ cumulativesky = False
146
+ selectTimes = True #TODO: check this out. new 8/20/19
147
+ if rb_fixedortracking.get() == 6:
148
+ fixedortracking=True # True, 'tracking' Tracking, Hourly for the Whole Year
149
+ cumulativesky = False
150
+
151
+ # TODO: Improve validation method.
152
+ try: albedo = entry_albedo.get() #this can either be a number or a material string
153
+ except: print("ALBEDO: Please type in a number!")
154
+ if len(entry_angledelta.get()) != 0:
155
+ angledelta = float(entry_angledelta.get())
156
+ if len(entry_axis_azimuth.get()) != 0:
157
+ axis_azimuth = float(entry_axis_azimuth.get())
158
+ if len(entry_azimuth.get()) != 0:
159
+ azimuth = float(entry_azimuth.get())
160
+ if len(entry_bifi.get()) != 0:
161
+ bifi = float( entry_bifi.get())
162
+ if len(entry_clearanceheight.get()) != 0:
163
+ clearanceheight = float(entry_clearanceheight.get())
164
+ if len(entry_diameter.get()) != 0:
165
+ diameter = float(entry_diameter.get())
166
+ if len(entry_epwfile.get()) != 0:
167
+ weatherfile = entry_epwfile.get()
168
+ if len(entry_gcr.get()) != 0:
169
+ gcr = float(entry_gcr.get())
170
+ if len(entry_getepwfileLat.get()) != 0:
171
+ lat = float(entry_getepwfileLat.get())
172
+ if len(entry_getepwfileLong.get()) != 0:
173
+ lon = float(entry_getepwfileLong.get())
174
+ if len(entry_hubheight.get()) != 0:
175
+ hubheight = float(entry_hubheight.get())
176
+ if len(entry_limitangle.get()) != 0:
177
+ limitangle = float(entry_limitangle.get())
178
+ if len(entry_moduletype.get()) != 0:
179
+ moduletype = entry_moduletype.get()
180
+ if len(entry_modWanted.get()) != 0:
181
+ modWanted = int(entry_modWanted.get())
182
+ if len(entry_nMods.get()) != 0:
183
+ nMods = int(entry_nMods.get())
184
+ if len(entry_nRows.get()) != 0:
185
+ nRows = int(entry_nRows.get())
186
+ if len(entry_numberofPanels.get()) != 0:
187
+ numberofPanels = int(entry_numberofPanels.get())
188
+ if len(entry_numcellsx.get()) != 0:
189
+ numcellsx = int(entry_numcellsx.get())
190
+ if len(entry_numcellsy.get()) != 0:
191
+ numcellsy = int(entry_numcellsy.get())
192
+ if len(entry_pitch.get()) != 0:
193
+ pitch = float(entry_pitch.get())
194
+ if len(entry_rowWanted.get()) != 0:
195
+ rowWanted = int(entry_rowWanted.get())
196
+ if len(entry_sensorsy.get()) != 0:
197
+ sensorsy = (entry_sensorsy.get())
198
+ if len(entry_simulation.get()) != 0:
199
+ simulation = entry_simulation.get()
200
+ if len(entry_testfolder.get()) != 0:
201
+ testfolder = entry_testfolder.get()
202
+ if len(entry_tilt.get()) != 0:
203
+ tilt = float(entry_tilt.get())
204
+ if len(entry_x.get()) != 0:
205
+ x = float(entry_x.get())
206
+ if len(entry_xcell.get()) != 0:
207
+ xcell = float(entry_xcell.get())
208
+ if len(entry_xcellgap.get()) != 0:
209
+ xcellgap = float(entry_xcellgap.get())
210
+ if len(entry_y.get()) != 0:
211
+ y = float(entry_y.get())
212
+ if len(entry_ycell.get()) != 0:
213
+ ycell = float(entry_ycell.get())
214
+ if len(entry_ycellgap.get()) != 0:
215
+ ycellgap = float(entry_ycellgap.get())
216
+ if len(entry_xgap.get()) != 0:
217
+ xgap = float(entry_xgap.get())
218
+ if len(entry_ygap.get()) != 0:
219
+ ygap = float(entry_ygap.get())
220
+ if len(entry_zgap.get()) != 0:
221
+ zgap = float(entry_zgap.get())
222
+
223
+
224
+ if len(entry_endtime.get()) != 0:
225
+ endtime = entry_endtime.get()
226
+ if len(entry_starttime.get()) != 0:
227
+ starttime = entry_starttime.get()
228
+
229
+
230
+ if rb_axisofrotation.get() == 0: axisofrotationTorqueTube=True
231
+ if rb_axisofrotation.get() == 1: axisofrotationTorqueTube=False
232
+
233
+ if rb_backtrack.get() == 0: backtrack=True
234
+ if rb_backtrack.get() == 1: backtrack=False
235
+
236
+ if rb_cellLevelModule.get() == 0: cellLevelModule=False
237
+ if rb_cellLevelModule.get() == 1: cellLevelModule=True
238
+
239
+
240
+
241
+
242
+ if rb_GCRorPitch.get() == 0: GCRorPitch='gcr'
243
+ if rb_GCRorPitch.get() == 1: GCRorPitch='pitch'
244
+
245
+ if rb_rewriteModule.get() == 0: rewriteModule=True
246
+ if rb_rewriteModule.get() == 1: rewriteModule=False
247
+
248
+ if rb_torqueTube.get() == 0: torqueTube=True
249
+ if rb_torqueTube.get() == 1: torqueTube=False
250
+
251
+ if rb_torqueTubeMaterial.get() == 0: torqueTubeMaterial='Metal_Grey'
252
+ if rb_torqueTubeMaterial.get() == 1: torqueTubeMaterial='black'
253
+ if rb_torqueTubeMaterial.get() == 2: invisible=True; torqueTubeMaterial='black'
254
+
255
+ if rb_tubeType.get() == 0: tubeType='round'
256
+ if rb_tubeType.get() == 1: tubeType='square'
257
+ if rb_tubeType.get() == 2: tubeType='hex'
258
+ if rb_tubeType.get() == 3: tubeType='oct'
259
+
260
+ if rb_weatherinputModule.get() == 0: weatherinputMode='True' # True gets epw
261
+ if rb_weatherinputModule.get() == 1: weatherinputMode='False' # False reads epw or TMY
262
+
263
+ #TODO: add validation for inputs depending on options selected
264
+
265
+
266
+ simulationParamsDict = {}
267
+ sceneParamsDict = {}
268
+ timeControlParamsDict = {}
269
+ trackingParamsDict = {}
270
+ torquetubeParamsDict = {}
271
+ moduleParamsDict = {}
272
+ analysisParamsDict = {}
273
+ cellModuleDict = {}
274
+
275
+ if testfolder is not None: simulationParamsDict['testfolder'] = testfolder
276
+ if weatherfile is not None: simulationParamsDict['weatherFile'] = weatherfile
277
+ if weatherinputMode is not None: simulationParamsDict['getEPW'] = weatherinputMode
278
+ if simulation is not None: simulationParamsDict['simulationname'] = simulation
279
+ if moduletype is not None: simulationParamsDict['moduletype'] = moduletype
280
+ if rewriteModule is not None: simulationParamsDict['rewriteModule'] = rewriteModule
281
+ if cellLevelModule is not None: simulationParamsDict['cellLevelModule'] = cellLevelModule
282
+ if axisofrotationTorqueTube is not None: simulationParamsDict['axisofrotationTorqueTube'] = axisofrotationTorqueTube
283
+ if torqueTube is not None: simulationParamsDict['torqueTube'] = torqueTube
284
+ simulationParamsDict['hpc'] = False #Fix
285
+ if fixedortracking is not None: simulationParamsDict['tracking'] = fixedortracking
286
+ if cumulativesky is not None: simulationParamsDict['cumulativeSky'] = cumulativesky
287
+ if selectTimes is not None: simulationParamsDict['selectTimes'] = selectTimes
288
+ if lat is not None: simulationParamsDict['latitude'] = lat
289
+ if lon is not None: simulationParamsDict['longitude'] = lon
290
+ simulationParamsDict['saveImage'] = True
291
+
292
+ if entry_starttime is not None: timeControlParamsDict['starttime'] = starttime
293
+ if entry_endtime is not None: timeControlParamsDict['endtime'] = endtime
294
+
295
+ if numberofPanels is not None: moduleParamsDict['numpanels'] = numberofPanels
296
+ if x is not None: moduleParamsDict['x'] = x
297
+ if y is not None: moduleParamsDict['y'] = y
298
+ if bifi is not None: moduleParamsDict['bifi'] = bifi
299
+ if xgap is not None: moduleParamsDict['xgap'] = xgap
300
+ if ygap is not None: moduleParamsDict['ygap'] = ygap
301
+ if zgap is not None: moduleParamsDict['zgap'] = zgap
302
+ if GCRorPitch is not None: sceneParamsDict['gcrorpitch'] = GCRorPitch
303
+ #print('gcr or pitch: {}'.format(GCRorPitch))
304
+ if GCRorPitch == 'gcr' and gcr is not None:
305
+ sceneParamsDict['gcr'] = gcr
306
+ elif pitch is not None:
307
+ sceneParamsDict['pitch'] = pitch
308
+ if albedo is not None: sceneParamsDict['albedo'] = albedo
309
+ if nMods is not None: sceneParamsDict['nMods'] = nMods
310
+ if nRows is not None: sceneParamsDict['nRows'] = nRows
311
+ if azimuth is not None: sceneParamsDict['azimuth'] = azimuth
312
+ if tilt is not None: sceneParamsDict['tilt'] = tilt
313
+ if clearanceheight is not None: sceneParamsDict['clearance_height'] = clearanceheight
314
+ if hubheight is not None: sceneParamsDict['hub_height'] = hubheight
315
+ if axis_azimuth is not None: sceneParamsDict['axis_azimuth'] = axis_azimuth
316
+
317
+ if backtrack is not None: trackingParamsDict['backtrack'] = backtrack
318
+ if limitangle is not None: trackingParamsDict['limit_angle'] = limitangle
319
+ if angledelta is not None: trackingParamsDict['angle_delta'] = angledelta
320
+
321
+ if torqueTube:
322
+ if diameter is not None: torquetubeParamsDict['diameter'] = diameter
323
+ if tubeType is not None: torquetubeParamsDict['tubetype'] = tubeType
324
+
325
+ if torqueTubeMaterial is not None: torquetubeParamsDict['material'] = torqueTubeMaterial
326
+ if invisible: torquetubeParamsDict['visible'] = False
327
+
328
+ if sensorsy is not None: analysisParamsDict['sensorsy'] = sensorsy
329
+ if modWanted is not None: analysisParamsDict['modWanted'] = modWanted
330
+ if rowWanted is not None: analysisParamsDict['rowWanted'] = rowWanted
331
+
332
+ if numcellsx is not None: cellModuleDict['numcellsx'] = numcellsx
333
+ if numcellsy is not None: cellModuleDict['numcellsy'] = numcellsy
334
+ if xcell is not None: cellModuleDict['xcell'] = xcell
335
+ if ycell is not None: cellModuleDict['ycell'] = ycell
336
+ if xcellgap is not None: cellModuleDict['xcellgap'] = xcellgap
337
+ if ycellgap is not None: cellModuleDict['ycellgap'] = ycellgap
338
+
339
+ # Creating None dictionaries for those empty ones
340
+ if timeControlParamsDict == {}:
341
+ timeControlParamsDict = None
342
+
343
+ if moduleParamsDict == {}:
344
+ moduleParamsDict = None
345
+
346
+ if trackingParamsDict == {}:
347
+ trackingParamsDict = None
348
+
349
+ if torquetubeParamsDict == {}:
350
+ torquetubeParamsDict = None
351
+
352
+ if analysisParamsDict == {}:
353
+ analysisParamsDict = None
354
+
355
+ if cellModuleDict == {}:
356
+ cellModuleDict = None
357
+
358
+ print("Read all values")
359
+ return simulationParamsDict, sceneParamsDict, timeControlParamsDict, \
360
+ moduleParamsDict, trackingParamsDict, torquetubeParamsDict, \
361
+ analysisParamsDict, cellModuleDict, inputvariablefile;
362
+
363
+ def save_inputfile(savetitle=None):
364
+
365
+ import bifacial_radiance.load
366
+
367
+ simulationParamsDict, sceneParamsDict, timeControlParamsDict, \
368
+ moduleParamsDict, trackingParamsDict, torquetubeParamsDict, \
369
+ analysisParamsDict, cellModuleDict, inputvariablefile = read_valuesfromGUI()
370
+
371
+ if savetitle is None:
372
+ savetitle = inputvariablefile
373
+
374
+ bifacial_radiance.load.savedictionariestoConfigurationIniFile(simulationParamsDict, sceneParamsDict,
375
+ timeControlParamsDict, moduleParamsDict,
376
+ trackingParamsDict, torquetubeParamsDict,
377
+ analysisParamsDict, cellModuleDict,
378
+ inifilename=savetitle)
379
+ print("Saved all Values to %s " % savetitle)
380
+
381
+
382
+ def runBifacialRadiance():
383
+ #TODO:
384
+ # Check if logic is correct. ModelChain itself saves the input values
385
+ # into a .ini file in the correct folder.
386
+
387
+ #TODO:
388
+ # Add validation that needed inputs are present?
389
+ #import bifacial_radiance.modelchain
390
+
391
+ simulationParamsDict, sceneParamsDict, timeControlParamsDict, \
392
+ moduleParamsDict, trackingParamsDict, torquetubeParamsDict, \
393
+ analysisParamsDict, cellModuleDict, inputvariablefile = read_valuesfromGUI()
394
+
395
+ #get a return out of runModelChain and pass it back out of the GUI.
396
+ self.data, analysis = bifacial_radiance.modelchain.runModelChain(simulationParamsDict=simulationParamsDict,
397
+ sceneParamsDict=sceneParamsDict,
398
+ timeControlParamsDict=timeControlParamsDict,
399
+ moduleParamsDict=moduleParamsDict,
400
+ trackingParamsDict=trackingParamsDict,
401
+ torquetubeParamsDict=torquetubeParamsDict,
402
+ analysisParamsDict=analysisParamsDict,
403
+ cellModuleDict=cellModuleDict
404
+ )
405
+
406
+ def setDefaultValues():
407
+ #TODO: read default.ini from data folder and set this automatically.
408
+ entry_albedo.insert(0,"0.62")
409
+ entry_angledelta.insert(0,"5")
410
+ entry_axis_azimuth.insert(0,"180")
411
+ entry_azimuth.insert(0,"180")
412
+ entry_clearanceheight.insert(0,"0.8")
413
+ entry_endtime.insert(0,"06_21_12")
414
+ entry_epwfile.insert(0, r"EPWs\\USA_VA_Richmond.Intl.AP.724010_TMY.epw") #FIX
415
+ entry_gcr.insert(0,"0.35")
416
+ entry_getepwfileLat.insert(0,"33")
417
+ entry_getepwfileLong.insert(0,"-110")
418
+ entry_hubheight.insert(0,"0.9")
419
+ entry_inputvariablefile.insert(0, "BB") #FIX
420
+ entry_limitangle.insert(0,"60")
421
+ entry_modWanted.insert(0,"") #was 10
422
+ entry_nMods.insert(0,"20")
423
+ entry_nRows.insert(0,"7")
424
+ entry_pitch.insert(0,"10")
425
+ entry_rowWanted.insert(0,"") #was 3
426
+ entry_sensorsy.insert(0,"10")
427
+ entry_simulation.insert(0,"Demo1")
428
+ entry_starttime.insert(0,"06_21_12")
429
+ entry_testfolder.insert(0, TEMP_PATH)
430
+ entry_tilt.insert(0,"10")
431
+
432
+ # Module parameters - populate by loading first module in module.json
433
+ """
434
+ entry_bifi.insert(0,"0.9")
435
+ entry_numberofPanels.insert(0,"2")
436
+ entry_numcellsx.insert(0,"12")
437
+ entry_numcellsy.insert(0,"6")
438
+ entry_diameter.insert(0,"0.1")
439
+ entry_x.insert(0,"0.98")
440
+ entry_xcell.insert(0,"0.15")
441
+ entry_xcellgap.insert(0,"0.01")
442
+ entry_y.insert(0,"1.98")
443
+ entry_ycell.insert(0,"0.15")
444
+ entry_ycellgap.insert(0,"0.01")
445
+ entry_xgap.insert(0,"0.05")
446
+ entry_ygap.insert(0,"0.15")
447
+ entry_zgap.insert(0,"0.10")
448
+ """
449
+
450
+
451
+
452
+ def activateAllEntries():
453
+ entry_albedo.config(state='normal')
454
+ entry_angledelta.config(state='normal')
455
+ entry_axis_azimuth.config(state='normal')
456
+ entry_azimuth.config(state='normal')
457
+ entry_bifi.config(state='normal')
458
+ entry_clearanceheight.config(state='normal')
459
+ entry_diameter.config(state='normal')
460
+ entry_endtime.config(state='normal')
461
+ entry_epwfile.config(state='normal')
462
+ entry_gcr.config(state='normal')
463
+ entry_getepwfileLat.config(state='normal')
464
+ entry_getepwfileLong.config(state='normal')
465
+ entry_hubheight.config(state='normal')
466
+ entry_inputvariablefile.config(state='normal')
467
+ entry_limitangle.config(state='normal')
468
+ entry_moduletype.config(state='normal')
469
+ entry_modWanted.config(state='normal')
470
+ entry_nMods.config(state='normal')
471
+ entry_nRows.config(state='normal')
472
+ entry_numberofPanels.config(state='normal')
473
+ entry_numcellsx.config(state='normal')
474
+ entry_numcellsy.config(state='normal')
475
+ entry_pitch.config(state='normal')
476
+ entry_rowWanted.config(state='normal')
477
+ entry_sensorsy.config(state='normal')
478
+ entry_simulation.config(state='normal')
479
+ entry_starttime.config(state='normal')
480
+ entry_testfolder.config(state='normal')
481
+ entry_tilt.config(state='normal')
482
+ entry_x.config(state='normal')
483
+ entry_xcell.config(state='normal')
484
+ entry_xcellgap.config(state='normal')
485
+ entry_y.config(state='normal')
486
+ entry_ycell.config(state='normal')
487
+ entry_ycellgap.config(state='normal')
488
+ entry_xgap.config(state='normal')
489
+ entry_ygap.config(state='normal')
490
+ entry_zgap.config(state='normal')
491
+
492
+ def read_inputfile():
493
+ r''' First it activates all entries, cleares all values,
494
+ assigns read values, and then pushes the right radio buttons in the
495
+ proper order so cells are activatd or not
496
+ '''
497
+
498
+ import bifacial_radiance.load
499
+
500
+ try: inputvariablefile = entry_inputvariablefile.get()
501
+ except: inputvariablefile = r'C:\Users\sayala\Documents\GitHub\bifacial_radiance\bifacial_radiance\data\default.ini'
502
+
503
+ #TODO: remove this file below used for developemnt
504
+ #inputvariablefile = r'C:\Users\sayala\Documents\GitHub\bifacial_radiance\bifacial_radiance\data\default.ini'
505
+
506
+ simulationParamsDict, sceneParamsDict, timeControlParamsDict, \
507
+ moduleParamsDict, trackingParamsDict, torquetubeParamsDict, \
508
+ analysisParamsDict, cellModuleDict, CECModParamsDict, \
509
+ frameParamsDict, omegaParamsDict, pilesParamsDict = bifacial_radiance.load.readconfigurationinputfile(inputvariablefile)
510
+
511
+ # TODO: above input params are unused: CECModParamsDict, frameParamsDict, omegaParamsDict, pilesParamsDict
512
+
513
+ # TODO: Think if this procedure is correct.
514
+ # readconfigurationfile already validates inputs in the configuration file.
515
+ # this just assigns it to them.
516
+ # Maybe print which inputs are being discarded because of options selected?
517
+
518
+ activateAllEntries()
519
+ clearAllValues()
520
+
521
+
522
+ #TODO: Validate empty inputs reading/entry or none dictionaries
523
+ try: entry_testfolder.insert(0,simulationParamsDict['testfolder'])
524
+ except: pass
525
+ try: entry_epwfile.insert(0,simulationParamsDict['weatherFile'])
526
+ except: pass
527
+ try: entry_getepwfileLong.insert(0,simulationParamsDict['longitude'])
528
+ except: pass
529
+ try: entry_getepwfileLat.insert(0,simulationParamsDict['latitude'])
530
+ except: pass
531
+ entry_simulation.insert(0,simulationParamsDict['simulationname'])
532
+ entry_moduletype.insert(0,simulationParamsDict['moduletype'])
533
+
534
+ #timeControlParamsDict
535
+ try: entry_starttime.insert(0,timeControlParamsDict['starttime'])
536
+ except: pass
537
+ try: entry_endtime.insert(0,timeControlParamsDict['endtime'])
538
+ except: pass
539
+
540
+ #moduleParamsDict
541
+ try: entry_numberofPanels.insert(0,moduleParamsDict['numpanels'])
542
+ except: pass
543
+ try: entry_x.insert(0,moduleParamsDict['x'])
544
+ except: pass
545
+ try: entry_y.insert(0,moduleParamsDict['y'])
546
+ except: pass
547
+ try: entry_bifi.insert(0,moduleParamsDict['bifi'])
548
+ except: pass
549
+ try: entry_xgap.insert(0,moduleParamsDict['xgap'])
550
+ except: pass
551
+ try: entry_ygap.insert(0,moduleParamsDict['ygap'])
552
+ except: pass
553
+ try: entry_zgap.insert(0,moduleParamsDict['zgap'])
554
+ except: pass
555
+
556
+ #sceneParamsDict
557
+ try: entry_gcr.insert(0,sceneParamsDict['gcr'])
558
+ except: pass
559
+ try: entry_pitch.insert(0,sceneParamsDict['pitch'])
560
+ except: pass
561
+ entry_albedo.insert(0,sceneParamsDict['albedo'])
562
+ try: entry_nMods.insert(0,sceneParamsDict['nMods'])
563
+ except: pass
564
+ try: entry_nRows.insert(0,sceneParamsDict['nRows'])
565
+ except: pass
566
+ try: entry_azimuth.insert(0,sceneParamsDict['azimuth'])
567
+ except: pass
568
+ try: entry_tilt.insert(0,sceneParamsDict['tilt'])
569
+ except: pass
570
+ try: entry_clearanceheight.insert(0,sceneParamsDict['clearance_height'])
571
+ except: pass
572
+ try: entry_hubheight.insert(0,sceneParamsDict['hub_height'])
573
+ except: pass
574
+ try: entry_axis_azimuth.insert(0,sceneParamsDict['axis_azimuth'])
575
+ except: pass
576
+
577
+ #trackingParamsDict
578
+ try: entry_angledelta.insert(0,trackingParamsDict['angle_delta'])
579
+ except: pass
580
+ try: entry_limitangle.insert(0,trackingParamsDict['limit_angle'])
581
+ except: pass
582
+ #torquetubeParamsDict
583
+ try: entry_diameter.insert(0,torquetubeParamsDict['diameter'])
584
+ except: pass
585
+
586
+ #analysisParamsDict
587
+ try: entry_sensorsy.insert(0,analysisParamsDict['sensorsy'])
588
+ except: pass
589
+ try: entry_modWanted.insert(0,analysisParamsDict['modWanted'])
590
+ except: pass
591
+ try: entry_rowWanted.insert(0,analysisParamsDict['rowWanted'])
592
+ except: pass
593
+
594
+ #cellModuleDict
595
+ try: entry_numcellsx.insert(0,cellModuleDict['numcellsx'])
596
+ except: pass
597
+ try: entry_numcellsy.insert(0,cellModuleDict['numcellsy'])
598
+ except: pass
599
+ try: entry_xcell.insert(0,cellModuleDict['xcell'])
600
+ except: pass
601
+ try: entry_xcellgap.insert(0,cellModuleDict['xcellgap'])
602
+ except: pass
603
+ try: entry_ycell.insert(0,cellModuleDict['ycell'])
604
+ except: pass
605
+ try: entry_ycellgap.insert(0,cellModuleDict['ycellgap'])
606
+ except: pass
607
+
608
+ # EPW boolean
609
+ if simulationParamsDict['getEPW']:
610
+ rad1_weatherinputModule.invoke() # get ePW activates if true
611
+ else:
612
+ rad2_weatherinputModule.invoke() # read EPW activates
613
+
614
+ if simulationParamsDict['rewriteModule']:
615
+ rad1_rewriteModule.invoke()
616
+ else:
617
+ rad2_rewriteModule.invoke()
618
+
619
+ #
620
+ if simulationParamsDict['tracking']:
621
+ if simulationParamsDict['cumulativeSky']:
622
+ rad5_fixedortracking.invoke()
623
+ else: # Hourly
624
+ if simulationParamsDict['selectTimes']:
625
+ rad7_fixedortracking.invoke()
626
+ else:
627
+ rad8_fixedortracking.invoke()
628
+ else: # fixed tilt
629
+ if simulationParamsDict['cumulativeSky']:
630
+ if simulationParamsDict['selectTimes']:
631
+ rad2_fixedortracking.invoke()
632
+ else: # full year
633
+ rad1_fixedortracking.invoke()
634
+ else:
635
+ if simulationParamsDict['selectTimes']:
636
+ rad3_fixedortracking.invoke()
637
+ else:
638
+ rad4_fixedortracking.invoke()
639
+ #if simulationParamsDict['selectTimes']:
640
+ # print("Error on simulation control. No daydate simulation option available for fixed systems. Do timestamps Range!")
641
+
642
+ # FIX THIS ONE IS NOT WORKING WHY.
643
+ if simulationParamsDict['axisofrotationTorqueTube']:
644
+ rad2_axisofrotation.invoke() # if false, rotate around panels
645
+ else:
646
+ rad1_axisofrotation.invoke() # if true, rotate around torque tube.
647
+
648
+ try:
649
+ # backtracking boolean
650
+ if trackingParamsDict['backtrack']:
651
+ rad1_backtrack.invoke()
652
+ else:
653
+ rad2_backtrack.invoke()
654
+ except: pass
655
+
656
+ # torqueTube boolean
657
+ if simulationParamsDict['torqueTube']:
658
+ rad1_torqueTube.invoke()
659
+ else:
660
+ rad2_torqueTube.invoke()
661
+
662
+ # tubeType
663
+ try:
664
+ if torquetubeParamsDict['tubetype'] == 'oct' or torquetubeParamsDict['tubetype'] == 'Oct' :
665
+ rad4_tubeType.invoke()
666
+ #rad4_tubeType.config(state='normal')
667
+ elif torquetubeParamsDict['tubetype'] == 'hex' or torquetubeParamsDict['tubetype'] == 'Hex':
668
+ rad3_tubeType.invoke()
669
+ #rad3_tubeType.config(state='normal')
670
+ elif torquetubeParamsDict['tubetype'] == 'square' or torquetubeParamsDict['tubetype'] == 'Square':
671
+ rad2_tubeType.invoke()
672
+ #rad2_tubeType.config(state='normal')
673
+ elif torquetubeParamsDict['tubetype'] == 'round' or torquetubeParamsDict['tubetype'] == 'Round':
674
+ rad1_tubeType.invoke()
675
+ #rad1_tubeType.config(state='normal')
676
+ else:
677
+ print ("wrong type of tubeType passed in input file")
678
+ except:
679
+ pass
680
+
681
+ # torqueTubeMaterial
682
+ try:
683
+ if torquetubeParamsDict['invisible'] is True:
684
+ rad3_torqueTubeMaterial.invoke()
685
+ elif torquetubeParamsDict['material'] == 'Metal_Grey':
686
+ rad1_torqueTubeMaterial.invoke()
687
+ elif torquetubeParamsDict['material'].lower() == 'black' :
688
+ rad2_torqueTubeMaterial.invoke()
689
+ else:
690
+ print ("wrong type of torquetubeMaterial passed in input file. Options: 'Metal_Grey' or 'black'")
691
+ except:
692
+ pass
693
+
694
+ # cellLevelModule boolean
695
+ if simulationParamsDict['cellLevelModule']: # If True, activate 2nd radio button.
696
+ rad2_cellLevelModule.invoke()
697
+ else:
698
+ rad1_cellLevelModule.invoke()
699
+
700
+ # gcrorpitch option
701
+ try:
702
+ if sceneParamsDict['gcrorpitch'] == 'gcr' or sceneParamsDict['gcrorpitch'] == 'GCR': # If True, activate 2nd radio button.
703
+ rad1_GCRorPitch.invoke()
704
+ elif sceneParamsDict['gcrorpitch'] == 'pitch' or sceneParamsDict['gcrorpitch'] == 'pitch':
705
+ rad2_GCRorPitch.invoke()
706
+ else:
707
+ print ("wrong type of GCR or pitch optoin on gcrorpitch in sceneParamsDict in input file. Options: 'gcr' or 'pitch'")
708
+ except:
709
+ pass
710
+
711
+ print ("Finish reading file %s " % inputvariablefile)
712
+
713
+ def setdefaultGray():
714
+ #Labels that should be inactive
715
+ epwfile_label.config(state='disabled')
716
+ startdate_label.config(state='disabled')
717
+ enddate_label.config(state='disabled')
718
+ backtrack_label.config(state='disabled')
719
+ limitangle_label.config(state='disabled')
720
+ angledelta_label.config(state='disabled')
721
+ axisofrotation_label.config(state='disabled')
722
+ numcellsx_label.config(state='disabled')
723
+ numcellsy_label.config(state='disabled')
724
+ xcell_label.config(state='disabled')
725
+ ycell_label.config(state='disabled')
726
+ xcellgap_label.config(state='disabled')
727
+ ycellgap_label.config(state='disabled')
728
+ pitch_label.config(state='disabled')
729
+ axis_azimuth_label.config(state='disabled')
730
+ hubheight_label.config(state='disabled')
731
+
732
+ #Entries that should be inactive
733
+ entry_epwfile.config(state='disabled')
734
+ entry_limitangle.config(state='disabled')
735
+ entry_angledelta.config(state='disabled')
736
+ entry_numcellsx.config(state='disabled')
737
+ entry_numcellsy.config(state='disabled')
738
+ entry_xcell.config(state='disabled')
739
+ entry_ycell.config(state='disabled')
740
+ entry_xcellgap.config(state='disabled')
741
+ entry_ycellgap.config(state='disabled')
742
+ entry_pitch.config(state='disabled')
743
+ entry_axis_azimuth.config(state='disabled')
744
+ entry_hubheight.config(state='disabled')
745
+
746
+ #buttons that should be inactive
747
+ epwfile_button.config(state='disabled')
748
+
749
+ #Radiobuttons that should be disabled
750
+ rad1_axisofrotation.config(state='disabled')
751
+ rad2_axisofrotation.config(state='disabled')
752
+ rad1_backtrack.config(state='disabled')
753
+ rad2_backtrack.config(state='disabled')
754
+
755
+
756
+ def setdefaultActive():
757
+ #Labels that should be active
758
+ getepwfile_label.config(state='normal')
759
+ azimuth_label.config(state='normal')
760
+ clearanceheight_label.config(state='normal')
761
+ x_label.config(state='normal')
762
+ y_label.config(state='normal')
763
+ gcr_label.config(state='normal')
764
+ tubeType_label.config(state='normal')
765
+ torqueTubeMaterial_label.config(state='normal')
766
+
767
+ #Radiobuttons that should be enabled
768
+ rad1_tubeType.config(state='normal')
769
+ rad2_tubeType.config(state='normal')
770
+ rad3_tubeType.config(state='normal')
771
+ rad4_tubeType.config(state='normal')
772
+ rad1_torqueTubeMaterial.config(state='normal')
773
+ rad2_torqueTubeMaterial.config(state='normal')
774
+ rad3_torqueTubeMaterial.config(state='normal')
775
+
776
+ def clearAllValues():
777
+
778
+ entry_albedo.delete(0,END)
779
+ entry_angledelta.delete(0,END)
780
+ entry_axis_azimuth.delete(0,END)
781
+ entry_azimuth.delete(0,END)
782
+ entry_bifi.delete(0,END)
783
+ entry_clearanceheight.delete(0,END)
784
+ entry_diameter.delete(0,END)
785
+ entry_endtime.delete(0,END)
786
+ entry_epwfile.delete(0,END)
787
+ entry_gcr.delete(0,END)
788
+ entry_getepwfileLat.delete(0,END)
789
+ entry_getepwfileLong.delete(0,END)
790
+ entry_hubheight.delete(0,END)
791
+ entry_inputvariablefile.delete(0,END)
792
+ entry_limitangle.delete(0,END)
793
+ entry_moduletype.delete(0,END)
794
+ entry_modWanted.delete(0,END)
795
+ entry_nMods.delete(0,END)
796
+ entry_nRows.delete(0,END)
797
+ entry_numberofPanels.delete(0,END)
798
+ entry_numcellsx.delete(0,END)
799
+ entry_numcellsy.delete(0,END)
800
+ entry_pitch.delete(0,END)
801
+ entry_rowWanted.delete(0,END)
802
+ entry_sensorsy.delete(0,END)
803
+ entry_simulation.delete(0,END)
804
+ entry_starttime.delete(0,END)
805
+ entry_testfolder.delete(0,END)
806
+ entry_tilt.delete(0,END)
807
+ entry_x.delete(0,END)
808
+ entry_xcell.delete(0,END)
809
+ entry_xcellgap.delete(0,END)
810
+ entry_y.delete(0,END)
811
+ entry_ycell.delete(0,END)
812
+ entry_ycellgap.delete(0,END)
813
+ entry_xgap.delete(0,END)
814
+ entry_ygap.delete(0,END)
815
+ entry_zgap.delete(0,END)
816
+
817
+ def setDefaults():
818
+ activateAllEntries()
819
+ clearAllValues() # enables all entries
820
+ setDefaultValues() # writes defaults to all Entries
821
+ setdefaultActive() # selected labels and radiobuttons set to "normal"
822
+
823
+ # Unselected
824
+ rad2_weatherinputModule.deselect()
825
+ rad2_tubeType.deselect()
826
+ rad3_tubeType.deselect()
827
+ rad4_tubeType.deselect()
828
+ rad2_torqueTubeMaterial.deselect()
829
+ rad3_torqueTubeMaterial.deselect()
830
+ rad2_torqueTube.deselect()
831
+ rad2_rewriteModule.deselect()
832
+ rad2_GCRorPitch.deselect()
833
+ rad2_fixedortracking.deselect()
834
+ rad3_fixedortracking.deselect()
835
+ rad4_fixedortracking.deselect()
836
+ rad5_fixedortracking.deselect()
837
+ rad7_fixedortracking.deselect()
838
+ rad8_fixedortracking.deselect()
839
+ rad2_cellLevelModule.deselect()
840
+
841
+
842
+ #Radio button Selected
843
+ rad1_weatherinputModule.invoke()
844
+ rad1_tubeType.invoke()
845
+ rad1_torqueTubeMaterial.invoke()
846
+ rad1_torqueTube.invoke()
847
+ rad1_rewriteModule.invoke()
848
+ rad1_GCRorPitch.invoke()
849
+ rad1_cellLevelModule.invoke()
850
+ rad1_fixedortracking.invoke()
851
+ #rad1_timecontrol.invoke()
852
+ # rad1_fixedortracking.invoke()
853
+ # rad1_cumulativesky.invoke()
854
+ #rad1_fixedortracking.config(state='normal')
855
+ #rad1_timecontrol.config(state='normal')
856
+ #rad1_cumulativesky.config(state='normal')
857
+
858
+
859
+
860
+ # Configure Normal radiobuttons.
861
+ rad1_weatherinputModule.config(state='normal')
862
+ rad1_tubeType.config(state='normal')
863
+ rad1_torqueTubeMaterial.config(state='normal')
864
+ rad1_torqueTube.config(state='normal')
865
+ rad1_rewriteModule.config(state='normal')
866
+ rad1_GCRorPitch.config(state='normal')
867
+ rad1_cellLevelModule.config(state='normal')
868
+
869
+
870
+ rad1_backtrack.invoke()
871
+ rad1_axisofrotation.invoke()
872
+ rad1_backtrack.config(state='normal')
873
+ rad1_axisofrotation.config(state='normal')
874
+ rad2_backtrack.deselect()
875
+ rad2_axisofrotation.deselect()
876
+ #cdeline edits
877
+ #rad1_cellLevelModule.invoke() # runs cellLevelModuleOff
878
+ #rad1_cellLevelModule.config(state='normal')
879
+ #rad2_cellLevelModule.deselect()
880
+
881
+ setdefaultGray() # gray out labels, entries and rb.
882
+
883
+ global fixedortracking
884
+ fixedortracking='fixed'
885
+
886
+ # Create all of the main containers
887
+ #Col1
888
+ maincontrol_frame = tk.Frame(frame, width=230, height=60)
889
+ simulationcontrol_frame = tk.Frame(frame, width=180, height=30)
890
+ trackingparams_frame = tk.Frame(frame, width=180, height=60)
891
+ torquetubeparams_frame = tk.Frame(frame, width=230, height=60)
892
+
893
+ #Col2
894
+ imagevariables_frame = tk.Frame(frame, width=230, height=60)
895
+ moduleparams_frame = tk.Frame(frame, width=230, height=60)
896
+ sceneparams_frame = tk.Frame(frame, width=230, height=60)
897
+ analysisparams_frame = tk.Frame(frame, width=230, height=60)
898
+
899
+
900
+
901
+ maincontrol_frame.bind("<Configure>", self._on_frame_configure)
902
+ simulationcontrol_frame.bind("<Configure>", self._on_frame_configure)
903
+ trackingparams_frame.bind("<Configure>", self._on_frame_configure)
904
+ torquetubeparams_frame.bind("<Configure>", self._on_frame_configure)
905
+ imagevariables_frame.bind("<Configure>", self._on_frame_configure)
906
+ moduleparams_frame.bind("<Configure>", self._on_frame_configure)
907
+ sceneparams_frame.bind("<Configure>", self._on_frame_configure)
908
+ analysisparams_frame.bind("<Configure>", self._on_frame_configure)
909
+
910
+
911
+ maincontrol_frame.grid(row=0, column=0, sticky="ew")
912
+ simulationcontrol_frame.grid(row=1, column=0, sticky="ew")
913
+ trackingparams_frame.grid(row=2, column=0, sticky="ew")
914
+ torquetubeparams_frame.grid(row=3, column=0, sticky="ew")
915
+
916
+ imagevariables_frame.grid(row=0, column=1, sticky="ew")
917
+ moduleparams_frame.grid(row=1, column=1, sticky="ew")
918
+ sceneparams_frame.grid(row=2, column=1, sticky="ew")
919
+ analysisparams_frame.grid(row=3, column=1, sticky="ew")
920
+
921
+
922
+ # MAIN CONTROL
923
+ ###################
924
+ # Create the widgets for the maincontrol_frame
925
+ def selGetEPW():
926
+ getepwfile_label.config(state='normal')
927
+ entry_getepwfileLat.config(state='normal')
928
+ entry_getepwfileLong.config(state='normal')
929
+ epwfile_label.config(state='disabled')
930
+ entry_epwfile.config(state='disabled')
931
+ epwfile_button.config(state='disabled')
932
+ def selReadEPW():
933
+ getepwfile_label.config(state='disabled')
934
+ entry_getepwfileLat.config(state='disabled')
935
+ entry_getepwfileLong.config(state='disabled')
936
+ epwfile_label.config(state='normal')
937
+ entry_epwfile.config(state='normal')
938
+ epwfile_button.config(state='normal')
939
+
940
+ maincontrol_label = ttk.Label(maincontrol_frame, background='lavender', text='Main Control', font=("Arial Bold", 15))
941
+ maincontrol_label.grid(row = 0)
942
+ inputvariablefile_label = ttk.Label(maincontrol_frame, background='orange', text='Input Variables File:')
943
+ inputvariablefile_label.grid(row = 1, sticky=W)
944
+ entry_inputvariablefile = Entry(maincontrol_frame, background="orange")
945
+ entry_inputvariablefile.grid(row=1, column=1)
946
+ inputvariablefile_button = Button(maincontrol_frame, width=10, text="Search", command=select_inputvariablefile)
947
+ inputvariablefile_button.grid(column=2, row=1, sticky= W)
948
+
949
+ inputfileRead_button = Button(maincontrol_frame, text="READ", command=read_inputfile)
950
+ inputfileRead_button.grid(column=0, row=2)
951
+ inputfileSave_button = Button(maincontrol_frame, text="SAVE", command=save_inputfile)
952
+ inputfileSave_button.grid(column=1, row=2)
953
+ testfolder_label = ttk.Label(maincontrol_frame, background='lavender', text='TestFolder:')
954
+ testfolder_label.grid(row = 3, sticky = W)
955
+ entry_testfolder = Entry(maincontrol_frame, background="pink")
956
+ entry_testfolder.grid(row=3, column=1)
957
+ testfolder_button = Button(maincontrol_frame, width=10, text="Search", command=select_testfolder)
958
+ testfolder_button.grid(column=2, row=3, sticky= W)
959
+
960
+
961
+ rb_weatherinputModule=IntVar()
962
+ rad1_weatherinputModule = ttk.Label(maincontrol_frame, background='lavender', text='WeatherFile Input:')
963
+ rad1_weatherinputModule.grid(row = 4, sticky=W)
964
+ rad1_weatherinputModule = Radiobutton(maincontrol_frame,background='lavender', variable=rb_weatherinputModule, text='GetEPW', value=0, command=selGetEPW)
965
+ rad2_weatherinputModule = Radiobutton(maincontrol_frame,background='lavender', variable=rb_weatherinputModule, text='ReadEPW / TMY', value=1, command=selReadEPW)
966
+ rad1_weatherinputModule.grid(column=1, row=4)
967
+ rad2_weatherinputModule.grid(column=2, row=4)
968
+ getepwfile_label = ttk.Label(maincontrol_frame, background='lavender', text='Get EPW (Lat/Lon):')
969
+ getepwfile_label.grid(row = 5, sticky=W)
970
+ entry_getepwfileLat = Entry(maincontrol_frame, background="white")
971
+ entry_getepwfileLat.grid(row=5, column=1)
972
+ #entry_getepwfileLat.insert(5,"33")
973
+ entry_getepwfileLong = Entry(maincontrol_frame, background="white")
974
+ entry_getepwfileLong.grid(row=5, column=2)
975
+ epwfile_label = ttk.Label(maincontrol_frame, background='lavender', text='EPW / TMY File:', state='disabled')
976
+ epwfile_label.grid(row = 6, sticky=W)
977
+ entry_epwfile = Entry(maincontrol_frame, background="white", state='disabled')
978
+ entry_epwfile.grid(row=6, column=1)
979
+ epwfile_button = Button(maincontrol_frame, state='disabled', width=10, text="Search", command=select_local_weatherfile)
980
+ epwfile_button.grid(column=2, row=6, sticky= W)
981
+
982
+ simulation_label = ttk.Label(maincontrol_frame, background='lavender', text='Simulation Name:')
983
+ simulation_label.grid(row = 7, sticky=W)
984
+ entry_simulation = Entry(maincontrol_frame, background="white")
985
+ entry_simulation.grid(row=7, column=1)
986
+
987
+ # customModule_label = ttk.Label(maincontrol_frame, background='lavender', text='Create Custom Module:')
988
+ # customModule_label.grid(row = 9, sticky=W)
989
+ # rb_customModule=IntVar()
990
+ # rad1_customModule = Radiobutton(maincontrol_frame,background='lavender', variable=rb_customModule, text='True', value=0)
991
+ # rad2_customModule = Radiobutton(maincontrol_frame,background='lavender', variable=rb_customModule, text='False', value=1)
992
+
993
+
994
+
995
+ # Simulation CONTROL
996
+ ###################
997
+
998
+ def selfixed():
999
+ global fixedortracking
1000
+ fixedortracking='fixed'
1001
+
1002
+ buttonImage.configure(image=image_fixed)
1003
+
1004
+ azimuth_label.config(state='normal')
1005
+ entry_azimuth.config(state='normal')
1006
+ clearanceheight_label.config(state='normal')
1007
+ entry_clearanceheight.config(state='normal')
1008
+ tilt_label.config(state='normal')
1009
+ entry_tilt.config(state='normal')
1010
+
1011
+ axis_azimuth_label.config(state='disabled')
1012
+ entry_axis_azimuth.config(state='disabled')
1013
+ hubheight_label.config(state='disabled')
1014
+ entry_hubheight.config(state='disabled')
1015
+
1016
+ backtrack_label.config(state='disabled')
1017
+ rad1_backtrack.config(state='disabled')
1018
+ rad2_backtrack.config(state='disabled')
1019
+ limitangle_label.config(state='disabled')
1020
+ entry_limitangle.config(state='disabled')
1021
+ angledelta_label.config(state='disabled')
1022
+ entry_angledelta.config(state='disabled')
1023
+
1024
+ axisofrotation_label.config(state='disabled')
1025
+ rad1_axisofrotation.config(state='disabled')
1026
+ rad2_axisofrotation.config(state='disabled')
1027
+
1028
+
1029
+ def selHSAT():
1030
+ global fixedortracking
1031
+ fixedortracking='tracking'
1032
+ buttonImage.configure(image=image_tracked)
1033
+
1034
+ azimuth_label.config(state='disabled')
1035
+ entry_azimuth.config(state='disabled')
1036
+ clearanceheight_label.config(state='disabled')
1037
+ entry_clearanceheight.config(state='disabled')
1038
+ tilt_label.config(state='disabled')
1039
+ entry_tilt.config(state='disabled')
1040
+
1041
+ axis_azimuth_label.config(state='normal')
1042
+ entry_axis_azimuth.config(state='normal')
1043
+ hubheight_label.config(state='normal')
1044
+ entry_hubheight.config(state='normal')
1045
+
1046
+ backtrack_label.config(state='normal')
1047
+ rad1_backtrack.config(state='normal')
1048
+ rad2_backtrack.config(state='normal')
1049
+ limitangle_label.config(state='normal')
1050
+ entry_limitangle.config(state='normal')
1051
+ angledelta_label.config(state='normal')
1052
+ entry_angledelta.config(state='normal')
1053
+
1054
+ axisofrotation_label.config(state='normal')
1055
+ rad1_axisofrotation.config(state='normal')
1056
+ rad2_axisofrotation.config(state='normal')
1057
+
1058
+ def tcAll():
1059
+ startdate_label.config(state='disabled')
1060
+ enddate_label.config(state='disabled')
1061
+ entry_starttime.config(state='disabled')
1062
+ entry_endtime.config(state='disabled')
1063
+
1064
+ def tcStartEndDate():
1065
+ startdate_label.config(state='normal')
1066
+ enddate_label.config(state='normal')
1067
+ entry_starttime.config(state='normal')
1068
+ entry_endtime.config(state='normal')
1069
+
1070
+ # Fixed, Cumulative Sky Yearly
1071
+ def tcOne():
1072
+ selfixed()
1073
+ tcAll()
1074
+
1075
+ # Fixed, cUmulative Sky with STart/End times
1076
+ def tcTwo():
1077
+ selfixed()
1078
+ tcStartEndDate()
1079
+
1080
+ # Fixed, Hourly by Tiestamps:
1081
+ def tcThree():
1082
+ selfixed()
1083
+ tcStartEndDate()
1084
+
1085
+ # Fixed, Hourly for the whole Year:
1086
+ def tcFour():
1087
+ selfixed()
1088
+ tcAll()
1089
+
1090
+ # Tracking, Cumulative sky Yearly
1091
+ def tcFive():
1092
+ selHSAT()
1093
+ tcAll()
1094
+
1095
+ # Tracking, Hourly for a Day
1096
+ def tcSix():
1097
+ selHSAT()
1098
+
1099
+ # Tracking, Hourly with STart/End Times
1100
+ def tcSeven():
1101
+ selHSAT()
1102
+ tcStartEndDate()
1103
+
1104
+ def tcEight():
1105
+ selHSAT()
1106
+ tcAll()
1107
+
1108
+ simulationcontrol_label = ttk.Label(simulationcontrol_frame, text='Simulation Control', font=("Arial Bold", 15))
1109
+ simulationcontrol_label.grid(row = 0, columnspan=2, sticky=W)
1110
+ rb_fixedortracking=IntVar()
1111
+ rad1_fixedortracking = Radiobutton(simulationcontrol_frame, variable=rb_fixedortracking, indicatoron = 0, width = 50, text='Fixed, Cumulative Sky Yearly', value=0, command=tcOne)
1112
+ rad2_fixedortracking = Radiobutton(simulationcontrol_frame, variable=rb_fixedortracking, indicatoron = 0, width = 50, text='Fixed, Cumulative Sky with Start/End times', value=1, command=tcTwo)
1113
+ rad3_fixedortracking = Radiobutton(simulationcontrol_frame, variable=rb_fixedortracking, indicatoron = 0, width = 50, text='Fixed, Hourly with Start/End times', value=2, command=tcThree) #text='Fixed, Hourly by Timestamps'
1114
+ rad4_fixedortracking = Radiobutton(simulationcontrol_frame, variable=rb_fixedortracking, indicatoron = 0, width = 50, text='Fixed, Hourly for the Whole Year', value=3, command=tcFour)
1115
+ rad5_fixedortracking = Radiobutton(simulationcontrol_frame, variable=rb_fixedortracking, indicatoron = 0, width = 50, text='Tracking, Cumulative Sky Yearly', value=4, command=tcFive)
1116
+ rad7_fixedortracking = Radiobutton(simulationcontrol_frame, variable=rb_fixedortracking, indicatoron = 0, width = 50, text='Tracking, Hourly with Start/End times', value=5, command=tcSeven)
1117
+ rad8_fixedortracking = Radiobutton(simulationcontrol_frame, variable=rb_fixedortracking, indicatoron = 0, width = 50, text='Tracking, Hourly for the Whole Year', value=6, command=tcEight)
1118
+ rad1_fixedortracking.grid(column=0, row=1, columnspan=3)
1119
+ rad2_fixedortracking.grid(column=0, row=2, columnspan=3)
1120
+ rad3_fixedortracking.grid(column=0, row=3, columnspan=3)
1121
+ rad4_fixedortracking.grid(column=0, row=4, columnspan=3)
1122
+ rad5_fixedortracking.grid(column=0, row=5, columnspan=3)
1123
+ rad7_fixedortracking.grid(column=0, row=6, columnspan=3)
1124
+ rad8_fixedortracking.grid(column=0, row=7, columnspan=3)
1125
+
1126
+ # Time CONTROL
1127
+ ###################
1128
+
1129
+ startdate_label = ttk.Label(simulationcontrol_frame, state='disabled', text='Start time ( mm_dd_HH or YYYY-mm-dd_HHMM ):')
1130
+ startdate_label.grid(row = 10, column=0, sticky = W, columnspan=2)
1131
+ entry_starttime = Entry(simulationcontrol_frame, state='disabled', background="white")
1132
+ entry_starttime.grid(row=10, column=2, sticky = W, columnspan=1)
1133
+
1134
+ enddate_label = ttk.Label(simulationcontrol_frame, state='disabled', text='End time ( mm_dd_HH or mm_dd_HH_MM):')
1135
+ enddate_label.grid(row= 11, column=0, sticky = W, columnspan=2)
1136
+ entry_endtime = Entry(simulationcontrol_frame, state='disabled', background="white")
1137
+ entry_endtime.grid(row=11, column=2, sticky = W, columnspan=1)
1138
+
1139
+ # Tracking Parameters
1140
+ ###################
1141
+
1142
+ def backtrackOn():
1143
+ rb_backtrack=0
1144
+
1145
+ def backtrackOff():
1146
+ rb_backtrack=1
1147
+
1148
+ trackingcontrol_label = ttk.Label(trackingparams_frame, text='Tracking Parameters', font=("Arial Bold", 15))
1149
+ trackingcontrol_label.grid(row = 0, columnspan=2, sticky=W)
1150
+ backtrack_label = ttk.Label(trackingparams_frame, state='disabled', text='Backtrack:')
1151
+ backtrack_label.grid(row=1, column=0, sticky = W)
1152
+ rb_backtrack=IntVar()
1153
+ rad1_backtrack = Radiobutton(trackingparams_frame, state='disabled', variable=rb_backtrack, text='True', value=0, command=backtrackOn)
1154
+ rad2_backtrack = Radiobutton(trackingparams_frame, state='disabled', variable=rb_backtrack, text='False', value=1, command=backtrackOff)
1155
+ rad1_backtrack.grid(column=1, row=1, sticky = W)
1156
+ rad2_backtrack.grid(column=2, row=1, sticky = W)
1157
+ limitangle_label = ttk.Label(trackingparams_frame, state='disabled', text='Limit Angle (deg):')
1158
+ limitangle_label.grid(row=2, column=0, sticky = W)
1159
+ entry_limitangle = Entry(trackingparams_frame, state='disabled', background="white")
1160
+ entry_limitangle.grid(row=2, column=1, columnspan=2, sticky = W)
1161
+ angledelta_label = ttk.Label(trackingparams_frame, state='disabled', text='Angle delta (deg):')
1162
+ angledelta_label.grid(row=4, column=0, sticky = W)
1163
+ entry_angledelta = Entry(trackingparams_frame, state='disabled', background="white")
1164
+ entry_angledelta.grid(row=4, column=1, columnspan=2)
1165
+
1166
+ axisofrotation_label = ttk.Label(trackingparams_frame, state='disabled', text='Axis of Rotation:')
1167
+ axisofrotation_label.grid(row=5, column=0, sticky = W)
1168
+ rb_axisofrotation=IntVar()
1169
+ rad1_axisofrotation = Radiobutton(trackingparams_frame, variable=rb_axisofrotation, state='disabled', text='Torque Tube', value=0)
1170
+ rad2_axisofrotation = Radiobutton(trackingparams_frame, width = 8, variable=rb_axisofrotation, state='disabled', text='Panels', value=1)
1171
+ rad1_axisofrotation.grid(row=5, column=1, sticky = W)
1172
+ rad2_axisofrotation.grid(row=5, column=2, sticky = W)
1173
+
1174
+
1175
+ # TorqueTube Parameters
1176
+ ###################
1177
+
1178
+ def torquetubeTrue():
1179
+ tubeType_label.config(state='normal')
1180
+ rad1_tubeType.config(state='normal')
1181
+ rad2_tubeType.config(state='normal')
1182
+ rad3_tubeType.config(state='normal')
1183
+ rad4_tubeType.config(state='normal')
1184
+ torqueTubeMaterial_label.config(state='normal')
1185
+ rad1_torqueTubeMaterial.config(state='normal')
1186
+ rad2_torqueTubeMaterial.config(state='normal')
1187
+ rad3_torqueTubeMaterial.config(state='normal')
1188
+ entry_diameter.config(state='normal')
1189
+
1190
+
1191
+ def torquetubeFalse():
1192
+ tubeType_label.config(state='disabled')
1193
+ rad1_tubeType.config(state='disabled')
1194
+ rad2_tubeType.config(state='disabled')
1195
+ rad3_tubeType.config(state='disabled')
1196
+ rad4_tubeType.config(state='disabled')
1197
+ torqueTubeMaterial_label.config(state='disabled')
1198
+ rad1_torqueTubeMaterial.config(state='disabled')
1199
+ rad2_torqueTubeMaterial.config(state='disabled')
1200
+ rad3_torqueTubeMaterial.config(state='disabled')
1201
+ entry_diameter.delete(0,END)
1202
+ entry_diameter.config(state='disabled')
1203
+
1204
+
1205
+ torquetubecontrol_label = ttk.Label(torquetubeparams_frame, text='TorqueTube Parameters', font=("Arial Bold", 15))
1206
+ torquetubecontrol_label.grid(row = 0, columnspan=3, sticky=W)
1207
+ torqueTube_label = ttk.Label(torquetubeparams_frame, text='TorqueTube:')
1208
+ torqueTube_label.grid(row=1, column=0, sticky = W)
1209
+ rb_torqueTube=IntVar()
1210
+ rad1_torqueTube = Radiobutton(torquetubeparams_frame, indicatoron = 0, width = 10, variable=rb_torqueTube, text='True', value=0, command=torquetubeTrue)
1211
+ rad2_torqueTube = Radiobutton(torquetubeparams_frame, indicatoron = 0, width = 10, variable=rb_torqueTube, text='False', value=1, command=torquetubeFalse)
1212
+ rad1_torqueTube.grid(column=1, row=1, sticky = W)
1213
+ rad2_torqueTube.grid(column=2, row=1, sticky = W)
1214
+ diameter_label = ttk.Label(torquetubeparams_frame, text='Diameter:')
1215
+ diameter_label.grid(row=2, column=0, sticky = W)
1216
+ entry_diameter = Entry(torquetubeparams_frame, width = 12, background="white")
1217
+ entry_diameter.grid(row=2, column=1, sticky = W)
1218
+ tubeType_label = ttk.Label(torquetubeparams_frame, text='Tube type:')
1219
+ tubeType_label.grid(row=3, column=0, sticky = W)
1220
+ rb_tubeType=IntVar()
1221
+ rad1_tubeType = Radiobutton(torquetubeparams_frame, variable=rb_tubeType, text='Round', value=0)
1222
+ rad2_tubeType = Radiobutton(torquetubeparams_frame, variable=rb_tubeType, text='Square', value=1)
1223
+ rad3_tubeType = Radiobutton(torquetubeparams_frame, width = 5, variable=rb_tubeType, text='Hex', value=2)
1224
+ rad4_tubeType = Radiobutton(torquetubeparams_frame, width = 5, variable=rb_tubeType, text='Oct', value=3)
1225
+ rad1_tubeType.grid(column=1, row=3, sticky = W)
1226
+ rad2_tubeType.grid(column=2, row=3, sticky = W)
1227
+ rad3_tubeType.grid(column=3, row=3, sticky = W)
1228
+ rad4_tubeType.grid(column=4, row=3, sticky = W)
1229
+ rb_torqueTubeMaterial=IntVar()
1230
+ torqueTubeMaterial_label = ttk.Label(torquetubeparams_frame, text='TorqueTube Material:')
1231
+ torqueTubeMaterial_label.grid(column=0, row=4, sticky = W)
1232
+ rad1_torqueTubeMaterial = Radiobutton(torquetubeparams_frame, variable=rb_torqueTubeMaterial, text='Metal_Grey', value=0)
1233
+ rad2_torqueTubeMaterial = Radiobutton(torquetubeparams_frame, variable=rb_torqueTubeMaterial, text='Black', value=1)
1234
+ rad3_torqueTubeMaterial = Radiobutton(torquetubeparams_frame, variable=rb_torqueTubeMaterial, text='Invisible', value=2)
1235
+ rad1_torqueTubeMaterial.grid(column=1, row = 4, sticky = W)
1236
+ rad2_torqueTubeMaterial.grid(column=2, row = 4, sticky = W)
1237
+ rad3_torqueTubeMaterial.grid(column=3, row = 4, sticky = W)
1238
+
1239
+ # MODULE PARAMETERS Parameters
1240
+ ###################
1241
+
1242
+ def cellLevelModuleOn():
1243
+ numcellsx_label.config(state='normal')
1244
+ entry_numcellsx.config(state='normal')
1245
+ numcellsy_label.config(state='normal')
1246
+ entry_numcellsy.config(state='normal')
1247
+ xcell_label.config(state='normal')
1248
+ entry_xcell.config(state='normal')
1249
+ ycell_label.config(state='normal')
1250
+ entry_ycell.config(state='normal')
1251
+ xcellgap_label.config(state='normal')
1252
+ entry_xcellgap.config(state='normal')
1253
+ ycellgap_label.config(state='normal')
1254
+ entry_ycellgap.config(state='normal')
1255
+ x_label.config(state='disabled')
1256
+ y_label.config(state='disabled')
1257
+ entry_x.config(state='disabled')
1258
+ entry_y.config(state='disabled')
1259
+
1260
+ def cellLevelModuleOff():
1261
+ numcellsx_label.config(state='disabled')
1262
+ entry_numcellsx.config(state='disabled')
1263
+ numcellsy_label.config(state='disabled')
1264
+ entry_numcellsy.config(state='disabled')
1265
+ xcell_label.config(state='disabled')
1266
+ entry_xcell.config(state='disabled')
1267
+ ycell_label.config(state='disabled')
1268
+ entry_ycell.config(state='disabled')
1269
+ xcellgap_label.config(state='disabled')
1270
+ entry_xcellgap.config(state='disabled')
1271
+ ycellgap_label.config(state='disabled')
1272
+ entry_ycellgap.config(state='disabled')
1273
+ x_label.config(state='normal')
1274
+ y_label.config(state='normal')
1275
+ entry_x.config(state='normal')
1276
+ entry_y.config(state='normal')
1277
+
1278
+ def getModuleJSONlist():
1279
+ """ populate entry_modulename with module names from module.json
1280
+ """
1281
+ import json
1282
+ jsonfile = os.path.join(DATA_PATH,'module.json')
1283
+ with open(jsonfile) as configfile:
1284
+ jsondata = json.load(configfile)
1285
+
1286
+ systemtuple = ('',)
1287
+ for key in jsondata.keys():
1288
+ systemtuple = systemtuple + (str(key),) #build the tuple of strings
1289
+ entry_modulename['values'] = systemtuple[1:]
1290
+ entry_modulename.current(0)
1291
+ self.jsondata = jsondata
1292
+
1293
+ def showModule(noprint=False):
1294
+ """ run objview to show view of a module
1295
+ create a temp module based on GUI parameters
1296
+ input: noprint (boolean) suppress module printing
1297
+ """
1298
+ #simulationParamsDict, sceneParamsDict, timeControlParamsDict, \
1299
+ #moduleParamsDict, trackingParamsDict, torquetubeParamsDict, \
1300
+ #analysisParamsDict, cellModuleDict,_
1301
+ P = read_valuesfromGUI()
1302
+ #simDict = P[0]; modDict = P[3]; tubeDict = P[5]
1303
+ if P[3] is None:
1304
+ print('Empty module dictionary - returning')
1305
+ return
1306
+
1307
+ moduletype = 'test-module'
1308
+ print('Creating test module')
1309
+
1310
+ # need to first create a dummy SceneObj to create the module .rad
1311
+ # file in TEMP_PATH
1312
+ demo = bifacial_radiance.RadianceObj(path = TEMP_PATH)
1313
+
1314
+ # create the kwargs for makeModule
1315
+ cellModuleParams = (P[7] if P[0]['cellLevelModule'] else None)
1316
+ kwargs = {'name':moduletype, 'numpanels':P[3]['numpanels'],
1317
+ 'x':P[3]['x'],'y':P[3]['y'], 'xgap':P[3]['xgap'],
1318
+ 'ygap':P[3]['ygap'],'zgap':P[3]['zgap']}
1319
+
1320
+ # Run makeModule with the above kwarg dictionary
1321
+ module = demo.makeModule(**kwargs)
1322
+ if cellModuleParams: module.addCellModule(**cellModuleParams)
1323
+ if P[5]:
1324
+ print(f'P5: {P[5]}')
1325
+ module.addTorquetube(**P[5])
1326
+
1327
+ if noprint is False:
1328
+ # show module
1329
+ module.showModule()
1330
+
1331
+ return demo
1332
+
1333
+
1334
+ def showScene():
1335
+ """ run objview to show view of a scene
1336
+ create a temp scene based on GUI parameters
1337
+ """
1338
+
1339
+ # first create the module given the current conditions of the GUI
1340
+ demo = showModule(noprint = True)
1341
+ moduletype = demo.module.name
1342
+
1343
+ # read in the GUI values
1344
+ #simulationParamsDict, sceneParamsDict, timeControlParamsDict, \
1345
+ #moduleParamsDict, trackingParamsDict, torquetubeParamsDict, \
1346
+ #analysisParamsDict, cellModuleDict,_
1347
+ P = read_valuesfromGUI()
1348
+
1349
+ # Case: tracking scenario
1350
+ if P[0]['tracking'] is True:
1351
+ print('Rendering tracker scene at 0 (noon) tilt')
1352
+ # assume 0 tilt
1353
+ key = '01_01_12'
1354
+ trackerdict = {key: {'surf_azm':P[1]['axis_azimuth']+90,
1355
+ 'surf_tilt': 0.0, 'theta':0, 'ghi':999} }
1356
+
1357
+ trackerdict = demo.makeScene1axis(trackerdict,
1358
+ sceneDict = P[1],
1359
+ cumulativesky=False,
1360
+ module=moduletype)
1361
+ scene = trackerdict[key]['scene']
1362
+ else: # fixed tilt scenario
1363
+ scene = demo.makeScene(module=moduletype, sceneDict=P[1])
1364
+
1365
+ scene.showScene()
1366
+
1367
+ def modulenamecallbackFunc(event):
1368
+ """ load specific module data from module.json after new module selected
1369
+ """
1370
+
1371
+ def enable_torquetube(d):
1372
+ """ torque tube details are enabled
1373
+ """
1374
+ rad1_torqueTube.invoke() # torquetube True button
1375
+ entry_diameter.delete(0,END) # torque tube diameter
1376
+ entry_diameter.insert(0,str(d['torquetube']['diameter']))
1377
+ #tubetype. 'round', square, hex, oct
1378
+ tubeoptions= {'round':rad1_tubeType.invoke,
1379
+ 'square':rad2_tubeType.invoke,
1380
+ 'hex':rad3_tubeType.invoke,
1381
+ 'oct':rad4_tubeType.invoke}
1382
+ tubeoptions.get(d['torquetube']['tubetype'].lower())
1383
+
1384
+ #material. 'Metal_Grey' or 'Black'
1385
+ if d['torquetube']['visible'] is False:
1386
+ rad3_torqueTubeMaterial.invoke()
1387
+ elif d['torquetube']['material'].lower() == 'black':
1388
+ rad2_torqueTubeMaterial.invoke()
1389
+ else:
1390
+ rad1_torqueTubeMaterial.invoke()
1391
+
1392
+ def disable_torquetube(d):
1393
+ """ torque tube details are disabled
1394
+ """
1395
+ rad2_torqueTube.invoke() # torquetube False button
1396
+ entry_diameter.delete(0,END)
1397
+ #if 'torquetube' in d:
1398
+ #entry_diameter.insert(0,str(d['torquetube']['diameter']))
1399
+
1400
+ def enable_cellModule(d):
1401
+ """cellModule parameters passed
1402
+ """
1403
+ rad2_cellLevelModule.invoke()
1404
+ # clear cellLevelModule entries loaded from json
1405
+ entry_numcellsx.delete(0,END)
1406
+ entry_numcellsy.delete(0,END)
1407
+ entry_xcell.delete(0,END)
1408
+ entry_ycell.delete(0,END)
1409
+ entry_xcellgap.delete(0,END)
1410
+ entry_ycellgap.delete(0,END)
1411
+
1412
+ # set module entries loaded from json
1413
+ entry_numcellsx.insert(0,str(d['cellModule']['numcellsx']))
1414
+ entry_numcellsy.insert(0,str(d['cellModule']['numcellsy']))
1415
+ entry_xcell.insert(0,str(d['cellModule']['xcell']))
1416
+ entry_ycell.insert(0,str(d['cellModule']['ycell']))
1417
+ entry_xcellgap.insert(0,str(d['cellModule']['xcellgap']))
1418
+ entry_ycellgap.insert(0,str(d['cellModule']['ycellgap']))
1419
+
1420
+
1421
+
1422
+ key = entry_modulename_value.get() # what is the value selected?
1423
+ #print(key + ' selected')
1424
+ if key != '': # '' not a dict key
1425
+ #print(self.jsondata[key])
1426
+ d = self.jsondata[key]
1427
+ self.moduletype = key
1428
+ # set radio buttons
1429
+ rad1_cellLevelModule.invoke() # non cell-level modules by default
1430
+ rad2_rewriteModule.invoke()
1431
+
1432
+ # clear module entries loaded from json
1433
+ entry_moduletype.delete(0,END)
1434
+ entry_numberofPanels.delete(0,END)
1435
+ entry_x.delete(0,END)
1436
+ entry_y.delete(0,END)
1437
+ entry_bifi.delete(0,END)
1438
+ entry_xgap.delete(0,END)
1439
+ entry_ygap.delete(0,END)
1440
+ entry_zgap.delete(0,END)
1441
+
1442
+ # set module entries loaded from json
1443
+ entry_moduletype.insert(0,key)
1444
+ entry_numberofPanels.insert(0,str(d['numpanels']))
1445
+ entry_x.insert(0,str(d['x']))
1446
+ entry_y.insert(0,str(d['y']))
1447
+ entry_bifi.insert(0,str(d['bifi']))
1448
+ entry_xgap.insert(0,str(d['xgap']))
1449
+ entry_ygap.insert(0,str(d['ygap']))
1450
+ entry_zgap.insert(0,str(d['zgap']))
1451
+
1452
+ # Torque tube details from json
1453
+ tubebool = d.get('torquetube')
1454
+ if tubebool:
1455
+ enable_torquetube(d)
1456
+ else:
1457
+ disable_torquetube(d)
1458
+ # cellModule details from json
1459
+ cellbool = d.get('cellModule')
1460
+ if cellbool:
1461
+ enable_cellModule(d)
1462
+
1463
+ moduleparams_label = ttk.Label(moduleparams_frame, text='Module Parameters', font=("Arial Bold", 15))
1464
+ moduleparams_label.grid(row = 0, columnspan=3, sticky=W)
1465
+
1466
+ entry_modulename_value = tk.StringVar()
1467
+ entry_modulename = ttk.Combobox(moduleparams_frame, textvariable=entry_modulename_value)
1468
+ entry_modulename.grid(row=0, column=2, sticky = W, columnspan=2)
1469
+ getModuleJSONlist() #set the module name values
1470
+ entry_modulename.bind("<<ComboboxSelected>>", modulenamecallbackFunc)
1471
+
1472
+ numberofPanels_label = ttk.Label(moduleparams_frame, text='Number of Panels')
1473
+ numberofPanels_label.grid(row=1, column=0, sticky = W)
1474
+ entry_numberofPanels = Entry(moduleparams_frame, width = 4)
1475
+ entry_numberofPanels.grid(row=1, column=1, sticky = W)
1476
+ cellLevelModule_label = ttk.Label(moduleparams_frame, text='Cell Level Module')
1477
+ cellLevelModule_label.grid(row=2, column=0, sticky = W)
1478
+ rb_cellLevelModule=IntVar()
1479
+ rad1_cellLevelModule = Radiobutton(moduleparams_frame, indicatoron = 0, width = 8, variable=rb_cellLevelModule, text='False', value=0, command=cellLevelModuleOff)
1480
+ rad2_cellLevelModule = Radiobutton(moduleparams_frame, indicatoron = 0, width = 8, variable=rb_cellLevelModule, text='True', value=1, command=cellLevelModuleOn)
1481
+ rad1_cellLevelModule.grid(column=1, row=2, sticky = W)
1482
+ rad2_cellLevelModule.grid(column=2, row=2, sticky = W)
1483
+
1484
+ numcellsx_label = ttk.Label(moduleparams_frame, state='disabled', text='numcells x:')
1485
+ numcellsx_label.grid(row=3, column=0, sticky = W)
1486
+ entry_numcellsx = Entry(moduleparams_frame, state='disabled', width = 6)
1487
+ entry_numcellsx.grid(row=3, column=1, sticky = W)
1488
+ numcellsy_label = ttk.Label(moduleparams_frame, state='disabled', text='numcells y:')
1489
+ numcellsy_label.grid(row=3, column=2, sticky = W)
1490
+ entry_numcellsy = Entry(moduleparams_frame, state='disabled', width = 6)
1491
+ entry_numcellsy.grid(row=3, column=3, sticky = W)
1492
+
1493
+ xcell_label = ttk.Label(moduleparams_frame, state='disabled', text='Size Xcell:')
1494
+ xcell_label.grid(row=4, column=0, sticky = W)
1495
+ entry_xcell = Entry(moduleparams_frame, state='disabled', width = 6)
1496
+ entry_xcell.grid(row=4, column=1, sticky = W)
1497
+ ycell_label = ttk.Label(moduleparams_frame, state='disabled', text='Size Ycell:')
1498
+ ycell_label.grid(row=4, column=2, sticky = W)
1499
+ entry_ycell = Entry(moduleparams_frame, state='disabled', width = 6)
1500
+ entry_ycell.grid(row=4, column=3, sticky = W)
1501
+
1502
+ xcellgap_label = ttk.Label(moduleparams_frame, state='disabled', text='Xcell gap:')
1503
+ xcellgap_label.grid(row=5, column=0, sticky = W)
1504
+ entry_xcellgap = Entry(moduleparams_frame, state='disabled', width = 6)
1505
+ entry_xcellgap.grid(row=5, column=1, sticky = W)
1506
+ ycellgap_label = ttk.Label(moduleparams_frame, state='disabled', text='Ycell gap:')
1507
+ ycellgap_label.grid(row=5, column=2, sticky = W)
1508
+ entry_ycellgap = Entry(moduleparams_frame, state='disabled', width = 6)
1509
+ entry_ycellgap.grid(row=5, column=3, sticky = W)
1510
+
1511
+ x_label = ttk.Label(moduleparams_frame, text='Module size x:')
1512
+ x_label.grid(row=6, column=0, sticky = W)
1513
+ entry_x = Entry(moduleparams_frame, width = 6)
1514
+ entry_x.grid(row=6, column=1, sticky = W)
1515
+ y_label = ttk.Label(moduleparams_frame, width = 4, text='y:')
1516
+ y_label.grid(row=6, column=2, sticky = W)
1517
+ entry_y = Entry(moduleparams_frame, width = 6)
1518
+ entry_y.grid(row=6, column=3, sticky = W)
1519
+ xgap_label = ttk.Label(moduleparams_frame, text='Xgap | Ygap | Zgap :')
1520
+ xgap_label.grid(row=7, column=0, sticky = W)
1521
+ entry_xgap = Entry(moduleparams_frame, width = 6)
1522
+ entry_xgap.grid(row=7, column=1, sticky = W)
1523
+ entry_ygap = Entry(moduleparams_frame, width = 6)
1524
+ entry_ygap.grid(row=7, column=2, sticky = W)
1525
+ entry_zgap = Entry(moduleparams_frame, width = 6)
1526
+ entry_zgap.grid(row=7, column=3, sticky = W)
1527
+ bifi_label = ttk.Label(moduleparams_frame, text='Bifacial Factor (i.e. 0.9):')
1528
+ bifi_label.grid(row=8, column=0, sticky = W)
1529
+ entry_bifi = Entry(moduleparams_frame, width = 6)
1530
+ entry_bifi.grid(row=8, column=1, sticky = W)
1531
+
1532
+ showModule_button = Button(moduleparams_frame, width = 10, text="VIEW", command=showModule)
1533
+ showModule_button.grid(column=2, row=8, columnspan=1)
1534
+
1535
+ moduletype_label = ttk.Label(moduleparams_frame, background='lavender', text='Module Name:')
1536
+ moduletype_label.grid(row = 9, sticky=W)
1537
+ entry_moduletype = Entry(moduleparams_frame, background="white")
1538
+ entry_moduletype.grid(row=9, column=1, columnspan=2)
1539
+ rewriteModule_label = ttk.Label(moduleparams_frame, background='lavender', text='Rewrite Module:')
1540
+ rewriteModule_label.grid(row = 10, sticky=W)
1541
+ rb_rewriteModule=IntVar()
1542
+ rad1_rewriteModule = Radiobutton(moduleparams_frame,background='lavender', variable=rb_rewriteModule, text='True', value=0)
1543
+ rad2_rewriteModule = Radiobutton(moduleparams_frame,background='lavender', variable=rb_rewriteModule, text='False', value=1)
1544
+ rad1_rewriteModule.grid(column=1, row=10)
1545
+ rad2_rewriteModule.grid(column=2, row=10)
1546
+
1547
+
1548
+
1549
+
1550
+ # SCENE PARAMETERS
1551
+ ###################
1552
+ def definebyGCR():
1553
+ gcr_label.config(state='normal')
1554
+ entry_gcr.config(state='normal')
1555
+ pitch_label.config(state='disabled')
1556
+ entry_pitch.config(state='disabled')
1557
+
1558
+ def definebyPitch():
1559
+ gcr_label.config(state='disabled')
1560
+ entry_gcr.config(state='disabled')
1561
+ pitch_label.config(state='normal')
1562
+ entry_pitch.config(state='normal')
1563
+
1564
+ def clearAllValuesButton():
1565
+ activateAllEntries()
1566
+ clearAllValues()
1567
+ setdefaultActive()
1568
+ setdefaultGray()
1569
+
1570
+
1571
+ sceneparams_label = ttk.Label(sceneparams_frame, text='Scene Parameters', font=("Arial Bold", 15))
1572
+ sceneparams_label.grid(row = 0, columnspan=3, sticky=W)
1573
+ GCRorPitch_label = ttk.Label(sceneparams_frame, text='Row spacing by:')
1574
+ GCRorPitch_label.grid(row=1, column=0, sticky = W)
1575
+ rb_GCRorPitch=IntVar()
1576
+ rad1_GCRorPitch = Radiobutton(sceneparams_frame, width = 8, variable=rb_GCRorPitch, text='GCR', value=0, command=definebyGCR)
1577
+ rad2_GCRorPitch = Radiobutton(sceneparams_frame, width = 8, variable=rb_GCRorPitch, text='Pitch', value=1, command=definebyPitch)
1578
+ rad1_GCRorPitch.grid(column=1, row=1, sticky = W)
1579
+ rad2_GCRorPitch.grid(column=2, row=1, sticky = W)
1580
+ gcr_label = ttk.Label(sceneparams_frame, text='GCR:')
1581
+ gcr_label.grid(row=2, column=0, sticky = W)
1582
+ entry_gcr = Entry(sceneparams_frame, width = 6)
1583
+ entry_gcr.grid(row=2, column=1, sticky = W)
1584
+ pitch_label = ttk.Label(sceneparams_frame, state='disabled', text='Pitch:')
1585
+ pitch_label.grid(row=2, column=2, sticky = W)
1586
+ entry_pitch = Entry(sceneparams_frame, state='disabled', width = 6)
1587
+ entry_pitch.grid(row=2, column=3, sticky = W)
1588
+ albedo_label = ttk.Label(sceneparams_frame, text='Albedo:')
1589
+ albedo_label.grid(row=3, column=0, sticky = W)
1590
+ entry_albedo = Entry(sceneparams_frame, width = 6)
1591
+ entry_albedo.grid(row=3, column=1, sticky = W)
1592
+ nMods_label = ttk.Label(sceneparams_frame, text='# Mods:')
1593
+ nMods_label.grid(row=4, column=0, sticky = W)
1594
+ entry_nMods = Entry(sceneparams_frame, width = 6)
1595
+ entry_nMods.grid(row=4, column=1, sticky = W)
1596
+ nRows_label = ttk.Label(sceneparams_frame, text='# Rows:')
1597
+ nRows_label.grid(row=4, column=2, sticky = W)
1598
+ entry_nRows = Entry(sceneparams_frame, width = 6)
1599
+ entry_nRows.grid(row=4, column=3, sticky = W)
1600
+
1601
+ azimuth_label = ttk.Label(sceneparams_frame, text='Azimuth Angle (i.e. 180 for South):')
1602
+ azimuth_label.grid(row=5, column=0, sticky = W, columnspan=2)
1603
+ entry_azimuth = Entry(sceneparams_frame, width = 6)
1604
+ entry_azimuth.grid(row=5, column=2, sticky = W)
1605
+
1606
+ clearanceheight_label = ttk.Label(sceneparams_frame, text='Clearance height: ')
1607
+ clearanceheight_label.grid(row=6, column=0, sticky = W, columnspan=2)
1608
+ entry_clearanceheight = Entry(sceneparams_frame, width = 6)
1609
+ entry_clearanceheight.grid(row=6, column=1, sticky = W)
1610
+
1611
+ tilt_label = ttk.Label(sceneparams_frame, text='Tilt: ')
1612
+ tilt_label.grid(row=6, column=2, sticky = W, columnspan=2)
1613
+ entry_tilt = Entry(sceneparams_frame, width = 6)
1614
+ entry_tilt.grid(row=6, column=3, sticky = W)
1615
+
1616
+ axis_azimuth_label = ttk.Label(sceneparams_frame, state='disabled', text='Axis Azimuth (i.e. 180 for EW HSATtrackers):')
1617
+ axis_azimuth_label.grid(row=7, column=0, sticky = W, columnspan=3)
1618
+ entry_axis_azimuth = Entry(sceneparams_frame, state='disabled', width = 6)
1619
+ entry_axis_azimuth.grid(row=7, column=3, sticky = W)
1620
+
1621
+ hubheight_label = ttk.Label(sceneparams_frame, state='disabled', text='Hub height: ')
1622
+ hubheight_label.grid(row=8, column=0, sticky = W, columnspan=2)
1623
+ entry_hubheight = Entry(sceneparams_frame, state='disabled', width = 6)
1624
+ entry_hubheight.grid(row=8, column=1, sticky = W)
1625
+
1626
+ showScene_button = Button(sceneparams_frame, width = 10, text="VIEW", command=showScene)
1627
+ showScene_button.grid(column=2, row=8, columnspan=1)
1628
+
1629
+
1630
+ # Analysis PARAMETERS
1631
+ ###################
1632
+ analysisparams_label = ttk.Label(analysisparams_frame, text='Analysis Parameters', font=("Arial Bold", 15))
1633
+ analysisparams_label.grid(row = 0, columnspan=3, sticky=W)
1634
+ sensorsy_label = ttk.Label(analysisparams_frame, text='# Sensors: ')
1635
+ sensorsy_label.grid(row=1, column=0, sticky = W)
1636
+ entry_sensorsy = Entry(analysisparams_frame, width = 6)
1637
+ entry_sensorsy.grid(row=1, column=1, sticky = W)
1638
+ modWanted_label = ttk.Label(analysisparams_frame, text='Mod Wanted: ')
1639
+ modWanted_label.grid(row=2, column=0, sticky = W)
1640
+ entry_modWanted = Entry(analysisparams_frame, width = 6)
1641
+ entry_modWanted.grid(row=2, column=1, sticky = W)
1642
+ rowWanted_label = ttk.Label(analysisparams_frame, text='Row Wanted: ')
1643
+ rowWanted_label.grid(row=2, column=2, sticky = W)
1644
+ entry_rowWanted = Entry(analysisparams_frame, width = 6)
1645
+ entry_rowWanted.grid(row=2, column=3, sticky = W)
1646
+ emptyspace = ttk.Label(analysisparams_frame, text='', font=("Arial Bold", 5))
1647
+ emptyspace.grid(row = 3, columnspan=3, sticky=W)
1648
+ Clear_button = Button(analysisparams_frame, text="CLEAR", command=clearAllValuesButton)
1649
+ Clear_button.grid(column=0, row=4)
1650
+ DEFAULT_button = Button(analysisparams_frame,text="DEFAULT", command=setDefaults)
1651
+ DEFAULT_button.grid(column=1, row=4)
1652
+ RUN_button = Button(analysisparams_frame, width = 25, text="RUN", command=runBifacialRadiance)
1653
+ RUN_button.grid(column=2, row=4, columnspan=3)
1654
+
1655
+ ## IMAGE STUFF
1656
+ #imagevariables_frame
1657
+ image_fixed = PhotoImage(file=os.path.join(IMAGE_PATH,'fig1_fixed_small.gif'))
1658
+ image_tracked = PhotoImage(file=os.path.join(IMAGE_PATH,'fig2_tracked_small.gif'))
1659
+ buttonImage = Button(imagevariables_frame, image=image_fixed)
1660
+ buttonImage.grid(row=0, columnspan=4, sticky=W)
1661
+
1662
+ setDefaults()
1663
+ setdefaultGray()
1664
+ entry_modulename.event_generate('<<ComboboxSelected>>') # populate module params
1665
+
1666
+
1667
+ # root.title("Bifacial_Radiance | v. 0_2_5")
1668
+
1669
+ def _on_frame_configure(self, event=None):
1670
+ self.canvas.configure(scrollregion=self.canvas.bbox("all"))
1671
+
1672
+ def gui():
1673
+ """
1674
+ Graphical user interface- just type bifacial_radiance.gui() to get started!
1675
+
1676
+ Returns
1677
+ -------
1678
+ None.
1679
+
1680
+ """
1681
+ root = Window()
1682
+ # bring window into focus
1683
+ root.lift()
1684
+ root.attributes('-topmost',True)
1685
+ root.after_idle(root.attributes,'-topmost',False)
1686
+ # run mainloop
1687
+ root.mainloop()
1688
+ print("\nNow leaving GUI")
1689
+ # Hold off on returning values for now until we can clean them first
1690
+ #print('Annual bifacial ratio average: %0.3f' %(
1691
+ # sum(root.data.Wm2Back) / sum(root.data.Wm2Front) ) )
1692
+ #return root.data
1693
+
1694
+ # If the script is run as a file, it needs to call gui().
1695
+ if __name__ == '__main__':
1696
+ gui()