Skip to content

Commit a073f31

Browse files
authored
Merge pull request #744 from RWTH-EBC/issue683_modelReportFromFork
Improve model report
2 parents 6283a82 + bd26857 commit a073f31

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

teaser/data/output/reports/model_report.py

+24-7
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,16 @@ def export_reports(bldg_data, bldg_name, path, prj):
183183
output_path_base = os.path.join(path, base_name)
184184
plotly_file_name = os.path.join(path, "plots", base_name + "_plotly.html")
185185
# Draw an abstract image of the building and save it with plotly to HTML
186-
interactive_fig = create_simple_3d_visualization(bldg_data, roof_angle=30)
186+
interactive_fig, fixed_height =\
187+
create_simple_3d_visualization(bldg_data, roof_angle=30)
187188
if interactive_fig:
188189
interactive_fig.write_html(plotly_file_name)
189190
else:
190191
plotly_file_name = None
191192
html_file_name = os.path.join(output_path_base + ".html")
192-
create_html_page(bldg_data, prj.name, bldg_name, html_file_name, plotly_file_name)
193+
create_html_page(
194+
bldg_data, prj.name, bldg_name, html_file_name, plotly_file_name,
195+
fixed_height)
193196
create_csv_report(bldg_data, output_path_base)
194197

195198

@@ -235,7 +238,9 @@ def create_csv_report(bldg_data, output_path_base):
235238
]
236239
# round values
237240
for key, value in prj_data_flat.items():
238-
if not isinstance(value, str):
241+
if not value:
242+
value = "-"
243+
elif not isinstance(value, str):
239244
prj_data_flat[key] = round(value, 2)
240245
else:
241246
prj_data_flat[key] = value
@@ -312,7 +317,8 @@ def add_compass_to_3d_plot(fig, x_y_axis_sizing):
312317
return fig
313318

314319

315-
def create_html_page(bldg_data, prj_name, bldg_name, html_file_name, iframe_src):
320+
def create_html_page(bldg_data, prj_name, bldg_name, html_file_name,
321+
iframe_src, fixed_height):
316322
html_content = f"""
317323
<!DOCTYPE html>
318324
<html>
@@ -459,7 +465,10 @@ def create_html_page(bldg_data, prj_name, bldg_name, html_file_name, iframe_src)
459465
<th scope="row">{html.escape(key_human_readable)}</th>
460466
"""
461467
if not isinstance(value, str):
462-
value = str(round(value, 2))
468+
if value:
469+
value = str(round(value, 2))
470+
else:
471+
value = "-"
463472
if not list_item:
464473
html_content += f"""
465474
<td>{html.escape(value)} </td>
@@ -508,7 +517,11 @@ def create_html_page(bldg_data, prj_name, bldg_name, html_file_name, iframe_src)
508517
<li><i>Only works for buildings with 4 directions currently,
509518
while the smallest will be interpreted as
510519
north, the next bigger one as east and so on.</i></li>
511-
<li><i>The roof is not displayed correctly yet</i></li>
520+
<li><i>The roof is not displayed correctly yet</i></li>"""
521+
if fixed_height:
522+
html_content += f"""<li><i>The height of all floors is assumed to be 3
523+
meters.</i></li>"""
524+
html_content += f"""
512525
</div>
513526
</div>
514527
</div>
@@ -561,6 +574,10 @@ def get_value_with_default(lst, index, default_value):
561574
window_area_south = get_value_with_default(window_values, 2, 0)
562575
window_area_west = get_value_with_default(window_values, 3, 0)
563576
height = bldg_data["Floor Height"]
577+
fixed_height = False
578+
if not height:
579+
height = 3
580+
fixed_height = True
564581
num_floors = bldg_data["Number of Floors"]
565582

566583
length_north = area_north / (num_floors * height)
@@ -754,7 +771,7 @@ def get_value_with_default(lst, index, default_value):
754771
)
755772
)
756773

757-
return fig
774+
return fig, fixed_height
758775
except Exception as e:
759776
message = type(e).__name__ + str(e.args)
760777
print(

0 commit comments

Comments
 (0)