adding NICE DB
Browse files- apps/database_page.py +21 -0
- queries/process_all_db.py +6 -0
- queries/process_nice_db.py +288 -0
- utils/utils_vars.py +1 -0
apps/database_page.py
CHANGED
@@ -9,6 +9,7 @@ from queries.process_all_db import (
|
|
9 |
process_all_tech_db,
|
10 |
process_all_tech_db_with_stats,
|
11 |
process_atoll_db,
|
|
|
12 |
)
|
13 |
from queries.process_gsm import process_gsm_data_to_excel, process_gsm_data_to_kml
|
14 |
from queries.process_invunit import process_invunit_data_to_excel
|
@@ -65,6 +66,9 @@ def download_button(database_type):
|
|
65 |
elif database_type == "Custom":
|
66 |
data = UtilsVars.final_atoll_database
|
67 |
file_name = f"Custom database_{datetime.now()}.xlsx"
|
|
|
|
|
|
|
68 |
st.download_button(
|
69 |
type="primary",
|
70 |
label=f"Download {database_type} Database File",
|
@@ -127,6 +131,17 @@ def execute_process_custom_db(uploaded_file):
|
|
127 |
download_button("Custom")
|
128 |
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
# def execute_process_all_tech_db_with_stats(uploaded_file: str, region_list: list):
|
131 |
def execute_process_all_tech_db_with_stats(uploaded_file: str):
|
132 |
|
@@ -264,6 +279,12 @@ if uploaded_file is not None:
|
|
264 |
"Generate ATL DB",
|
265 |
on_click=lambda: execute_process_custom_db(uploaded_file),
|
266 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
except Exception as e:
|
268 |
st.error(f"Error: {e}")
|
269 |
|
|
|
9 |
process_all_tech_db,
|
10 |
process_all_tech_db_with_stats,
|
11 |
process_atoll_db,
|
12 |
+
process_nice_db,
|
13 |
)
|
14 |
from queries.process_gsm import process_gsm_data_to_excel, process_gsm_data_to_kml
|
15 |
from queries.process_invunit import process_invunit_data_to_excel
|
|
|
66 |
elif database_type == "Custom":
|
67 |
data = UtilsVars.final_atoll_database
|
68 |
file_name = f"Custom database_{datetime.now()}.xlsx"
|
69 |
+
elif database_type == "Nice":
|
70 |
+
data = UtilsVars.final_nice_database
|
71 |
+
file_name = f"Nice database_{datetime.now()}.xlsx"
|
72 |
st.download_button(
|
73 |
type="primary",
|
74 |
label=f"Download {database_type} Database File",
|
|
|
131 |
download_button("Custom")
|
132 |
|
133 |
|
134 |
+
def execute_process_nice_db(uploaded_file):
|
135 |
+
if uploaded_file is not None:
|
136 |
+
start_time = time.time()
|
137 |
+
process_nice_db(uploaded_file)
|
138 |
+
execution_time = time.time() - start_time
|
139 |
+
st.write(
|
140 |
+
f"Nice databases are generated. Execution time: {execution_time:.2f} seconds"
|
141 |
+
)
|
142 |
+
download_button("Nice")
|
143 |
+
|
144 |
+
|
145 |
# def execute_process_all_tech_db_with_stats(uploaded_file: str, region_list: list):
|
146 |
def execute_process_all_tech_db_with_stats(uploaded_file: str):
|
147 |
|
|
|
279 |
"Generate ATL DB",
|
280 |
on_click=lambda: execute_process_custom_db(uploaded_file),
|
281 |
)
|
282 |
+
if DumpType.full_dump == True:
|
283 |
+
with col12:
|
284 |
+
st.button(
|
285 |
+
"Generate Nice DB",
|
286 |
+
on_click=lambda: execute_process_nice_db(uploaded_file),
|
287 |
+
)
|
288 |
except Exception as e:
|
289 |
st.error(f"Error: {e}")
|
290 |
|
queries/process_all_db.py
CHANGED
@@ -3,6 +3,7 @@ from queries.process_gsm import combined_gsm_database, gsm_analaysis
|
|
3 |
from queries.process_invunit import process_invunit_data
|
4 |
from queries.process_lte import lte_fdd_analaysis, lte_tdd_analaysis, process_lte_data
|
5 |
from queries.process_mrbts import process_mrbts_data
|
|
|
6 |
from queries.process_site_db import site_db
|
7 |
from queries.process_wcdma import process_wcdma_data, wcdma_analaysis
|
8 |
from utils.convert_to_excel import convert_database_dfs, convert_dfs
|
@@ -80,3 +81,8 @@ def process_all_tech_db_with_stats(
|
|
80 |
def process_atoll_db(filepath: str):
|
81 |
clear_all_dbs()
|
82 |
process_data_for_atoll(filepath)
|
|
|
|
|
|
|
|
|
|
|
|
3 |
from queries.process_invunit import process_invunit_data
|
4 |
from queries.process_lte import lte_fdd_analaysis, lte_tdd_analaysis, process_lte_data
|
5 |
from queries.process_mrbts import process_mrbts_data
|
6 |
+
from queries.process_nice_db import process_data_for_nice
|
7 |
from queries.process_site_db import site_db
|
8 |
from queries.process_wcdma import process_wcdma_data, wcdma_analaysis
|
9 |
from utils.convert_to_excel import convert_database_dfs, convert_dfs
|
|
|
81 |
def process_atoll_db(filepath: str):
|
82 |
clear_all_dbs()
|
83 |
process_data_for_atoll(filepath)
|
84 |
+
|
85 |
+
|
86 |
+
def process_nice_db(filepath: str):
|
87 |
+
clear_all_dbs()
|
88 |
+
process_data_for_nice(filepath)
|
queries/process_nice_db.py
ADDED
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Process NICE database files and convert them to a standardized format for Atoll.
|
3 |
+
|
4 |
+
This module handles processing of LTE, WCDMA, and GSM network data from NICE database files
|
5 |
+
and converts them into a standardized format suitable for Atoll network planning tool.
|
6 |
+
"""
|
7 |
+
|
8 |
+
from typing import List
|
9 |
+
|
10 |
+
import pandas as pd
|
11 |
+
|
12 |
+
from queries.process_gsm import process_gsm_data
|
13 |
+
from queries.process_lte import process_lte_data
|
14 |
+
from queries.process_wcdma import process_wcdma_data
|
15 |
+
from utils.convert_to_excel import convert_dfs
|
16 |
+
from utils.utils_vars import UtilsVars
|
17 |
+
|
18 |
+
# Constants for column names
|
19 |
+
LTE_NICE_EMETTEUR_COLUMNS: List[str] = [
|
20 |
+
"MRBTS",
|
21 |
+
"LNBTS",
|
22 |
+
"LNCEL",
|
23 |
+
"final_name",
|
24 |
+
"code",
|
25 |
+
"SectorId",
|
26 |
+
"band",
|
27 |
+
"band_type",
|
28 |
+
"lnbts_name",
|
29 |
+
"Azimut",
|
30 |
+
"Longitude",
|
31 |
+
"Latitude",
|
32 |
+
"Hauteur",
|
33 |
+
"earfcnDL",
|
34 |
+
]
|
35 |
+
|
36 |
+
|
37 |
+
WCDMA_NICE_EMETTEUR_COLUMNS: List[str] = [
|
38 |
+
"RNC",
|
39 |
+
"WBTS",
|
40 |
+
"WCEL",
|
41 |
+
"site_name",
|
42 |
+
"name",
|
43 |
+
"code",
|
44 |
+
"CId",
|
45 |
+
"LAC",
|
46 |
+
"RAC",
|
47 |
+
"UARFCN",
|
48 |
+
"SectorID",
|
49 |
+
"band",
|
50 |
+
"Azimut",
|
51 |
+
"Longitude",
|
52 |
+
"Latitude",
|
53 |
+
"Hauteur",
|
54 |
+
]
|
55 |
+
|
56 |
+
|
57 |
+
GSM_NICE_COLUMNS: List[str] = [
|
58 |
+
"code",
|
59 |
+
"SectorId2",
|
60 |
+
"Latitude",
|
61 |
+
"Longitude",
|
62 |
+
"Hauteur",
|
63 |
+
"Azimut",
|
64 |
+
"BSC",
|
65 |
+
"BCF",
|
66 |
+
"BTS",
|
67 |
+
"band",
|
68 |
+
"name",
|
69 |
+
"site_name",
|
70 |
+
"cellId",
|
71 |
+
"locationAreaIdLAC",
|
72 |
+
"rac",
|
73 |
+
]
|
74 |
+
|
75 |
+
# Common column names
|
76 |
+
VENDOR: str = "Nokia"
|
77 |
+
DEFAULT_TILT: int = 0
|
78 |
+
|
79 |
+
|
80 |
+
def _process_lte_data(file_path: str) -> pd.DataFrame:
|
81 |
+
"""
|
82 |
+
Process LTE data from the NICE database file.
|
83 |
+
|
84 |
+
Args:
|
85 |
+
file_path: Path to the NICE database file
|
86 |
+
|
87 |
+
Returns:
|
88 |
+
pd.DataFrame: Processed LTE data in Atoll format
|
89 |
+
"""
|
90 |
+
try:
|
91 |
+
lte_fdd_df, lte_tdd_df = process_lte_data(file_path)
|
92 |
+
lte_tdd_df = lte_tdd_df.rename(columns={"earfcn": "earfcnDL"})
|
93 |
+
|
94 |
+
# Combine FDD and TDD data
|
95 |
+
lte_nice_emetteur_df = pd.concat([lte_fdd_df, lte_tdd_df], ignore_index=True)
|
96 |
+
lte_nice_emetteur_df = lte_nice_emetteur_df[LTE_NICE_EMETTEUR_COLUMNS]
|
97 |
+
|
98 |
+
# Rename columns to Atoll format
|
99 |
+
column_mapping = {
|
100 |
+
"final_name": "LNCEL Name",
|
101 |
+
"code": "Site ID",
|
102 |
+
"SectorId": "Sector ID",
|
103 |
+
"band_type": "Type",
|
104 |
+
"lnbts_name": "LNBTS Name",
|
105 |
+
"Azimut": "Azimuth",
|
106 |
+
"Hauteur": "Height",
|
107 |
+
"earfcnDL": "EARFCN",
|
108 |
+
"band": "Band",
|
109 |
+
}
|
110 |
+
lte_nice_emetteur_df = lte_nice_emetteur_df.rename(columns=column_mapping)
|
111 |
+
|
112 |
+
# Add common columns
|
113 |
+
lte_nice_emetteur_df["Vendor"] = VENDOR
|
114 |
+
lte_nice_emetteur_df["M_Tilt"] = DEFAULT_TILT
|
115 |
+
lte_nice_emetteur_df["E_Tilt"] = DEFAULT_TILT
|
116 |
+
|
117 |
+
# Reorder columns
|
118 |
+
return lte_nice_emetteur_df[
|
119 |
+
[
|
120 |
+
"Site ID",
|
121 |
+
"Sector ID",
|
122 |
+
"Latitude",
|
123 |
+
"Longitude",
|
124 |
+
"Azimuth",
|
125 |
+
"Height",
|
126 |
+
"M_Tilt",
|
127 |
+
"E_Tilt",
|
128 |
+
"Vendor",
|
129 |
+
"Band",
|
130 |
+
"MRBTS",
|
131 |
+
"LNBTS",
|
132 |
+
"LNCEL",
|
133 |
+
"LNBTS Name",
|
134 |
+
"LNCEL Name",
|
135 |
+
"EARFCN",
|
136 |
+
"Type",
|
137 |
+
]
|
138 |
+
]
|
139 |
+
except Exception as e:
|
140 |
+
raise RuntimeError(f"Error processing LTE data: {str(e)}")
|
141 |
+
|
142 |
+
|
143 |
+
def _process_wcdma_data(file_path: str) -> pd.DataFrame:
|
144 |
+
"""
|
145 |
+
Process WCDMA data from the NICE database file.
|
146 |
+
|
147 |
+
Args:
|
148 |
+
file_path: Path to the NICE database file
|
149 |
+
|
150 |
+
Returns:
|
151 |
+
pd.DataFrame: Processed WCDMA data in Atoll format
|
152 |
+
"""
|
153 |
+
try:
|
154 |
+
wcdma_nice_df = process_wcdma_data(file_path)
|
155 |
+
wcdma_nice_emetteur_df = wcdma_nice_df[WCDMA_NICE_EMETTEUR_COLUMNS]
|
156 |
+
|
157 |
+
# Rename columns to Atoll format
|
158 |
+
column_mapping = {
|
159 |
+
"site_name": "WBTS Name",
|
160 |
+
"name": "WCEL Name",
|
161 |
+
"code": "Site ID",
|
162 |
+
"CId": "CID",
|
163 |
+
"SectorID": "Sector ID",
|
164 |
+
"band": "Band",
|
165 |
+
"Azimut": "Azimuth",
|
166 |
+
"Hauteur": "Height",
|
167 |
+
}
|
168 |
+
wcdma_nice_emetteur_df = wcdma_nice_emetteur_df.rename(columns=column_mapping)
|
169 |
+
|
170 |
+
# Add common columns
|
171 |
+
wcdma_nice_emetteur_df["Vendor"] = VENDOR
|
172 |
+
wcdma_nice_emetteur_df["M_Tilt"] = DEFAULT_TILT
|
173 |
+
wcdma_nice_emetteur_df["E_Tilt"] = DEFAULT_TILT
|
174 |
+
|
175 |
+
# Reorder columns
|
176 |
+
return wcdma_nice_emetteur_df[
|
177 |
+
[
|
178 |
+
"Site ID",
|
179 |
+
"Sector ID",
|
180 |
+
"Latitude",
|
181 |
+
"Longitude",
|
182 |
+
"Azimuth",
|
183 |
+
"Height",
|
184 |
+
"M_Tilt",
|
185 |
+
"E_Tilt",
|
186 |
+
"Vendor",
|
187 |
+
"Band",
|
188 |
+
"RNC",
|
189 |
+
"WBTS",
|
190 |
+
"WCEL",
|
191 |
+
"WBTS Name",
|
192 |
+
"WCEL Name",
|
193 |
+
"CID",
|
194 |
+
"LAC",
|
195 |
+
"RAC",
|
196 |
+
"UARFCN",
|
197 |
+
]
|
198 |
+
]
|
199 |
+
except Exception as e:
|
200 |
+
raise RuntimeError(f"Error processing WCDMA data: {str(e)}")
|
201 |
+
|
202 |
+
|
203 |
+
def _process_gsm_data(file_path: str) -> pd.DataFrame:
|
204 |
+
"""
|
205 |
+
Process GSM data from the NICE database file.
|
206 |
+
|
207 |
+
Args:
|
208 |
+
file_path: Path to the NICE database file
|
209 |
+
|
210 |
+
Returns:
|
211 |
+
pd.DataFrame: Processed GSM data in Atoll format
|
212 |
+
"""
|
213 |
+
try:
|
214 |
+
gsm_nice_df = process_gsm_data(file_path)
|
215 |
+
gsm_nice_emetteur_df = gsm_nice_df[GSM_NICE_COLUMNS]
|
216 |
+
|
217 |
+
# Rename columns to Atoll format
|
218 |
+
column_mapping = {
|
219 |
+
"code": "Site ID",
|
220 |
+
"SectorId2": "Sector ID",
|
221 |
+
"Hauteur": "Height",
|
222 |
+
"Azimut": "Azimuth",
|
223 |
+
"name": "BTS Name",
|
224 |
+
"locationAreaIdLAC": "LAC",
|
225 |
+
"site_name": "BCF Name",
|
226 |
+
"band": "Band",
|
227 |
+
"cellId": "CID",
|
228 |
+
"rac": "RAC",
|
229 |
+
}
|
230 |
+
gsm_nice_emetteur_df = gsm_nice_emetteur_df.rename(columns=column_mapping)
|
231 |
+
|
232 |
+
# Add common columns
|
233 |
+
gsm_nice_emetteur_df["Vendor"] = VENDOR
|
234 |
+
gsm_nice_emetteur_df["M_Tilt"] = DEFAULT_TILT
|
235 |
+
gsm_nice_emetteur_df["E_Tilt"] = DEFAULT_TILT
|
236 |
+
|
237 |
+
# Reorder columns
|
238 |
+
return gsm_nice_emetteur_df[
|
239 |
+
[
|
240 |
+
"Site ID",
|
241 |
+
"Sector ID",
|
242 |
+
"Latitude",
|
243 |
+
"Longitude",
|
244 |
+
"Azimuth",
|
245 |
+
"Height",
|
246 |
+
"M_Tilt",
|
247 |
+
"E_Tilt",
|
248 |
+
"Vendor",
|
249 |
+
"Band",
|
250 |
+
"BSC",
|
251 |
+
"BCF",
|
252 |
+
"BTS",
|
253 |
+
"BCF Name",
|
254 |
+
"BTS Name",
|
255 |
+
"CID",
|
256 |
+
"LAC",
|
257 |
+
"RAC",
|
258 |
+
]
|
259 |
+
]
|
260 |
+
except Exception as e:
|
261 |
+
raise RuntimeError(f"Error processing GSM data: {str(e)}")
|
262 |
+
|
263 |
+
|
264 |
+
def process_data_for_nice(file_path: str) -> None:
|
265 |
+
"""
|
266 |
+
Main function to process NICE database file and convert it to Atoll format.
|
267 |
+
|
268 |
+
Args:
|
269 |
+
file_path: Path to the NICE database file
|
270 |
+
|
271 |
+
Raises:
|
272 |
+
FileNotFoundError: If the input file doesn't exist
|
273 |
+
RuntimeError: If there's an error processing the data
|
274 |
+
"""
|
275 |
+
try:
|
276 |
+
# Process each technology's data
|
277 |
+
gsm_data = _process_gsm_data(file_path)
|
278 |
+
wcdma_data = _process_wcdma_data(file_path)
|
279 |
+
lte_data = _process_lte_data(file_path)
|
280 |
+
|
281 |
+
# Convert to final format and store in UtilsVars
|
282 |
+
UtilsVars.final_nice_database = convert_dfs(
|
283 |
+
[gsm_data, wcdma_data, lte_data], ["GSM", "WCDMA", "LTE"]
|
284 |
+
)
|
285 |
+
except FileNotFoundError as e:
|
286 |
+
raise FileNotFoundError(f"Input file not found: {file_path}") from e
|
287 |
+
except Exception as e:
|
288 |
+
raise RuntimeError(f"Failed to process NICE database: {str(e)}") from e
|
utils/utils_vars.py
CHANGED
@@ -103,6 +103,7 @@ class UtilsVars:
|
|
103 |
final_all_database = None
|
104 |
atoll_dfs = []
|
105 |
final_atoll_database = None
|
|
|
106 |
neighbors_database = ""
|
107 |
file_path = ""
|
108 |
gsm_kml_file = None
|
|
|
103 |
final_all_database = None
|
104 |
atoll_dfs = []
|
105 |
final_atoll_database = None
|
106 |
+
final_nice_database = None
|
107 |
neighbors_database = ""
|
108 |
file_path = ""
|
109 |
gsm_kml_file = None
|