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,623 @@
1
+ import numpy as np
2
+ import os
3
+ import pandas as pd
4
+ import time
5
+ import math
6
+ from itertools import chain
7
+ from itertools import product
8
+
9
+ from bifacial_radiance import AnalysisObj, load, MetObj, RadianceObj
10
+ from bifacial_radiance.spectral_utils import (spectral_property,
11
+ spectral_irradiance_smarts,
12
+ spectral_albedo_smarts)
13
+
14
+ from dask.distributed import Client
15
+
16
+ #from multitask_worker.worker import run_partial
17
+ #from multitask_worker.slurm_utils import slurm_worker_id, slurm_worker_cnt
18
+
19
+ from math import sin, cos, radians
20
+
21
+ # Generate spectra for DNI, DHI and albedo using smarts
22
+
23
+ # Run simulation using the given timestamp and wavelength
24
+ def simulate_single(idx=None, wavelength=None,
25
+ test_folder_fmt=None, best_data_file=None, data_folder=None):
26
+
27
+ # Verify test_folder exists before creating radiance obj
28
+ test_folder = test_folder_fmt.format(f'{idx:04}',f'{wavelength:04}')
29
+ if not os.path.exists(test_folder):
30
+ os.makedirs(test_folder)
31
+
32
+ ### NEW FOR SPECTRA
33
+
34
+ # Create radiance obj
35
+ radiance_name = 'BEST'
36
+ rad_obj = RadianceObj(radiance_name, str(test_folder))
37
+
38
+ # Set ground
39
+ rad_obj.readWeatherFile(best_data_file, label = 'center')
40
+
41
+ # Check to see if file exists
42
+ foo=rad_obj.metdata.datetime[idx]
43
+
44
+ # If a wavelength was specified, assume this is a spectral simulation and
45
+ # try to load spectra files.
46
+ # Determine file suffix
47
+ suffix = f'_{idx}.txt'
48
+
49
+ # Generate/Load albedo
50
+ alb_file = os.path.join(data_folder, "alb"+suffix)
51
+ spectral_alb = spectral_property.load_file(alb_file)
52
+
53
+ # Generate/Load dni and dhi
54
+ dni_file = os.path.join(data_folder, "dni"+suffix)
55
+ dhi_file = os.path.join(data_folder, "dhi"+suffix)
56
+ ghi_file = os.path.join(data_folder, "ghi"+suffix)
57
+ spectral_dni = spectral_property.load_file(dni_file)
58
+ spectral_dhi = spectral_property.load_file(dhi_file)
59
+ spectral_ghi = spectral_property.load_file(ghi_file)
60
+
61
+ weighted_albedo = False
62
+ if wavelength:
63
+ alb = spectral_alb[wavelength]
64
+ dni = spectral_dni[wavelength]
65
+ dhi = spectral_dhi[wavelength]
66
+ elif weighted_albedo:
67
+ _alb = np.array(spectral_alb[range(300, 2501, 10)])
68
+ _dni = np.array(spectral_dni[range(300, 2501, 10)])
69
+ _dhi = np.array(spectral_dhi[range(300, 2501, 10)])
70
+ _ghi = np.array(spectral_ghi[range(300, 2501, 10)])
71
+
72
+ alb_scale = np.sum(_alb * (_ghi))/np.sum(alb * (_ghi))
73
+ alb *= alb_scale
74
+ print(f'For IDX {idx}, albedo scaled by {alb_scale}')
75
+
76
+
77
+ res_name = "irr_Hydra_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)+'.csv'
78
+
79
+ rad_obj.setGround(alb)
80
+ # Set sky
81
+ solpos = rad_obj.metdata.solpos.iloc[idx]
82
+ zen = float(solpos.zenith)
83
+ azm = float(solpos.azimuth) - 180
84
+ rad_obj.gendaylit2manual(dni, dhi, 90 - zen, azm)
85
+
86
+
87
+ lat=39.742 # NREL SSRL location
88
+ lon=-105.179 # NREL SSRL location
89
+ elev=1829
90
+ timezone=-7
91
+ axis_tilt=0
92
+ axis_azimuth=180
93
+ limit_angle=60
94
+ backtrack=True # Set to false since it's only 1 row, no shading.
95
+ gcr=0.35
96
+ angledelta=0 # rounding to ints
97
+ numpanels=1
98
+ torquetube=False # We are going to add it separately
99
+ diameter = 0.130175 # 5 1/8 in
100
+ torqueTubeMaterial='Metal_Grey'
101
+ tubetype='Round'
102
+ axisofrotationTorqueTube = True
103
+ azimuth=90
104
+ material = 'Metal_Grey'
105
+ hub_height = 1.5#0.927
106
+ postdiamy = 0.1016 # N-S measurement, 4 "
107
+ postdiamx = 0.1524 # E-W measurement, 6 "
108
+ ttedgeoffset = -1.07 # south edge 42 in. negative because that's how I coded the trnaslation.
109
+ ttedgeoffsetNorth = 0.10795 # North edge $ 4 1/4 inches
110
+ length = 21.64-ttedgeoffset+ttedgeoffsetNorth # map goes from beginning of south post, but there is a bit more post to hold the sensor
111
+ decimate = True
112
+ zgap = 0.05 + diameter/2 # 1 inch of arm, + 1 3/16 of panel width on average ~ 0.055 m
113
+ decimateinterval = '15Min'
114
+ pitch=5.7 # distance between rows
115
+ ypostlist=[0, 4.199, 10.414, 16.63, 21.64]
116
+ ymods=[0.589, 1.596, 2.603, 3.610, 4.788, 5.795, 6.803, 7.810, 8.818, 9.825, 11.003, 12.011, 13.018, 14.026, 15.034, 16.041, 17.220, 18.230, 19.240, 20.250]
117
+
118
+ numcellsx = 6
119
+ numcellsy = 12
120
+ xcell = 0.142
121
+ ycell = 0.142
122
+ xcellgap = 0.02
123
+ ycellgap = 0.02
124
+ module_type = 'Bi60'
125
+
126
+ xgap = 0.046
127
+ ygap=0
128
+ glass = False
129
+
130
+ # Set tracker information
131
+ try:
132
+ tilt = round(rad_obj.getSingleTimestampTrackerAngle(rad_obj.metdata, idx, gcr, limit_angle=65),1)
133
+ except:
134
+ print("Night time !!!!!!!!!")
135
+ print("")
136
+ print("")
137
+ return None
138
+
139
+ if math.isnan(tilt):
140
+ return None
141
+
142
+ sazm = 90
143
+
144
+ cellLevelModuleParams = {'numcellsx': numcellsx, 'numcellsy':numcellsy,
145
+ 'xcell': xcell, 'ycell': ycell, 'xcellgap': xcellgap, 'ycellgap': ycellgap}
146
+
147
+ # Running make module on HPC can cause issues if too many works try to
148
+ # write to the module file at the same time. If something goes wrong,
149
+ # assume the module has already been created.
150
+ '''
151
+ try:
152
+
153
+ mymodule = rad_obj.makeModule(name=module_type, torquetube=torquetube, diameter=diameter, tubetype=tubetype, material=material,
154
+ xgap=xgap, ygap=ygap, zgap=zgap, numpanels=numpanels,# x=0.952, y=1.924,
155
+ cellLevelModuleParams=cellLevelModuleParams,
156
+ axisofrotationTorqueTube=axisofrotationTorqueTube, glass=glass, z=0.0002)
157
+ rad_obj.makeModule(name='sensor', x=0.15, y=0.15, z=0.04)
158
+
159
+ except:
160
+ print('Failed to make module.')
161
+ '''
162
+ radname = "Bi60_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)+"_"
163
+
164
+ sceneDict1 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*0, 'originy': ymods[0]}
165
+ sceneObj1 = rad_obj.makeScene(moduletype=module_type, sceneDict=sceneDict1, radname = radname)
166
+
167
+ sceneDict2 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*1, 'originy': ymods[0]}
168
+ sceneObj2 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict2, radname = radname)
169
+
170
+ sceneDict3 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*2, 'originy': ymods[0]}
171
+ sceneObj3 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict3, radname = radname)
172
+
173
+ sceneDict4 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*3, 'originy': ymods[0]}
174
+ sceneObj4 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict4, radname = radname)
175
+
176
+ sceneDict5 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*4, 'originy': ymods[0]}
177
+ sceneObj5 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict5, radname = radname)
178
+
179
+ sceneDict6 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*5, 'originy': ymods[0]}
180
+ sceneObj6 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict6, radname = radname)
181
+
182
+ sceneDict7 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*6, 'originy': ymods[0]}
183
+ sceneObj7 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict7, radname = radname)
184
+
185
+ sceneDict8 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*7, 'originy': ymods[0]}
186
+ sceneObj8 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict8, radname = radname)
187
+
188
+ sceneDict9 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*8, 'originy': ymods[0]}
189
+ sceneObj9 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict9, radname = radname)
190
+
191
+ sceneDict10 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*9, 'originy': ymods[0]}
192
+ sceneObj10 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict10, radname = radname)
193
+
194
+ #sceneObjects[tilt] = {'Obj1': sceneObj1, 'Obj2': sceneObj2, 'Obj3': sceneObj3, 'Obj4': sceneObj4, 'Obj5': sceneObj5, 'Obj6': sceneObj6, 'Obj7': sceneObj7, 'Obj8': sceneObj8, 'Obj9': sceneObj9, 'Obj10': sceneObj10}
195
+
196
+ modulesArray = []
197
+ fieldArray = []
198
+
199
+ modulesArray.append(sceneObj1)
200
+ modulesArray.append(sceneObj2)
201
+ modulesArray.append(sceneObj3)
202
+ modulesArray.append(sceneObj4)
203
+ modulesArray.append(sceneObj5)
204
+ modulesArray.append(sceneObj6)
205
+ modulesArray.append(sceneObj7)
206
+ modulesArray.append(sceneObj8)
207
+ modulesArray.append(sceneObj9)
208
+ modulesArray.append(sceneObj10)
209
+ fieldArray.append(modulesArray)
210
+
211
+
212
+ textrow1 = ''
213
+ textrow2 = sceneObj2.text + '\r\n'
214
+ textrow3 = sceneObj3.text + '\r\n'
215
+ textrow4 = sceneObj4.text + '\r\n'
216
+ textrow5 = sceneObj5.text + '\r\n'
217
+ textrow6 = sceneObj6.text + '\r\n'
218
+ textrow7 = sceneObj7.text + '\r\n'
219
+ textrow8 = sceneObj8.text + '\r\n'
220
+ textrow9 = sceneObj9.text + '\r\n'
221
+ textrow10 = sceneObj10.text + '\r\n'
222
+
223
+ # Row 1
224
+ for i in range(1, 20):
225
+ modulesArray = []
226
+
227
+ sceneDict1 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*0, 'originy': ymods[i]}
228
+ sceneObj1 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict1, radname = radname)
229
+
230
+ sceneDict2 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*1, 'originy': ymods[i]}
231
+ sceneObj2 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict2, radname = radname)
232
+
233
+ sceneDict3 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*2, 'originy': ymods[i]}
234
+ sceneObj3 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict3, radname = radname)
235
+
236
+ sceneDict4 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*3, 'originy': ymods[i]}
237
+ sceneObj4 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict4, radname = radname)
238
+
239
+ sceneDict5 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*4, 'originy': ymods[i]}
240
+ sceneObj5 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict5, radname = radname)
241
+
242
+ sceneDict6 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*5, 'originy': ymods[i]}
243
+ sceneObj6 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict6, radname = radname)
244
+
245
+ sceneDict7 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*6, 'originy': ymods[i]}
246
+ sceneObj7 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict7, radname = radname)
247
+
248
+ sceneDict8 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*7, 'originy': ymods[i]}
249
+ sceneObj8 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict8, radname = radname)
250
+
251
+ sceneDict9 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*8, 'originy': ymods[i]}
252
+ sceneObj9 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict9, radname = radname)
253
+
254
+ sceneDict10 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*9, 'originy': ymods[i]}
255
+ sceneObj10 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict10, radname = radname)
256
+
257
+ textrow1 += sceneObj1.text + '\r\n'
258
+ textrow2 += sceneObj2.text + '\r\n'
259
+ textrow3 += sceneObj3.text + '\r\n'
260
+ textrow4 += sceneObj4.text + '\r\n'
261
+ textrow5 += sceneObj5.text + '\r\n'
262
+ textrow6 += sceneObj6.text + '\r\n'
263
+ textrow7 += sceneObj7.text + '\r\n'
264
+ textrow8 += sceneObj8.text + '\r\n'
265
+ textrow9 += sceneObj9.text + '\r\n'
266
+ textrow10 += sceneObj10.text + '\r\n'
267
+
268
+ modulesArray.append(sceneObj1)
269
+ modulesArray.append(sceneObj2)
270
+ modulesArray.append(sceneObj3)
271
+ modulesArray.append(sceneObj4)
272
+ modulesArray.append(sceneObj5)
273
+ modulesArray.append(sceneObj6)
274
+ modulesArray.append(sceneObj7)
275
+ modulesArray.append(sceneObj8)
276
+ modulesArray.append(sceneObj9)
277
+ modulesArray.append(sceneObj10)
278
+
279
+ fieldArray.append(modulesArray)
280
+
281
+
282
+ # Redoing the first module to append everything to it.
283
+ sceneDict1 = {'tilt': tilt, 'pitch':pitch,'hub_height':hub_height,'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': pitch*0, 'originy': ymods[0]}
284
+ sceneObj1 = rad_obj.makeScene(moduletype=module_type,sceneDict=sceneDict1, radname = radname)
285
+
286
+ rad_obj.appendtoScene(sceneObj1.radfiles, '', textrow1)
287
+ rad_obj.appendtoScene(sceneObj1.radfiles, '', textrow2)
288
+ rad_obj.appendtoScene(sceneObj1.radfiles, '', textrow3)
289
+ rad_obj.appendtoScene(sceneObj1.radfiles, '', textrow4)
290
+ rad_obj.appendtoScene(sceneObj1.radfiles, '', textrow5)
291
+ rad_obj.appendtoScene(sceneObj1.radfiles, '', textrow6)
292
+ rad_obj.appendtoScene(sceneObj1.radfiles, '', textrow7)
293
+ rad_obj.appendtoScene(sceneObj1.radfiles, '', textrow8)
294
+ rad_obj.appendtoScene(sceneObj1.radfiles, '', textrow9)
295
+ rad_obj.appendtoScene(sceneObj1.radfiles, '', textrow10)
296
+
297
+ # Custom BSA Geometry
298
+ # Bottom posttubes and torquetube:
299
+ for i in range (0, 10):
300
+ xpost = i*pitch
301
+
302
+ # adding torquetube
303
+ torquetube = '\n\r! genrev Metal_Grey torquetube{} t*{} {} 32 | xform -rx -90 -t {} {} {}'.format(i, length, diameter/2.0, xpost, ttedgeoffset, hub_height-zgap)
304
+ rad_obj.appendtoScene(sceneObj1.radfiles, '', torquetube)
305
+
306
+ for j in range (0,5):
307
+ ypost = ypostlist[j]
308
+
309
+ post1='! genbox Metal_Grey pile{} {} {} {} | xform -t {} {} 0 '.format((str(i)+","+str(j)),postdiamx, postdiamy, hub_height, -postdiamx/2.0+xpost, -postdiamy+ypost)
310
+ rad_obj.appendtoScene(sceneObj1.radfiles, '', post1)
311
+
312
+ ###########################
313
+ # Create sensor objects #
314
+ ###########################
315
+
316
+
317
+ # West Sensors
318
+ shhw = 1.5 + (1 - 0.226/2)*sin(radians(tilt)) + (0.130175/2 + 0.05 - 0.02)*cos(radians(tilt))
319
+ sxw = pitch*2 - (1 - 0.226/2)*cos(radians(tilt)) + (0.130175/2 + 0.05 - 0.02)*sin(radians(tilt))
320
+ syw = ymods[9] + 0.5 + 0.226/2
321
+ sensorw_scene = {'tilt': tilt, 'pitch':1,'hub_height': shhw, 'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': sxw, 'originy': syw,'appendRadfile':True}
322
+ res_name = "SensorW_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)
323
+ sensorw_sceneObj = rad_obj.makeScene(moduletype='sensor',sceneDict=sensorw_scene, radname = res_name)
324
+
325
+ syw = ymods[15] + 0.5 + 0.226/2
326
+ sensorIMTw_scene = {'tilt': tilt, 'pitch':1,'hub_height': shhw, 'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': sxw, 'originy': syw,'appendRadfile':True}
327
+ res_name = "SensorIMTW_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)
328
+ sensorIMTw_sceneObj = rad_obj.makeScene(moduletype='sensor',sceneDict=sensorIMTw_scene, radname=res_name)
329
+
330
+ # East Sensors
331
+ shhe = 1.5 - (1 - 0.226/2)*sin(radians(tilt)) + (0.130175/2 + 0.05 - 0.02)*cos(radians(tilt))
332
+ sxe = pitch*2 + (1 - 0.226/2)*cos(radians(tilt)) + (0.130175/2 + 0.05 - 0.02)*sin(radians(tilt))
333
+ sye = ymods[9] + 0.5 + 0.226/2
334
+ sensore_scene = {'tilt': tilt, 'pitch':1,'hub_height': shhe, 'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': sxe, 'originy': sye,'appendRadfile':True}
335
+ res_name = "SensorE_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)
336
+ sensore_sceneObj = rad_obj.makeScene(moduletype='sensor',sceneDict=sensore_scene, radname=res_name)
337
+
338
+ sye = ymods[15] + 0.5 + 0.226/2
339
+ sensorIMTe_scene = {'tilt': tilt, 'pitch':1,'hub_height': shhe, 'azimuth':azimuth,'nMods': 1, 'nRows': 1, 'originx': sxe, 'originy': sye,'appendRadfile':True}
340
+ res_name = "SensorIMTE_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)
341
+ sensorIMTe_sceneObj = rad_obj.makeScene(moduletype='sensor',sceneDict=sensorIMTe_scene, radname=res_name)
342
+
343
+ # Build oct file
344
+ sim_name = "BEST_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)
345
+ octfile = rad_obj.makeOct(rad_obj.getfilelist(), octname=sim_name)
346
+
347
+ #################
348
+ # Run analysis #
349
+ #################
350
+
351
+ #Row 3 Module 10 sensors
352
+ analysis = AnalysisObj(octfile, rad_obj.basename)
353
+
354
+ frontscan, backscan = analysis.moduleAnalysis(sensorw_sceneObj, sensorsy=1)#, frontsurfaceoffset=0.021)#, backsurfaceoffset = 0.02)
355
+ res_name = "SensorW_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)
356
+ frontdict, backdict = analysis.analysis(octfile, res_name, frontscan, backscan)
357
+
358
+ frontscan, backscan = analysis.moduleAnalysis(sensore_sceneObj, sensorsy=1)#, frontsurfaceoffset=0.021)#, backsurfaceoffset = 0.02)
359
+ res_name = "SensorE_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)
360
+ frontdict, backdict = analysis.analysis(octfile, res_name, frontscan, backscan)
361
+
362
+ #IMT Sensors Row 3 Module 5
363
+ '''
364
+ frontscan, backscan = analysis.moduleAnalysis(sensorIMTw_sceneObj, sensorsy=1)#, frontsurfaceoffset=0.021)#, backsurfaceoffset = 0.02)
365
+ res_name = "SensorIMTW_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)
366
+ frontdict, backdict = analysis.analysis(octfile, res_name, frontscan, backscan)
367
+
368
+ frontscan, backscan = analysis.moduleAnalysis(sensorIMTe_sceneObj, sensorsy=1)#, frontsurfaceoffset=0.021)#, backsurfaceoffset = 0.02)
369
+ res_name = "SensorIMTE_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)
370
+ frontdict, backdict = analysis.analysis(octfile, res_name, frontscan, backscan)
371
+
372
+ #fieldARray[module][row]
373
+
374
+ #HYDRA
375
+ modmod = 16
376
+ rowrow = 1
377
+ frontscan, backscan = analysis.moduleAnalysis(fieldArray[modmod][rowrow], sensorsy=12)#, frontsurfaceoffset=0.021)#, backsurfaceoffset = 0.02)
378
+ res_name = "Hydra_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)
379
+ frontdict, backdict = analysis.analysis(octfile, res_name, frontscan, backscan)
380
+
381
+ '''
382
+
383
+ #LOCATION_APOGEES
384
+ modmod = 9
385
+ rowrow = 2
386
+ frontscan, backscan = analysis.moduleAnalysis(fieldArray[modmod][rowrow], sensorsy=4)#, frontsurfaceoffset=0.021)#, backsurfaceoffset = 0.02)
387
+ frontscan['ystart'] = frontscan['ystart'] + 0.45
388
+ backscan['ystart'] = backscan['ystart'] + 0.45
389
+ res_name = "Apogee_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)
390
+ frontdict, backdict = analysis.analysis(octfile, res_name, frontscan, backscan)
391
+
392
+
393
+ '''
394
+ # SCAN FULL ROWS
395
+ for rowrow in range(5, 7):
396
+ for modmod in range(0, 20):
397
+ frontscan, backscan = analysis.moduleAnalysis(fieldArray[modmod][rowrow], sensorsy=12)#, frontsurfaceoffset=0.021)#, backsurfaceoffset = 0.02)
398
+ res_name = "Row_"+str(rowrow)+"_Mod_"+str(modmod)+"_"+str(foo.year)+"_"+str(foo.month)+"_"+str(foo.day)+"_"+str(foo.hour)+"_"+str(foo.minute)
399
+ frontdict, backdict = analysis.analysis(octfile, res_name, frontscan, backscan)
400
+ '''
401
+ # Read in results
402
+ #results_file = os.path.join('results', f'irr_sensor_{sim_name}.csv')
403
+ #results = load.read1Result(results_file)
404
+ results = 1
405
+
406
+ # Format output
407
+ #tracker_theta = tilt
408
+ #front = ','.join([ str(f) for f in results['Wm2Front'] ])
409
+ #back = ','.join([ str(r) for r in results['Wm2Back'] ])
410
+ print("***** Finished simulation for "+ str(foo))
411
+ #time_str = metdata.datetime[idx]
412
+ # print(f"sim_results,{idx},{time_str},{wavelength},{dni},{dhi},{alb}," \
413
+ # f"{tracker_theta},{front},{back}")
414
+ return results
415
+
416
+
417
+
418
+ def run_simulations_dask(arraysimulations, kwargs):
419
+ # Create client
420
+
421
+ scheduler_file = '/scratch/sayala/dask_testing/scheduler.json'
422
+ client = Client(scheduler_file=scheduler_file)
423
+
424
+ # Iterate over inputs
425
+ futures = []
426
+
427
+ for ii in range(0, len(arraysimulations)):
428
+ idx = arraysimulations.iloc[ii].idx
429
+ wavelength = arraysimulations.iloc[ii].wavelength
430
+ test_folder = test_folder_fmt.format(f'{idx:04}',f'{wavelength:04}')
431
+ if not os.path.exists(test_folder):
432
+ futures.append(client.submit(simulate_single, idx=idx, wavelength=wavelength, **kwargs))
433
+ else:
434
+ print("\n\nAlready simulated ***********************\n\n", idx, wavelength)
435
+
436
+ # Get results for all simulations
437
+ res = client.gather(futures)
438
+
439
+ # Close all dask workers and scheduler
440
+ try:
441
+ client.shutdown()
442
+ except:
443
+ pass
444
+
445
+ # Close client
446
+ client.close()
447
+
448
+ res = 'FINISHED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
449
+ return res
450
+
451
+ def compileResults(testfolder, resultsfile):
452
+ # ASsumes there is an overarching folder, where
453
+ # Folder > custoname_idx_XXXX > custoname_Spectra_XXXX > results
454
+ # and resultfiles are irr_custoname_YEAR_MONTH_DAY_HOUR_MINUTE.CSV'
455
+ #
456
+ # ie. folder: r'/scratch/sayala/BEST_SpectraMarch/BEST_APOGGEE_Spectra_Mark_NotScaled'
457
+ # testfolder = r'C:\Users\sayala\Documents\HPC_Scratch\BEST_Spectra'
458
+ # Reading results in results/folder like: irr_SensorW_2020_10_30_8_30.csv'
459
+ # SAving into resultsfile = r'C:\Users\sayala\Desktop\Dask\Compiled_SPECTRA_Results\TEMP\March15_Results.csv'
460
+
461
+
462
+ arrayWm2Front = []
463
+ arrayWm2Back = []
464
+ arrayMatFront = []
465
+ arrayMatBack = []
466
+ monthlist=[]
467
+ daylist=[]
468
+ hourlist=[]
469
+ yearlist=[]
470
+ minutelist=[]
471
+ #faillist=[]
472
+ addresslist=[]
473
+ wavlist = []
474
+ sensorlist = []
475
+ indexlist = []
476
+
477
+ # List all IDX folders
478
+ idxlist = sorted(os.listdir(testfolder))
479
+ print('{} Indexes in the directory'.format(idxlist.__len__()))
480
+
481
+ # Loop over Timestamps
482
+ for ii in range (0, len(idxlist)):
483
+ idx = int(idxlist[ii][-4:])
484
+
485
+ spectralist = sorted(os.listdir(os.path.join(testfolder, idxlist[ii])))
486
+
487
+ # Loop over Spectras
488
+ for jj in range(0, len(spectralist)):
489
+ wav = int(spectralist[jj][-4:])
490
+
491
+ resultslist = sorted(os.listdir(os.path.join(testfolder, idxlist[ii], spectralist[jj], 'results')))
492
+
493
+ # Loop over Sensors
494
+ for kk in range(0, len(resultslist)):
495
+
496
+ try:
497
+ resultfile=os.path.join(testfolder, idxlist[ii], spectralist[jj], 'results', resultslist[kk])
498
+ sensorname = resultslist[kk].split('_')[1]
499
+ year = resultslist[kk].split('_')[2]
500
+ month = resultslist[kk].split('_')[3]
501
+ day = resultslist[kk].split('_')[4]
502
+ hour = resultslist[kk].split('_')[5]
503
+ try:
504
+ minute = int(resultslist[kk].split('_')[6].split('.')[0])
505
+ except:
506
+ minute = 0
507
+
508
+ # resultsDF = bifacial_radiance.load.read1Result(resultfile)
509
+ resultsDF = load.read1Result(resultfile)
510
+ wavlist.append(wav)
511
+ indexlist.append(idx)
512
+ arrayWm2Front.append(list(resultsDF['Wm2Front']))
513
+ arrayWm2Back.append(list(resultsDF['Wm2Back']))
514
+ arrayMatFront.append(list(resultsDF['mattype']))
515
+ arrayMatBack.append(list(resultsDF['rearMat']))
516
+ yearlist.append(year)
517
+ monthlist.append(month)
518
+ daylist.append(day)
519
+ hourlist.append(hour)
520
+ minutelist.append(minute)
521
+ sensorlist.append(sensorname)
522
+ addresslist.append(resultfile)
523
+ except:
524
+ print(" FAILED index ", idx, " wav ", wav, " file ", resultslist[kk] )
525
+
526
+ resultsdf = pd.DataFrame(list(zip(arrayWm2Front, arrayWm2Back,
527
+ arrayMatFront, arrayMatBack)),
528
+ columns = ['br_Wm2Front', 'br_Wm2Back',
529
+ 'br_MatFront', 'br_MatBack'])
530
+ resultsdf['minute'] = minutelist
531
+ resultsdf['hour'] = hourlist
532
+ resultsdf['day'] = daylist
533
+ resultsdf['month'] = monthlist
534
+ resultsdf['year'] = yearlist
535
+ resultsdf['wavelength'] = wavlist
536
+ resultsdf['sensor'] = sensorlist
537
+ resultsdf['file'] = addresslist
538
+ resultsdf['idx'] = indexlist
539
+
540
+ format = '%Y-%m-%d %H:%M:00'
541
+ datesread = pd.to_datetime(resultsdf[['year','month','day','hour','minute']], format=format)
542
+ resultsdf['timestamp'] = datesread
543
+
544
+ resultsdf.to_csv(resultsfile)
545
+
546
+
547
+ def findMissingSimulationValues(resultsfile, idxs=None, wavs=None, sensors=None):
548
+
549
+ data = pd.read_csv(resultsfile)
550
+ #data['timestamp']= pd.to_datetime(data['timestamp'])
551
+
552
+ if idxs is None:
553
+ idxs = list(data.idx.unique())
554
+
555
+ if wavs is None:
556
+ wavs = list(data.wavelength.unique())
557
+
558
+ if sensors is None:
559
+ sensors = list(data.sensor.unique())
560
+
561
+ # Make Ideal Dataframe
562
+ ideal = pd.DataFrame(
563
+ list(product(idxs, wavs, sensors)),
564
+ columns=['idx', 'wavelength', 'sensor'])
565
+
566
+ ideal.idx = ideal.idx.astype('int64')
567
+ ideal.wavelength = ideal.wavelength.astype('int64')
568
+
569
+ # Set idx, wavelenths and sensors as indexes
570
+ ideal.set_index(['idx','wavelength','sensor'], inplace=True)
571
+ foo = data.copy()
572
+ foo.set_index(['idx','wavelength','sensor'], inplace=True)
573
+
574
+ # Concatenate to generate missing values (nan)
575
+ result = pd.concat([foo, ideal], axis=1, sort=False)
576
+
577
+ # Select missing values (na)
578
+ result = result[result['br_Wm2Back'].isna()]
579
+
580
+ # Reset index and generate subset dataframe to return
581
+ result.reset_index(inplace=True)
582
+ missing = result[['idx','wavelength','sensor']]
583
+
584
+ return missing
585
+
586
+
587
+ if __name__ == "__main__":
588
+ # Define locations within file system
589
+
590
+ #best_data_file = '/scratch/sayala/WeatherFiles/spectral_experiment_TMY.csv'
591
+ best_data_file = '/scratch/sayala/SPECTRAS_Used/spctrutils_Oct2127/spectratimesTMY.csv'
592
+
593
+ cases = ['Mark_NotScaled', 'Mark_Scaled', 'SRRL_NotScaled', 'SRRL_Scaled']
594
+ i = 2
595
+
596
+ test_folder_fmt = '/scratch/sayala/BEST_SpectraMarch/BEST_APOGGEE_Spectra_'+cases[i]+'/BEST_idx_{}/Spectra_{}'
597
+ data_folder = '/scratch/sayala/SPECTRAS_Used/spctrutils_Oct2127/'+cases[i]
598
+
599
+ # Define inputs
600
+ kwargs = {
601
+ 'best_data_file': best_data_file,
602
+ 'test_folder_fmt': test_folder_fmt,
603
+ 'data_folder': data_folder
604
+ }
605
+
606
+ wavelengths = np.array(list(chain(range(300, 1101, 5), range(1110, 2501, 10))))
607
+ indices = np.array(list(range(10, 43)))
608
+
609
+
610
+ try:
611
+ # Make Dataframe with missing entries only
612
+ resultsfile = r'/scratch/sayala/BEST_SpectraMarch/March15_Results.csv'
613
+ currenttestfolder = r'/scratch/sayala/BEST_SpectraMarch/BEST_APOGGEE_Spectra_'+cases[i]
614
+ compileResults(testfolder=currenttestfolder, resultsfile=resultsfile)
615
+ arraysimulations = findMissingSimulationValues(resultsfile, idxs=indices, wavs=wavelengths)
616
+ except:
617
+ # Make Ideal Dataframe
618
+ "No files simulated yet, Strating from 0"
619
+ arraysimulations = pd.DataFrame(
620
+ list(product(indices, wavelengths)),
621
+ columns=['indices', 'wavelengths'])
622
+
623
+ run_simulations_dask(arraysimulations, kwargs)
@@ -0,0 +1,4 @@
1
+ # Ignore everything in this directory
2
+ *
3
+ # Except this file
4
+ !.gitignore
@@ -0,0 +1,24 @@
1
+ try:
2
+ from importlib.metadata import PackageNotFoundError, version
3
+ except ImportError:
4
+ # for python < 3.8 (remove when dropping 3.7 support)
5
+ from importlib_metadata import PackageNotFoundError, version
6
+
7
+ try:
8
+ __version__ = version(__package__)
9
+ except PackageNotFoundError:
10
+ __version__ = "0+unknown"
11
+
12
+
13
+ from bifacial_radiance.main import AnalysisObj, GroundObj, MetObj, RadianceObj, SceneObj
14
+ #from bifacial_radiance.readepw import readepw
15
+ from bifacial_radiance.module import ModuleObj
16
+ from bifacial_radiance import load
17
+ from bifacial_radiance import modelchain
18
+ from bifacial_radiance.gui import gui
19
+ from bifacial_radiance import mismatch
20
+ from bifacial_radiance.spectral_utils import generate_spectra
21
+ from bifacial_radiance import performance
22
+ #from ._version import get_versions
23
+ #__version__ = get_versions()['version']
24
+ #del get_versions