Skip to content

Commit 69b3d65

Browse files
committed
Tutorial notebook updates. Add py3.12 support
1 parent 5f2a2b3 commit 69b3d65

10 files changed

+266
-238
lines changed

docs/tutorials/1 - Fixed Tilt Yearly Results.ipynb

+114-118
Large diffs are not rendered by default.

docs/tutorials/1 - Fixed Tilt Yearly Results.py

+33-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# coding: utf-8
33

4-
# In[2]:
4+
# In[1]:
55

66

77
# This information helps with debugging and getting support :)
@@ -67,7 +67,7 @@
6767
#
6868
#
6969

70-
# In[1]:
70+
# In[2]:
7171

7272

7373
import os
@@ -86,7 +86,7 @@
8686

8787
# This will load bifacial_radiance and other libraries from python that will be useful for this Jupyter Journal:
8888

89-
# In[2]:
89+
# In[3]:
9090

9191

9292
try:
@@ -101,7 +101,7 @@
101101

102102
# ## 2. Create a Radiance Object
103103

104-
# In[3]:
104+
# In[4]:
105105

106106

107107
# Create a RadianceObj 'object' named bifacial_example. no whitespace allowed
@@ -119,7 +119,7 @@
119119

120120
# To see more options of ground materials available (located on ground.rad), run this function without any input.
121121

122-
# In[4]:
122+
# In[5]:
123123

124124

125125
# Input albedo number or material name like 'concrete'.
@@ -128,7 +128,7 @@
128128

129129
# If a number between 0 and 1 is passed, it assumes it's an albedo value. For this example, we want a high-reflectivity rooftop albedo surface, so we will set the albedo to 0.62
130130

131-
# In[5]:
131+
# In[6]:
132132

133133

134134
albedo = 0.62
@@ -141,7 +141,7 @@
141141
#
142142
# There are various options provided in bifacial_radiance to load weatherfiles. getEPW is useful because you just set the latitude and longitude of the location and it donwloads the meteorologicla data for any location.
143143

144-
# In[6]:
144+
# In[7]:
145145

146146

147147
# Pull in meteorological data using pyEPW for any global lat/lon
@@ -152,7 +152,7 @@
152152
#
153153
# To load the data, use readWeatherFile. This reads EPWs, TMY meterological data, or even your own data as long as it follows TMY data format (With any time resoultion).
154154

155-
# In[7]:
155+
# In[8]:
156156

157157

158158
# Read in the weather data pulled in above.
@@ -167,7 +167,7 @@
167167
# or using gencumulativesky to generate a cumulativesky for the entire year.
168168
#
169169

170-
# In[8]:
170+
# In[9]:
171171

172172

173173
fullYear = True
@@ -196,7 +196,8 @@
196196
# </div>
197197
#
198198

199-
# In[9]:
199+
# In[10]:
200+
200201

201202

202203
module_type = 'test-module'
@@ -206,7 +207,8 @@
206207

207208
# In case you want to use a pre-defined module or a module you've created previously, they are stored in a JSON format in data/module.json, and the options available can be called with printModules:
208209

209-
# In[10]:
210+
# In[11]:
211+
210212

211213

212214
availableModules = demo.printModules()
@@ -221,15 +223,17 @@
221223
# Azimuth gets measured from N = 0, so for South facing modules azimuth should equal 180 degrees
222224
#
223225

224-
# In[11]:
226+
# In[12]:
227+
225228

226229

227230
sceneDict = {'tilt':10,'pitch':3,'clearance_height':0.2,'azimuth':180, 'nMods': 20, 'nRows': 7}
228231

229232

230233
# To make the scene we have to create a Scene Object through the method makeScene. This method will create a .rad file in the objects folder, with the parameters specified in sceneDict and the module created above. You can alternatively pass a string with the name of the `moduletype`.
231234

232-
# In[12]:
235+
# In[13]:
236+
233237

234238

235239
scene = demo.makeScene(module,sceneDict)
@@ -242,15 +246,17 @@
242246
# Radiance requires an "Oct" file that combines the ground, sky and the scene object into it.
243247
# The method makeOct does this for us.
244248

245-
# In[13]:
249+
# In[14]:
250+
246251

247252

248253
octfile = demo.makeOct(demo.getfilelist())
249254

250255

251256
# To see what files got merged into the octfile, you can use the helper method getfilelist. This is useful for advanced simulations too, specially when you want to have different Scene objects in the same simulation, or if you want to add other custom elements to your scene (like a building, for example)
252257

253-
# In[14]:
258+
# In[15]:
259+
254260

255261

256262
demo.getfilelist()
@@ -265,15 +271,17 @@
265271

266272
# First let's create the Analysis Object
267273

268-
# In[15]:
274+
# In[16]:
275+
269276

270277

271278
analysis = AnalysisObj(octfile, demo.basename)
272279

273280

274281
# Then let's specify the sensor location. If no parameters are passed to moduleAnalysis, it will scan the center module of the center row:
275282

276-
# In[16]:
283+
# In[17]:
284+
277285

278286

279287
frontscan, backscan = analysis.moduleAnalysis(scene)
@@ -284,15 +292,17 @@
284292
# ![Simple example for south facing module](../images_wiki/Journal1Pics/frontscan_backscan.png)
285293
# Analysis saves the measured irradiances in the front and in the back on the results folder. Prints out the ratio of the average of the rear and front irradiance values along a chord of the module.
286294

287-
# In[17]:
295+
# In[18]:
296+
288297

289298

290299
results = analysis.analysis(octfile, demo.basename, frontscan, backscan)
291300

292301

