File size: 3,726 Bytes
d269960
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import pandas as pd
import plotly.express as px
import streamlit as st

from process_kpi.process_gsm_capacity import GsmCapacity, analyze_gsm_data
from utils.convert_to_excel import (  # Import convert_dfs from the appropriate module
    convert_dfs,
    convert_gsm_dfs,
)

st.title(" 📊 GSM Capacity Analysis")
doc_col, image_col = st.columns(2)

with doc_col:
    st.write(
        """
        The report should be run with a minimum of 3 days of data.
        - Daily Aggregated
        - Site level
        - Exported in CSV format.
        """
    )

with image_col:
    st.image("./assets/gsm_capacity.png", width=250)

file1, file2, file3 = st.columns(3)

with file1:
    uploaded_dump = st.file_uploader("Upload Dump file in xlsb format", type="xlsb")
with file2:
    uploaded_daily_report = st.file_uploader(
        "Upload Daily Report in CSV format", type="csv"
    )
with file3:
    uploaded_bh_report = st.file_uploader(
        "Upload Busy Hour Report in CSV format", type="csv"
    )


col1, col2 = st.columns(2)

threshold_col1, threshold_col2 = st.columns(2)
threshold_col3, threshold_col4 = st.columns(2)

if (
    uploaded_dump is not None
    and uploaded_daily_report is not None
    and uploaded_bh_report is not None
):
    # WbtsCapacity.final_results = None
    with col1:
        number_of_kpi_days = st.number_input(
            "Number of days for analysis",
            min_value=3,
            max_value=30,
            value=7,
        )
    with col2:
        number_of_threshold_days = st.number_input(
            "Number of days for threshold",
            min_value=1,
            max_value=30,
            value=3,
        )

    with threshold_col1:
        availability_threshold = st.number_input(
            "Availability Threshold", min_value=1, max_value=100, value=95
        )
    with threshold_col2:
        tch_abis_fails_threshold = st.number_input(
            "TCH ABIS Fails Threshold", min_value=0, value=10
        )
    with threshold_col3:
        sddch_blocking_threshold = st.number_input(
            "SDDCH Blocking Threshold", min_value=0.1, value=0.5
        )
    with threshold_col4:
        tch_blocking_threshold = st.number_input(
            "TCH Blocking Threshold", min_value=0.1, value=0.5
        )

    if st.button("Analyze Data", type="primary"):
        dfs = analyze_gsm_data(
            dump_path=uploaded_dump,
            daily_report_path=uploaded_daily_report,
            bh_report_path=uploaded_bh_report,
            number_of_kpi_days=number_of_kpi_days,
            number_of_threshold_days=number_of_threshold_days,
            availability_threshold=availability_threshold,
            tch_abis_fails_threshold=tch_abis_fails_threshold,
            sddch_blocking_threshold=sddch_blocking_threshold,
            tch_blocking_threshold=tch_blocking_threshold,
        )

        if dfs is not None:
            gsm_analysis_df = dfs[0]
            bh_kpi_df = dfs[1]
            GsmCapacity.final_results = convert_gsm_dfs(
                [gsm_analysis_df, bh_kpi_df], ["GSM_Analysis", "BH_KPI_Analysis"]
            )

            # GsmCapacity.final_results = convert_gsm_dfs(
            #     [gsm_analysis_df], ["GSM_Analysis"]
            # )

            if GsmCapacity.final_results is not None:
                st.download_button(
                    on_click="ignore",
                    type="primary",
                    label="Download the Analysis Report",
                    data=GsmCapacity.final_results,
                    file_name="GSM_Analysis_Report.xlsx",
                    mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                )

        st.write(gsm_analysis_df)