File size: 9,714 Bytes
027f03b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1de5db
027f03b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1de5db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
027f03b
 
 
 
 
 
 
 
 
 
 
 
d1de5db
027f03b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1de5db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
import pandas as pd
import plotly.express as px
import streamlit as st

from process_kpi.process_lte_capacity import process_lte_bh_report
from utils.convert_to_excel import convert_lte_analysis_dfs
from utils.kpi_analysis_utils import LteCapacity

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

with doc_col:
    st.write(
        """
        The report analyzes LTE capacity based on:
        - Dump file required
        - BH Cell level KPI report in CSV format
        - Availability and PRB usage thresholds
        """
    )

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

file1, file2 = st.columns(2)

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

# Parameters
param_col1, param_col2 = st.columns(2)
param_col3, param_col4 = st.columns(2)
param_col5, param_col6 = st.columns(2)

with param_col1:
    num_last_days = st.number_input(
        "Number of last days for analysis", value=7, min_value=1
    )

with param_col2:
    num_threshold_days = st.number_input(
        "Number of days for threshold", value=3, min_value=1
    )

with param_col3:
    availability_threshold = st.number_input(
        "Availability threshold (%)", value=95.0, min_value=0.0, max_value=100.0
    )

with param_col4:
    prb_usage_threshold = st.number_input(
        "PRB usage threshold (%)", value=80.0, min_value=0.0, max_value=100.0
    )

with param_col5:
    prb_diff_between_cells = st.number_input(
        "Maximum PRB usage difference between cells (%)",
        value=20.0,
        min_value=0.0,
        max_value=100.0,
    )

with param_col6:
    #     DL PRB Util p TTI Lev_10
    # E-UTRAN Avg PRB usage per TTI DL
    main_prb_to_use = st.selectbox(
        "Main PRB to use",
        ["DL PRB Util p TTI Lev_10", "E-UTRAN Avg PRB usage per TTI DL"],
        index=1,
    )


