-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy path21 - Weather to Module Performance.py
More file actions
219 lines (115 loc) · 5.69 KB
/
21 - Weather to Module Performance.py
File metadata and controls
219 lines (115 loc) · 5.69 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/usr/bin/env python
# coding: utf-8
# In[1]:
# This information helps with debugging and getting support :)
import sys, platform
import pandas as pd
import bifacial_radiance as br
print("Working on a ", platform.system(), platform.release())
print("Python version ", sys.version)
print("Pandas version ", pd.__version__)
print("bifacial_radiance version ", br.__version__)
# # 21 - Weather to Module Performance
# ## Modeling Performance, an End to End Simulation
#
# This tutorial shows how to use the new function on bifacial_radiance calculatePerformanceModule performance, as well as how to find CEC Module parameters.
#
# In[2]:
import os
from pathlib import Path
testfolder = str(Path().resolve().parent.parent / 'bifacial_radiance' / 'TEMP' / 'Tutorial_21')
if not os.path.exists(testfolder): os.mkdir(testfolder)
# Another option using relative address; for some operative systems you might need '/' instead of '\'
# testfolder = os.path.abspath(r'..\..\bifacial_radiance\TEMP')
print ("Your simulation will be stored in %s" % testfolder)
# In[3]:
import bifacial_radiance
import numpy as np
import pandas as pd
import pvlib
bifacial_radiance.__version__
# ## Geting a CEC Module to pass into demo.makeModule
# In[4]:
url = 'https://raw.githubusercontent.com/NREL/SAM/patch/deploy/libraries/CEC%20Modules.csv'
db = pd.read_csv(url, index_col=0) # Reading this might take 1 min or so, the database is big.
# Find the module that you want. In this case we know it's a SunPower of model SPR-E19-310-COM.
#
# Make sure you select only 1 module from the database -- sometimes there are similar names.
# In[5]:
modfilter2 = db.index.str.startswith('SunPower') & db.index.str.endswith('SPR-E19-310-COM')
print(modfilter2)
CECMod = db[modfilter2]
print(len(CECMod), " modules selected. Name of 1st entry: ", CECMod.index[0])
# In[ ]:
# In[6]:
# Selecting only two times as examples
starttime = '01_13_11'; endtime = '01_13_12'
demo = bifacial_radiance.RadianceObj('tutorial_21', path = testfolder) # Create a RadianceObj 'object'
weatherfile = demo.getEPW(lat = 37.5, lon = -77.6) # This location corresponds to Richmond, VA.
metdata = demo.readWeatherFile(weatherFile=weatherfile, starttime=starttime, endtime=endtime)
demo.setGround(0.2)
# The CEC data should be passed into the ModuleObj, either at time of creation, or sometime before it is passed into makeScene.
# In[7]:
mymodule = demo.makeModule(name='test-module', x=1, y=2, bifi=0.9, CECMod=CECMod)
# The same data could instead be passed after the ModuleObj's definition, or at time of performance analysis:
# In[8]:
mymodule.addCEC(CECMod)
# In[9]:
# Let's make a second module, and set it to the default Prism Solar module type
mymodule2 = demo.makeModule(name='test', x=1, y=2, bifi=0.8, CECMod=None)
# We're going to set up two scenes, each with a different module type!
# In[10]:
sceneDict = {'tilt': 0, 'azimuth': 180, 'pitch': 5,'hub_height':1.5, 'nMods':5, 'nRows': 2}
trackerdict = demo.set1axis(metdata = metdata, cumulativesky = False)
trackerdict = demo.gendaylit1axis()
trackerdict = demo.makeScene1axis(trackerdict, module = mymodule, sceneDict = sceneDict)
# Make a second scene with the other module type
# In[11]:
sceneDict2 = {'tilt': 0, 'azimuth': 180, 'pitch': 5,'hub_height':2.5, 'nMods':2, 'nRows': 1, 'originx': -15}
trackerdict = demo.makeScene1axis(trackerdict, module = mymodule2, sceneDict=sceneDict2, append=True)
# In[12]:
# Compile both scenes into one octfile. Run 2 different analyses, one on each scene with different front and rear y scan
trackerdict = demo.makeOct1axis()
trackerdict = demo.analysis1axis(sensorsy=[1,3], append=False)
trackerdict = demo.analysis1axis(sensorsy=[3,2], sceneNum=1)
# In[13]:
# Include an AgriPV groundscan too
trackerdict = demo.analysis1axisground(sceneNum=1, sensorsground=10, customname='Silvanas_')
# In[14]:
# show the initial irradiance results before continuing:
demo.results
# ## Calculating the Performance and Exporting the Results to a CSV
# In[15]:
# Calculate performance.
pd.set_option('display.max_columns', 1000);
compiledResults = demo.calculatePerformance1axis()
print(f'\nCompiled results:\n')
display(compiledResults)
# In[16]:
demo.exportTrackerDict(savefile=os.path.join('results','Final_Results.csv'),reindex=False)
pd.read_csv(os.path.join('results','Final_Results.csv'))
# ## Now look at gencumulativesky tracking workflow
# In[17]:
starttime = '01_13_11'; endtime = '12_13_12'
demo = bifacial_radiance.RadianceObj('tutorial_21', path = testfolder) # Create a RadianceObj 'object'
weatherfile = demo.getEPW(lat = 37.5, lon = -77.6) # This location corresponds to Richmond, VA.
metdata = demo.readWeatherFile(weatherFile=weatherfile, starttime=starttime, endtime=endtime)
#metdata = demo.readWeatherFile(weatherFile=weatherfile)
demo.setGround(0.2)
mymodule = demo.makeModule(name='test-module', x=1, y=2, bifi=0.9, CECMod=CECMod)
# In[18]:
sceneDict = {'tilt': 0, 'azimuth': 180, 'pitch': 5,'hub_height':1.5, 'nMods':5, 'nRows': 2}
trackerdict = demo.set1axis(metdata=metdata, cumulativesky=True, limit_angle=15, backtrack=False)
trackerdict = demo.genCumSky1axis()
trackerdict = demo.makeScene1axis(trackerdict, module = mymodule, sceneDict = sceneDict)
trackerdict = demo.makeOct1axis()
trackerdict = demo.analysis1axis(modWanted = [2,4], sensorsy=[2,3])
trackerdict = demo.analysis1axisground(sensorsground=10)
# In[19]:
results = demo.calculatePerformance1axis() # saves to demo.compiledResults and results/Cumulative_Results.csv
print('\nCompiled results:\n')
display(demo.compiledResults)
# In[20]:
# Results are also automatically saved in \results\Cumulative_Results.csv
pd.read_csv(os.path.join('results','Cumulative_Results.csv'))
# In[ ]: