Commit
•
3e931f8
1
Parent(s):
7a5cc85
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import plotly.graph_objects as go
|
4 |
+
|
5 |
+
st.set_page_config(page_title="اداره زراعت و کنترل محصول", layout="wide")
|
6 |
+
|
7 |
+
def show_dashboard():
|
8 |
+
st.title("داشبورد")
|
9 |
+
uploaded_file = st.file_uploader("بارگذاری فایل CSV", type=["csv"])
|
10 |
+
if uploaded_file:
|
11 |
+
data = pd.read_csv(uploaded_file)
|
12 |
+
st.dataframe(data)
|
13 |
+
if st.button("تحلیل داده با نمودار"):
|
14 |
+
st.plotly_chart(plot_3d_chart(data, 'week', 'height'))
|
15 |
+
|
16 |
+
def show_crop_growth_analysis():
|
17 |
+
st.title("تحلیل رشد محصول")
|
18 |
+
uploaded_file = st.file_uploader("بارگذاری فایل CSV", type=["csv"])
|
19 |
+
if uploaded_file:
|
20 |
+
data = pd.read_csv(uploaded_file)
|
21 |
+
st.dataframe(data)
|
22 |
+
if st.button("تحلیل داده با نمودار"):
|
23 |
+
st.plotly_chart(plot_3d_chart(data, 'week', 'height'))
|
24 |
+
|
25 |
+
def show_weather_data():
|
26 |
+
st.title("دادههای هواشناسی")
|
27 |
+
uploaded_file = st.file_uploader("بارگذاری فایل CSV", type=["csv"])
|
28 |
+
if uploaded_file:
|
29 |
+
data = pd.read_csv(uploaded_file)
|
30 |
+
st.dataframe(data)
|
31 |
+
if st.button("تحلیل داده با نمودار"):
|
32 |
+
st.plotly_chart(plot_3d_chart(data, 'week', 'height'))
|
33 |
+
|
34 |
+
def show_crop_health_monitoring():
|
35 |
+
st.title("پایش سلامت محصول")
|
36 |
+
uploaded_file = st.file_uploader("بارگذاری فایل CSV", type=["csv"])
|
37 |
+
if uploaded_file:
|
38 |
+
data = pd.read_csv(uploaded_file)
|
39 |
+
st.dataframe(data)
|
40 |
+
if st.button("تحلیل داده با نمودار"):
|
41 |
+
st.plotly_chart(plot_3d_chart(data, 'week', 'height'))
|
42 |
+
|
43 |
+
def show_reports():
|
44 |
+
st.title("گزارشها")
|
45 |
+
uploaded_file = st.file_uploader("بارگذاری فایل CSV", type=["csv"])
|
46 |
+
if uploaded_file:
|
47 |
+
data = pd.read_csv(uploaded_file)
|
48 |
+
st.dataframe(data)
|
49 |
+
if st.button("تحلیل داده با نمودار"):
|
50 |
+
st.plotly_chart(plot_3d_chart(data, 'week', 'height'))
|
51 |
+
|
52 |
+
def show_growth_comparison():
|
53 |
+
st.title("مقایسه رشد و ارتفاع 1399 با 1403")
|
54 |
+
uploaded_file_1399 = st.file_uploader("بارگذاری فایل 1399 CSV", type=["csv"], key="1399")
|
55 |
+
uploaded_file_1403 = st.file_uploader("بارگذاری فایل 1403 CSV", type=["csv"], key="1403")
|
56 |
+
if uploaded_file_1399 and uploaded_file_1403:
|
57 |
+
data_1399 = pd.read_csv(uploaded_file_1399)
|
58 |
+
data_1403 = pd.read_csv(uploaded_file_1403)
|
59 |
+
st.dataframe(data_1399)
|
60 |
+
st.dataframe(data_1403)
|
61 |
+
if st.button("تحلیل داده با نمودار"):
|
62 |
+
st.plotly_chart(plot_3d_chart(data_1399, 'week', 'height', title="سال 1399"))
|
63 |
+
st.plotly_chart(plot_3d_chart(data_1403, 'week', 'height', title="سال 1403"))
|
64 |
+
st.plotly_chart(compare_growth(data_1399, data_1403, 'week', 'height'))
|
65 |
+
|
66 |
+
def plot_3d_chart(data, x_column, y_column, title=""):
|
67 |
+
fig = go.Figure(data=[go.Scatter3d(x=data[x_column], y=data[y_column], z=data[y_column],
|
68 |
+
mode='markers+lines', marker=dict(size=5))])
|
69 |
+
fig.update_layout(title=title, scene=dict(xaxis_title=x_column, yaxis_title=y_column, zaxis_title='ارتفاع'))
|
70 |
+
return fig
|
71 |
+
|
72 |
+
def compare_growth(data1, data2, x_column, y_column):
|
73 |
+
fig = go.Figure()
|
74 |
+
fig.add_trace(go.Scatter3d(x=data1[x_column], y=data1[y_column], z=data1[y_column],
|
75 |
+
mode='markers+lines', name="سال 1399", marker=dict(size=5)))
|
76 |
+
fig.add_trace(go.Scatter3d(x=data2[x_column], y=data2[y_column], z=data2[y_column],
|
77 |
+
mode='markers+lines', name="سال 1403", marker=dict(size=5)))
|
78 |
+
fig.update_layout(title="مقایسه رشد و ارتفاع 1399 با 1403",
|
79 |
+
scene=dict(xaxis_title=x_column, yaxis_title=y_column, zaxis_title='ارتفاع'))
|
80 |
+
return fig
|
81 |
+
|
82 |
+
st.sidebar.title("منو")
|
83 |
+
menu = st.sidebar.selectbox("انتخاب کنید", ["داشبورد", "تحلیل رشد محصول", "دادههای هواشناسی", "پایش سلامت محصول", "گزارشها", "مقایسه رشد و ارتفاع 1399 با 1403"])
|
84 |
+
|
85 |
+
if menu == "داشبورد":
|
86 |
+
show_dashboard()
|
87 |
+
elif menu == "تحلیل رشد محصول":
|
88 |
+
show_crop_growth_analysis()
|
89 |
+
elif menu == "دادههای هواشناسی":
|
90 |
+
show_weather_data()
|
91 |
+
elif menu == "پایش سلامت محصول":
|
92 |
+
show_crop_health_monitoring()
|
93 |
+
elif menu == "گزارشها":
|
94 |
+
show_reports()
|
95 |
+
elif menu == "مقایسه رشد و ارتفاع 1399 با 1403":
|
96 |
+
show_growth_comparison()
|