if uploaded_dump is not None and uploaded_bh_report is not None:
    if st.button("Analyze Data", type="primary"):
        with st.spinner("Processing data..."):
            results = process_lte_bh_report(
                dump_path=uploaded_dump,
                bh_report_path=uploaded_bh_report,
                num_last_days=num_last_days,
                num_threshold_days=num_threshold_days,
                availability_threshold=availability_threshold,
                prb_usage_threshold=prb_usage_threshold,
                prb_diff_between_cells_threshold=prb_diff_between_cells,
                main_prb_to_use=main_prb_to_use,
            )
        if results is not None:
            bh_report: pd.DataFrame = results[0]
            lte_analysis_df: pd.DataFrame = results[1]
            LteCapacity.final_results = convert_lte_analysis_dfs(
                [lte_analysis_df, bh_report], ["LTE_Analysis", "LTE_BH_Report"]
            )
            st.download_button(
                on_click="ignore",
                type="primary",
                label="Download the Analysis Report",
                data=LteCapacity.final_results,
                file_name="LTE_Analysis_Report.xlsx",
                mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
            )
            st.write(lte_analysis_df)
            # Add dataframe and Pie chart with "final_comments" distribution
            st.markdown("***")
            st.markdown(":blue[**Final comment distribution**]")
            final_comments_df = (
                lte_analysis_df.groupby("final_comments")
                .size()
                .reset_index(name="count")
                .sort_values(by="count", ascending=False)
            )
            final_comments_col1, final_comments_col2 = st.columns((1, 3))
            with final_comments_col1:
                st.write(final_comments_df)
            with final_comments_col2:
                fig = px.pie(
                    final_comments_df,
                    names="final_comments",
                    values="count",
                    hover_name="final_comments",
                    hover_data=["count"],
                    title="Final comment distribution",
                )
                fig.update_layout(height=600)
                fig.update_traces(
                    texttemplate="%{label}: %{value}",
                    textfont_size=15,
                    textposition="outside",
                )
                st.plotly_chart(fig, use_container_width=True)
            # Add dataframe and Pie chart with "final_comments" distribution where num_congested_cells > 0
            st.markdown("***")
            st.markdown(":blue[**Congested cells distribution**]")
            congested_cells_df = (
                lte_analysis_df[lte_analysis_df["num_congested_cells"] > 0]
                .groupby("final_comments")
                .size()
                .reset_index(name="count")
                .sort_values(by="count", ascending=False)
            )
            congested_cells_col1, congested_cells_col2 = st.columns((1, 3))
            with congested_cells_col1:
                st.write(congested_cells_df)
            with congested_cells_col2:
                fig = px.pie(
                    congested_cells_df,
                    names="final_comments",
                    values="count",
                    hover_name="final_comments",
                    hover_data=["count"],
                    title="Congested cells distribution",
                )
                fig.update_layout(height=600)
                fig.update_traces(
                    texttemplate="%{label}: %{value}",
                    textfont_size=15,
                    textposition="outside",
                )
                st.plotly_chart(fig, use_container_width=True)

            # Add dataframe and Bar chart with "final_comments" distribution where num_congested_cells > 0 per Region
            st.markdown("***")
            st.markdown(":blue[**Congested cells distribution per Region**]")
            congested_cells_region_df = (
                lte_analysis_df[lte_analysis_df["num_congested_cells"] > 0]
                .groupby(["Region", "final_comments"])
                .size()
                .reset_index(name="count")
                .sort_values(by="count", ascending=False)
            )
            congested_cells_region_col1, congested_cells_region_col2 = st.columns(
                (1, 3)
            )
            with congested_cells_region_col1:
                st.write(congested_cells_region_df)
            with congested_cells_region_col2:
                fig = px.bar(
                    congested_cells_region_df,
                    x="Region",
                    y="count",
                    color="final_comments",
                    title="Congested cells distribution per Region",
                )
                fig.update_layout(height=600)
                fig.update_traces(
                    texttemplate="%{value}", textfont_size=15, textposition="outside"
                )
                st.plotly_chart(fig, use_container_width=True)
            # Add dataframe and Bar chart with "final_comments" distribution where num_congested_cells > 0 per Region groupby region
            st.markdown("***")
            st.markdown(
                ":blue[**Congested cells distribution per Region groupby Region**]"
            )
            congested_cells_region_groupby_region_df = (
                lte_analysis_df[lte_analysis_df["num_congested_cells"] > 0]
                .groupby(["Region"])
                .size()
                .reset_index(name="count")
                .sort_values(by="count", ascending=False)
            )
            (
                congested_cells_region_groupby_region_col1,
                congested_cells_region_groupby_region_col2,
            ) = st.columns((1, 3))
            with congested_cells_region_groupby_region_col1:
                st.write(congested_cells_region_groupby_region_df)
            with congested_cells_region_groupby_region_col2:
                fig = px.bar(
                    congested_cells_region_groupby_region_df,
                    x="Region",
                    y="count",
                    title="Congested cells distribution per Region groupby Region",
                )
                fig.update_layout(height=600)
                fig.update_traces(
                    texttemplate="%{value}", textfont_size=15, textposition="outside"
                )
                st.plotly_chart(fig, use_container_width=True)
            # create a map plot with scatter_map with code ,Longitude,Latitude,final_comments
            st.markdown("***")
            st.markdown(":blue[**Final comments distribution**]")
            map_df = lte_analysis_df[
                ["code", "Longitude", "Latitude", "final_comments"]
            ].dropna(subset=["code", "Longitude", "Latitude", "final_comments"])
            # add size column equalt to 20
            map_df["size"] = 20

            fig = px.scatter_map(
                map_df,
                lat="Latitude",
                lon="Longitude",
                color="final_comments",
                size="size",
                zoom=10,
                height=600,
                title="Final comments distribution",
                hover_data={
                    "code": True,
                    "final_comments": True,
                },
                hover_name="code",
            )
            fig.update_layout(mapbox_style="open-street-map")
            st.plotly_chart(fig, use_container_width=True)