Skip to content

Add total_loss parameter for fiber attenuation (OTDR measurement support)#560

Open
LynchXLQ wants to merge 1 commit into
Telecominfraproject:masterfrom
LynchXLQ:feature/fiber-total-loss
Open

Add total_loss parameter for fiber attenuation (OTDR measurement support)#560
LynchXLQ wants to merge 1 commit into
Telecominfraproject:masterfrom
LynchXLQ:feature/fiber-total-loss

Conversation

@LynchXLQ
Copy link
Copy Markdown

@LynchXLQ LynchXLQ commented Feb 7, 2026

Summary

This PR adds support for specifying fiber attenuation as total loss (dB) instead of only via loss_coef (dB/km). This addresses the use case where users have OTDR measurements that report total span loss directly.

Resolves #441

Changes

gnpy/core/parameters.py (FiberParams)

  • Accept total_loss as an alternative to loss_coef
  • When total_loss is provided, derive loss_coef = total_loss / length
  • Support both scalar and frequency-dependent total_loss (dict with value and frequency keys)
  • Fully backward compatible: loss_coef continues to work unchanged
  • asdict() preserves the original parameter (total_loss or loss_coef)

gnpy/core/elements.py (Fiber)

  • to_json exports total_loss / total_loss_per_frequency when total_loss was the input

gnpy/tools/yang_convert_utils.py & convert_legacy_yang.py

  • YANG format conversion support for total_loss / total_loss_per_frequency

Tests

  • Scalar total_loss → correct loss_coef derivation
  • Frequency-dependent total_loss → correct per-frequency loss_coef
  • Backward compatibility (loss_coef still works)
  • Round-trip serialization via asdict()

Usage Example

{
  "uid": "fiber-span-1",
  "type": "Fiber",
  "params": {
    "length": 80,
    "length_units": "km",
    "total_loss": 16.0,
    "con_in": 0.5,
    "con_out": 0.5,
    "pmd_coef": 1.265e-15
  }
}

cc @jktjkt

@LynchXLQ LynchXLQ force-pushed the feature/fiber-total-loss branch 3 times, most recently from 937b9e9 to 67118a5 Compare February 8, 2026 03:53
…ation

Support OTDR-measured total span loss via new Fiber.total_loss parameter.
When provided, it overrides loss_coef with an effective per-km value.

- Add total_loss field to Fiber element with validation
- Compute effective loss_coef = total_loss / length when total_loss is set
- Add tests for total_loss functionality and edge cases
- Add author entry to AUTHORS.rst
@LynchXLQ LynchXLQ force-pushed the feature/fiber-total-loss branch from 67118a5 to 45a11e5 Compare February 8, 2026 04:06
@EstherLerouzic
Copy link
Copy Markdown
Collaborator

Dear @LynchXLQ , thanks a lot for your contribution! We will review it and will give you feedback as soon as possible. We normally use gerrithub for review (https://review.gerrithub.io/q/project:Telecominfraproject/oopt-gnpy). If you are familiar with it please push your commits there. If not I can do it for you, so that we can start the review process.
Regards

@LynchXLQ
Copy link
Copy Markdown
Author

Thanks @EstherLerouzic! I've pushed the changes to GerritHub: https://review.gerrithub.io/c/Telecominfraproject/oopt-gnpy/+/1231186

Looking forward to your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fiber attenuation: total loss vs. loss-per-km

2 participants