293302
# The results are also automatically saved in the results folder. Some of our input/output functions can be used to read the results and work with them, for example:
294303

295-
# In[18]:
304+
# In[19]:
305+
296306

297307

298308
load.read1Result('results\irr_tutorial_1.csv')
@@ -304,7 +314,8 @@
304314
#
305315
# Assuming that our module has a bifaciality factor (rear to front performance) of 90%, our <u> bifacial gain </u> is of:
306316

307-
# In[19]:
317+
# In[20]:
318+
308319

309320

310321
bifacialityfactor = 0.9
@@ -323,6 +334,7 @@
323334
# In[20]:
324335

325336

337+
326338
## Comment the ! line below to run rvu from the Jupyter notebook instead of your terminal.
327339
## Simulation will stop until you close the rvu window
328340

@@ -338,6 +350,7 @@
338350
# In[21]:
339351

340352

353+
341354
## Comment the line below to run rvu from the Jupyter notebook instead of your terminal.
342355
## Simulation will stop until you close the rvu window
343356

docs/tutorials/11 - AgriPV Systems.py

+21-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# coding: utf-8
33

4-
# In[ ]:
4+
# In[1]:
55

66

77
# This information helps with debugging and getting support :)
@@ -56,7 +56,7 @@
5656
#
5757
# The magic is that, for doing the carport we see in the figure, we are going to do a 4-up configuration of modules (**numpanels**), and we are going to repeat that 3-UP 6 times (**nMods**)
5858

59-
# In[1]:
59+
# In[2]:
6060

6161

6262
import os
@@ -70,15 +70,15 @@
7070
print ("Your simulation will be stored in %s" % testfolder)
7171

7272

73-
# In[2]:
73+
# In[3]:
7474

7575

7676
from bifacial_radiance import *
7777
import numpy as np
7878
import pandas as pd
7979

8080

81-
# In[3]:
81+
# In[4]:
8282

8383

8484
simulationname = 'tutorial_11'
@@ -147,7 +147,8 @@
147147
#
148148
# ***rvu -vf views\front.vp -e .01 tutorial_11.oct***
149149

150-
# In[4]:
150+
# In[5]:
151+
151152

152153

153154
## Comment the ! line below to run rvu from the Jupyter notebook instead of your terminal.
@@ -168,7 +169,7 @@
168169
#
169170
# Positions of the piles could be done more programatically, but they are kinda estimated at the moment.
170171

171-
# In[5]:
172+
# In[7]:
172173

173174

174175
torquetubelength = module.scenex*(nMods)
@@ -192,7 +193,7 @@
192193
demo.appendtoScene(radfile=scene.radfiles, customObject=customObject, text="!xform -rz 0")
193194

194195

195-
# In[6]:
196+
# In[8]:
196197

197198

198199
name='Pile'
@@ -220,7 +221,8 @@
220221
#
221222
#
222223

223-
# In[7]:
224+
# In[9]:
225+
224226

225227

226228
## Comment the ! line below to run rvu from the Jupyter notebook instead of your terminal.
@@ -240,21 +242,21 @@
240242
#
241243
# We are also increasign the number of points sampled accross the collector width, with the variable **sensorsy** passed to **moduleanalysis**. We are also increasing the step between sampling points, to be able to sample in between the rows.
242244

243-
# In[8]:
245+
# In[10]:
244246

245247

246248
analysis = AnalysisObj(octfile, demo.name)
247249
sensorsy = 20
248250
frontscan, backscan = analysis.moduleAnalysis(scene, sensorsy=sensorsy)
249251

250252

251-
# In[9]:
253+
# In[11]:
252254

253255

254256
groundscan = frontscan
255257

256258

257-
# In[10]:
259+
# In[12]:
258260

259261

260262
groundscan['zstart'] = 0.05 # setting it 5 cm from the ground.
@@ -263,7 +265,7 @@
263265
groundscan
264266

265267

266-
# In[11]:
268+
# In[13]:
267269

268270

269271
analysis.analysis(octfile, simulationname+"_groundscan", groundscan, backscan) # compare the back vs front irradiance
@@ -281,13 +283,13 @@
281283

282284
# ![AgriPV modeled step 4](../images_wiki/AdvancedJournals/spacing_between_modules.PNG)
283285

284-
# In[12]:
286+
# In[14]:
285287

286288

287289
import seaborn as sns
288290

289291

290-
# In[13]:
292+
# In[ ]:
291293

292294

293295
sensorsx = 20
@@ -306,7 +308,7 @@
306308

307309
# Read all the files generated into one dataframe
308310

309-
# In[14]:
311+
# In[ ]:
310312

311313

312314
filestarter = "irr_tutorial_11_groundscan_"
@@ -347,21 +349,21 @@
347349

348350
# Creating a new dataframe where each element in the front irradiance list is a column. Also transpose and reverse so it looks like a top-down view of the ground.
349351

350-
# In[15]:
352+
# In[ ]:
351353

352354

353355
df3 = pd.DataFrame(resultsdf['br_Wm2Front'].to_list())
354356
reversed_df = df3.T.iloc[::-1]
355357

356358

357-
# In[16]:
359+
# In[ ]:
358360

359361

360362
sns.set(rc={'figure.figsize':(11.7,8.27)})
361363
print(sns)
362364

363365

364-
# In[17]:
366+
# In[ ]:
365367

366368

367369
# Plot
@@ -381,7 +383,7 @@
381383
#
382384
#
383385

384-
# In[18]:
386+
# In[ ]:
385387

386388

387389
name='Center_Grass'

0 commit comments

Comments
 (0)