File size: 1,861 Bytes
9ad0e2d
 
 
 
f366666
9ad0e2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import tropycal.tracks as tracks


@st.cache(allow_output_mutation=True)
def read_data(basin='north_atlantic', source='hurdat', include_btk=False):
    return tracks.TrackDataset(basin=basin, source=source, include_btk=include_btk)


def app():

    st.title("Hurricane Mapping")

    row1_col1, row1_col2 = st.columns([3, 1])

    with row1_col1:
        empty = st.empty()
        empty.image("https://i.imgur.com/Ec7qsR0.png")

    with row1_col2:

        checkbox = st.checkbox("Select from a list of hurricanes", value=False)
        if checkbox:
            if st.session_state.get('hurricane') is None:
                st.session_state['hurricane'] = read_data()

            years = st.slider(
                'Select a year', min_value=1950, max_value=2022, value=(2000, 2010)
            )
            storms = st.session_state['hurricane'].filter_storms(year_range=years)
            selected = st.selectbox('Select a storm', storms)
            storm = st.session_state['hurricane'].get_storm(selected)
            ax = storm.plot()
            fig = ax.get_figure()
            empty.pyplot(fig)
        else:

            name = st.text_input("Or enter a storm Name", "michael")
            if name:
                if st.session_state.get('hurricane') is None:
                    st.session_state['hurricane'] = read_data()
                basin = st.session_state['hurricane']
                years = basin.search_name(name)
                if len(years) > 0:
                    year = st.selectbox("Select a year", years)
                    storm = basin.get_storm((name, year))
                    ax = storm.plot()
                    fig = ax.get_figure()
                    empty.pyplot(fig)
                else:
                    empty.text("No storms found")
                    st.write("No storms found")