DavMelchi commited on
Commit
01dd930
·
1 Parent(s): 240674a

add site_band_config

Browse files
README.md CHANGED
@@ -39,6 +39,7 @@ You can access the hosted version of the app at [https://davmelchi-db-query.hf.s
39
  - [x] Add option to download Neighbors database
40
  - [x] Add page to update physical db
41
  - [x] Add Core dump checking App
 
42
  - [ ] Add dashboards for each database (Count of NE)
43
  - [ ] Add the ability to select columns
44
  - [ ] Error handling
 
39
  - [x] Add option to download Neighbors database
40
  - [x] Add page to update physical db
41
  - [x] Add Core dump checking App
42
+ - [x] Add site config band in database
43
  - [ ] Add dashboards for each database (Count of NE)
44
  - [ ] Add the ability to select columns
45
  - [ ] Error handling
apps/import_physical_db.py CHANGED
@@ -39,7 +39,9 @@ if uploaded_file is not None:
39
  elif len(df) <= 500:
40
  st.error("Error: The file must contain more than 500 rows.")
41
  else:
42
- st.success("File successfully validated.")
 
 
43
 
44
  # Display the DataFrame
45
  st.write(df)
 
39
  elif len(df) <= 500:
40
  st.error("Error: The file must contain more than 500 rows.")
41
  else:
42
+ st.success(
43
+ "File successfully validated. Click on the Save button to save the new physical database file."
44
+ )
45
 
46
  # Display the DataFrame
47
  st.write(df)
queries/process_gsm.py CHANGED
@@ -1,6 +1,7 @@
1
  import pandas as pd
2
 
3
  from queries.process_trx import process_trx_data
 
4
  from utils.convert_to_excel import convert_dfs, save_dataframe
5
  from utils.utils_vars import UtilsVars
6
 
@@ -43,6 +44,7 @@ BTS_COLUMNS = [
43
  "band_frequence",
44
  "type_cellule",
45
  "configuration_schema",
 
46
  ]
47
 
48
  BCF_COLUMNS = [
@@ -80,11 +82,16 @@ def process_gsm_data(file_path: str):
80
  df_bts["sectorId"].map(UtilsVars.sector_mapping).fillna(df_bts["sectorId"])
81
  )
82
  df_bts["band_frequence"] = (
83
- df_bts["frequencyBandInUse"].map(UtilsVars.band_frequence).fillna("not found")
 
 
84
  )
85
  df_bts["type_cellule"] = (
86
  df_bts["frequencyBandInUse"].map(UtilsVars.type_cellule).fillna("not found")
87
  )
 
 
 
88
  df_bts["configuration_schema"] = (
89
  df_bts["frequencyBandInUse"]
90
  .map(UtilsVars.configuration_schema)
@@ -107,15 +114,19 @@ def process_gsm_data(file_path: str):
107
 
108
  df_trx = process_trx_data(file_path)
109
 
 
 
 
110
  # Merge dataframes
111
  df_bts_bcf = pd.merge(df_bts, df_bcf, on="ID_BCF", how="left")
112
  df_2g = pd.merge(df_bts_bcf, df_trx, on="ID_BTS", how="left")
 
113
 
114
  df_physical_db = UtilsVars.physisal_db
115
  df_2g = pd.merge(df_2g, df_physical_db, on="Code_Sector", how="left")
116
 
117
  # Save dataframes
118
- # save_dataframe(df_bts, "bts")
119
  # save_dataframe(df_bcf, "bcf")
120
  # save_dataframe(df_trx, "trx")
121
  # df_2g2 = save_dataframe(df_2g, "2g")
@@ -127,5 +138,11 @@ def process_gsm_data(file_path: str):
127
 
128
 
129
  def process_gsm_data_to_excel(file_path: str):
 
 
 
 
 
 
130
  gsm_dfs = process_gsm_data(file_path)
131
  UtilsVars.final_gsm_database = convert_dfs([gsm_dfs], ["GSM"])
 
1
  import pandas as pd
2
 
3
  from queries.process_trx import process_trx_data
4
+ from utils.config_band import config_band
5
  from utils.convert_to_excel import convert_dfs, save_dataframe
6
  from utils.utils_vars import UtilsVars
7
 
 
44
  "band_frequence",
45
  "type_cellule",
46
  "configuration_schema",
47
+ "band",
48
  ]
49
 
50
  BCF_COLUMNS = [
 
82
  df_bts["sectorId"].map(UtilsVars.sector_mapping).fillna(df_bts["sectorId"])
83
  )
84
  df_bts["band_frequence"] = (
85
+ df_bts["frequencyBandInUse"]
86
+ .map(UtilsVars.oml_band_frequence)
87
+ .fillna("not found")
88
  )
89
  df_bts["type_cellule"] = (
90
  df_bts["frequencyBandInUse"].map(UtilsVars.type_cellule).fillna("not found")
91
  )
92
+ df_bts["band"] = (
93
+ df_bts["frequencyBandInUse"].map(UtilsVars.gsm_band).fillna("not found")
94
+ )
95
  df_bts["configuration_schema"] = (
96
  df_bts["frequencyBandInUse"]
97
  .map(UtilsVars.configuration_schema)
 
114
 
115
  df_trx = process_trx_data(file_path)
116
 
117
+ # create band dataframe
118
+ df_band = config_band(df_bts)
119
+
120
  # Merge dataframes
121
  df_bts_bcf = pd.merge(df_bts, df_bcf, on="ID_BCF", how="left")
122
  df_2g = pd.merge(df_bts_bcf, df_trx, on="ID_BTS", how="left")
123
+ df_2g = pd.merge(df_2g, df_band, on="code", how="left")
124
 
125
  df_physical_db = UtilsVars.physisal_db
126
  df_2g = pd.merge(df_2g, df_physical_db, on="Code_Sector", how="left")
127
 
128
  # Save dataframes
129
+ # save_dataframe(df_band, "BAND")
130
  # save_dataframe(df_bcf, "bcf")
131
  # save_dataframe(df_trx, "trx")
132
  # df_2g2 = save_dataframe(df_2g, "2g")
 
138
 
139
 
140
  def process_gsm_data_to_excel(file_path: str):
141
+ """
142
+ Process data from the specified file path and save it to a excel file.
143
+
144
+ Args:
145
+ file_path (str): The path to the file.
146
+ """
147
  gsm_dfs = process_gsm_data(file_path)
148
  UtilsVars.final_gsm_database = convert_dfs([gsm_dfs], ["GSM"])
queries/process_lte.py CHANGED
@@ -1,6 +1,7 @@
1
  import numpy as np
2
  import pandas as pd
3
 
 
4
  from utils.convert_to_excel import convert_dfs, save_dataframe
5
  from utils.utils_vars import UtilsVars, get_band
6
 
@@ -94,6 +95,9 @@ def process_lte_data(file_path: str):
94
  df_lncel["band_type"] = np.where(df_lncel["band"] == "L2300", "TDD", "FDD")
95
  df_lncel = df_lncel[LNCEL_COLUMNS]
96
 
 
 
 
97
  # Process LNBTS data
98
  df_lnbts = dfs["LNBTS"]
99
  df_lnbts.columns = df_lnbts.columns.str.replace(r"[ ]", "", regex=True)
@@ -105,6 +109,7 @@ def process_lte_data(file_path: str):
105
 
106
  # Merge dataframes
107
  df_lncel_lnbts = pd.merge(df_lncel, df_lnbts, on="ID_LNBTS", how="left")
 
108
 
109
  df_physical_db = UtilsVars.physisal_db
110
  df_physical_db = df_physical_db[
 
1
  import numpy as np
2
  import pandas as pd
3
 
4
+ from utils.config_band import config_band
5
  from utils.convert_to_excel import convert_dfs, save_dataframe
6
  from utils.utils_vars import UtilsVars, get_band
7
 
 
95
  df_lncel["band_type"] = np.where(df_lncel["band"] == "L2300", "TDD", "FDD")
96
  df_lncel = df_lncel[LNCEL_COLUMNS]
97
 
98
+ # create band dataframe
99
+ df_band = config_band(df_lncel)
100
+
101
  # Process LNBTS data
102
  df_lnbts = dfs["LNBTS"]
103
  df_lnbts.columns = df_lnbts.columns.str.replace(r"[ ]", "", regex=True)
 
109
 
110
  # Merge dataframes
111
  df_lncel_lnbts = pd.merge(df_lncel, df_lnbts, on="ID_LNBTS", how="left")
112
+ df_lncel_lnbts = pd.merge(df_lncel_lnbts, df_band, on="code", how="left")
113
 
114
  df_physical_db = UtilsVars.physisal_db
115
  df_physical_db = df_physical_db[
queries/process_wcdma.py CHANGED
@@ -1,5 +1,6 @@
1
  import pandas as pd
2
 
 
3
  from utils.convert_to_excel import convert_dfs, save_dataframe
4
  from utils.extract_code import extract_code_from_mrbts
5
  from utils.utils_vars import UtilsVars
@@ -39,6 +40,7 @@ WCEL_COLUMNS = [
39
  "Code_Sector",
40
  "code_wcel",
41
  "porteuse",
 
42
  ]
43
 
44
  WBTS_COLUMNS = [
@@ -96,6 +98,11 @@ def process_wcdma_data(file_path: str):
96
  df_wcel["porteuse"] = (
97
  df_wcel["UARFCN"].map(UtilsVars.porteuse_mapping).fillna("not found")
98
  )
 
 
 
 
 
99
  # Process WBTS data
100
  df_wbts = dfs["WBTS"]
101
  df_wbts.columns = df_wbts.columns.str.replace(r"[ ]", "", regex=True)
@@ -120,6 +127,7 @@ def process_wcdma_data(file_path: str):
120
  df_3g = df_3g[WCEL_COLUMNS]
121
 
122
  df_physical_db = UtilsVars.physisal_db
 
123
  df_3g = pd.merge(df_3g, df_physical_db, on="Code_Sector", how="left")
124
  # Save dataframes
125
  # save_dataframe(df_wcel, "wcel")
@@ -136,5 +144,11 @@ def process_wcdma_data(file_path: str):
136
 
137
 
138
  def process_wcdma_data_to_excel(file_path: str):
 
 
 
 
 
 
139
  wcdma_dfs = process_wcdma_data(file_path)
140
  UtilsVars.final_wcdma_database = convert_dfs([wcdma_dfs], ["WCDMA"])
 
1
  import pandas as pd
2
 
3
+ from utils.config_band import config_band
4
  from utils.convert_to_excel import convert_dfs, save_dataframe
5
  from utils.extract_code import extract_code_from_mrbts
6
  from utils.utils_vars import UtilsVars
 
40
  "Code_Sector",
41
  "code_wcel",
42
  "porteuse",
43
+ "band",
44
  ]
45
 
46
  WBTS_COLUMNS = [
 
98
  df_wcel["porteuse"] = (
99
  df_wcel["UARFCN"].map(UtilsVars.porteuse_mapping).fillna("not found")
100
  )
101
+ df_wcel["band"] = df_wcel["UARFCN"].map(UtilsVars.wcdma_band).fillna("not found")
102
+
103
+ # create config_band dataframe
104
+ df_band = config_band(df_wcel)
105
+
106
  # Process WBTS data
107
  df_wbts = dfs["WBTS"]
108
  df_wbts.columns = df_wbts.columns.str.replace(r"[ ]", "", regex=True)
 
127
  df_3g = df_3g[WCEL_COLUMNS]
128
 
129
  df_physical_db = UtilsVars.physisal_db
130
+ df_3g = pd.merge(df_3g, df_band, on="code", how="left")
131
  df_3g = pd.merge(df_3g, df_physical_db, on="Code_Sector", how="left")
132
  # Save dataframes
133
  # save_dataframe(df_wcel, "wcel")
 
144
 
145
 
146
  def process_wcdma_data_to_excel(file_path: str):
147
+ """
148
+ Process WCDMA data from the specified file path and convert it to Excel format
149
+
150
+ Args:
151
+ file_path (str): The path to the file.
152
+ """
153
  wcdma_dfs = process_wcdma_data(file_path)
154
  UtilsVars.final_wcdma_database = convert_dfs([wcdma_dfs], ["WCDMA"])
utils/config_band.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+
3
+
4
+ def config_band(df: pd.DataFrame) -> pd.DataFrame:
5
+ """
6
+ Create a dataframe that contains the site configuration band for each site code.
7
+
8
+ Parameters
9
+ ----------
10
+ df : pd.DataFrame
11
+ The dataframe containing the site information, with columns "code" and "band"
12
+
13
+ Returns
14
+ -------
15
+ pd.DataFrame
16
+ The dataframe containing the site configuration band for each site code, with columns "code" and "site_config_band"
17
+ """
18
+ df_band = df[["code", "band"]].copy()
19
+ df_band["ID"] = df_band[["code", "band"]].astype(str).apply("_".join, axis=1)
20
+ # remove duplicates ID
21
+ df_band = df_band.drop_duplicates(subset=["ID"])
22
+ df_band = df_band[["code", "band"]]
23
+ df_band = (
24
+ df_band.groupby("code")["band"]
25
+ .apply(lambda x: "/".join(sorted(x)))
26
+ .reset_index()
27
+ )
28
+ # rename band to config
29
+ df_band.rename(columns={"band": "site_config_band"}, inplace=True)
30
+
31
+ return df_band
utils/utils_vars.py CHANGED
@@ -19,7 +19,8 @@ def get_physical_db():
19
  class UtilsVars:
20
  sector_mapping = {4: 1, 5: 2, 6: 3, 11: 1, 12: 2, 13: 3}
21
  type_cellule = {1: "Macro Cell 1800", 0: "Macro Cell 900"}
22
- band_frequence = {1: "OML BAND GSM 1800", 0: "OML BAND GSM 900"}
 
23
  configuration_schema = {1: "EGPRS 1800", 0: "EGPRS 900"}
24
  channeltype_mapping = {4: "BCCH", 3: "TCH"}
25
  porteuse_mapping = {
@@ -29,6 +30,13 @@ class UtilsVars:
29
  10787: "OML UTRA Band I",
30
  10837: "OML UTRA Band I",
31
  }
 
 
 
 
 
 
 
32
  final_lte_database = ""
33
  final_gsm_database = ""
34
  final_wcdma_database = ""
 
19
  class UtilsVars:
20
  sector_mapping = {4: 1, 5: 2, 6: 3, 11: 1, 12: 2, 13: 3}
21
  type_cellule = {1: "Macro Cell 1800", 0: "Macro Cell 900"}
22
+ oml_band_frequence = {1: "OML BAND GSM 1800", 0: "OML BAND GSM 900"}
23
+ gsm_band = {1: "G1800", 0: "G900"}
24
  configuration_schema = {1: "EGPRS 1800", 0: "EGPRS 900"}
25
  channeltype_mapping = {4: "BCCH", 3: "TCH"}
26
  porteuse_mapping = {
 
30
  10787: "OML UTRA Band I",
31
  10837: "OML UTRA Band I",
32
  }
33
+ wcdma_band = {
34
+ 3004: "U900",
35
+ 3006: "U900",
36
+ 10787: "U2100",
37
+ 10837: "U2100",
38
+ 10812: "U2100",
39
+ }
40
  final_lte_database = ""
41
  final_gsm_database = ""
42
  final_wcdma_database = ""