File size: 5,268 Bytes
3e931f8
 
 
ed62af0
3e931f8
55d5f91
ed62af0
55d5f91
 
3e931f8
55d5f91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3e931f8
 
 
 
 
 
 
9d61dec
3e931f8
 
 
 
 
 
 
 
9d61dec
3e931f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9d61dec
 
 
3e931f8
55d5f91
3e931f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import plotly.graph_objects as go
from datasets import load_dataset

# Load the dataset
ds = load_dataset("Esmaeilkiani/moghayesecroplogging")

# Set page configuration
st.set_page_config(page_title="اداره زراعت و کنترل محصول", layout="wide")

# Apply custom CSS and JavaScript
def local_css(file_name):
    with open(file_name) as f:
        st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)

def local_js(file_name):
    with open(file_name) as f:
        st.markdown(f'<script>{f.read()}</script>', unsafe_allow_html=True)

local_css("styles.css")
local_js("scripts.js")

# Function to plot 3D chart
def plot_3d_chart(data, x_column, y_column, title=""):
    fig = go.Figure(data=[go.Scatter3d(x=data[x_column], y=data[y_column], z=data[y_column],
                                       mode='markers+lines', marker=dict(size=5))])
    fig.update_layout(title=title, scene=dict(xaxis_title=x_column, yaxis_title=y_column, zaxis_title='ارتفاع'))
    return fig

# Function to compare growth
def compare_growth(data1, data2, x_column, y_column):
    fig = go.Figure()
    fig.add_trace(go.Scatter3d(x=data1[x_column], y=data1[y_column], z=data1[y_column],
                               mode='markers+lines', name="سال 1399", marker=dict(size=5)))
    fig.add_trace(go.Scatter3d(x=data2[x_column], y=data2[y_column], z=data2[y_column],
                               mode='markers+lines', name="سال 1403", marker=dict(size=5)))
    fig.update_layout(title="مقایسه رشد و ارتفاع 1399 با 1403",
                      scene=dict(xaxis_title=x_column, yaxis_title=y_column, zaxis_title='ارتفاع'))
    return fig

# Functions for different pages
def show_dashboard():
    st.title("داشبورد")
    uploaded_file = st.file_uploader("بارگذاری فایل CSV", type=["csv"])
    if uploaded_file:
        data = pd.read_csv(uploaded_file)
        st.dataframe(data)
        if st.button("تحلیل داده با نمودار"):
            st.plotly_chart(plot_3d_chart(data, 'هفته', 'ارتفاع'))

def show_crop_growth_analysis():
    st.title("تحلیل رشد محصول")
    uploaded_file = st.file_uploader("بارگذاری فایل CSV", type=["csv"])
    if uploaded_file:
        data = pd.read_csv(uploaded_file)
        st.dataframe(data)
        if st.button("تحلیل داده با نمودار"):
            st.plotly_chart(plot_3d_chart(data, 'هفته', 'ارتفاع'))

def show_weather_data():
    st.title("داده‌های هواشناسی")
    uploaded_file = st.file_uploader("بارگذاری فایل CSV", type=["csv"])
    if uploaded_file:
        data = pd.read_csv(uploaded_file)
        st.dataframe(data)
        if st.button("تحلیل داده با نمودار"):
            st.plotly_chart(plot_3d_chart(data, 'week', 'height'))

def show_crop_health_monitoring():
    st.title("پایش سلامت محصول")
    uploaded_file = st.file_uploader("بارگذاری فایل CSV", type=["csv"])
    if uploaded_file:
        data = pd.read_csv(uploaded_file)
        st.dataframe(data)
        if st.button("تحلیل داده با نمودار"):
            st.plotly_chart(plot_3d_chart(data, 'week', 'height'))

def show_reports():
    st.title("گزارش‌ها")
    uploaded_file = st.file_uploader("بارگذاری فایل CSV", type=["csv"])
    if uploaded_file:
        data = pd.read_csv(uploaded_file)
        st.dataframe(data)
        if st.button("تحلیل داده با نمودار"):
            st.plotly_chart(plot_3d_chart(data, 'week', 'height'))

def show_growth_comparison():
    st.title("مقایسه رشد و ارتفاع 1399 با 1403")
    uploaded_file_1399 = st.file_uploader("بارگذاری فایل 1399 CSV", type=["csv"], key="1399")
    uploaded_file_1403 = st.file_uploader("بارگذاری فایل 1403 CSV", type=["csv"], key="1403")
    if uploaded_file_1399 and uploaded_file_1403:
        data_1399 = pd.read_csv(uploaded_file_1399)
        data_1403 = pd.read_csv(uploaded_file_1403)
        st.dataframe(data_1399)
        st.dataframe(data_1403)
        if st.button("تحلیل داده با نمودار"):
            st.plotly_chart(plot_3d_chart(data_1399, 'هفته', 'ارتفاع', title="سال 1399"))
            st.plotly_chart(plot_3d_chart(data_1403, 'هفته', 'ارتفاع', title="سال 1403"))
            st.plotly_chart(compare_growth(data_1399, data_1403, 'هفته', 'ارتفاع'))

# Sidebar menu
st.sidebar.title("منو")
menu = st.sidebar.selectbox("انتخاب کنید", ["داشبورد", "تحلیل رشد محصول", "داده‌های هواشناسی", "پایش سلامت محصول", "گزارش‌ها", "مقایسه رشد و ارتفاع 1399 با 1403"])

if menu == "داشبورد":
    show_dashboard()
elif menu == "تحلیل رشد محصول":
    show_crop_growth_analysis()
elif menu == "داده‌های هواشناسی":
    show_weather_data()
elif menu == "پایش سلامت محصول":
    show_crop_health_monitoring()
elif menu == "گزارش‌ها":
    show_reports()
elif menu == "مقایسه رشد و ارتفاع 1399 با 1403":
    show_growth_comparison()