Major refactoring of RFCP backend: - Modular propagation models (8 models) - SharedMemoryManager for terrain data - ProcessPoolExecutor parallel processing - WebSocket progress streaming - Building filtering pipeline (351k → 15k) - 82 unit tests Performance: Standard preset 38s → 5s (7.6x speedup) Known issue: Detailed preset timeout (fix in 3.1.0)
55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
"""
|
|
RF unit conversions.
|
|
"""
|
|
|
|
import math
|
|
|
|
|
|
def dbm_to_watts(dbm: float) -> float:
|
|
"""Convert dBm to watts."""
|
|
return 10 ** ((dbm - 30) / 10)
|
|
|
|
|
|
def watts_to_dbm(watts: float) -> float:
|
|
"""Convert watts to dBm."""
|
|
if watts <= 0:
|
|
return -float('inf')
|
|
return 10 * math.log10(watts) + 30
|
|
|
|
|
|
def dbm_to_mw(dbm: float) -> float:
|
|
"""Convert dBm to milliwatts."""
|
|
return 10 ** (dbm / 10)
|
|
|
|
|
|
def mw_to_dbm(mw: float) -> float:
|
|
"""Convert milliwatts to dBm."""
|
|
if mw <= 0:
|
|
return -float('inf')
|
|
return 10 * math.log10(mw)
|
|
|
|
|
|
def frequency_to_wavelength(frequency_mhz: float) -> float:
|
|
"""Convert frequency (MHz) to wavelength (meters)."""
|
|
return 300.0 / frequency_mhz
|
|
|
|
|
|
def wavelength_to_frequency(wavelength_m: float) -> float:
|
|
"""Convert wavelength (meters) to frequency (MHz)."""
|
|
return 300.0 / wavelength_m
|
|
|
|
|
|
def eirp_dbm(power_dbm: float, gain_dbi: float) -> float:
|
|
"""Calculate EIRP in dBm."""
|
|
return power_dbm + gain_dbi
|
|
|
|
|
|
def eirp_watts(power_dbm: float, gain_dbi: float) -> float:
|
|
"""Calculate EIRP in watts."""
|
|
return dbm_to_watts(power_dbm + gain_dbi)
|
|
|
|
|
|
def path_loss_to_signal_dbm(power_dbm: float, gain_dbi: float, path_loss_db: float) -> float:
|
|
"""Calculate received signal level in dBm from EIRP and path loss."""
|
|
return power_dbm + gain_dbi - path_loss_db
|