forked from NREL/bifacial_radiance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6 - Advanced topics - Understanding trackerdict structure.py
140 lines (105 loc) · 4.69 KB
/
6 - Advanced topics - Understanding trackerdict structure.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/env python
# coding: utf-8
# # 6 - Advanced topics: Understanding trackerdict structure
#
# Tutorial 6 gives a good, detailed introduction to the trackerdict structure step by step.
# Here is a condensed summary of functions you can use to explore the tracker dictionary.
#
#
# ### Steps:
#
# <ol>
# <li> <a href='#step1'> Create a short Simulation + tracker dictionary beginning to end for 1 day </a></li>
# <li> <a href='#step2'> Explore the tracker dictionary </a></li>
# <li> <a href='#step3'> Explore Save Options </a></li>
# </ol>
# <a id='step 1'></a>
# ### 1. Create a short Simulation + tracker dictionary beginning to end for 1 day
# In[1]:
import bifacial_radiance
from pathlib import Path
import os
testfolder = str(Path().resolve().parent.parent / 'bifacial_radiance' / 'Tutorial_06')
if not os.path.exists(testfolder):
os.makedirs(testfolder)
simulationName = 'tutorial_6'
moduletype = 'test-module'
albedo = "litesoil" # this is one of the options on ground.rad
lat = 37.5
lon = -77.6
# Scene variables
nMods = 3
nRows = 1
hub_height = 2.3 # meters
pitch = 10 # meters # We will be using pitch instead of GCR for this example.
# Traking parameters
cumulativesky = False
limit_angle = 45 # tracker rotation limit angle
angledelta = 0.01 # we will be doing hourly simulation, we want the angle to be as close to real tracking as possible.
backtrack = True
#makeModule parameters
# x and y will be defined by the cell-level module parameters
xgap = 0.01
ygap = 0.10
zgap = 0.05
numpanels = 2
torquetube = True
axisofrotationTorqueTube = False
diameter = 0.1
tubetype = 'Oct' # This will make an octagonal torque tube.
material = 'black' # Torque tube will be made of this material (0% reflectivity)
tubeParams = {'diameter':diameter,
'tubetype':tubetype,
'material':material,
'axisofrotation':axisofrotationTorqueTube,
'visible':torquetube}
# Simulation range between two hours
startdate = '11_06_11' # Options: mm_dd, mm_dd_HH, mm_dd_HHMM, YYYY-mm-dd_HHMM
enddate = '11_06_14'
# Cell Parameters
numcellsx = 6
numcellsy = 12
xcell = 0.156
ycell = 0.156
xcellgap = 0.02
ycellgap = 0.02
demo = bifacial_radiance.RadianceObj(simulationName, path=testfolder)
demo.setGround(albedo)
epwfile = demo.getEPW(lat,lon)
metdata = demo.readWeatherFile(epwfile, starttime=startdate, endtime=enddate)
cellLevelModuleParams = {'numcellsx': numcellsx, 'numcellsy':numcellsy,
'xcell': xcell, 'ycell': ycell, 'xcellgap': xcellgap, 'ycellgap': ycellgap}
mymodule = demo.makeModule(name=moduletype, xgap=xgap, ygap=ygap, zgap=zgap,
numpanels=numpanels, cellModule=cellLevelModuleParams, tubeParams=tubeParams)
sceneDict = {'pitch':pitch,'hub_height':hub_height, 'nMods': nMods, 'nRows': nRows}
demo.set1axis(limit_angle=limit_angle, backtrack=backtrack, gcr=mymodule.sceney / pitch, cumulativesky=cumulativesky)
demo.gendaylit1axis()
demo.makeScene1axis(module=mymodule, sceneDict=sceneDict)
demo.makeOct1axis()
demo.analysis1axis()
# <a id='step2'></a>
# ### 2. Explore the tracker dictionary
#
# You can use any of the below options to explore the tracking dictionary. Copy it into an empty cell to see their contents.
# In[8]:
print(demo) # Shows all keys for top-level RadianceObj
trackerkeys = sorted(demo.trackerdict.keys()) # get the trackerdict keys to see a specific hour.
demo.trackerdict[trackerkeys[0]] # This prints all trackerdict content
demo.trackerdict[trackerkeys[0]]['scene'] # This shows the Scene Object contents
demo.trackerdict[trackerkeys[0]]['scene'].module.scenex # This shows the Module Object in the Scene's contents
demo.trackerdict[trackerkeys[0]]['scene'].sceneDict # Printing the scene dictionary saved in the Scene Object
demo.trackerdict[trackerkeys[0]]['scene'].sceneDict['tilt'] # Addressing one of the variables in the scene dictionary
# Looking at the AnalysisObj results indivudally
demo.trackerdict[trackerkeys[0]]['AnalysisObj'] # This shows the Analysis Object contents
demo.trackerdict[trackerkeys[0]]['AnalysisObj'].mattype # Addressing one of the variables in the Analysis Object
# Looking at the Analysis results Accumulated for the day:
demo.Wm2Back # this value is the addition of every individual irradiance result for each hour simulated.
# Access module values
demo.trackerdict[trackerkeys[0]]['scene'].module.scenex
# <a id='step3'></a>
# ### 3. Explore Save Options
#
# The following lines offer ways to save your trackerdict or your demo object.
# In[9]:
demo.exportTrackerDict(trackerdict = demo.trackerdict, savefile = 'results\\test_reindexTrue.csv', reindex = False)
demo.save(savefile = 'results\\demopickle.pickle')