Update sections.py
Browse files- sections.py +66 -21
sections.py
CHANGED
|
@@ -602,34 +602,79 @@ def section_final_checks() -> None:
|
|
| 602 |
for f in FREQUENCIES
|
| 603 |
}
|
| 604 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 605 |
# ββ RT60 final check βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 606 |
with t_rt:
|
| 607 |
-
if st.session_state.room_volume == 0 or not
|
| 608 |
-
st.warning("β οΈ Provide volume
|
| 609 |
else:
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
st.
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 620 |
fig = plot_rt_band(
|
| 621 |
y_cur,
|
| 622 |
-
[st.session_state.rt_min]*6,
|
| 623 |
-
[st.session_state.rt_max]*6,
|
| 624 |
"Final RT60 vs Standard Range",
|
| 625 |
)
|
| 626 |
-
fig.add_trace(
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
|
|
|
|
|
|
| 633 |
st.plotly_chart(fig, use_container_width=True)
|
| 634 |
st.session_state.fig_rt_final = fig
|
| 635 |
|
|
|
|
| 602 |
for f in FREQUENCIES
|
| 603 |
}
|
| 604 |
|
| 605 |
+
# ββ RT60 final check βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 606 |
+
# with t_rt:
|
| 607 |
+
# if st.session_state.room_volume == 0 or not combined:
|
| 608 |
+
# st.warning("β οΈ Provide volume + materials, then run Acoustic Treatment.")
|
| 609 |
+
# else:
|
| 610 |
+
# new_rt = {f: calc_abs_area(st.session_state.room_volume, a)
|
| 611 |
+
# for f, a in combined.items()}
|
| 612 |
+
# st.markdown("New RT60 values after acoustic treatment")
|
| 613 |
+
# st.dataframe(pd.DataFrame([new_rt], index=["New RT60"]),
|
| 614 |
+
# use_container_width=True)
|
| 615 |
+
|
| 616 |
+
# y_cur = ([float(st.session_state.df_current_rt.iloc[0][f])
|
| 617 |
+
# for f in FREQUENCIES]
|
| 618 |
+
# if st.session_state.df_current_rt is not None else [None]*6)
|
| 619 |
+
|
| 620 |
+
# fig = plot_rt_band(
|
| 621 |
+
# y_cur,
|
| 622 |
+
# [st.session_state.rt_min]*6,
|
| 623 |
+
# [st.session_state.rt_max]*6,
|
| 624 |
+
# "Final RT60 vs Standard Range",
|
| 625 |
+
# )
|
| 626 |
+
# fig.add_trace(go.Scatter(
|
| 627 |
+
# x=FREQUENCIES,
|
| 628 |
+
# y=[new_rt[f] for f in FREQUENCIES],
|
| 629 |
+
# mode="lines+markers",
|
| 630 |
+
# name="New",
|
| 631 |
+
# marker_color="#d62728",
|
| 632 |
+
# ))
|
| 633 |
+
# st.plotly_chart(fig, use_container_width=True)
|
| 634 |
+
# st.session_state.fig_rt_final = fig
|
| 635 |
+
|
| 636 |
+
# ββ RT60 final check βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 637 |
# ββ RT60 final check βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 638 |
with t_rt:
|
| 639 |
+
if st.session_state.room_volume == 0 or not st.session_state.new_absorption:
|
| 640 |
+
st.warning("β οΈ Provide room volume and at least one new material, then run Acoustic Treatment.")
|
| 641 |
else:
|
| 642 |
+
# --------------------------------------------------------------
|
| 643 |
+
# Use *only* the absorption contributed by the new materials
|
| 644 |
+
# (st.session_state.new_absorption) for Sabine RT60 calculation
|
| 645 |
+
# --------------------------------------------------------------
|
| 646 |
+
new_rt = {
|
| 647 |
+
f: (0.16 * st.session_state.room_volume / a) if a > 0 else float("inf")
|
| 648 |
+
for f, a in st.session_state.new_absorption.items()
|
| 649 |
+
}
|
| 650 |
+
|
| 651 |
+
st.markdown("New RT60 values after acoustic treatment (based on new materials only)")
|
| 652 |
+
st.dataframe(
|
| 653 |
+
pd.DataFrame([new_rt], index=["New RT60"]), use_container_width=True
|
| 654 |
+
)
|
| 655 |
+
|
| 656 |
+
# Plot current vs standard band vs new RT60
|
| 657 |
+
y_cur = (
|
| 658 |
+
[float(st.session_state.df_current_rt.iloc[0][f]) for f in FREQUENCIES]
|
| 659 |
+
if st.session_state.df_current_rt is not None
|
| 660 |
+
else [None] * 6
|
| 661 |
+
)
|
| 662 |
+
|
| 663 |
fig = plot_rt_band(
|
| 664 |
y_cur,
|
| 665 |
+
[st.session_state.rt_min] * 6,
|
| 666 |
+
[st.session_state.rt_max] * 6,
|
| 667 |
"Final RT60 vs Standard Range",
|
| 668 |
)
|
| 669 |
+
fig.add_trace(
|
| 670 |
+
go.Scatter(
|
| 671 |
+
x=FREQUENCIES,
|
| 672 |
+
y=[new_rt[f] for f in FREQUENCIES],
|
| 673 |
+
mode="lines+markers",
|
| 674 |
+
name="New",
|
| 675 |
+
marker_color="#d62728",
|
| 676 |
+
)
|
| 677 |
+
)
|
| 678 |
st.plotly_chart(fig, use_container_width=True)
|
| 679 |
st.session_state.fig_rt_final = fig
|
| 680 |
|