File size: 7,686 Bytes
9a4ad92 |
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
"""
Process NICE database files and convert them to a standardized format for Atoll.
This module handles processing of LTE, WCDMA, and GSM network data from NICE database files
and converts them into a standardized format suitable for Atoll network planning tool.
"""
from typing import List
import pandas as pd
from queries.process_gsm import process_gsm_data
from queries.process_lte import process_lte_data
from queries.process_wcdma import process_wcdma_data
from utils.convert_to_excel import convert_dfs
from utils.utils_vars import UtilsVars
# Constants for column names
LTE_NICE_EMETTEUR_COLUMNS: List[str] = [
"MRBTS",
"LNBTS",
"LNCEL",
"final_name",
"code",
"SectorId",
"band",
"band_type",
"lnbts_name",
"Azimut",
"Longitude",
"Latitude",
"Hauteur",
"earfcnDL",
]
WCDMA_NICE_EMETTEUR_COLUMNS: List[str] = [
"RNC",
"WBTS",
"WCEL",
"site_name",
"name",
"code",
"CId",
"LAC",
"RAC",
"UARFCN",
"SectorID",
"band",
"Azimut",
"Longitude",
"Latitude",
"Hauteur",
]
GSM_NICE_COLUMNS: List[str] = [
"code",
"SectorId2",
"Latitude",
"Longitude",
"Hauteur",
"Azimut",
"BSC",
"BCF",
"BTS",
"band",
"name",
"site_name",
"cellId",
"locationAreaIdLAC",
"rac",
]
# Common column names
VENDOR: str = "Nokia"
DEFAULT_TILT: int = 0
def _process_lte_data(file_path: str) -> pd.DataFrame:
"""
Process LTE data from the NICE database file.
Args:
file_path: Path to the NICE database file
Returns:
pd.DataFrame: Processed LTE data in Atoll format
"""
try:
lte_fdd_df, lte_tdd_df = process_lte_data(file_path)
lte_tdd_df = lte_tdd_df.rename(columns={"earfcn": "earfcnDL"})
# Combine FDD and TDD data
lte_nice_emetteur_df = pd.concat([lte_fdd_df, lte_tdd_df], ignore_index=True)
lte_nice_emetteur_df = lte_nice_emetteur_df[LTE_NICE_EMETTEUR_COLUMNS]
# Rename columns to Atoll format
column_mapping = {
"final_name": "LNCEL Name",
"code": "Site ID",
"SectorId": "Sector ID",
"band_type": "Type",
"lnbts_name": "LNBTS Name",
"Azimut": "Azimuth",
"Hauteur": "Height",
"earfcnDL": "EARFCN",
"band": "Band",
}
lte_nice_emetteur_df = lte_nice_emetteur_df.rename(columns=column_mapping)
# Add common columns
lte_nice_emetteur_df["Vendor"] = VENDOR
lte_nice_emetteur_df["M_Tilt"] = DEFAULT_TILT
lte_nice_emetteur_df["E_Tilt"] = DEFAULT_TILT
# Reorder columns
return lte_nice_emetteur_df[
[
"Site ID",
"Sector ID",
"Latitude",
"Longitude",
"Azimuth",
"Height",
"M_Tilt",
"E_Tilt",
"Vendor",
"Band",
"MRBTS",
"LNBTS",
"LNCEL",
"LNBTS Name",
"LNCEL Name",
"EARFCN",
"Type",
]
]
except Exception as e:
raise RuntimeError(f"Error processing LTE data: {str(e)}")
def _process_wcdma_data(file_path: str) -> pd.DataFrame:
"""
Process WCDMA data from the NICE database file.
Args:
file_path: Path to the NICE database file
Returns:
pd.DataFrame: Processed WCDMA data in Atoll format
"""
try:
wcdma_nice_df = process_wcdma_data(file_path)
wcdma_nice_emetteur_df = wcdma_nice_df[WCDMA_NICE_EMETTEUR_COLUMNS]
# Rename columns to Atoll format
column_mapping = {
"site_name": "WBTS Name",
"name": "WCEL Name",
"code": "Site ID",
"CId": "CID",
"SectorID": "Sector ID",
"band": "Band",
"Azimut": "Azimuth",
"Hauteur": "Height",
}
wcdma_nice_emetteur_df = wcdma_nice_emetteur_df.rename(columns=column_mapping)
# Add common columns
wcdma_nice_emetteur_df["Vendor"] = VENDOR
wcdma_nice_emetteur_df["M_Tilt"] = DEFAULT_TILT
wcdma_nice_emetteur_df["E_Tilt"] = DEFAULT_TILT
# Reorder columns
return wcdma_nice_emetteur_df[
[
"Site ID",
"Sector ID",
"Latitude",
"Longitude",
"Azimuth",
"Height",
"M_Tilt",
"E_Tilt",
"Vendor",
"Band",
"RNC",
"WBTS",
"WCEL",
"WBTS Name",
"WCEL Name",
"CID",
"LAC",
"RAC",
"UARFCN",
]
]
except Exception as e:
raise RuntimeError(f"Error processing WCDMA data: {str(e)}")
def _process_gsm_data(file_path: str) -> pd.DataFrame:
"""
Process GSM data from the NICE database file.
Args:
file_path: Path to the NICE database file
Returns:
pd.DataFrame: Processed GSM data in Atoll format
"""
try:
gsm_nice_df = process_gsm_data(file_path)
gsm_nice_emetteur_df = gsm_nice_df[GSM_NICE_COLUMNS]
# Rename columns to Atoll format
column_mapping = {
"code": "Site ID",
"SectorId2": "Sector ID",
"Hauteur": "Height",
"Azimut": "Azimuth",
"name": "BTS Name",
"locationAreaIdLAC": "LAC",
"site_name": "BCF Name",
"band": "Band",
"cellId": "CID",
"rac": "RAC",
}
gsm_nice_emetteur_df = gsm_nice_emetteur_df.rename(columns=column_mapping)
# Add common columns
gsm_nice_emetteur_df["Vendor"] = VENDOR
gsm_nice_emetteur_df["M_Tilt"] = DEFAULT_TILT
gsm_nice_emetteur_df["E_Tilt"] = DEFAULT_TILT
# Reorder columns
return gsm_nice_emetteur_df[
[
"Site ID",
"Sector ID",
"Latitude",
"Longitude",
"Azimuth",
"Height",
"M_Tilt",
"E_Tilt",
"Vendor",
"Band",
"BSC",
"BCF",
"BTS",
"BCF Name",
"BTS Name",
"CID",
"LAC",
"RAC",
]
]
except Exception as e:
raise RuntimeError(f"Error processing GSM data: {str(e)}")
def process_data_for_nice(file_path: str) -> None:
"""
Main function to process NICE database file and convert it to Atoll format.
Args:
file_path: Path to the NICE database file
Raises:
FileNotFoundError: If the input file doesn't exist
RuntimeError: If there's an error processing the data
"""
try:
# Process each technology's data
gsm_data = _process_gsm_data(file_path)
wcdma_data = _process_wcdma_data(file_path)
lte_data = _process_lte_data(file_path)
# Convert to final format and store in UtilsVars
UtilsVars.final_nice_database = convert_dfs(
[gsm_data, wcdma_data, lte_data], ["GSM", "WCDMA", "LTE"]
)
except FileNotFoundError as e:
raise FileNotFoundError(f"Input file not found: {file_path}") from e
except Exception as e:
raise RuntimeError(f"Failed to process NICE database: {str(e)}") from e
|