from __future__ import annotations from dataclasses import dataclass from math import exp @dataclass(frozen=True) class P833Coefficients: gamma_db_per_m: float max_attenuation_db: float def p833_attenuation( depth_m: float, freq_hz: float, forest_type: str, coefficients: P833Coefficients | None = None, ) -> float: if depth_m <= 0: return 0.0 if freq_hz <= 0: raise ValueError("freq_hz must be positive") if coefficients is None: raise NotImplementedError( "P.833 coefficients must be supplied from ITU-R tables for " f"forest_type={forest_type}" ) coeff = coefficients if coeff.max_attenuation_db <= 0: raise ValueError("max_attenuation_db must be positive") return coeff.max_attenuation_db * ( 1 - exp(-(depth_m * coeff.gamma_db_per_m) / coeff.max_attenuation_db) )