GSM Congested vs operational distance Trial 1
Browse files
apps/kpi_analysis/gsm_capacity.py
CHANGED
|
@@ -42,7 +42,7 @@ col1, col2 = st.columns(2)
|
|
| 42 |
|
| 43 |
threshold_col1, threshold_col2 = st.columns(2)
|
| 44 |
threshold_col3, threshold_col4 = st.columns(2)
|
| 45 |
-
max_traffic_threshold_col1,
|
| 46 |
|
| 47 |
|
| 48 |
if (
|
|
@@ -86,10 +86,10 @@ if (
|
|
| 86 |
max_traffic_threshold = st.number_input(
|
| 87 |
"TCH Utilization Max Traffic Threshold", min_value=0, value=90
|
| 88 |
)
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
|
| 94 |
if st.button("Analyze Data", type="primary"):
|
| 95 |
dfs = analyze_gsm_data(
|
|
@@ -103,15 +103,17 @@ if (
|
|
| 103 |
sdcch_blocking_threshold=sdcch_blocking_threshold,
|
| 104 |
tch_blocking_threshold=tch_blocking_threshold,
|
| 105 |
max_traffic_threshold=max_traffic_threshold,
|
|
|
|
| 106 |
)
|
| 107 |
|
| 108 |
if dfs is not None:
|
| 109 |
gsm_analysis_df: pd.DataFrame = dfs[0]
|
| 110 |
bh_kpi_df: pd.DataFrame = dfs[1]
|
| 111 |
daily_kpi_df: pd.DataFrame = dfs[2]
|
|
|
|
| 112 |
GsmCapacity.final_results = convert_gsm_dfs(
|
| 113 |
-
[gsm_analysis_df, bh_kpi_df, daily_kpi_df],
|
| 114 |
-
["GSM_Analysis", "BH_KPI_Analysis", "Daily_KPI_Analysis"],
|
| 115 |
)
|
| 116 |
|
| 117 |
# GsmCapacity.final_results = convert_gsm_dfs(
|
|
|
|
| 42 |
|
| 43 |
threshold_col1, threshold_col2 = st.columns(2)
|
| 44 |
threshold_col3, threshold_col4 = st.columns(2)
|
| 45 |
+
max_traffic_threshold_col1, operational_neighbours_distance_col1 = st.columns(2)
|
| 46 |
|
| 47 |
|
| 48 |
if (
|
|
|
|
| 86 |
max_traffic_threshold = st.number_input(
|
| 87 |
"TCH Utilization Max Traffic Threshold", min_value=0, value=90
|
| 88 |
)
|
| 89 |
+
with operational_neighbours_distance_col1:
|
| 90 |
+
operational_neighbours_distance = st.number_input(
|
| 91 |
+
"Operational Neighbours Distance", min_value=0, value=1
|
| 92 |
+
)
|
| 93 |
|
| 94 |
if st.button("Analyze Data", type="primary"):
|
| 95 |
dfs = analyze_gsm_data(
|
|
|
|
| 103 |
sdcch_blocking_threshold=sdcch_blocking_threshold,
|
| 104 |
tch_blocking_threshold=tch_blocking_threshold,
|
| 105 |
max_traffic_threshold=max_traffic_threshold,
|
| 106 |
+
operational_neighbours_distance=operational_neighbours_distance,
|
| 107 |
)
|
| 108 |
|
| 109 |
if dfs is not None:
|
| 110 |
gsm_analysis_df: pd.DataFrame = dfs[0]
|
| 111 |
bh_kpi_df: pd.DataFrame = dfs[1]
|
| 112 |
daily_kpi_df: pd.DataFrame = dfs[2]
|
| 113 |
+
distance_df: pd.DataFrame = dfs[3]
|
| 114 |
GsmCapacity.final_results = convert_gsm_dfs(
|
| 115 |
+
[gsm_analysis_df, bh_kpi_df, daily_kpi_df, distance_df],
|
| 116 |
+
["GSM_Analysis", "BH_KPI_Analysis", "Daily_KPI_Analysis", "Distance"],
|
| 117 |
)
|
| 118 |
|
| 119 |
# GsmCapacity.final_results = convert_gsm_dfs(
|
process_kpi/process_gsm_capacity.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import numpy as np
|
| 2 |
import pandas as pd
|
| 3 |
|
|
|
|
| 4 |
from queries.process_gsm import combined_gsm_database
|
| 5 |
from utils.check_sheet_exist import execute_checks_sheets_exist
|
| 6 |
from utils.convert_to_excel import convert_dfs, save_dataframe
|
|
@@ -20,8 +21,18 @@ from utils.kpi_analysis_utils import (
|
|
| 20 |
|
| 21 |
class GsmCapacity:
|
| 22 |
final_results = None
|
|
|
|
| 23 |
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
GSM_COLUMNS = [
|
| 26 |
"ID_BTS",
|
| 27 |
"site_name",
|
|
@@ -46,6 +57,8 @@ GSM_COLUMNS = [
|
|
| 46 |
"number_trx_per_bcf",
|
| 47 |
"TRX_TCH",
|
| 48 |
"MAL_TCH",
|
|
|
|
|
|
|
| 49 |
]
|
| 50 |
|
| 51 |
TRX_COLUMNS = [
|
|
@@ -404,10 +417,58 @@ def get_gsm_databases(dump_path: str) -> pd.DataFrame:
|
|
| 404 |
lambda x: GsmAnalysis.erlangB_table.get(int(x), 0)
|
| 405 |
)
|
| 406 |
|
| 407 |
-
# save_dataframe(gsm_df, "GSM")
|
| 408 |
return gsm_df
|
| 409 |
|
| 410 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
def analyze_gsm_data(
|
| 412 |
dump_path: str,
|
| 413 |
daily_report_path: str,
|
|
@@ -419,7 +480,9 @@ def analyze_gsm_data(
|
|
| 419 |
sdcch_blocking_threshold: float,
|
| 420 |
tch_blocking_threshold: float,
|
| 421 |
max_traffic_threshold: int,
|
|
|
|
| 422 |
):
|
|
|
|
| 423 |
|
| 424 |
daily_kpi_dfs: pd.DataFrame = analyse_daily_data(
|
| 425 |
daily_report_path=daily_report_path,
|
|
@@ -540,9 +603,9 @@ def analyze_gsm_data(
|
|
| 540 |
new_column="Final comment",
|
| 541 |
)
|
| 542 |
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
|
| 548 |
-
return [gsm_analysis_df, bh_kpi_full_df, daily_kpi_full_df]
|
|
|
|
| 1 |
import numpy as np
|
| 2 |
import pandas as pd
|
| 3 |
|
| 4 |
+
from apps.multi_points_distance_calculator import calculate_distances
|
| 5 |
from queries.process_gsm import combined_gsm_database
|
| 6 |
from utils.check_sheet_exist import execute_checks_sheets_exist
|
| 7 |
from utils.convert_to_excel import convert_dfs, save_dataframe
|
|
|
|
| 21 |
|
| 22 |
class GsmCapacity:
|
| 23 |
final_results = None
|
| 24 |
+
operational_neighbours_df = None
|
| 25 |
|
| 26 |
|
| 27 |
+
OPERATIONAL_NEIGHBOURS_COLUMNS = [
|
| 28 |
+
"ID_BTS",
|
| 29 |
+
"name",
|
| 30 |
+
"operational_comment",
|
| 31 |
+
"BH Congestion status",
|
| 32 |
+
"Longitude",
|
| 33 |
+
"Latitude",
|
| 34 |
+
]
|
| 35 |
+
|
| 36 |
GSM_COLUMNS = [
|
| 37 |
"ID_BTS",
|
| 38 |
"site_name",
|
|
|
|
| 57 |
"number_trx_per_bcf",
|
| 58 |
"TRX_TCH",
|
| 59 |
"MAL_TCH",
|
| 60 |
+
"Longitude",
|
| 61 |
+
"Latitude",
|
| 62 |
]
|
| 63 |
|
| 64 |
TRX_COLUMNS = [
|
|
|
|
| 417 |
lambda x: GsmAnalysis.erlangB_table.get(int(x), 0)
|
| 418 |
)
|
| 419 |
|
|
|
|
| 420 |
return gsm_df
|
| 421 |
|
| 422 |
|
| 423 |
+
def get_operational_neighbours(distance: int) -> pd.DataFrame:
|
| 424 |
+
|
| 425 |
+
operational_df: pd.DataFrame = GsmCapacity.operational_neighbours_df
|
| 426 |
+
operational_df = operational_df[
|
| 427 |
+
["ID_BTS", "name", "operational_comment", "Longitude", "Latitude"]
|
| 428 |
+
]
|
| 429 |
+
# keep row only if column "operational_comment" is not "Operational is OK"
|
| 430 |
+
operational_df = operational_df[
|
| 431 |
+
operational_df["operational_comment"] != "Operational is OK"
|
| 432 |
+
]
|
| 433 |
+
|
| 434 |
+
# Rename all columns in operational_df by adding "Dataset2_" prefix
|
| 435 |
+
operational_df = operational_df.add_prefix("Dataset2_")
|
| 436 |
+
|
| 437 |
+
congested_df: pd.DataFrame = GsmCapacity.operational_neighbours_df
|
| 438 |
+
congested_df = congested_df[
|
| 439 |
+
["ID_BTS", "name", "BH Congestion status", "Longitude", "Latitude"]
|
| 440 |
+
]
|
| 441 |
+
|
| 442 |
+
# Remove NaN , empty string
|
| 443 |
+
congested_df = congested_df[congested_df["BH Congestion status"] != ""]
|
| 444 |
+
|
| 445 |
+
# Remove rows where "BH Congestion status" is "nan, nan"
|
| 446 |
+
congested_df = congested_df[congested_df["BH Congestion status"] != "nan, nan"]
|
| 447 |
+
|
| 448 |
+
# Rename all columns in congested_df by adding "Dataset1_" prefix
|
| 449 |
+
congested_df = congested_df.add_prefix("Dataset1_")
|
| 450 |
+
|
| 451 |
+
distances_dfs = calculate_distances(
|
| 452 |
+
congested_df,
|
| 453 |
+
operational_df,
|
| 454 |
+
"Dataset1_ID_BTS",
|
| 455 |
+
"Dataset1_Latitude",
|
| 456 |
+
"Dataset1_Longitude",
|
| 457 |
+
"Dataset2_ID_BTS",
|
| 458 |
+
"Dataset2_Latitude",
|
| 459 |
+
"Dataset2_Longitude",
|
| 460 |
+
)
|
| 461 |
+
distances_df = distances_dfs[0]
|
| 462 |
+
df1 = distances_df[distances_df["Distance_km"] <= distance]
|
| 463 |
+
|
| 464 |
+
# save_dataframe(operational_df, "Operational Neighbours")
|
| 465 |
+
# save_dataframe(congested_df, "Congested Neighbours")
|
| 466 |
+
# # save_dataframe(distances_df, "Distances")
|
| 467 |
+
# save_dataframe(df1, "Closest Neighbours")
|
| 468 |
+
|
| 469 |
+
return df1
|
| 470 |
+
|
| 471 |
+
|
| 472 |
def analyze_gsm_data(
|
| 473 |
dump_path: str,
|
| 474 |
daily_report_path: str,
|
|
|
|
| 480 |
sdcch_blocking_threshold: float,
|
| 481 |
tch_blocking_threshold: float,
|
| 482 |
max_traffic_threshold: int,
|
| 483 |
+
operational_neighbours_distance: int,
|
| 484 |
):
|
| 485 |
+
GsmCapacity.operational_neighbours_df = None
|
| 486 |
|
| 487 |
daily_kpi_dfs: pd.DataFrame = analyse_daily_data(
|
| 488 |
daily_report_path=daily_report_path,
|
|
|
|
| 603 |
new_column="Final comment",
|
| 604 |
)
|
| 605 |
|
| 606 |
+
GsmCapacity.operational_neighbours_df = gsm_analysis_df[
|
| 607 |
+
OPERATIONAL_NEIGHBOURS_COLUMNS
|
| 608 |
+
]
|
| 609 |
+
distance_df = get_operational_neighbours(operational_neighbours_distance)
|
| 610 |
|
| 611 |
+
return [gsm_analysis_df, bh_kpi_full_df, daily_kpi_full_df, distance_df]
|