Meteorama commited on
Commit
d7b9aaa
·
verified ·
1 Parent(s): b691b81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -157
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import streamlit as st
2
- import pyplot.express as px
3
  import openmeteo_requests
4
  import requests_cache
5
  import pandas as pd
@@ -41,92 +41,7 @@ end_date = start_date + timedelta(days=10)
41
  st.caption(f"Time Period: {parseday(start_date)} to {parseday(end_date)}")
42
 
43
  #Draw Tabs
44
- tab1, tab2 = st.tabs(['Overall', 'Daily'])
45
-
46
- #Min and Max temperature
47
- min_max_date_list = []
48
- min_max_min_list = []
49
- min_max_max_list = []
50
- for i in range(11):
51
- cur_date = start_date + timedelta(days=i)
52
- minidf = wxdata[(wxdata['Day'] == cur_date.day)&(wxdata['Month'] == cur_date.month)&(wxdata['Year'] == cur_date.year)]
53
- min_max_date_list.append(cur_date)
54
- min_max_min_list.append(minidf['temperature_2m'].min())
55
- min_max_max_list.append(minidf['temperature_2m'].max())
56
-
57
- min_max_df = pd.DataFrame()
58
- min_max_df['Date'] = min_max_date_list
59
- min_max_df['Minimum Temperature'] = min_max_min_list
60
- min_max_df['Maximum Temperature'] = min_max_max_list
61
-
62
- mintempfig = px.line(min_max_df, x = 'Date', y = 'Minimum Temperature')
63
- maxtempfig = px.line(min_max_df, x = 'Date', y = 'Maximum Temperature')
64
-
65
- with tab1.expander("Minimum and Maximum Temperature"):
66
- st.plotly_chart(mintempfig, use_container_width = True)
67
- st.plotly_chart(maxtempfig, use_container_width = True)
68
-
69
- #temperature and inversion
70
- #Temperature plot
71
- tempfig = px.line(wxdata, x = 'Date_IST', y = 'temperature_2m', hover_data= 'temperature_925hPa',
72
- labels = {'Date_IST': 'Date and Time', 'temperature_2m': 'Dry Bulb Temp', 'temperature_925hPa': 'Temp at F/L025'})
73
-
74
- #Inversion
75
- invlist = []
76
- temp2mlist = wxdata['temperature_2m'].values
77
- temp025list = wxdata['temperature_925hPa'].values
78
-
79
- for t in range(len(temp2mlist)):
80
- if((temp025list[t] - temp2mlist[t])>0):
81
- invlist.append((temp025list[t] - temp2mlist[t]))
82
- else:
83
- invlist.append(0)
84
-
85
- wxdata['Inversion'] = invlist
86
- invfig = px.bar(wxdata, x='Date_IST', y='Inversion')
87
-
88
-
89
- with tab1.expander("Temperature and Inversion"):
90
- st.plotly_chart(tempfig, use_container_width = True)
91
- st.plotly_chart(invfig, use_container_width = True)
92
-
93
- #RH plot
94
- rhfig = px.line(wxdata, x = 'Date_IST', y = 'relative_humidity_2m', labels = {'newdate': 'Date and Time', 'relative_humidity_2m': 'RH(%age)'})
95
-
96
- with tab1.expander("Relative Humidity"):
97
- st.plotly_chart(rhfig, use_container_width = True)
98
-
99
- #Cloud Plots
100
- cloudsfig = px.line(wxdata, x = 'Date_IST', y = 'cloud_cover', hover_data = ['cloud_cover_low', 'cloud_cover_mid', 'cloud_cover_high'],
101
- labels = {'Date_IST': 'Date and Time', 'cloud_cover': 'Total Cloud Cover (%age)',
102
- 'cloud_cover_low': 'Low Clouds',
103
- 'cloud_cover_mid': 'Medium Clouds',
104
- 'cloud_cover_high': 'High Clouds'})
105
- cloudsfig.update_layout(yaxis_range=[0,100])
106
- lowcloudsfig = px.line(wxdata, x = 'Date_IST', y = 'cloud_cover_low', hover_data = ['cloud_cover', 'cloud_cover_mid', 'cloud_cover_high'],
107
- labels = {'Date_IST': 'Date and Time', 'cloud_cover': 'Total Cloud Cover (%age)',
108
- 'cloud_cover_low': 'Low Clouds',
109
- 'cloud_cover_mid': 'Medium Clouds',
110
- 'cloud_cover_high': 'High Clouds'})
111
- midcloudsfig = px.line(wxdata, x = 'Date_IST', y = 'cloud_cover_mid', hover_data = ['cloud_cover', 'cloud_cover_low', 'cloud_cover_high'],
112
- labels = {'Date_IST': 'Date and Time', 'cloud_cover': 'Total Cloud Cover (%age)',
113
- 'cloud_cover_low': 'Low Clouds',
114
- 'cloud_cover_mid': 'Medium Clouds',
115
- 'cloud_cover_high': 'High Clouds'})
116
- highcloudsfig = px.line(wxdata, x = 'Date_IST', y = 'cloud_cover_high', hover_data = ['cloud_cover', 'cloud_cover_low', 'cloud_cover_mid'],
117
- labels = {'Date_IST': 'Date and Time', 'cloud_cover': 'Total Cloud Cover (%age)',
118
- 'cloud_cover_low': 'Low Clouds',
119
- 'cloud_cover_mid': 'Medium Clouds',
120
- 'cloud_cover_high': 'High Clouds'})
121
- lowcloudsfig.update_layout(yaxis_range=[0,100])
122
- midcloudsfig.update_layout(yaxis_range=[0,100])
123
- highcloudsfig.update_layout(yaxis_range=[0,100])
124
-
125
- with tab1.expander("Cloudiness"):
126
- st.plotly_chart(cloudsfig, use_container_width = True)
127
- st.plotly_chart(lowcloudsfig, use_container_width = True)
128
- st.plotly_chart(midcloudsfig, use_container_width = True)
129
- st.plotly_chart(highcloudsfig, use_container_width = True)
130
 
