fix integrate tilt data into conversion

add some tests

Signed-off-by: JennyLescop <jenny.lescop@orange.com>
Change-Id: I4bb9a16b5db7890247568cce9d4b4f81ad2f7d34
This commit is contained in:
JennyLescop
2025-02-06 15:57:20 +01:00
committed by Esther Le Rouzic
parent 101eb8f969
commit 57a5e9732b
5 changed files with 44 additions and 33 deletions

View File

@@ -950,6 +950,16 @@ class Edfa(_Node):
@property
def to_json(self):
"""Converts the Edfa's state to a JSON-compatible dictionary.
Adapts the json export: scalar or vector.
:return Dict[str, Any]: JSON representation of the Edfa.
"""
# keep None value for tilt_target and avoid exporting -0.0 values
tilt_target = None
if self.tilt_target is not None:
tilt_target = 0 if self.tilt_target == -0.0 else self.tilt_target
_to_json = {
'uid': self.uid,
'type': type(self).__name__,
@@ -957,7 +967,7 @@ class Edfa(_Node):
'operational': {
'gain_target': round(self.effective_gain, 6) if self.effective_gain else None,
'delta_p': self.delta_p,
'tilt_target': round(self.tilt_target, 5) if self.tilt_target is not None else None,
'tilt_target': round(tilt_target, 5) if tilt_target is not None else None,
# defined per lambda on the amp band
'out_voa': self.out_voa
},
@@ -988,7 +998,8 @@ class Edfa(_Node):
f' type_variety: {self.params.type_variety}',
f' effective gain(dB): {self.effective_gain:.2f}',
' (before att_in and before output VOA)',
f' tilt-target(dB) {self.tilt_target if self.tilt_target else 0:.2f}',
# tilt_target is per lambda on the amp band
f' tilt-target(dB) {self.tilt_target if self.tilt_target not in [None, -0.0] else 0:.2f}',
# avoids -0.00 value for tilt_target
f' noise figure (dB): {nf:.2f}',
f' (including att_in)',

View File

@@ -667,14 +667,14 @@ def parse_excel(input_filename: Path) -> Tuple[List[Node], List[Link], List[Eqpt
'amp type': 'east_amp_type',
'amp gain': 'east_amp_gain',
'delta p': 'east_amp_dp',
'tilt': 'east_tilt',
'tilt': 'east_tilt_vs_wavelength',
'att_out': 'east_att_out'
},
'west': {
'amp type': 'west_amp_type',
'amp gain': 'west_amp_gain',
'delta p': 'west_amp_dp',
'tilt': 'west_tilt',
'tilt': 'west_tilt_vs_wavelength',
'att_out': 'west_att_out'
}
}

Binary file not shown.

View File

@@ -1472,7 +1472,7 @@
"type": "Edfa",
"type_variety": "std_low_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1493,7 +1493,7 @@
"operational": {
"gain_target": 18.0,
"delta_p": null,
"tilt_target": 0,
"tilt_target": -1.0,
"out_voa": 0.5
},
"metadata": {
@@ -1510,7 +1510,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1529,7 +1529,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1548,7 +1548,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1567,7 +1567,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1586,7 +1586,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1624,7 +1624,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1643,7 +1643,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1662,7 +1662,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1681,7 +1681,7 @@
"type": "Edfa",
"type_variety": "std_low_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1738,7 +1738,7 @@
"type": "Edfa",
"type_variety": "std_booster",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1757,7 +1757,7 @@
"type": "Edfa",
"type_variety": "std_booster",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1776,7 +1776,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1795,7 +1795,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1814,7 +1814,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1848,7 +1848,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1867,7 +1867,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1886,7 +1886,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1905,7 +1905,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1924,7 +1924,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1943,7 +1943,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1962,7 +1962,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -1981,7 +1981,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -2000,7 +2000,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -2019,7 +2019,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -2038,7 +2038,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0
@@ -2057,7 +2057,7 @@
"type": "Edfa",
"type_variety": "test_fixed_gain",
"operational": {
"gain_target": 20,
"gain_target": 20.0,
"delta_p": null,
"tilt_target": 0,
"out_voa": 0

View File

@@ -1209,7 +1209,7 @@
"operational": {
"gain_target": 18.0,
"delta_p": null,
"tilt_target": null,
"tilt_target": -1.0,
"out_voa": 0.5
}
},