Skip to content
Edit this page

ictdesigntools.optical.media

Optical transmission media: fibre categories and their limits, from data/fibers.toml.

copper.media (planned) holds the copper cable categories the same way.

Single-mode categories follow the ITU-T Recommendations (G.652, G.653, G.654, G.655, G.656 and G.657); multimode follows G.651.1 and the ISO/IEC 11801 / TIA OM categories. Each value is the category's limit for cabled fibre (a maximum attenuation, a dispersion bound, a PMD link design value), so a design that meets it meets the category; a product's datasheet is usually better.

>>> f = fiber("G.652.D")
>>> f.attenuation_db_per_km(1310), f.attenuation_db_per_km(1550)
(0.4, 0.3)
>>> f.pmd_ps(100)
2.0
>>> fiber("g657b3").min_bend_radius_mm
5
>>> [round(d, 2) for d in fiber("g656").dispersion_ps_per_nm_km(1550)]
[3.6, 9.28]

Dispersion is a range, not one number, because a category allows any fibre inside its limits. Where a category gives a zero-dispersion wavelength range and a maximum slope there, the range comes from the usual approximation for standard single-mode fibre, D(λ) = S0/4 · (λ - λ0⁴/λ³) ps/(nm·km), taken at the ends of the λ0 range with the slope between zero and its maximum. Where it gives bounding curves, those are used.

FiberError

Bases: ValueError

An unknown fibre category, or a wavelength the category does not cover.

Band dataclass

Band(from_nm: float, to_nm: float, db_per_km: float)

A maximum attenuation coefficient over a wavelength range (from == to for one).

Bend dataclass

Bend(
    radius_mm: float, turns: int, nm: float, max_db: float
)

A macrobending loss limit: at most max_db for turns turns at radius_mm.

Fiber dataclass

Fiber(
    slug: str,
    name: str,
    mode: str,
    source: str,
    attenuation: tuple[Band, ...],
    macrobend: tuple[Bend, ...] = (),
    mfd_nm: float = 0.0,
    mfd_um: tuple[float, float] | None = None,
    mfd_tolerance_um: float = 0.0,
    cutoff_nm: float = 0.0,
    core_um: float = 0.0,
    lambda0_nm: tuple[float, float] | None = None,
    s0_max_ps_per_nm2_km: float = 0.0,
    s1550_max_ps_per_nm2_km: float = 0.0,
    d_min: tuple[tuple[float, float], ...] = (),
    d_max: tuple[tuple[float, float], ...] = (),
    dispersion_sign: str = "",
    pmdq_ps_per_sqrt_km: float = 0.0,
    obw_850_mhz_km: float = 0.0,
    obw_1300_mhz_km: float = 0.0,
    emb_850_mhz_km: float = 0.0,
    emb_953_mhz_km: float = 0.0,
)

min_bend_radius_mm property

min_bend_radius_mm: float | None

The smallest radius the category sets a macrobending limit at.

attenuation_db_per_km

attenuation_db_per_km(nm: float) -> float

The maximum cable attenuation coefficient at nm: the narrowest range that holds it. Raises FiberError when the category sets none there.

Source code in src/ictdesigntools/optical/media.py
def attenuation_db_per_km(self, nm: float) -> float:
    """The maximum cable attenuation coefficient at ``nm``: the narrowest range that holds
    it. Raises ``FiberError`` when the category sets none there."""
    held = [b for b in self.attenuation if b.holds(nm)]
    if not held:
        covered = ", ".join(
            f"{b.from_nm:g}" if b.from_nm == b.to_nm else f"{b.from_nm:g}-{b.to_nm:g}"
            for b in self.attenuation
        )
        raise FiberError(f"{self.name} sets no attenuation at {nm:g} nm (only {covered} nm).")
    return min(held, key=lambda b: (b.to_nm - b.from_nm, b.db_per_km)).db_per_km

dispersion_ps_per_nm_km

dispersion_ps_per_nm_km(
    nm: float,
) -> tuple[float, float] | None

The (lowest, highest) chromatic dispersion coefficient the category allows at nm, ps/(nm·km), or None when it sets no limit there. A category whose bounds hold for either sign (G.655.C) returns the positive range.

