|
""" |
|
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 |
|
|
|
|
|
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", |
|
] |
|
|
|
|
|
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"}) |
|
|
|
|
|
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] |
|
|
|
|
|
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) |
|
|
|
|
|
lte_nice_emetteur_df["Vendor"] = VENDOR |
|
lte_nice_emetteur_df["M_Tilt"] = DEFAULT_TILT |
|
lte_nice_emetteur_df["E_Tilt"] = DEFAULT_TILT |
|
|
|
|
|
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] |
|
|
|
|
|
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) |
|
|
|
|
|
wcdma_nice_emetteur_df["Vendor"] = VENDOR |
|
wcdma_nice_emetteur_df["M_Tilt"] = DEFAULT_TILT |
|
wcdma_nice_emetteur_df["E_Tilt"] = DEFAULT_TILT |
|
|
|
|
|
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] |
|
|
|
|
|
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) |
|
|
|
|
|
gsm_nice_emetteur_df["Vendor"] = VENDOR |
|
gsm_nice_emetteur_df["M_Tilt"] = DEFAULT_TILT |
|
gsm_nice_emetteur_df["E_Tilt"] = DEFAULT_TILT |
|
|
|
|
|
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: |
|
|
|
gsm_data = _process_gsm_data(file_path) |
|
wcdma_data = _process_wcdma_data(file_path) |
|
lte_data = _process_lte_data(file_path) |
|
|
|
|
|
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 |
|
|