WJHWJH1208 commited on
Commit ·
e8f5cff
1
Parent(s): d57ef1d
add file
Browse files
app.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import altair as alt
|
| 3 |
+
import pandas as pd
|
| 4 |
+
|
| 5 |
+
url = (
|
| 6 |
+
'https://raw.githubusercontent.com/UIUC-iSchool-DataViz/is445_data/main/bfro_reports_fall2022.csv'
|
| 7 |
+
)
|
| 8 |
+
data = pd.read_csv(url)
|
| 9 |
+
|
| 10 |
+
st.title('IS445 Homework 5')
|
| 11 |
+
st.subheader("NETID: wei51")
|
| 12 |
+
data['date'] = pd.to_datetime(data['date'])
|
| 13 |
+
|
| 14 |
+
data = data[data['date'] > '1973-04-29']
|
| 15 |
+
data = data[data['season'] != 'Unknown']
|
| 16 |
+
|
| 17 |
+
st.write('Dataset Preview')
|
| 18 |
+
st.dataframe(data.head())
|
| 19 |
+
|
| 20 |
+
st.title("Weather Data Analysis")
|
| 21 |
+
|
| 22 |
+
# Filter data for latitude, wind speed, and season
|
| 23 |
+
latitude_wind_season_data = data[['latitude', 'wind_speed', 'season']].dropna()
|
| 24 |
+
|
| 25 |
+
# Latitude and wind speed analysis by season
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
st.subheader("Latitude and Wind Speed Scatter Plot by Season")
|
| 29 |
+
latitude_wind_season_chart = alt.Chart(latitude_wind_season_data).mark_circle(size=60, opacity=0.6).encode(
|
| 30 |
+
x=alt.X('latitude:Q', title='Latitude', scale=alt.Scale(domain=[25, 50])),
|
| 31 |
+
y=alt.Y('wind_speed:Q', title='Wind Speed (mph)'),
|
| 32 |
+
color=alt.Color('season:N', title="Season"),
|
| 33 |
+
tooltip=['latitude', 'wind_speed', 'season']
|
| 34 |
+
).properties(
|
| 35 |
+
width=600,
|
| 36 |
+
height=400,
|
| 37 |
+
title="Latitude and Wind Speed Scatter Plot by Season"
|
| 38 |
+
).interactive()
|
| 39 |
+
|
| 40 |
+
st.altair_chart(latitude_wind_season_chart, use_container_width=True)
|
| 41 |
+
|
| 42 |
+
st.subheader("This visualization highlights the relationship between latitude and wind speed across different seasons, aiming to observe any variations in wind speed at different latitudes and how they may be influenced by seasonal changes. I used a scatter plot with latitude on the x-axis, constrained between 25 and 50 degrees to focus on the range relevant to the data, while wind_speed is on the y-axis, allowing us to see the distribution of wind speeds across latitudes. Each season is represented by a distinct color, creating a clear visual distinction that helps to identify seasonal trends. For marks, I chose circles with a semi-transparent opacity to manage overlapping points, enhancing the readability of densely packed data points."
|
| 43 |
+
"From the visualization, we can observe that wind speeds tend to cluster below 10 mph across most latitudes, with occasional higher wind speeds more sparsely distributed. There doesn’t appear to be a strong correlation between latitude and wind speed; rather, the variation in wind speed seems fairly consistent across latitudes. Seasonal differences are also subtle, although Winter shows a slightly broader distribution of wind speeds at higher latitudes. If I had more time, I would experiment with interactive features, such as filters to view individual seasons in isolation, or tooltips that provide additional context for each data point (e.g., specific dates or geographic locations) to offer deeper insights into the seasonal and geographic patterns in the data.")
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
# Cloud cover and temperature relationship
|
| 47 |
+
st.subheader("Relationship between Cloud Cover and Average Temperature")
|
| 48 |
+
cloud_temp_chart = alt.Chart(data).mark_circle(size=60, opacity=0.5).encode(
|
| 49 |
+
x=alt.X('cloud_cover:Q', title='Cloud Cover (%)', scale=alt.Scale(domain=[0, 1])),
|
| 50 |
+
y=alt.Y('temperature_mid:Q', title='Average Temperature (°F)'),
|
| 51 |
+
color=alt.Color('season:N', legend=alt.Legend(title="Season")),
|
| 52 |
+
tooltip=['cloud_cover:Q', 'temperature_mid:Q', 'season:N']
|
| 53 |
+
).properties(
|
| 54 |
+
width=600,
|
| 55 |
+
height=400,
|
| 56 |
+
title="Scatter Plot of Cloud Cover and Average Temperature"
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
st.altair_chart(cloud_temp_chart, use_container_width=True)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
st.subheader("This visualization highlights the relationship between cloud cover and average temperature across different seasons, aiming to examine how temperature varies with cloud cover percentages and seasonal changes. The x-axis represents cloud cover (0 to 1, or 0% to 100%), while the y-axis shows average temperature in Fahrenheit, ranging from 0°F to 100°F. Each season is color-coded, with Fall, Spring, Summer, and Winter represented by distinct colors, helping to distinguish seasonal patterns. I used a scatter plot with semi-transparent circular marks to handle overlapping data points, making the distribution of points and any seasonal trends easier to interpret."
|
| 63 |
+
|
| 64 |
+
"From the visualization, we can observe that higher temperatures tend to occur in Summer and lower temperatures in Winter, as expected. Interestingly, there does not appear to be a strong correlation between cloud cover and average temperature, as temperature values are distributed widely across all cloud cover percentages. However, at lower cloud cover levels (e.g., less than 20%), there is a noticeable cluster of higher temperatures, suggesting that clearer skies might be associated with warmer days. If I had more time, I would add interactive filters to allow users to view data from individual seasons or cloud cover ranges and possibly incorporate additional variables, like humidity, to explore more nuanced relationships.")
|