Skip to content
Edit this page

ictdesigntools.optical.osnr

Optical signal-to-noise ratio (OSNR) along a chain of amplified spans.

Every optical amplifier adds amplified spontaneous emission (ASE). At an amplifier's input the signal, per channel, meets noise of about NF · h·ν · B (NF its noise figure, h·ν the photon energy, B the reference bandwidth), so the OSNR one amplifier leaves is

OSNR = P_in − NF − 10·log10(h·ν·B / 1 mW)            (dB, P_in in dBm per channel)

which is the familiar 58 + P_in − NF at 1550 nm in 0.1 nm (12.5 GHz). Noise from a chain adds in linear terms: 1/OSNR_total = Σ 1/OSNR_i (with a transmitter's own OSNR, when given, as one more term). Each Stage is a span loss followed by an amplifier; by default the amplifier's gain makes up that loss, so the channel power returns to the launch level.

>>> stages = [Stage(22, Amplifier(5.5))] * 4
>>> r = link_osnr(1.0, stages)
>>> round(r.osnr_db, 1)
25.4
>>> round(ase_reference_dbm(1550), 2)
-57.95
>>> r = check("400zr", 1.0, stages)
>>> r.passes, round(r.margin_db, 1)
(False, -0.6)

OsnrError

Bases: ValueError

A stage or chain that cannot be worked out.

Amplifier dataclass

Amplifier(
    nf_db: float,
    gain_db: float | None = None,
    max_output_dbm: float | None = None,
    name: str = "",
)

An optical amplifier: its noise figure, and its gain (None: make up the span loss before it). max_output_dbm is its total output power limit, if known.

Stage dataclass

Stage(loss_db: float, amplifier: Amplifier)

loss_db of span (fibre, connections, any passive parts) and the amplifier after it.

ase_reference_dbm

ase_reference_dbm(
    wavelength_nm: float = 1550.0,
    bandwidth_ghz: float = REFERENCE_BANDWIDTH_GHZ,
) -> float

10·log10(h·ν·B / 1 mW): the noise one photon per second per hertz of reference band carries, the constant in the OSNR equation.

Source code in src/ictdesigntools/optical/osnr.py
def ase_reference_dbm(wavelength_nm: float = 1550.0,
                      bandwidth_ghz: float = REFERENCE_BANDWIDTH_GHZ) -> float:  # fmt: skip
    """10·log10(h·ν·B / 1 mW): the noise one photon per second per hertz of reference band
    carries, the constant in the OSNR equation."""
    nu = LIGHT / (wavelength_nm * 1e-9)
    return 10 * math.log10(PLANCK * nu * bandwidth_ghz * 1e9 / 1e-3)

per_channel_dbm

per_channel_dbm(total_dbm: float, channels: int) -> float

The power per channel when channels share total_dbm equally.

Source code in src/ictdesigntools/optical/osnr.py
def per_channel_dbm(total_dbm: float, channels: int) -> float:
    """The power per channel when ``channels`` share ``total_dbm`` equally."""
    if channels < 1:
        raise OsnrError("Give at least one channel.")
    return total_dbm - 10 * math.log10(channels)
link_osnr(
    launch_dbm: float,
    stages,
    wavelength_nm: float = 1550.0,
    bandwidth_ghz: float = REFERENCE_BANDWIDTH_GHZ,
    transmitter_osnr_db: float | None = None,
    channels: int = 1,
) -> OsnrResult

The OSNR after a chain of stages, launching launch_dbm per channel. With channels, an amplifier's max_output_dbm is checked against their total.

Source code in src/ictdesigntools/optical/osnr.py
def link_osnr(launch_dbm: float, stages, wavelength_nm: float = 1550.0,
              bandwidth_ghz: float = REFERENCE_BANDWIDTH_GHZ,
              transmitter_osnr_db: float | None = None,
              channels: int = 1) -> OsnrResult:  # fmt: skip
    """The OSNR after a chain of ``stages``, launching ``launch_dbm`` per channel. With
    ``channels``, an amplifier's ``max_output_dbm`` is checked against their total."""
    stages = list(stages)
    if not stages:
        raise OsnrError("Give at least one amplified stage.")
    ref = ase_reference_dbm(wavelength_nm, bandwidth_ghz)
    terms = [] if transmitter_osnr_db is None else [transmitter_osnr_db]
    power = launch_dbm
    out = []
    for s in stages:
        a = s.amplifier
        p_in = power - s.loss_db
        gain = s.loss_db if a.gain_db is None else a.gain_db
        p_out = p_in + gain
        if a.max_output_dbm is not None:
            total = p_out + 10 * math.log10(channels)
            if total > a.max_output_dbm + 1e-9:
                raise OsnrError(f"{a.name or 'An amplifier'} would put out {total:.1f} dBm, over "
                                f"its {a.max_output_dbm:g} dBm limit.")  # fmt: skip
        own = p_in - a.nf_db - ref
        terms.append(own)
        out.append(StageResult(p_in, p_out, own, _add(terms)))
        power = p_out
    return OsnrResult(launch_dbm, tuple(out), _add(terms), wavelength_nm, bandwidth_ghz)

check

check(
    iface: str | Interface,
    launch_dbm: float,
    stages,
    margin_db: float = 0.0,
    **kwargs,
) -> OsnrCheck

Whether the chain's OSNR meets an amplified interface's requirement plus margin_db (for ageing, nonlinear effects and filtering, which this does not model).

Source code in src/ictdesigntools/optical/osnr.py
def check(iface: str | Interface, launch_dbm: float, stages, margin_db: float = 0.0,
          **kwargs) -> OsnrCheck:  # fmt: skip
    """Whether the chain's OSNR meets an amplified interface's requirement plus ``margin_db``
    (for ageing, nonlinear effects and filtering, which this does not model)."""
    i = iface if isinstance(iface, Interface) else interface(iface)
    if i.osnr_db is None:
        raise OsnrError(f"{i.name} has no required OSNR: it is not an amplified interface.")
    kwargs.setdefault("wavelength_nm", sum(i.nm) / 2)
    r = link_osnr(launch_dbm, stages, **kwargs)
    return OsnrCheck(i, r, i.osnr_db + margin_db, r.osnr_db - i.osnr_db - margin_db)