-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_menu.py
More file actions
129 lines (111 loc) · 4.82 KB
/
app_menu.py
File metadata and controls
129 lines (111 loc) · 4.82 KB
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
import streamlit as st
import pandas as pd
import numpy as np
# Set page title
st.set_page_config(page_title="Researcher Profile and STEM Data Explorer", layout="wide")
# Sidebar Menu
st.sidebar.title("Navigation")
menu = st.sidebar.radio(
"Go to:",
["Researcher Profile", "Publications", "STEM Data Explorer", "Contact"],
)
# Dummy STEM data
physics_data = pd.DataFrame({
"Experiment": ["Alpha Decay", "Beta Decay", "Gamma Ray Analysis", "Quark Study", "Higgs Boson"],
"Energy (MeV)": [4.2, 1.5, 2.9, 3.4, 7.1],
"Date": pd.date_range(start="2024-01-01", periods=5),
})
astronomy_data = pd.DataFrame({
"Celestial Object": ["Mars", "Venus", "Jupiter", "Saturn", "Moon"],
"Brightness (Magnitude)": [-2.0, -4.6, -1.8, 0.2, -12.7],
"Observation Date": pd.date_range(start="2024-01-01", periods=5),
})
weather_data = pd.DataFrame({
"City": ["Cape Town", "London", "New York", "Tokyo", "Sydney"],
"Temperature (°C)": [25, 10, -3, 15, 30],
"Humidity (%)": [65, 70, 55, 80, 50],
"Recorded Date": pd.date_range(start="2024-01-01", periods=5),
})
# Sections based on menu selection
if menu == "Researcher Profile":
st.title("Researcher Profile")
st.sidebar.header("Profile Options")
# Collect basic information
name = "Dr. Simanga Mchunu"
field = "Machine Learning Engineer"
institution = "University of Science"
# Display basic profile information
st.write(f"**Name:** {name}")
st.write(f"**Field of Research:** {field}")
st.write(f"**Institution:** {institution}")
elif menu == "Publications":
st.title("Publications")
st.sidebar.header("Upload and Filter")
# Upload publications file
uploaded_file = st.file_uploader("Upload a CSV of Publications", type="csv")
if uploaded_file:
publications = pd.read_csv(uploaded_file)
st.dataframe(publications)
# Add filtering for year or keyword
keyword = st.text_input("Filter by keyword", "")
if keyword:
filtered = publications[
publications.apply(lambda row: keyword.lower() in row.astype(str).str.lower().values, axis=1)
]
st.write(f"Filtered Results for '{keyword}':")
st.dataframe(filtered)
else:
st.write("Showing all publications")
# Publication trends
if "Year" in publications.columns:
st.subheader("Publication Trends")
year_counts = publications["Year"].value_counts().sort_index()
st.bar_chart(year_counts)
else:
st.write("The CSV does not have a 'Year' column to visualize trends.")
elif menu == "STEM Data Explorer":
st.title("STEM Data Explorer")
st.sidebar.header("Data Selection")
# Tabbed view for STEM data
data_option = st.sidebar.selectbox(
"Choose a dataset to explore",
["Physics Experiments", "Astronomy Observations", "Weather Data"]
)
if data_option == "Physics Experiments":
st.write("### Physics Experiment Data")
st.dataframe(physics_data)
# Add widget to filter by Energy levels
energy_filter = st.slider("Filter by Energy (MeV)", 0.0, 10.0, (0.0, 10.0))
filtered_physics = physics_data[
physics_data["Energy (MeV)"].between(energy_filter[0], energy_filter[1])
]
st.write(f"Filtered Results for Energy Range {energy_filter}:")
st.dataframe(filtered_physics)
elif data_option == "Astronomy Observations":
st.write("### Astronomy Observation Data")
st.dataframe(astronomy_data)
# Add widget to filter by Brightness
brightness_filter = st.slider("Filter by Brightness (Magnitude)", -15.0, 5.0, (-15.0, 5.0))
filtered_astronomy = astronomy_data[
astronomy_data["Brightness (Magnitude)"].between(brightness_filter[0], brightness_filter[1])
]
st.write(f"Filtered Results for Brightness Range {brightness_filter}:")
st.dataframe(filtered_astronomy)
elif data_option == "Weather Data":
st.write("### Weather Data")
st.dataframe(weather_data)
# Add widgets to filter by temperature and humidity
temp_filter = st.slider("Filter by Temperature (°C)", -10.0, 40.0, (-10.0, 40.0))
humidity_filter = st.slider("Filter by Humidity (%)", 0, 100, (0, 100))
filtered_weather = weather_data[
weather_data["Temperature (°C)"].between(temp_filter[0], temp_filter[1]) &
weather_data["Humidity (%)"].between(humidity_filter[0], humidity_filter[1])
]
st.write(f"Filtered Results for Temperature {temp_filter} and Humidity {humidity_filter}:")
st.dataframe(filtered_weather)
elif menu == "Contact":
# Add a contact section
st.header("Contact Information")
name = "Dr Simanga Mchunu"
email = "sima@hotmail.com"
st.write(f"You can reach {name} at {email}.")