File size: 22,995 Bytes
00ac9b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5872239
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
00ac9b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
import pandas as pd
import numpy as np
import streamlit as st
import folium
import folium.plugins

from streamlit_folium import st_folium
from branca.element import Figure


from precipitation_function import date_split,lat_long_process_precp
from precipitation_function import concat_func, drop_dup_funct,lat_long_type
from precipitation_function import daily_precp_plot,start_end_date_ui,lat_long_ui,year_selection_ui
from precipitation_function import monthly_mean_plot, annual_max_precip_plot,daily_precp_data,cumulative_plot
from precipitation_function import annual_max_precip_plot,annual_min_precip_plot,annual_avg_plot,max_precip,min_precip,avg_precip,cumulative

from temperature_functions import convert_df, map_creation, search_func

def run():
    fig = Figure(width = 550,height = 350)

    nearest_lat_long = 0
    nn = 0
    start = pd.to_datetime('2001/01/01')
    end = pd.to_datetime('2019/12/31')

    #precipitation data
    # bucket_name = "timeseries_data_storage"
    # file_path_1 = "precip_data/precip1.zip"
    # file_path_2 = "precip_data/precip2.zip"
    # file_path_3 = "precip_data/precip3.zip"
    # file_path_4 = "precip_data/precip4.zip"
    # file_path_5 = "precip_data/precip5.zip"
    # file_path_6 = "precip_data/precip6.zip"
    # file_path_7 = "precip_data/precip7.zip"
    # file_path_8 = "precip_data/precip8.zip"
    # file_path_9 = "precip_data/precip9.zip"
    # file_path_10 = "precip_data/precip10.zip"
    # file_path_11 = "precip_data/precip11.zip"
    # file_path_12 = "precip_data/precip12.zip"
    # file_path_13 = "precip_data/precip13.zip"
    # file_path_14 = "precip_data/precip14.zip"
    # file_path_15 = "precip_data/precip15.zip"
    # file_path_16 = "precip_data/precip16.zip"



    precipitation_1_og = pd.read_csv('historicalData/precip1.zip',compression = 'zip')
    precipitation_2_og = pd.read_csv('historicalData/precip2.zip',compression = 'zip')
    precipitation_3_og = pd.read_csv('historicalData/precip3.zip',compression = 'zip')
    precipitation_4_og = pd.read_csv('historicalData/precip4.zip',compression = 'zip')
    precipitation_5_og = pd.read_csv('historicalData/precip5.zip',compression = 'zip')
    precipitation_6_og = pd.read_csv('historicalData/precip6.zip',compression = 'zip')
    precipitation_7_og = pd.read_csv('historicalData/precip7.zip',compression = 'zip')
    precipitation_8_og = pd.read_csv('historicalData/precip8.zip',compression = 'zip')
    precipitation_9_og = pd.read_csv('historicalData/precip9.zip',compression = 'zip')
    precipitation_10_og = pd.read_csv('historicalData/precip10.zip',compression = 'zip')
    precipitation_11_og = pd.read_csv('historicalData/precip11.zip',compression = 'zip')
    precipitation_12_og = pd.read_csv('historicalData/precip12.zip',compression = 'zip')
    precipitation_13_og = pd.read_csv('historicalData/precip13.zip',compression = 'zip')
    precipitation_14_og = pd.read_csv('historicalData/precip14.zip',compression = 'zip')
    precipitation_15_og = pd.read_csv('historicalData/precip15.zip',compression = 'zip')
    precipitation_16_og = pd.read_csv('historicalData/precip16.zip',compression = 'zip')


    lat_long_precipitation_1 = precipitation_1_og['lat_long']
    lat_long_precipitation_2 = precipitation_2_og['lat_long']
    lat_long_precipitation_3 = precipitation_3_og['lat_long']
    lat_long_precipitation_4 = precipitation_4_og['lat_long']
    lat_long_precipitation_5 = precipitation_5_og['lat_long']
    lat_long_precipitation_6 = precipitation_6_og['lat_long']
    lat_long_precipitation_7 = precipitation_7_og['lat_long']
    lat_long_precipitation_8 = precipitation_8_og['lat_long']
    lat_long_precipitation_9 = precipitation_9_og['lat_long']
    lat_long_precipitation_10 = precipitation_10_og['lat_long']
    lat_long_precipitation_11 = precipitation_11_og['lat_long']
    lat_long_precipitation_12 = precipitation_12_og['lat_long']
    lat_long_precipitation_13 = precipitation_13_og['lat_long']
    lat_long_precipitation_14 = precipitation_14_og['lat_long']
    lat_long_precipitation_15 = precipitation_15_og['lat_long']
    lat_long_precipitation_16 = precipitation_16_og['lat_long']



    lat_long_precipitation_list_1 = concat_func(lat_long_precipitation_1,lat_long_precipitation_2,lat_long_precipitation_3,lat_long_precipitation_4)
    lat_long_precipitation_list_2 = concat_func(lat_long_precipitation_5,lat_long_precipitation_6,lat_long_precipitation_7,lat_long_precipitation_8)
    lat_long_precipitation_list_3 = concat_func(lat_long_precipitation_9,lat_long_precipitation_10,lat_long_precipitation_11,lat_long_precipitation_12)
    lat_long_precipitation_list_4 = concat_func(lat_long_precipitation_13,lat_long_precipitation_14,lat_long_precipitation_15,lat_long_precipitation_16)
    lat_long_precipitation_list   = concat_func(lat_long_precipitation_list_1,lat_long_precipitation_list_2,lat_long_precipitation_list_3,lat_long_precipitation_list_4)


    precipitation_conc_1 = concat_func(precipitation_1_og,precipitation_2_og,precipitation_3_og,precipitation_4_og)
    precipitation_conc_2 = concat_func(precipitation_5_og,precipitation_6_og,precipitation_7_og,precipitation_8_og)
    precipitation_conc_3 = concat_func(precipitation_9_og,precipitation_10_og,precipitation_11_og,precipitation_12_og)
    precipitation_conc_4 = concat_func(precipitation_13_og,precipitation_14_og,precipitation_15_og,precipitation_16_og)
    precipitation = concat_func(precipitation_conc_1,precipitation_conc_2,precipitation_conc_3,precipitation_conc_4)

    # precipitation = precipitation.drop([Unnamed:0.2,Unnamed:0.1,Unnamed:0],axis =1)
    precipitation.drop(precipitation.filter(regex="Unnamed"),axis=1, inplace=True)
    # st.write(precipitation.head())
    precipitation_temp = precipitation.copy()
    precipitation_temp = precipitation_temp.groupby('lat_long')

    with st.sidebar:
        data_type = st.radio("Select Data Type to View",
                        ('Daily Precipitation','Cumulative Monthly Precipitation','Monthly Average Precipitation',
                        'Annual Maximum Precipitation','Annual Minimum Precipitation',
                        'Annual Average Precipitation','Annual Max, Min, & Average Precipitation'))

    if data_type == "Cumulative Monthly Precipitation":
        col1,col2 = st.columns(2)
        with col1:
            start_year,end_year = year_selection_ui(99,100)
        with col2:
            #calling the ui method to create a lat long input UI
            latitude_input,longitude_input = lat_long_ui(300,400)


        latitude_input,longitude_input= float(latitude_input),float(longitude_input)
        nearest_lat_long = search_func(latitude_input,longitude_input,lat_long_precipitation_list,precipitation)
        option = lat_long_type(nearest_lat_long)

        with col1:
            st.write("**Nearest latitude and longitude from the entered latitude longitude is :**",option)

        df_cumulative = precipitation_temp.get_group(option)
        df_cumulative = date_split(df_cumulative)

        lat  = float(option.split(',')[0])
        long = float(option.split(',')[1])
        m = map_creation(lat,long,0,0)
        last_click = m['last_clicked']

        with col2:
            if last_click is not None:
                clicked_lat = last_click['lat']
                clicked_long = last_click['lng']
                st.markdown("**Last Clicked Latitude Longitude point is:**")
                st.write("{:0.2f},{:0.2f}".format(clicked_lat,clicked_long))
                nn = search_func(clicked_lat,clicked_long,lat_long_precipitation_list,precipitation)
                nn = lat_long_type(nn)
                st.write("**Nearest Latitude and Longitude is:**",nn)
                st.markdown(" ")

            else:
                st.markdown("**Click on the map to fetch the Latitude and Longitude**")

        if last_click is not None:
            clicked_lat = last_click['lat']
            clicked_long = last_click['lng']
            map_creation(lat,long,clicked_lat,clicked_long)

        df_c = cumulative(df_cumulative,start_year,end_year)
        fig_cumulative = cumulative_plot(df_c)
        st.plotly_chart(fig_cumulative,use_container_width=True)
        c1,c2,c3,c4,c5 = st.columns(5)
        with c3:
            st.download_button("Download Data",data = convert_df(df_c),
                                file_name='cumulative_precipitation.csv',
                                mime='text/csv',)


    elif data_type == "Daily Precipitation":
        col1,col2 = st.columns(2)
        with col1:
            #calling the ui method to create a start end date input UI
            start,end = start_end_date_ui(start,end,11,22)
        with col2:
            latitude_input,longitude_input = lat_long_ui(1,2)


        latitude_input,longitude_input= float(latitude_input),float(longitude_input)
        nearest_lat_long = search_func(latitude_input,longitude_input,lat_long_precipitation_list,precipitation)
        option = lat_long_type(nearest_lat_long)

        with col1:
            st.write("**Nearest latitude and longitude from the entered latitude longitude is :**",option)


        lat  = float(option.split(',')[0])
        long = float(option.split(',')[1])
        m = map_creation(lat,long,0,0)
        last_click = m['last_clicked']

        with col2:
            if last_click is not None:
                clicked_lat = last_click['lat']
                clicked_long = last_click['lng']
                st.markdown("**Last Clicked Latitude Longitude point is:**")
                st.write("{:0.2f},{:0.2f}".format(clicked_lat,clicked_long))
                nn = search_func(clicked_lat,clicked_long,lat_long_precipitation_list,precipitation)
                nn = lat_long_type(nn)
                st.write("**Nearest Latitude and Longitude is:**",nn)
                st.markdown(" ")

            else:
                st.markdown("**Click on the map to fetch the Latitude and Longitude**")

        if last_click is not None:
            clicked_lat = last_click['lat']
            clicked_long = last_click['lng']
            map_creation(lat,long,clicked_lat,clicked_long)


        daily_precp_df = daily_precp_data(precipitation_temp,start,end,option)
        # st.write(daily_precp_df.head())
        daily_precp_df.drop_duplicates(inplace = True)
        daily_df = daily_precp_df.loc[str(start):str(end)]
        # st.write(daily_df)
        fig_daily_precp = daily_precp_plot(daily_df)
        st.plotly_chart(fig_daily_precp,use_container_width = True)

        c1,c2,c3,c4,c5 = st.columns(5)
        with c3:
            st.download_button("Download Data",data = convert_df(daily_precp_df),
                                file_name='daily_precipitation.csv',
                                mime='text/csv',)


    elif data_type == 'Monthly Average Precipitation':
        col1,col2 = st.columns(2)
        with col1:
            start_year,end_year = year_selection_ui(9,10)
        with col2:
            #calling the ui method to create a lat long input UI
            latitude_input,longitude_input = lat_long_ui(3,4)

        latitude_input,longitude_input= float(latitude_input),float(longitude_input)
        nearest_lat_long = search_func(latitude_input,longitude_input,lat_long_precipitation_list,precipitation)
        option = lat_long_type(nearest_lat_long)

        lat  = float(option.split(',')[0])
        long = float(option.split(',')[1])
        m = map_creation(lat,long,0,0)

        last_click = m['last_clicked']

        with col1:
            st.write("**Nearest latitude and longitude from the entered latitude longitude is :**",option)

        with col2:
            if last_click is not None:
                clicked_lat = last_click['lat']
                clicked_long = last_click['lng']
                st.markdown("**Last Clicked Latitude Longitude point is:**")
                st.write("{:0.2f},{:0.2f}".format(clicked_lat,clicked_long))
                nn = search_func(clicked_lat,clicked_long,lat_long_precipitation_list,precipitation)
                nn = lat_long_type(nn)
                st.write("**Nearest Latitude and Longitude is:**",nn)
                st.markdown(" ")

            else:
                st.markdown("**Click on the map to fetch the Latitude and Longitude**")

        if last_click is not None:
            clicked_lat = last_click['lat']
            clicked_long = last_click['lng']
            map_creation(lat,long,clicked_lat,clicked_long)


        precipitation_monthly_avg = precipitation_temp.get_group(option)
        precipitation_monthly_avg = date_split(precipitation_monthly_avg)
        precipt_monthly_avg_df = precipitation_monthly_avg.groupby(['Year','Month'],as_index=False)['precip'].mean()
        precipt_monthly_avg_df = precipt_monthly_avg_df.set_index('Year')
        precipitation_monthly_avg_df = precipt_monthly_avg_df.loc[str(start_year):str(end_year)]
        precipitation_monthly_avg_df.reset_index(inplace = True)
        mean_chart_plot = monthly_mean_plot(precipitation_monthly_avg_df)
        st.altair_chart(mean_chart_plot)


        c1,c2,c3,c4,c5 = st.columns(5)
        with c3:
            st.download_button("Download Data",data = convert_df(precipitation_monthly_avg_df),
                                file_name='Monthly_avg_precipitation.csv',
                                mime='text/csv',)


    elif data_type == 'Annual Maximum Precipitation':
        col1,col2 = st.columns(2)
        with col1:
            start_year,end_year = year_selection_ui(11,12)
        with col2:
            #calling the ui method to create a lat long input UI
            latitude_input,longitude_input = lat_long_ui(5,6)

        latitude_input,longitude_input= float(latitude_input),float(longitude_input)
        nearest_lat_long = search_func(latitude_input,longitude_input,lat_long_precipitation_list,precipitation)
        option = lat_long_type(nearest_lat_long)

        lat  = float(option.split(',')[0])
        long = float(option.split(',')[1])
        m = map_creation(lat,long,0,0)
        last_click = m['last_clicked']

        with col1:
            st.write("**Nearest latitude and longitude from the entered latitude longitude is :**",option)

        with col2:
            if last_click is not None:
                clicked_lat = last_click['lat']
                clicked_long = last_click['lng']
                st.markdown("**Last Clicked Latitude Longitude point is:**")
                st.write("{:0.2f},{:0.2f}".format(clicked_lat,clicked_long))
                nn = search_func(clicked_lat,clicked_long,lat_long_precipitation_list,precipitation)
                nn = lat_long_type(nn)
                st.write("**Nearest Latitude and Longitude is:**",nn)
                st.markdown(" ")

            else:
                st.markdown("**Click on the map to fetch the Latitude and Longitude**")

        if last_click is not None:
            clicked_lat = last_click['lat']
            clicked_long = last_click['lng']
            map_creation(lat,long,clicked_lat,clicked_long)

        Annual_max_precip = max_precip(precipitation_temp,option,start_year,end_year)
        fig_max = annual_max_precip_plot(Annual_max_precip)
        st.plotly_chart(fig_max,use_container_width=True)

        c1,c2,c3,c4,c5 = st.columns(5)
        with c3:
            st.download_button("Download Data",data = convert_df(Annual_max_precip),
                                file_name='Annual_max_precipitation.csv',
                                mime='text/csv',)


    elif data_type == 'Annual Minimum Precipitation':
        col1,col2 = st.columns(2)
        with col1:
            start_year,end_year = year_selection_ui(13,14)
        with col2:
            #calling the ui method to create a lat long input UI
            latitude_input,longitude_input = lat_long_ui(7,8)

        latitude_input,longitude_input= float(latitude_input),float(longitude_input)
        nearest_lat_long = search_func(latitude_input,longitude_input,lat_long_precipitation_list,precipitation)
        option = lat_long_type(nearest_lat_long)

        lat  = float(option.split(',')[0])
        long = float(option.split(',')[1])
        m = map_creation(lat,long,0,0)
        last_click = m['last_clicked']

        with col1:
            st.write("**Nearest latitude and longitude from the entered latitude longitude is :**",option)

        with col2:
            if last_click is not None:
                clicked_lat = last_click['lat']
                clicked_long = last_click['lng']
                st.markdown("**Last Clicked Latitude Longitude point is:**")
                st.write("{:0.2f},{:0.2f}".format(clicked_lat,clicked_long))
                nn = search_func(clicked_lat,clicked_long,lat_long_precipitation_list,precipitation)
                nn = lat_long_type(nn)
                st.write("**Nearest Latitude and Longitude is:**",nn)
                st.markdown(" ")
            else:
                st.markdown("**Click on the map to fetch the Latitude and Longitude**")

        if last_click is not None:
            clicked_lat = last_click['lat']
            clicked_long = last_click['lng']
            map_creation(lat,long,clicked_lat,clicked_long)


        minimum_precip_df = min_precip(precipitation_temp,option,start_year,end_year)
        fig_min = annual_min_precip_plot(minimum_precip_df)
        st.plotly_chart(fig_min,use_container_width = True)


        c1,c2,c3,c4,c5 = st.columns(5)
        with c3:
            st.download_button("Download Data",data = convert_df(minimum_precip_df),
                                file_name='Annual_minimum_precipitation.csv',
                                mime='text/csv',)



    elif data_type == 'Annual Average Precipitation':
        col1,col2 = st.columns(2)
        with col1:
            start_year,end_year = year_selection_ui(15,16)
        with col2:
            #calling the ui method to create a lat long input UI
            latitude_input,longitude_input = lat_long_ui(9,10)

        latitude_input,longitude_input= float(latitude_input),float(longitude_input)
        nearest_lat_long = search_func(latitude_input,longitude_input,lat_long_precipitation_list,precipitation)
        option = lat_long_type(nearest_lat_long)

        lat  = float(option.split(',')[0])
        long = float(option.split(',')[1])
        m = map_creation(lat,long,0,0)
        last_click = m['last_clicked']

        with col1:
            st.write("**Nearest latitude and longitude from the entered latitude longitude is :**",option)

        with col2:
            if last_click is not None:
                clicked_lat = last_click['lat']
                clicked_long = last_click['lng']
                st.markdown("**Last Clicked Latitude Longitude point is:**")
                st.write("{:0.2f},{:0.2f}".format(clicked_lat,clicked_long))
                nn = search_func(clicked_lat,clicked_long,lat_long_precipitation_list,precipitation)
                nn = lat_long_type(nn)
                st.write("**Nearest Latitude and Longitude is:**",nn)
                st.markdown(" ")
            else:
                st.markdown("**Click on the map to fetch the Latitude and Longitude**")

        if last_click is not None:
            clicked_lat = last_click['lat']
            clicked_long = last_click['lng']
            map_creation(lat,long,clicked_lat,clicked_long)

        avg_precip_df_se = avg_precip(precipitation_temp,option,start_year,end_year)
        fig_avg = annual_avg_plot(avg_precip_df_se)
        st.plotly_chart(fig_avg,use_container_width = True)

        c1,c2,c3,c4,c5 = st.columns(5)
        with c3:
            st.download_button("Download Data",data = convert_df(avg_precip_df_se),
                                file_name='Annual_avg_precipitation.csv',
                                mime='text/csv',)

    elif data_type == 'Annual Max, Min, & Average Precipitation':
        col1,col2 = st.columns(2)
        with col1:
            start_year,end_year = year_selection_ui(17,18)

        with col2:
            latitude_input,longitude_input = lat_long_ui(11,12)

        latitude_input,longitude_input= float(latitude_input),float(longitude_input)
        nearest_lat_long = search_func(latitude_input,longitude_input,lat_long_precipitation_list,precipitation)
        option = lat_long_type(nearest_lat_long)

        lat  = float(option.split(',')[0])
        long = float(option.split(',')[1])
        m = map_creation(lat,long,0,0)

        last_click = m['last_clicked']
        with col1:
            st.write("**Nearest latitude and longitude from the entered latitude longitude is :**",option)

        with col2:
            if last_click is not None:
                clicked_lat = last_click['lat']
                clicked_long = last_click['lng']
                st.markdown("**Last Clicked Latitude Longitude point is:**")
                st.write("{:0.2f},{:0.2f}".format(clicked_lat,clicked_long))
                nn = search_func(clicked_lat,clicked_long,lat_long_precipitation_list,precipitation)
                nn = lat_long_type(nn)
                st.write("**Nearest Latitude and Longitude is:**",nn)
                st.markdown(" ")
            else:
                st.markdown("**Click on the map to fetch the Latitude and Longitude**")

            if last_click is not None:
                clicked_lat = last_click['lat']
                clicked_long = last_click['lng']
                map_creation(lat,long,clicked_lat,clicked_long)

        col11,col22,col33 = st.columns(3)
        with col11:
            annual_max_data = max_precip(precipitation_temp,option,start_year,end_year)
            fig_max_2 = annual_max_precip_plot(annual_max_data)
            st.plotly_chart(fig_max_2,use_container_width=True)
            st.download_button("Download Data",data = convert_df(annual_max_data),
                                file_name='Annual_max_precipitation_data.csv',
                                mime='text/csv',)

        with col22:
            annual_min_data = min_precip(precipitation_temp,option,start_year,end_year)
            fig_min_2 = annual_min_precip_plot(annual_min_data)
            st.plotly_chart(fig_min_2,use_container_width = True)
            st.download_button("Download Data",data = convert_df(annual_min_data),
                                file_name='Annual_min_precipitation_data.csv',
                                mime='text/csv',)

        with col33:
            annual_avg_data = avg_precip(precipitation_temp,option,start_year,end_year)
            fig_avg_2 = annual_avg_plot(annual_avg_data)
            st.plotly_chart(fig_avg_2, use_container_width = True)
            st.download_button("Download Data",data = convert_df(annual_avg_data),
                                file_name='Annual_avg_precipitation_data.csv',
                                mime='text/csv',)


if __name__ == 'main':
    run()