Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,64 +13,98 @@ st.set_page_config(
|
|
| 13 |
# --- Custom CSS ---
|
| 14 |
st.markdown("""
|
| 15 |
<style>
|
| 16 |
-
/*
|
| 17 |
-
|
| 18 |
-
|
|
|
|
| 19 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
/*
|
| 22 |
-
|
| 23 |
-
font-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
}
|
| 25 |
|
| 26 |
-
/*
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
font-
|
| 30 |
-
line-height: 1.4;
|
| 31 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
/*
|
| 34 |
-
[data-testid="stSidebar"] {
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
}
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
.metric-card {
|
| 40 |
-
background-color: #
|
| 41 |
-
padding:
|
| 42 |
-
border-radius:
|
| 43 |
text-align: center;
|
| 44 |
-
margin-bottom:
|
| 45 |
-
border: 1px solid #
|
| 46 |
-
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
| 47 |
}
|
|
|
|
| 48 |
.big-number {
|
| 49 |
-
font-size:
|
| 50 |
-
font-weight:
|
| 51 |
color: #ff4b4b;
|
|
|
|
|
|
|
| 52 |
}
|
|
|
|
| 53 |
.sub-text {
|
| 54 |
-
font-size: 1.
|
| 55 |
-
|
|
|
|
| 56 |
}
|
| 57 |
|
| 58 |
-
/*
|
| 59 |
-
[data-testid="stSidebar"] {
|
| 60 |
-
font-size: 1rem;
|
| 61 |
-
}
|
| 62 |
-
[data-testid="stSidebar"] label {
|
| 63 |
-
font-size: 1rem !important;
|
| 64 |
-
font-weight: 500 !important;
|
| 65 |
-
}
|
| 66 |
-
.sidebar-question {
|
| 67 |
-
font-size: 1.6rem;
|
| 68 |
-
font-weight: bold;
|
| 69 |
-
margin-bottom: 5px;
|
| 70 |
-
color: #31333F;
|
| 71 |
-
}
|
| 72 |
.spacer {
|
| 73 |
-
margin-
|
|
|
|
|
|
|
|
|
|
| 74 |
}
|
| 75 |
</style>
|
| 76 |
""", unsafe_allow_html=True)
|
|
@@ -94,7 +128,8 @@ ai_demand_gw = st.sidebar.number_input(
|
|
| 94 |
"Demand (GW)",
|
| 95 |
value=100,
|
| 96 |
step=10,
|
| 97 |
-
|
|
|
|
| 98 |
)
|
| 99 |
with st.sidebar.expander("More on AI Demand Forecasts"):
|
| 100 |
st.write("According to [EpochAI](https://epoch.ai/gradient-updates/is-almost-everyone-wrong-about-americas-ai-power-problem#:~:text=Our%20best%20projections%20suggest%20that%20the%20US%20will%20need%20around%20100%20GW%20of%20power%20by%202030.) the best projections suggest that the US will need ~100 GW of power by 2030.")
|
|
@@ -106,6 +141,7 @@ st.sidebar.markdown('<p class="sidebar-question">2. What proportion of power wil
|
|
| 106 |
gas_share = st.sidebar.slider(
|
| 107 |
"Gas Share",
|
| 108 |
min_value=0, max_value=100, value=90, step=5,
|
|
|
|
| 109 |
label_visibility="collapsed"
|
| 110 |
)
|
| 111 |
|
|
@@ -129,6 +165,7 @@ st.sidebar.markdown('<p class="sidebar-question">3. What will the efficiency of
|
|
| 129 |
turbine_eff_percent = st.sidebar.slider(
|
| 130 |
"Efficiency",
|
| 131 |
min_value=35, max_value=60, value=45, step=1,
|
|
|
|
| 132 |
label_visibility="collapsed"
|
| 133 |
)
|
| 134 |
|
|
@@ -173,9 +210,8 @@ with c2:
|
|
| 173 |
<div class="metric-card">
|
| 174 |
<div class="sub-text">2030 US Emissions Increase due to AI</div>
|
| 175 |
<div class="big-number">+{percent_increase:.2f}%</div>
|
| 176 |
-
<div class="sub-text">{ai_emissions_mmt:.1f} Million
|
| 177 |
<div style="font-size: 1em; color: #888; margin-top: 10px;">
|
| 178 |
-
Based on {gas_share}% Gas Share & {turbine_eff_percent}% Efficiency
|
| 179 |
</div>
|
| 180 |
</div>
|
| 181 |
""", unsafe_allow_html=True)
|
|
@@ -227,7 +263,7 @@ fig1.update_layout(
|
|
| 227 |
},
|
| 228 |
yaxis={
|
| 229 |
'title': {
|
| 230 |
-
'text': "Emissions (Million
|
| 231 |
'font': {'size': 20}
|
| 232 |
},
|
| 233 |
'tickfont': {'size': 16}
|
|
|
|
| 13 |
# --- Custom CSS ---
|
| 14 |
st.markdown("""
|
| 15 |
<style>
|
| 16 |
+
/* --- 1. Global Font Reset --- */
|
| 17 |
+
/* Applies a clean, modern system font to the whole app */
|
| 18 |
+
html, body, [class*="css"] {
|
| 19 |
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" !important;
|
| 20 |
}
|
| 21 |
+
|
| 22 |
+
/* --- 2. Sidebar Layout & Width --- */
|
| 23 |
+
[data-testid="stSidebar"] {
|
| 24 |
+
width: 450px !important;
|
| 25 |
+
min-width: 450px !important;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
/* --- 3. Sidebar Typography --- */
|
| 29 |
|
| 30 |
+
/* The Custom Question Headers */
|
| 31 |
+
.sidebar-question {
|
| 32 |
+
font-size: 1.4rem;
|
| 33 |
+
font-weight: 700;
|
| 34 |
+
color: #1f2937; /* Dark grey for better contrast */
|
| 35 |
+
margin-bottom: 8px;
|
| 36 |
+
line-height: 1.3;
|
| 37 |
}
|
| 38 |
|
| 39 |
+
/* Standard Streamlit Labels (e.g., above sliders if visible) */
|
| 40 |
+
[data-testid="stSidebar"] label {
|
| 41 |
+
font-size: 1.1rem !important;
|
| 42 |
+
font-weight: 600 !important;
|
|
|
|
| 43 |
}
|
| 44 |
+
|
| 45 |
+
/* Markdown Paragraphs in Sidebar (e.g., in Expanders) */
|
| 46 |
+
[data-testid="stSidebar"] .stMarkdown p {
|
| 47 |
+
font-size: 1.05rem !important;
|
| 48 |
+
line-height: 1.5;
|
| 49 |
+
color: #4b5563;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
/* --- 4. Sidebar Input Styling --- */
|
| 53 |
|
| 54 |
+
/* Number Input: The actual number text */
|
| 55 |
+
[data-testid="stSidebar"] [data-testid="stNumberInput"] input {
|
| 56 |
+
font-size: 1.4rem !important;
|
| 57 |
+
font-weight: 700 !important;
|
| 58 |
+
color: #ff4b4b; /* Matches your theme color */
|
| 59 |
+
padding-top: 5px;
|
| 60 |
+
padding-bottom: 5px;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
/* Slider: Min/Max/Current Values */
|
| 64 |
+
[data-testid="stSidebar"] [data-testid="stTickBarMin"],
|
| 65 |
+
[data-testid="stSidebar"] [data-testid="stTickBarMax"] {
|
| 66 |
+
font-size: 1rem !important;
|
| 67 |
+
font-weight: 600 !important;
|
| 68 |
}
|
| 69 |
+
|
| 70 |
+
/* Slider: The Hover/Drag Value Popup */
|
| 71 |
+
[data-testid="stSidebar"] .stSlider [data-testid="stThumbValue"] {
|
| 72 |
+
font-size: 1.2rem !important;
|
| 73 |
+
font-weight: bold !important;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/* --- 5. Main Dashboard Components --- */
|
| 77 |
+
|
| 78 |
.metric-card {
|
| 79 |
+
background-color: #ffffff;
|
| 80 |
+
padding: 30px;
|
| 81 |
+
border-radius: 12px;
|
| 82 |
text-align: center;
|
| 83 |
+
margin-bottom: 25px;
|
| 84 |
+
border: 1px solid #e5e7eb;
|
| 85 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
| 86 |
}
|
| 87 |
+
|
| 88 |
.big-number {
|
| 89 |
+
font-size: 3.5rem;
|
| 90 |
+
font-weight: 800;
|
| 91 |
color: #ff4b4b;
|
| 92 |
+
margin: 10px 0;
|
| 93 |
+
line-height: 1;
|
| 94 |
}
|
| 95 |
+
|
| 96 |
.sub-text {
|
| 97 |
+
font-size: 1.25rem;
|
| 98 |
+
font-weight: 500;
|
| 99 |
+
color: #6b7280;
|
| 100 |
}
|
| 101 |
|
| 102 |
+
/* Custom Spacer for Sidebar */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
.spacer {
|
| 104 |
+
margin-top: 1.5rem;
|
| 105 |
+
margin-bottom: 1.5rem;
|
| 106 |
+
height: 1px;
|
| 107 |
+
background-color: #e5e7eb; /* Subtle divider line */
|
| 108 |
}
|
| 109 |
</style>
|
| 110 |
""", unsafe_allow_html=True)
|
|
|
|
| 128 |
"Demand (GW)",
|
| 129 |
value=100,
|
| 130 |
step=10,
|
| 131 |
+
format="%d GW",
|
| 132 |
+
label_visibility="collapsed"
|
| 133 |
)
|
| 134 |
with st.sidebar.expander("More on AI Demand Forecasts"):
|
| 135 |
st.write("According to [EpochAI](https://epoch.ai/gradient-updates/is-almost-everyone-wrong-about-americas-ai-power-problem#:~:text=Our%20best%20projections%20suggest%20that%20the%20US%20will%20need%20around%20100%20GW%20of%20power%20by%202030.) the best projections suggest that the US will need ~100 GW of power by 2030.")
|
|
|
|
| 141 |
gas_share = st.sidebar.slider(
|
| 142 |
"Gas Share",
|
| 143 |
min_value=0, max_value=100, value=90, step=5,
|
| 144 |
+
format="%d%%",
|
| 145 |
label_visibility="collapsed"
|
| 146 |
)
|
| 147 |
|
|
|
|
| 165 |
turbine_eff_percent = st.sidebar.slider(
|
| 166 |
"Efficiency",
|
| 167 |
min_value=35, max_value=60, value=45, step=1,
|
| 168 |
+
format="%d%%",
|
| 169 |
label_visibility="collapsed"
|
| 170 |
)
|
| 171 |
|
|
|
|
| 210 |
<div class="metric-card">
|
| 211 |
<div class="sub-text">2030 US Emissions Increase due to AI</div>
|
| 212 |
<div class="big-number">+{percent_increase:.2f}%</div>
|
| 213 |
+
<div class="sub-text">{ai_emissions_mmt:.1f} Million tCO<sub>2</sub>e</div>
|
| 214 |
<div style="font-size: 1em; color: #888; margin-top: 10px;">
|
|
|
|
| 215 |
</div>
|
| 216 |
</div>
|
| 217 |
""", unsafe_allow_html=True)
|
|
|
|
| 263 |
},
|
| 264 |
yaxis={
|
| 265 |
'title': {
|
| 266 |
+
'text': "Emissions (Million tCO<sub>2</sub>e)",
|
| 267 |
'font': {'size': 20}
|
| 268 |
},
|
| 269 |
'tickfont': {'size': 16}
|