added formulas
This commit is contained in:
+39
-44
@@ -2,7 +2,7 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from app.config import get_settings
|
||||
from app.core.atmosphere import atmospheric_loss_between
|
||||
from app.core.diffraction import deygout
|
||||
from app.core.diffraction import bullington_equivalent_loss
|
||||
from app.core.fresnel import LosSample, los_analysis
|
||||
from app.core.geo import GeoPoint, sample_path
|
||||
from app.core.propagation import itm_loss, manual_link_budget, p452_loss
|
||||
@@ -34,11 +34,12 @@ def link_budget(request: LinkBudgetRequest, db: Session | None = None) -> LinkBu
|
||||
freq_hz=freq_hz,
|
||||
k=request.k_factor,
|
||||
)
|
||||
diffraction_db = deygout(
|
||||
knife_edge_diffraction_db = bullington_equivalent_loss(
|
||||
surface_profile,
|
||||
tx_height_agl=request.tx.height_agl,
|
||||
rx_height_agl=request.rx.height_agl,
|
||||
freq_hz=freq_hz,
|
||||
k=request.k_factor,
|
||||
)
|
||||
vegetation_db = vegetation_loss_along(
|
||||
points,
|
||||
@@ -47,55 +48,46 @@ def link_budget(request: LinkBudgetRequest, db: Session | None = None) -> LinkBu
|
||||
)
|
||||
atmospheric_db = atmospheric_loss_between(tx, rx, freq_hz)
|
||||
|
||||
active_diffraction_db = diffraction_db
|
||||
fspl_db = manual_link_budget(
|
||||
tx,
|
||||
rx,
|
||||
request.tx.power_dbm,
|
||||
request.tx.gain_dbi,
|
||||
request.rx.gain_dbi,
|
||||
request.rx.sensitivity_dbm,
|
||||
request.frequency_mhz,
|
||||
).fspl_db
|
||||
active_diffraction_db = knife_edge_diffraction_db
|
||||
active_atmospheric_db = atmospheric_db
|
||||
propagation_model_loss_db = fspl_db + knife_edge_diffraction_db
|
||||
propagation_excess_db = knife_edge_diffraction_db
|
||||
|
||||
if request.model == "manual":
|
||||
propagation_db = 0.0
|
||||
pass
|
||||
elif request.model == "itm":
|
||||
propagation_db = (
|
||||
itm_loss(
|
||||
tx,
|
||||
rx,
|
||||
tx_height_agl=request.tx.height_agl,
|
||||
rx_height_agl=request.rx.height_agl,
|
||||
freq_mhz=request.frequency_mhz,
|
||||
elevation_profile_m=elevation_profile,
|
||||
dem_path=str(settings.dem_path),
|
||||
)
|
||||
- manual_link_budget(
|
||||
tx,
|
||||
rx,
|
||||
request.tx.power_dbm,
|
||||
request.tx.gain_dbi,
|
||||
request.rx.gain_dbi,
|
||||
request.rx.sensitivity_dbm,
|
||||
request.frequency_mhz,
|
||||
).fspl_db
|
||||
propagation_model_loss_db = itm_loss(
|
||||
tx,
|
||||
rx,
|
||||
tx_height_agl=request.tx.height_agl,
|
||||
rx_height_agl=request.rx.height_agl,
|
||||
freq_mhz=request.frequency_mhz,
|
||||
elevation_profile_m=elevation_profile,
|
||||
dem_path=str(settings.dem_path),
|
||||
)
|
||||
active_diffraction_db = propagation_db
|
||||
propagation_excess_db = propagation_model_loss_db - fspl_db
|
||||
active_diffraction_db = propagation_excess_db
|
||||
elif request.model == "p452":
|
||||
propagation_db = (
|
||||
p452_loss(
|
||||
tx,
|
||||
rx,
|
||||
tx_height_agl=request.tx.height_agl,
|
||||
rx_height_agl=request.rx.height_agl,
|
||||
freq_mhz=request.frequency_mhz,
|
||||
elevation_profile_m=elevation_profile,
|
||||
dem_path=str(settings.dem_path),
|
||||
)
|
||||
- manual_link_budget(
|
||||
tx,
|
||||
rx,
|
||||
request.tx.power_dbm,
|
||||
request.tx.gain_dbi,
|
||||
request.rx.gain_dbi,
|
||||
request.rx.sensitivity_dbm,
|
||||
request.frequency_mhz,
|
||||
).fspl_db
|
||||
propagation_model_loss_db = p452_loss(
|
||||
tx,
|
||||
rx,
|
||||
tx_height_agl=request.tx.height_agl,
|
||||
rx_height_agl=request.rx.height_agl,
|
||||
freq_mhz=request.frequency_mhz,
|
||||
elevation_profile_m=elevation_profile,
|
||||
dem_path=str(settings.dem_path),
|
||||
)
|
||||
active_diffraction_db = propagation_db
|
||||
propagation_excess_db = propagation_model_loss_db - fspl_db
|
||||
active_diffraction_db = propagation_excess_db
|
||||
active_atmospheric_db = 0.0
|
||||
else:
|
||||
raise NotImplementedError(f"{request.model} link model is not supported")
|
||||
@@ -131,6 +123,9 @@ def link_budget(request: LinkBudgetRequest, db: Session | None = None) -> LinkBu
|
||||
geometric_obstructions_count=len(geometric_obstructions),
|
||||
building_obstructions_count=len(building_obstructions),
|
||||
worst_obstruction=_convert_obstruction(los_result.worst_sample),
|
||||
propagation_model_loss_db=propagation_model_loss_db,
|
||||
propagation_excess_db=propagation_excess_db,
|
||||
knife_edge_diffraction_db=knife_edge_diffraction_db,
|
||||
data_sources=DataSources(
|
||||
dem=bool(raster_files(settings.dem_path)),
|
||||
buildings=request.include_buildings and db is not None,
|
||||
|
||||
Reference in New Issue
Block a user