From 225cafa8b7d00626dcad77ed9032101ab84767cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Fri, 4 Jun 2021 22:36:06 +0200 Subject: [PATCH] Floating point formatting of elements' operational parameters The current JSON data loader preserves (some) integers as integers. When printed, the value might not contain any decimal points. The YANG patch series, however, forces floats when floats are expected (while still allowing None). This makes the output subtly different. Change-Id: I0e0c013eb3abddb4aeac1ba43bf0d473fed731d4 --- gnpy/core/elements.py | 10 +-- .../invocation/openroadm-Stockholm-Gothenburg | 82 +++++++++---------- tests/invocation/transmission_main_example | 8 +- .../transmission_main_example__raman | 6 +- 4 files changed, 53 insertions(+), 53 deletions(-) diff --git a/gnpy/core/elements.py b/gnpy/core/elements.py index 2c3485c9..8e61b423 100644 --- a/gnpy/core/elements.py +++ b/gnpy/core/elements.py @@ -217,7 +217,7 @@ class Roadm(_Node): return '\n'.join([f'{type(self).__name__} {self.uid}', f' effective loss (dB): {self.effective_loss:.2f}', - f' pch out (dBm): {self.effective_pch_out_db!r}']) + f' pch out (dBm): {self.effective_pch_out_db:.2f}']) def propagate(self, pref, *carriers, degree): # pin_target and loss are read from eqpt_config.json['Roadm'] @@ -346,7 +346,7 @@ class Fiber(_Node): f' total loss (dB): {self.loss:.2f}', f' (includes conn loss (dB) in: {self.params.con_in:.2f} out: {self.params.con_out:.2f})', f' (conn loss out includes EOL margin defined in eqpt_config.json)', - f' pch out (dBm): {self.pch_out_db!r}']) + f' pch out (dBm): {self.pch_out_db:.2f}']) @property def loss(self): @@ -614,9 +614,9 @@ class Edfa(_Node): f' pad att_in (dB): {self.att_in:.2f}', f' Power In (dBm): {self.pin_db:.2f}', f' Power Out (dBm): {self.pout_db:.2f}', - f' Delta_P (dB): {self.delta_p!r}', - f' target pch (dBm): {self.target_pch_out_db!r}', - f' effective pch (dBm): {self.effective_pch_out_db!r}', + f' Delta_P (dB): ' + f'{self.delta_p:.2f}' if self.delta_p is not None else 'None', + f' target pch (dBm): ' + f'{self.target_pch_out_db:.2f}' if self.target_pch_out_db is not None else 'None', + f' effective pch (dBm): {self.effective_pch_out_db:.2f}', f' output VOA (dB): {self.out_voa:.2f}']) def interpol_params(self, frequencies, pin, baud_rates, pref): diff --git a/tests/invocation/openroadm-Stockholm-Gothenburg b/tests/invocation/openroadm-Stockholm-Gothenburg index 90b08ee8..206669c0 100644 --- a/tests/invocation/openroadm-Stockholm-Gothenburg +++ b/tests/invocation/openroadm-Stockholm-Gothenburg @@ -16,7 +16,7 @@ Transceiver trx_Stockholm PMD (ps): 0.00 Roadm roadm_Stockholm effective loss (dB): 22.00 - pch out (dBm): -20 + pch out (dBm): -20.00 Edfa Edfa_booster_roadm_Stockholm_to_fiber (Stockholm → Norrköping)_(1/2) type_variety: openroadm_mw_mw_booster effective gain(dB): 22.00 @@ -26,9 +26,9 @@ Edfa Edfa_booster_roadm_Stockholm_to_fiber (Stockholm → Norrköping)_(1/2) pad att_in (dB): 0.00 Power In (dBm): -0.18 Power Out (dBm): 21.82 - Delta_P (dB): 0 - target pch (dBm): 2.0 - effective pch (dBm): 2.0 + Delta_P (dB): 0.00 + target pch (dBm): 2.00 + effective pch (dBm): 2.00 output VOA (dB): 0.00 Fiber fiber (Stockholm → Norrköping)_(1/2) type_variety: SSMF @@ -47,9 +47,9 @@ Edfa Edfa_fiber (Stockholm → Norrköping)_(1/2) pad att_in (dB): 0.00 Power In (dBm): 5.51 Power Out (dBm): 21.84 - Delta_P (dB): 0 - target pch (dBm): 2.0 - effective pch (dBm): 2.0 + Delta_P (dB): 0.00 + target pch (dBm): 2.00 + effective pch (dBm): 2.00 output VOA (dB): 0.00 Fiber fiber (Stockholm → Norrköping)_(2/2) type_variety: SSMF @@ -68,13 +68,13 @@ Edfa Edfa_preamp_roadm_Norrköping_from_fiber (Stockholm → Norrköping)_(2/2) pad att_in (dB): 0.00 Power In (dBm): 5.53 Power Out (dBm): 21.87 - Delta_P (dB): 0 - target pch (dBm): 2.0 - effective pch (dBm): 2.0 + Delta_P (dB): 0.00 + target pch (dBm): 2.00 + effective pch (dBm): 2.00 output VOA (dB): 0.00 Roadm roadm_Norrköping effective loss (dB): 22.00 - pch out (dBm): -20 + pch out (dBm): -20.00 Edfa Edfa_booster_roadm_Norrköping_to_fiber (Norrköping → Linköping) type_variety: openroadm_mw_mw_booster effective gain(dB): 22.00 @@ -84,9 +84,9 @@ Edfa Edfa_booster_roadm_Norrköping_to_fiber (Norrköping → Linköping) pad att_in (dB): 0.00 Power In (dBm): -0.18 Power Out (dBm): 21.82 - Delta_P (dB): 0 - target pch (dBm): 2.0 - effective pch (dBm): 2.0 + Delta_P (dB): 0.00 + target pch (dBm): 2.00 + effective pch (dBm): 2.00 output VOA (dB): 0.00 Fiber fiber (Norrköping → Linköping) type_variety: SSMF @@ -95,7 +95,7 @@ Fiber fiber (Norrköping → Linköping) total loss (dB): 11.00 (includes conn loss (dB) in: 0.00 out: 0.00) (conn loss out includes EOL margin defined in eqpt_config.json) - pch out (dBm): -9.0 + pch out (dBm): -9.00 Edfa Edfa_preamp_roadm_Linköping_from_fiber (Norrköping → Linköping) type_variety: openroadm_mw_mw_preamp effective gain(dB): 11.00 @@ -105,13 +105,13 @@ Edfa Edfa_preamp_roadm_Linköping_from_fiber (Norrköping → Linköping) pad att_in (dB): 0.00 Power In (dBm): 10.83 Power Out (dBm): 21.83 - Delta_P (dB): 0 - target pch (dBm): 2.0 - effective pch (dBm): 2.0 + Delta_P (dB): 0.00 + target pch (dBm): 2.00 + effective pch (dBm): 2.00 output VOA (dB): 0.00 Roadm roadm_Linköping effective loss (dB): 22.00 - pch out (dBm): -20 + pch out (dBm): -20.00 Edfa Edfa_booster_roadm_Linköping_to_fiber (Linköping → Jönköping) type_variety: openroadm_mw_mw_booster effective gain(dB): 22.00 @@ -121,9 +121,9 @@ Edfa Edfa_booster_roadm_Linköping_to_fiber (Linköping → Jönköping) pad att_in (dB): 0.00 Power In (dBm): -0.18 Power Out (dBm): 21.82 - Delta_P (dB): 0 - target pch (dBm): 2.0 - effective pch (dBm): 2.0 + Delta_P (dB): 0.00 + target pch (dBm): 2.00 + effective pch (dBm): 2.00 output VOA (dB): 0.00 Fiber fiber (Linköping → Jönköping) type_variety: SSMF @@ -132,7 +132,7 @@ Fiber fiber (Linköping → Jönköping) total loss (dB): 26.80 (includes conn loss (dB) in: 0.00 out: 0.00) (conn loss out includes EOL margin defined in eqpt_config.json) - pch out (dBm): -24.8 + pch out (dBm): -24.80 Edfa Edfa_preamp_roadm_Jönköping_from_fiber (Linköping → Jönköping) type_variety: openroadm_mw_mw_preamp effective gain(dB): 26.80 @@ -142,13 +142,13 @@ Edfa Edfa_preamp_roadm_Jönköping_from_fiber (Linköping → Jönköping) pad att_in (dB): 0.00 Power In (dBm): -4.97 Power Out (dBm): 21.86 - Delta_P (dB): 0 - target pch (dBm): 2.0 - effective pch (dBm): 2.0 + Delta_P (dB): 0.00 + target pch (dBm): 2.00 + effective pch (dBm): 2.00 output VOA (dB): 0.00 Roadm roadm_Jönköping effective loss (dB): 22.00 - pch out (dBm): -20 + pch out (dBm): -20.00 Edfa Edfa_booster_roadm_Jönköping_to_fiber (Jönköping → Borås) type_variety: openroadm_mw_mw_booster effective gain(dB): 22.00 @@ -158,9 +158,9 @@ Edfa Edfa_booster_roadm_Jönköping_to_fiber (Jönköping → Borås) pad att_in (dB): 0.00 Power In (dBm): -0.18 Power Out (dBm): 21.82 - Delta_P (dB): 0 - target pch (dBm): 2.0 - effective pch (dBm): 2.0 + Delta_P (dB): 0.00 + target pch (dBm): 2.00 + effective pch (dBm): 2.00 output VOA (dB): 0.00 Fiber fiber (Jönköping → Borås) type_variety: SSMF @@ -179,13 +179,13 @@ Edfa Edfa_preamp_roadm_Borås_from_fiber (Jönköping → Borås) pad att_in (dB): 0.00 Power In (dBm): 4.01 Power Out (dBm): 21.84 - Delta_P (dB): 0 - target pch (dBm): 2.0 - effective pch (dBm): 2.0 + Delta_P (dB): 0.00 + target pch (dBm): 2.00 + effective pch (dBm): 2.00 output VOA (dB): 0.00 Roadm roadm_Borås effective loss (dB): 22.00 - pch out (dBm): -20 + pch out (dBm): -20.00 Edfa Edfa_booster_roadm_Borås_to_fiber (Borås → Gothenburg) type_variety: openroadm_mw_mw_booster effective gain(dB): 22.00 @@ -195,9 +195,9 @@ Edfa Edfa_booster_roadm_Borås_to_fiber (Borås → Gothenburg) pad att_in (dB): 0.00 Power In (dBm): -0.18 Power Out (dBm): 21.82 - Delta_P (dB): 0 - target pch (dBm): 2.0 - effective pch (dBm): 2.0 + Delta_P (dB): 0.00 + target pch (dBm): 2.00 + effective pch (dBm): 2.00 output VOA (dB): 0.00 Fiber fiber (Borås → Gothenburg) type_variety: SSMF @@ -216,13 +216,13 @@ Edfa Edfa_preamp_roadm_Gothenburg_from_fiber (Borås → Gothenburg) pad att_in (dB): 0.00 Power In (dBm): 8.30 Power Out (dBm): 21.84 - Delta_P (dB): 0 - target pch (dBm): 2.0 - effective pch (dBm): 2.0 + Delta_P (dB): 0.00 + target pch (dBm): 2.00 + effective pch (dBm): 2.00 output VOA (dB): 0.00 Roadm roadm_Gothenburg effective loss (dB): 22.00 - pch out (dBm): -20 + pch out (dBm): -20.00 Transceiver trx_Gothenburg GSNR (0.1nm, dB): 18.90 GSNR (signal bw, dB): 14.88 diff --git a/tests/invocation/transmission_main_example b/tests/invocation/transmission_main_example index 57b2b0d7..41391272 100644 --- a/tests/invocation/transmission_main_example +++ b/tests/invocation/transmission_main_example @@ -21,7 +21,7 @@ Fiber Span1 total loss (dB): 17.00 (includes conn loss (dB) in: 0.50 out: 0.50) (conn loss out includes EOL margin defined in eqpt_config.json) - pch out (dBm): -17.0 + pch out (dBm): -17.00 Edfa Edfa1 type_variety: std_low_gain effective gain(dB): 15.00 @@ -31,9 +31,9 @@ Edfa Edfa1 pad att_in (dB): 0.00 Power In (dBm): 1.81 Power Out (dBm): 16.82 - Delta_P (dB): -2 - target pch (dBm): -2.0 - effective pch (dBm): -2.0 + Delta_P (dB): -2.00 + target pch (dBm): -2.00 + effective pch (dBm): -2.00 output VOA (dB): 0.00 Transceiver Site_B GSNR (0.1nm, dB): 31.17 diff --git a/tests/invocation/transmission_main_example__raman b/tests/invocation/transmission_main_example__raman index ce086777..5156a16d 100644 --- a/tests/invocation/transmission_main_example__raman +++ b/tests/invocation/transmission_main_example__raman @@ -31,9 +31,9 @@ Edfa Edfa1 pad att_in (dB): 2.26 Power In (dBm): 11.07 Power Out (dBm): 16.82 - Delta_P (dB): -2 - target pch (dBm): -2.0 - effective pch (dBm): -2.0 + Delta_P (dB): -2.00 + target pch (dBm): -2.00 + effective pch (dBm): -2.00 output VOA (dB): 0.00 Transceiver Site_B GSNR (0.1nm, dB): 31.43