-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhtml_maker.py
518 lines (424 loc) · 21.9 KB
/
html_maker.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
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
def summary_to_html(lat, lon, closest_height, powercurve, mean, ws_level, kwh_produced_avg_year, version="latest"):
if version == "latest":
# This version is based on:https://codepen.io/mrsahar/pen/yOVGBQ
# (one of tabled styles listed at: https://devdevout.com/css/css-tables, authored by: Sahar Ali Raza)
html = """
<p class="results_text">Analysis presented below was performed using
summary data from <strong>NREL's 20-year
<a href="https://www.energy.gov/eere/wind/articles/new-wind-resource-database-includes-updated-wind-toolkit" target="_blank" rel="noopener noreferrer">NREL's WTK-LED dataset</a></strong> using the following options:
<!-- <sup>*</sup> --!>
</p>
<br>
<ul class="results_text">
<li>Selected location (lat, lon): <strong>%.5f, %.5f</strong></li>
<li>Selected hub height: <strong>%.1f meters</strong></li>
<li>Selected power curve: <strong>%s</strong></li>
</ul>
<div id="generic_price_table">
<section>
<div class="container">
<!--BLOCK ROW START-->
<div class="row">
<div class="col-md-4">
<!--PRICE CONTENT START-->
<div class="generic_content clearfix">
<!--HEAD PRICE DETAIL START-->
<div class="generic_head_price clearfix">
<!--HEAD CONTENT START-->
<div class="generic_head_content clearfix">
<!--HEAD START-->
<div class="head_bg"></div>
<div class="head">
<span>Average wind speed</span>
</div>
<!--//HEAD END-->
</div>
<!--//HEAD CONTENT END-->
<!--PRICE START-->
<div class="generic_price_tag clearfix">
<span class="price">
<span class="currency">%.2f</span>
</span>
</div>
<!--//PRICE END-->
</div>
<!--//HEAD PRICE DETAIL END-->
<!--FEATURE LIST START-->
<div class="generic_feature_list">
<ul>
<li><span>m/s, </span> meters per second</li>
</ul>
</div>
<!--//FEATURE LIST END-->
</div>
<!--//PRICE CONTENT END-->
</div>
<div class="col-md-4">
<!--PRICE CONTENT START-->
<div class="generic_content clearfix">
<!--HEAD PRICE DETAIL START-->
<div class="generic_head_price clearfix">
<!--HEAD CONTENT START-->
<div class="generic_head_content clearfix">
<!--HEAD START-->
<div class="head_bg"></div>
<div class="head">
<span>Wind Resource</span>
</div>
<!--//HEAD END-->
</div>
<!--//HEAD CONTENT END-->
<!--PRICE START-->
<div class="generic_price_tag clearfix">
<span class="price">
<span class="sign">level: </span>
<span class="currency">%s</span>
</span>
</div>
<!--//PRICE END-->
</div>
<!--//HEAD PRICE DETAIL END-->
<!--FEATURE LIST START-->
<div class="generic_feature_list">
<ul>
<li>based on average wind speed</li>
</ul>
</div>
<!--//FEATURE LIST END-->
</div>
<!--//PRICE CONTENT END-->
</div>
<div class="col-md-4">
<!--PRICE CONTENT START-->
<div class="generic_content clearfix">
<!--HEAD PRICE DETAIL START-->
<div class="generic_head_price clearfix">
<!--HEAD CONTENT START-->
<div class="generic_head_content clearfix">
<!--HEAD START-->
<div class="head_bg"></div>
<div class="head">
<span>Energy Production</span>
</div>
<!--//HEAD END-->
</div>
<!--//HEAD CONTENT END-->
<!--PRICE START-->
<div class="generic_price_tag clearfix">
<span class="price">
<span class="currency">%s</span>
</span>
</div>
<!--//PRICE END-->
</div>
<!--//HEAD PRICE DETAIL END-->
<!--FEATURE LIST START-->
<div class="generic_feature_list">
<ul>
<li><span>Average kWh/year</span></li>
</ul>
</div>
<!--//FEATURE LIST END-->
</div>
<!--//PRICE CONTENT END-->
</div>
</div>
<!--//BLOCK ROW END-->
</div>
</section>
</div>
<div>
<p class="results_disclaimer_text"><span>
<!-- <sup>*</sup> --!>
Disclaimer: This summary represents a PRELIMINARY analysis.
Research conducted at national laboratories suggests that multiple models should be used for
more thorough analysis.
Reach out to a qualified installer for a refined estimate.
</span></p>
</div>
""" % (lat, lon, closest_height, powercurve, mean, ws_level, kwh_produced_avg_year)
return html
elif version == "v2":
html = """
<p class="results_text">Analysis presented below was done using NREL's WTK-LED dataset<sup>*</sup> and its 12x24 summaries for 2001-2020 at %d meters.</p>
<br>
<table border="0" cellspacing="10" class="summary_table">
<tbody>
<tr>
<td><span class="summary_table_metric">20-year wind speed average, m/s:</span></td>
</tr>
<tr>
<td><span class="summary_table_value">%.2f</span></td>
</tr>
</tbody>
</table>
<br>
<p class="results_disclaimer_text"><sup>*</sup> Disclaimer: Research conducted at national laboratories suggests that multiple models should be used for
more thorough analysis.</p>
""" % (mean, closest_height)
return html
elif version == "v1":
html = """
<table border="0" cellspacing="10" class="summary_table">
<tbody>
<tr>
<td><span class="summary_table_metric">All-time wind speed average, m/s:</span></td>
</tr>
<tr>
<td><span class="summary_table_value">%.2f</span></td>
</tr>
<tr>
<td><span class="summary_table_desc">estimated using 12x24 summaries from WTK-LED<br>for 2001-2020 at %d meters.</span></td>
</tr>
</tbody>
</table>
""" % (mean, closest_height)
html += """
<hr>
<table border="0" cellspacing="10" class="yearly_table">
<tbody>
<tr>
<td><span class="yearly_table_metric">Wind speed average for<br><u>lowest</u> year (%d):</span></td>
<td><span class="yearly_table_metric">Wind speed average for<br><u>median</u> year (%d):</span></td>
<td><span class="yearly_table_metric">Wind speed average for<br><u>highest</u> year (%d):</span></td>
</tr>
<tr>
<td><span class="yearly_table_value">%.2f</span></td>
<td><span class="yearly_table_value">%.2f</span></td>
<td><span class="yearly_table_value">%.2f</span></td>
</tr>
</tbody>
</table>
""" % (2008, 2010, 2012, mean*0.9, mean*1.0, mean*1.1)
return html
else:
return ""
def windresource_to_html(mean, ws_level, moderate_resource_thresh_ms, high_resource_thresh_ms, closest_height, version="latest", windrose_plot_name=""):
if version == "latest":
# This version is based on the latest in summary_to_html()
html = """
<p class="results_text">The wind resource is characterized by wind speed and wind direction.
These are both illustrated by a "wind rose" which shows how fast the wind blows from each wind direction throughout the year.
</p>
<br>
<p class="results_text">
Understanding where the wind comes from and how fast the wind blows are critical to placing the wind turbine
in a location that will not be affected by nearby structures and trees.
</p>
<br>
"""
if windrose_plot_name:
html += """
<div classes="centered">
<div>
<table>
<tr>
<td><img id=\"windrose_plot\" src=\"%s\"/></td>
</tr>
</table>
</div>
</div>
<br>
""" % windrose_plot_name
html += """
<p class="results_text">
Whether or not a specific project site is a good candidate for a wind turbine is based on several key factors including available financial incentives,
the cost of power in the area, cost to install the turbine as well as the wind resource. In the absence of detailed project economics,
it is illustrative to understand whether the wind speed is generally "low", "moderate", or "high" -- which correlates directly with low, moderate or high turbine performance.
</p>
<br>
"""
html += """
<div id="windresource_table">
<section>
<div class="container">
<!--BLOCK ROW START-->
<div class="row">
<div class="windresource-col">
<!--PRICE CONTENT START-->
<div class="windresource_content clearfix">
<!--HEAD PRICE DETAIL START-->
<div class="windresource_head_price clearfix">
<!--HEAD CONTENT START-->
<div class="windresource_head_content clearfix">
<!--HEAD START-->
<div class="head_bg"></div>
<div class="head">
<span>Wind Resource</span>
</div>
<!--//HEAD END-->
</div>
<!--//HEAD CONTENT END-->
<!--PRICE START-->
<div class="windresource_price_tag clearfix">
<span class="price">
<span class="sign">level: </span>
<span class="currency">%s</span>
</span>
</div>
<!--//PRICE END-->
</div>
<!--//HEAD PRICE DETAIL END-->
<!--FEATURE LIST START-->
<div class="windresource_feature_list">
<ul>
<li><span class="details_label">Details:</span></li>
<li><span>Estimated average wind speed is at %.2f m/s.</span></li>
<li><span>Low</span> wind resource referts to wind speeds <span>below %.2f m/s.</span></li>
<li><span>Moderate</span> wind resource refers to wind speeds <span>between %.2f and %.2f m/s.</span></li>
<li><span>High</span> wind resource refers to wind speeds <span>above %.2f m/s.</span></li>
</ul>
</div>
<!--//FEATURE LIST END-->
</div>
<!--//PRICE CONTENT END-->
</div>
</div>
<!--//BLOCK ROW END-->
</div>
</section>
</div>
<!--
<div>
<p class="results_disclaimer_text"><span><sup>*</sup> Disclaimer: ...</span></p>
</div>
--!>
""" % (ws_level, mean, moderate_resource_thresh_ms, moderate_resource_thresh_ms, high_resource_thresh_ms, high_resource_thresh_ms) #, closest_height)
return html
else:
return ""
def energyproduction_to_html(monthly_df, yearly_df):
monthly_html = monthly_df.to_html(classes="estimates_by_month_table") # classes="detailed_yearly_table")
yearly_html = yearly_df.to_html(classes="estimates_by_year_table") #classes="detailed_yearly_table")
html = """
<p class="results_text">
The wind resource, and by extension the energy production, varies month to month and year to year.
It is important to understand the average characteristics as well as the variability you can expect to see from your wind turbine on any given year.
</p>
<br>
<!-- <p class="results_text">
The table on the left details the wind speed and energy output for each month based on the average of 20 years at your site.
The summary on the right gives the total energy output for the lowest and highest of 20 years as well as an average year.
</p>
<br>
--!>
<table border="0" cellspacing="10" class="yearly_table">
<tbody>
<tr>
<td>
<!-- <span class="tooltip monthly_table_tooltip"><i class="fas fa-info-circle"></i></span> -->
<span class="production_label">Estimates <u>by month</u>:</span>
</td>
<td>
<!-- <span class="tooltip yearly_table_tooltip"><i class="fas fa-info-circle"></i></span> -->
<span class="production_label">Estimates <u>by year</u>:</span>
</td>
</tr>
<!-- <tr>
<td>The table below details the wind speed and energy output for each month<br>based on the average of 20 years at your site.</td>
<td>The table below gives the total energy output for the lowest and highest<br>of 20 years as well as the average year.</td>
</tr> --!>
<tr class="tr_top_align">
<td>%s</td>
<td>%s</td>
</tr>
</tbody>
</table>
""" % (monthly_html, yearly_html)
return html
def era5_summary_to_html(era5_global_avg, era5_closest_height_column, era5_df_avg_yearly_production):
# This version is based on:https://codepen.io/mrsahar/pen/yOVGBQ
# (one of tabled styles listed at: https://devdevout.com/css/css-tables, authored by: Sahar Ali Raza)
era5_df_avg_yearly_production = "{:,.0f}".format(era5_df_avg_yearly_production)
height = int(era5_closest_height_column.replace("ws", ""))
html = """
<p class="results_text">This analysis is done using hourly <a href="https://www.ecmwf.int/en/forecasts/dataset/ecmwf-reanalysis-v5" target="_blank" rel="noopener noreferrer">ERA5</a> data (2013--2023).
</p>
<br>
<p class="results_text">ERA5 height that is closest to the selected hub height: %d meters.
</p>
<br>
<div id="generic_price_table">
<section>
<div class="container">
<!--BLOCK ROW START-->
<div class="row">
<div class="col-md-4">
<!--PRICE CONTENT START-->
<div class="generic_content clearfix">
<!--HEAD PRICE DETAIL START-->
<div class="generic_head_price clearfix">
<!--HEAD CONTENT START-->
<div class="generic_head_content clearfix">
<!--HEAD START-->
<div class="head_bg"></div>
<div class="head">
<span>Average wind speed</span>
</div>
<!--//HEAD END-->
</div>
<!--//HEAD CONTENT END-->
<!--PRICE START-->
<div class="generic_price_tag clearfix">
<span class="price">
<span class="currency">%.2f</span>
</span>
</div>
<!--//PRICE END-->
</div>
<!--//HEAD PRICE DETAIL END-->
<!--FEATURE LIST START-->
<div class="generic_feature_list">
<ul>
<li><span>m/s, </span> meters per second</li>
</ul>
</div>
<!--//FEATURE LIST END-->
</div>
<!--//PRICE CONTENT END-->
</div>
<div class="col-md-4">
<!--PRICE CONTENT START-->
<div class="generic_content clearfix">
<!--HEAD PRICE DETAIL START-->
<div class="generic_head_price clearfix">
<!--HEAD CONTENT START-->
<div class="generic_head_content clearfix">
<!--HEAD START-->
<div class="head_bg"></div>
<div class="head">
<span>Energy Production</span>
</div>
<!--//HEAD END-->
</div>
<!--//HEAD CONTENT END-->
<!--PRICE START-->
<div class="generic_price_tag clearfix">
<span class="price">
<span class="currency">%s</span>
</span>
</div>
<!--//PRICE END-->
</div>
<!--//HEAD PRICE DETAIL END-->
<!--FEATURE LIST START-->
<div class="generic_feature_list">
<ul>
<li><span>Average kWh/year</span></li>
</ul>
</div>
<!--//FEATURE LIST END-->
</div>
<!--//PRICE CONTENT END-->
</div>
</div>
<!--//BLOCK ROW END-->
</div>
</section>
</div>
<div style="clear:both"></div>
<p class="era5_bottom_text"><span>
<a href="https://github.com/NREL/dw-tap-api/blob/master/docs/datasets_and_analysis.md#era5" target="_blank" rel="noopener noreferrer">Read more about dataset and analysis</a>.
</span></p>
""" % (height, era5_global_avg, era5_df_avg_yearly_production)
return html