131
  #precipitaion plot
132
  pptfig = px.bar(wxdata, x = 'Date_IST', y = 'precipitation', labels = {'Date_IST': 'Date and Time', 'precipitation': 'Precipitation'})
@@ -155,76 +70,6 @@ with tab2.expander("Current Weather Register"):
155
  st.table(makecwr(wxdata2))
156
 
157
 
158
- #temperature and inversion
159
- #Temperature plot
160
- tempfig = px.line(wxdata2, x = 'Date_IST', y = 'temperature_2m', hover_data= 'temperature_925hPa',
161
- labels = {'Date_IST': 'Date and Time', 'temperature_2m': 'Dry Bulb Temp', 'temperature_925hPa': 'Temp at F/L025'})
162
-
163
- #Inversion
164
- invlist = []
165
- temp2mlist = wxdata2['temperature_2m'].values
166
- temp025list = wxdata2['temperature_925hPa'].values
167
-
168
- for t in range(len(temp2mlist)):
169
- if((temp025list[t] - temp2mlist[t])>0):
170
- invlist.append((temp025list[t] - temp2mlist[t]))
171
- else:
172
- invlist.append(0)
173
-
174
- wxdata2['Inversion'] = invlist
175
- invfig = px.bar(wxdata2, x='Date_IST', y='Inversion')
176
- invfig.update_layout(yaxis_range=[0,5])
177
-
178
- with tab2.expander("Temperature and Inversion"):
179
- st.plotly_chart(tempfig, use_container_width = True)
180
- st.plotly_chart(invfig, use_container_width = True)
181
-
182
- #RH plot
183
- rhfig = px.line(wxdata2, x = 'Date_IST', y = 'relative_humidity_2m', labels = {'newdate': 'Date and Time', 'relative_humidity_2m': 'RH(%age)'})
184
-
185
- with tab2.expander("Relative Humidity"):
186
- st.plotly_chart(rhfig, use_container_width = True)
187
-
188
- #Cloud Plots
189
- cloudsfig = px.line(wxdata2, x = 'Date_IST', y = 'cloud_cover', hover_data = ['cloud_cover_low', 'cloud_cover_mid', 'cloud_cover_high'],
190
- labels = {'Date_IST': 'Date and Time', 'cloud_cover': 'Total Cloud Cover (%age)',
191
- 'cloud_cover_low': 'Low Clouds',
192
- 'cloud_cover_mid': 'Medium Clouds',
193
- 'cloud_cover_high': 'High Clouds'})
194
- cloudsfig.update_layout(yaxis_range=[0,100])
195
- lowcloudsfig = px.line(wxdata2, x = 'Date_IST', y = 'cloud_cover_low', hover_data = ['cloud_cover', 'cloud_cover_mid', 'cloud_cover_high'],
196
- labels = {'Date_IST': 'Date and Time', 'cloud_cover': 'Total Cloud Cover (%age)',
197
- 'cloud_cover_low': 'Low Clouds',
198
- 'cloud_cover_mid': 'Medium Clouds',
199
- 'cloud_cover_high': 'High Clouds'})
200
- midcloudsfig = px.line(wxdata2, x = 'Date_IST', y = 'cloud_cover_mid', hover_data = ['cloud_cover', 'cloud_cover_low', 'cloud_cover_high'],
201
- labels = {'Date_IST': 'Date and Time', 'cloud_cover': 'Total Cloud Cover (%age)',
202
- 'cloud_cover_low': 'Low Clouds',
203
- 'cloud_cover_mid': 'Medium Clouds',
204
- 'cloud_cover_high': 'High Clouds'})
205
- highcloudsfig = px.line(wxdata2, x = 'Date_IST', y = 'cloud_cover_high', hover_data = ['cloud_cover', 'cloud_cover_low', 'cloud_cover_mid'],
206
- labels = {'Date_IST': 'Date and Time', 'cloud_cover': 'Total Cloud Cover (%age)',
207
- 'cloud_cover_low': 'Low Clouds',
208
- 'cloud_cover_mid': 'Medium Clouds',
209
- 'cloud_cover_high': 'High Clouds'})
210
- lowcloudsfig.update_layout(yaxis_range=[0,100])
211
- midcloudsfig.update_layout(yaxis_range=[0,100])
212
- highcloudsfig.update_layout(yaxis_range=[0,100])
213
-
214
- with tab2.expander("Cloudiness"):
215
- st.plotly_chart(cloudsfig, use_container_width = True)
216
- st.plotly_chart(lowcloudsfig, use_container_width = True)
217
- st.plotly_chart(midcloudsfig, use_container_width = True)
218
- st.plotly_chart(highcloudsfig, use_container_width = True)
219
-
220
- #pressure plot
221
- qnhfig = px.line(wxdata2, x = 'Date_IST', y = 'surface_pressure', labels = {'Date_IST': 'Date and Time', 'surface_pressure': 'QNH(hPa)'})
222
- qnhfig.update_layout(yaxis_range=[995,1018])
223
-
224
-
225
- with tab2.expander("Surface Pressure"):
226
- st.plotly_chart(qnhfig, use_container_width = True)
227
-
228
  old_ht = [500,2500,5000,10000,18000,30000,35000,40000]
229
  new_ht = [1000, 2000, 3000, 5000, 7000, 9000, 15000, 18000, 25000, 30000]
230
  upper_air_df = pd.DataFrame()
 
1
  import streamlit as st
2
+ import plotly.express as px
3
  import openmeteo_requests
4
  import requests_cache
5
  import pandas as pd
 
41
  st.caption(f"Time Period: {parseday(start_date)} to {parseday(end_date)}")
42
 
43
  #Draw Tabs
44
+ tab1, tab2 = st.tabs(['PPTN', 'LOCAL FCST'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  #precipitaion plot
47
  pptfig = px.bar(wxdata, x = 'Date_IST', y = 'precipitation', labels = {'Date_IST': 'Date and Time', 'precipitation': 'Precipitation'})
 
70
  st.table(makecwr(wxdata2))
71
 
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  old_ht = [500,2500,5000,10000,18000,30000,35000,40000]
74
  new_ht = [1000, 2000, 3000, 5000, 7000, 9000, 15000, 18000, 25000, 30000]
75
  upper_air_df = pd.DataFrame()