Eman96 commited on
Commit
88a0904
·
verified ·
1 Parent(s): 250fd87

Upload 9 files

Browse files
.gitattributes CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ data/cleaned_weather_data.csv filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official Python image as a parent image
2
+ FROM python:3.11-slim
3
+
4
+ # Set the working directory in the container
5
+ WORKDIR /app
6
+
7
+ # Copy the current directory contents into the container at /usr/src/app
8
+ COPY . /app
9
+
10
+ # Install any needed packages specified in requirements.txt
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Make port 80 available to the world outside this container
14
+ EXPOSE 5006
15
+
16
+ # Define environment variable
17
+ ENV BOKEH_ALLOW_WS_ORIGIN=localhost:5006
18
+
19
+ # Run app.py when the container launches
20
+ CMD ["bokeh", "serve", "--show", "dashboard/app.py"]
clouds.png ADDED
dashboard/app.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import panel as pn
2
+ from panel.template import FastListTemplate
3
+ from data_manager import DataManager
4
+ from visualizations import temp_chart, create_aqi_plot, condition_pie_chart, create_wind_speed_plot
5
+ from dashboard_components import create_location_selector, create_temp_unit_selector
6
+
7
+ data_manager = DataManager('data/cleaned_weather_data.csv', )
8
+ location_selector = create_location_selector(data_manager.weather['location_name'].unique().tolist())
9
+ temp_unit_selector = create_temp_unit_selector(options=['Celsius', 'Fahrenheit'])
10
+
11
+ @pn.depends(location_selector.param.value, temp_unit_selector.param.value)
12
+ def update_plots(country, temp_unit):
13
+ # Generate plot figures
14
+ temp_plot = temp_chart(country, temp_unit)
15
+ aqi_plot = create_aqi_plot(country)
16
+ condition_pie_plot = condition_pie_chart(country)
17
+ wind_speed_plot = create_wind_speed_plot(country)
18
+
19
+ # Create Panel objects for each plot directly here
20
+ temp_plot_panel = pn.pane.Plotly(temp_plot)
21
+ aqi_plot_panel = pn.pane.Plotly(aqi_plot)
22
+ condition_pie_plot_panel = pn.pane.Plotly(condition_pie_plot)
23
+ wind_speed_plot_panel = pn.pane.Plotly(wind_speed_plot)
24
+
25
+ # Arrange the Panel objects in rows and columns
26
+ row1 = pn.Row(pn.Column(temp_unit_selector, pn.Row(temp_plot_panel, aqi_plot_panel)))
27
+ row2 = pn.Row(pn.Column(pn.Row(condition_pie_plot_panel, wind_speed_plot_panel)))
28
+
29
+ main_column = pn.Column(row1, row2)
30
+
31
+ return main_column
32
+
33
+ # Template for the dashboard
34
+ template = FastListTemplate(
35
+ title='Global Weather Overview Dashboard',
36
+ sidebar=[
37
+ pn.pane.Markdown("# WorldWide Weather Analytics"),
38
+ pn.pane.Markdown(" Global weather encompasses temperature changes, weather conditions, wind patterns,\
39
+ and air quality, each significantly impacting ecosystems, human health, and agriculture.\
40
+ Understanding these elements is crucial for managing environmental risks and enhancing \
41
+ resilience against climatic variations."),
42
+
43
+ pn.pane.PNG('clouds.png', sizing_mode='scale_both'),
44
+ pn.pane.Markdown("#### Settings"),
45
+ location_selector
46
+ ],
47
+ main=[
48
+ # Dynamically update the plots based on user selections
49
+ update_plots]
50
+ ,
51
+ header_background="#9381ff",
52
+ accent_base_color="#b8b8ff",
53
+ # background_color='#bbd1ea',
54
+ main_layout='card')
55
+
56
+
57
+ template.servable()
dashboard/dashboard_components.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import panel as pn
2
+
3
+ def create_location_selector(options):
4
+ return pn.widgets.Select(name='Select Location', options=options)
5
+
6
+ def create_temp_unit_selector(options):
7
+ return pn.widgets.RadioButtonGroup(name='Temperature Unit', options=options, button_type='primary')
dashboard/data_manager.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+
3
+ class DataManager:
4
+ def __init__(self, file_path):
5
+ self.weather = pd.read_csv(file_path)
6
+
7
+ def get_location_data(self, location):
8
+ return self.weather[self.weather['location_name'] == location]
9
+
dashboard/visualizations.py ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import plotly.express as px
2
+ import pandas as pd
3
+ from data_manager import DataManager
4
+
5
+ data_manager = DataManager('data/cleaned_weather_data.csv')
6
+
7
+
8
+ def temp_chart(location, temp_unit):
9
+ df = data_manager.get_location_data(location)
10
+ y_axis = 'Temperature (°C)' if temp_unit == 'Celsius' else 'Temperature (°F)'
11
+ fig = px.line(df, x='last_updated', y=y_axis, color_discrete_sequence=['#7158e2'])
12
+ fig.update_layout(
13
+ title={
14
+ 'text': f'Temperature Trends over Time',
15
+ 'y': 0.96,
16
+ 'x': 0.5,
17
+ 'xanchor': 'center',
18
+ 'yanchor': 'top',
19
+ 'font': {'color': 'RebeccaPurple', 'size': 20}
20
+ },
21
+ xaxis=dict(
22
+ title='Date',
23
+ titlefont=dict(
24
+ family="Arial, sans-serif",
25
+ size=15,
26
+ color="RebeccaPurple"
27
+ )
28
+ ),
29
+ yaxis=dict(
30
+ title=y_axis,
31
+ titlefont=dict(
32
+ family="Arial, sans-serif",
33
+ size=15,
34
+ color="RebeccaPurple"
35
+ )
36
+ )
37
+ )
38
+
39
+
40
+ return fig
41
+
42
+
43
+ # Aqi and Pollutants Concentration
44
+
45
+ def create_aqi_plot(location):
46
+ data = data_manager.get_location_data(location)
47
+ air_quality_columns = [
48
+ 'air_quality_Carbon_Monoxide', 'air_quality_Ozone', 'air_quality_Nitrogen_dioxide',
49
+ 'air_quality_Sulphur_dioxide', 'air_quality_PM2.5', 'air_quality_PM10'
50
+ ]
51
+ avg_concentration = data[air_quality_columns].mean()
52
+ readable_labels = {
53
+ 'air_quality_Carbon_Monoxide': 'CO',
54
+ 'air_quality_Ozone': 'O3',
55
+ 'air_quality_Nitrogen_dioxide': 'NO2',
56
+ 'air_quality_Sulphur_dioxide': 'SO2',
57
+ 'air_quality_PM2.5': 'PM2.5',
58
+ 'air_quality_PM10': 'PM10'
59
+ }
60
+ avg_concentration.index = [readable_labels[col] for col in avg_concentration.index]
61
+ avg_concentration = avg_concentration.sort_values(ascending=False).reset_index()
62
+ avg_concentration.columns = ['Pollutants', 'Average Concentration']
63
+
64
+ fig = px.bar(avg_concentration, x='Pollutants', y='Average Concentration',
65
+ title=f'Average Air Quality Indexes for {location}',color='Pollutants',
66
+ color_discrete_sequence=px.colors.qualitative.Set3,
67
+ template='plotly_white'
68
+ )
69
+ fig.update_layout(showlegend=False)
70
+ fig.update_layout(
71
+ title={
72
+ 'text': f'Average Air Quality ({location})',
73
+ 'y': 0.96,
74
+ 'x': 0.5,
75
+ 'xanchor': 'center',
76
+ 'yanchor': 'top',
77
+ 'font': {'color': 'RebeccaPurple', 'size': 20}
78
+ },
79
+ xaxis=dict(
80
+ title='Pollutants',
81
+ titlefont=dict(
82
+ family="Arial, sans-serif",
83
+ size=15,
84
+ color="RebeccaPurple"
85
+ )
86
+ ),
87
+ yaxis=dict(
88
+ title='Average Concentration',
89
+ titlefont=dict(
90
+ family="Arial, sans-serif",
91
+ size=15,
92
+ color="RebeccaPurple"
93
+ )
94
+ )
95
+ )
96
+ return fig
97
+
98
+ # Weather Conditions
99
+ def condition_pie_chart(location):
100
+ data = data_manager.get_location_data(location)
101
+ weather_counts = data['condition_text'].value_counts().head(4)
102
+ fig = px.pie(weather_counts, values=weather_counts.values, names=weather_counts.index,
103
+ title='Weather Condition Distribution', hole=0.6,
104
+ color_discrete_sequence=px.colors.qualitative.Set3
105
+ )
106
+ fig.update_traces(textinfo='percent')
107
+ fig.update_layout(showlegend=True)
108
+ fig.update_layout(uniformtext_minsize=12, uniformtext_mode='hide')
109
+ fig.update_layout(
110
+ title={
111
+ 'text': f'Weather Condition Distribution ',
112
+ 'y':0.96,
113
+ 'x':0.5,
114
+ 'xanchor': 'center',
115
+ 'yanchor': 'top',
116
+ 'font': {'color': 'RebeccaPurple', 'size': 20}})
117
+ fig.update_layout(
118
+ font=dict(
119
+ family="Arial, sans-serif",
120
+ size=12,
121
+ color="RebeccaPurple"
122
+ )
123
+ )
124
+ fig.update_layout(
125
+ legend=dict(
126
+ orientation="h",
127
+ yanchor="bottom",
128
+ y=1.01,
129
+ xanchor="auto",
130
+ x=0.9
131
+ )
132
+ )
133
+ return fig
134
+
135
+
136
+ # Wind speed
137
+ def create_wind_speed_plot(location):
138
+ data = data_manager.get_location_data(location)
139
+ fig = px.line(data, x='last_updated', y='Wind Speed (kph)', color_discrete_sequence=['#7158e2'])
140
+ fig.update_layout(
141
+ title={
142
+ 'text': f'Wind Speed Trends',
143
+ 'y': 0.96,
144
+ 'x': 0.5,
145
+ 'xanchor': 'center',
146
+ 'yanchor': 'top',
147
+ 'font': {'color': 'RebeccaPurple', 'size': 20}
148
+ },
149
+ xaxis=dict(
150
+ title='Date',
151
+ titlefont=dict(
152
+ family="Arial, sans-serif",
153
+ size=15,
154
+ color="RebeccaPurple"
155
+ )
156
+ ),
157
+ yaxis=dict(
158
+ title=f'Wind Speed (kph)',
159
+ titlefont=dict(
160
+ family="Arial, sans-serif",
161
+ size=15,
162
+ color="RebeccaPurple"
163
+ )
164
+ )
165
+ )
166
+ return fig
167
+
data/cleaned_weather_data.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fd0181bda730c9d45d3efdc339c430f66e1c059d5fe8a306c8c599f9b3f17688
3
+ size 10742154
requirements.txt ADDED
Binary file (1.58 kB). View file
 
weather.png ADDED