Skip to content
Edit this page

ictdesigntools.optical.budget

Optical loss budget and optical power budget, using ITU-T terminology.

Terms follow ITU-T G.957 / G.959.1 / G.984.2 and the system-design guidance in G.Sup39:

  • Reference points: S (just after the transmitter's optical connector) and R (just before the receiver's); the optical path is everything between them.
  • Mean launched power (P_min .. P_max) at S, receiver sensitivity (S_rx, the minimum mean received power) and receiver overload (P_ovl, the maximum) at R.
  • Attenuation of the optical path, in dB. The attenuation range a system supports is A_min = P_max - P_ovl to A_max = P_min - S_rx - P_pen - M, with P_pen the maximum optical path penalty and M a margin.
  • Link (path) attenuation, the worst-case sum for a planned link (G.Sup39): A = alpha * L + n_s * a_s + n_c * a_c + A_other + M_c with alpha the fibre attenuation coefficient (dB/km), L the length, a_s / a_c the mean splice and connector attenuations, and M_c the cable margin.

The defaults below are planning values, not figures from a Recommendation: take the numbers that apply to your fibre, components and equipment from their datasheets. The equipment-class presets are typical figures for GPON classes B+ and C+ (ITU-T G.984.2) and for common Ethernet optics (vendor datasheets); check each against the module actually used.

OpticalError

Bases: ValueError

Raised when optical budget inputs are out of range or inconsistent.

LossInput dataclass

LossInput(
    wavelength_nm: int,
    length_km: float = 0.0,
    attenuation_db_per_km: float | None = None,
    connector_count: int = 0,
    connector_loss_db: float | None = None,
    splice_count: int = 0,
    splice_loss_db: float | None = None,
    splitter: str = "none",
    other_loss_db: float = 0.0,
    margin_db: float = DEFAULT_MARGIN,
    budget_db: float | None = None,
    fiber: str = "",
)

A planned link. None coefficients and losses take the planning values above.

LossResult dataclass

LossResult(
    inp: LossInput,
    items: tuple[LossItem, ...],
    attenuation_db_per_km: float,
)

nominal_db property

nominal_db: float

Attenuation of the optical path before margin.

total_db property

total_db: float

Link attenuation, including the cable margin.

PowerInput dataclass

PowerInput(
    preset: str,
    launch_power_min_dbm: float,
    launch_power_max_dbm: float,
    rx_sensitivity_dbm: float,
    rx_overload_dbm: float,
    path_penalty_db: float = 0.0,
    margin_db: float = 0.0,
    attenuation_max_db: float | None = None,
    attenuation_min_db: float | None = None,
)

Equipment figures at reference points S and R, and the planned path attenuation.

from_preset classmethod

from_preset(
    preset: str, **overrides: float | None
) -> PowerInput

The preset's figures, with any given (not None) values in their place.

Source code in src/ictdesigntools/optical/budget.py
@classmethod
def from_preset(cls, preset: str, **overrides: float | None) -> PowerInput:
    """The preset's figures, with any given (not ``None``) values in their place."""
    base = POWER_PRESETS.get(preset)
    if base is None:
        raise OpticalError(
            f"“{preset}” is not a supported equipment preset (use {', '.join(POWER_PRESETS)})."
        )
    values = {
        "launch_power_min_dbm": base.launch_power_min_dbm,
        "launch_power_max_dbm": base.launch_power_max_dbm,
        "rx_sensitivity_dbm": base.rx_sensitivity_dbm,
        "rx_overload_dbm": base.rx_overload_dbm,
        "path_penalty_db": base.path_penalty_db,
        "margin_db": base.margin_db,
    }
    values.update({key: value for key, value in overrides.items() if value is not None})
    return cls(preset=preset, **values)

PowerResult dataclass

PowerResult(inp: PowerInput)

max_attenuation_db property

max_attenuation_db: float

Largest attenuation the link may have: P_min - S_rx - P_pen - M.

min_attenuation_db property

min_attenuation_db: float

Smallest attenuation that keeps the receiver out of overload: P_max - P_ovl.

rx_power_min_dbm property

rx_power_min_dbm: float | None

Lowest mean received power at R: P_min - A_max.

rx_power_max_dbm property

rx_power_max_dbm: float | None

Highest mean received power at R: P_max - A_min.

sensitivity_margin_db property

sensitivity_margin_db: float | None

Margin above receiver sensitivity at worst case, after the path penalty.

overload_headroom_db property

overload_headroom_db: float | None

How far the highest received power is below the receiver overload.

check

check(
    value: float, what: str, low: float, high: float
) -> float

Return value if it is a finite number from low to high, else raise.

Source code in src/ictdesigntools/optical/budget.py
def check(value: float, what: str, low: float, high: float) -> float:
    """Return ``value`` if it is a finite number from ``low`` to ``high``, else raise."""
    if not math.isfinite(value) or not low <= value <= high:
        raise OpticalError(f"{what.capitalize()} must be between {low:g} and {high:g}.")
    return value