Source code in src/ictdesigntools/optical/media.py
def dispersion_ps_per_nm_km(self, nm: float) -> tuple[float, float] | None:
    """The (lowest, highest) chromatic dispersion coefficient the category allows at ``nm``,
    ps/(nm·km), or None when it sets no limit there. A category whose bounds hold for
    either sign (G.655.C) returns the positive range."""
    lo, hi = _along(self.d_min, nm), _along(self.d_max, nm)
    if (lo is None or hi is None) and self.lambda0_nm and self.s0_max_ps_per_nm2_km:
        ends = [_slope_model(self.s0_max_ps_per_nm2_km, l0, nm) for l0 in self.lambda0_nm]
        lo = min([*ends, 0.0]) if lo is None else lo
        hi = max([*ends, 0.0]) if hi is None else hi
    if lo is None and hi is None:
        return None
    if lo is None:  # a maximum only (G.654.A to D)
        lo = min(0.0, hi)
    if hi is None:
        hi = lo
    return (lo, hi)

max_dispersion_ps_per_nm_km

max_dispersion_ps_per_nm_km(nm: float) -> float | None

The largest dispersion magnitude allowed at nm: the worst case for a link.

Source code in src/ictdesigntools/optical/media.py
def max_dispersion_ps_per_nm_km(self, nm: float) -> float | None:
    """The largest dispersion magnitude allowed at ``nm``: the worst case for a link."""
    found = self.dispersion_ps_per_nm_km(nm)
    return None if found is None else max(abs(found[0]), abs(found[1]))

pmd_ps

pmd_ps(length_km: float) -> float

The PMD link design value for length_km: PMDQ grows with the square root of the length, as the differential group delay of concatenated sections adds in quadrature.

Source code in src/ictdesigntools/optical/media.py
def pmd_ps(self, length_km: float) -> float:
    """The PMD link design value for ``length_km``: PMDQ grows with the square root of the
    length, as the differential group delay of concatenated sections adds in quadrature."""
    if length_km < 0:
        raise FiberError("Length cannot be negative.")
    return self.pmdq_ps_per_sqrt_km * math.sqrt(length_km)

bend_limits

bend_limits(radius_mm: float) -> tuple[Bend, ...]

The macrobending limits that apply at radius_mm: those set at the smallest specified radius not below it. Empty when radius_mm is tighter than any.

Source code in src/ictdesigntools/optical/media.py
def bend_limits(self, radius_mm: float) -> tuple[Bend, ...]:
    """The macrobending limits that apply at ``radius_mm``: those set at the smallest
    specified radius not below it. Empty when ``radius_mm`` is tighter than any."""
    radii = sorted({b.radius_mm for b in self.macrobend if b.radius_mm <= radius_mm})
    if not radii:
        return ()
    return tuple(b for b in self.macrobend if b.radius_mm == radii[-1])

fibers

fibers(mode: str = '') -> tuple[Fiber, ...]

Every category, or only mode ("single" or "multi").

Source code in src/ictdesigntools/optical/media.py
def fibers(mode: str = "") -> tuple[Fiber, ...]:
    """Every category, or only ``mode`` ("single" or "multi")."""
    return tuple(f for f in _all().values() if not mode or f.mode == mode)

fiber

fiber(name: str) -> Fiber

A category by slug or name, written any common way: g652d, G.652.D, ITU-T G.652.D, OM4.

Source code in src/ictdesigntools/optical/media.py
def fiber(name: str) -> Fiber:
    """A category by slug or name, written any common way: ``g652d``, ``G.652.D``,
    ``ITU-T G.652.D``, ``OM4``."""
    slug = _index().get(_key(name))
    if slug is None:
        known = ", ".join(f.name for f in _all().values())
        raise FiberError(f"“{name}” is not a known fibre category (use {known}).")
    return _all()[slug]

for_bend_radius

for_bend_radius(radius_mm: float) -> tuple[Fiber, ...]

The single-mode categories with a macrobending limit at radius_mm or tighter, so rated for bends that tight.

Source code in src/ictdesigntools/optical/media.py
def for_bend_radius(radius_mm: float) -> tuple[Fiber, ...]:
    """The single-mode categories with a macrobending limit at ``radius_mm`` or tighter, so
    rated for bends that tight."""
    return tuple(
        f for f in fibers("single")
        if f.min_bend_radius_mm is not None and f.min_bend_radius_mm <= radius_mm
    )  # fmt: skip