SANIDHYAG commited on
Commit
06cdbac
·
verified ·
1 Parent(s): 4ad8f07

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -63
app.py DELETED
@@ -1,63 +0,0 @@
1
- import streamlit as st
2
- import requests
3
- import pandas as pd
4
- import altair as alt
5
- from datetime import datetime
6
-
7
- st.set_page_config(page_title="Climate Clock Dashboard", layout="wide")
8
- st.title("🌍 Real-Time Climate Clock Dashboard")
9
-
10
- # Fetch Climate Clock API data
11
- api_url = "https://api.climateclock.world/v2/clock"
12
- response = requests.get(api_url)
13
- data = response.json()
14
- clock = data["data"]["clocks"]
15
-
16
- # CO2 Budget Visualization
17
- co2_clock = clock["co2"]
18
- co2_remaining = float(co2_clock["remaining"])
19
- co2_rate = float(co2_clock["rate"])
20
- projected_years = 10
21
- current_year = datetime.now().year
22
- years = list(range(current_year, current_year + projected_years))
23
- remaining_values = [co2_remaining - co2_rate * i for i in range(projected_years)]
24
- co2_df = pd.DataFrame({'Year': years, 'Remaining CO₂ Budget (Gt)': remaining_values})
25
-
26
- st.subheader("💨 Projected CO₂ Budget Depletion (Next 10 Years)")
27
- co2_chart = alt.Chart(co2_df).mark_line(point=True).encode(
28
- x='Year:O',
29
- y='Remaining CO₂ Budget (Gt):Q',
30
- tooltip=['Year', 'Remaining CO₂ Budget (Gt)']
31
- ).properties(width=700, height=400)
32
- st.altair_chart(co2_chart, use_container_width=True)
33
-
34
- # Renewable Energy Progress Visualization
35
- renewables_clock = clock["renewables"]
36
- renewables_percent = float(renewables_clock["percentage"])
37
- renewable_df = pd.DataFrame({
38
- 'Type': ['Renewables', 'Others'],
39
- 'Percentage': [renewables_percent, 100 - renewables_percent]
40
- })
41
-
42
- st.subheader("⚡ Global Energy Source Share")
43
- renewable_chart = alt.Chart(renewable_df).mark_arc(innerRadius=50).encode(
44
- theta='Percentage:Q',
45
- color='Type:N',
46
- tooltip=['Type', 'Percentage']
47
- ).properties(width=400, height=400)
48
- st.altair_chart(renewable_chart, use_container_width=True)
49
-
50
- # Lifeline Section
51
- st.subheader("🌱 Lifeline Metrics")
52
- lifelines = clock["lifelines"]
53
- lifeline_data = [{'Label': l['label'], 'Value': float(l['value'])} for l in lifelines]
54
- lifeline_df = pd.DataFrame(lifeline_data)
55
-
56
- lifeline_chart = alt.Chart(lifeline_df).mark_bar().encode(
57
- x=alt.X('Label:N', sort='-y'),
58
- y='Value:Q',
59
- tooltip=['Label', 'Value']
60
- ).properties(width=700, height=400)
61
- st.altair_chart(lifeline_chart, use_container_width=True)
62
-
63
- st.caption("Data source: Climate Clock API (https://climateclock.world)")