Skip to content

Commit

Permalink
Floating point formatting of elements' operational parameters
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jktjkt committed Jun 4, 2021
1 parent ad9cbb8 commit 225cafa
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 53 deletions.
10 changes: 5 additions & 5 deletions gnpy/core/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def __str__(self):

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']
Expand Down Expand Up @@ -346,7 +346,7 @@ def __str__(self):
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):
Expand Down Expand Up @@ -614,9 +614,9 @@ def __str__(self):
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):
Expand Down
82 changes: 41 additions & 41 deletions tests/invocation/openroadm-Stockholm-Gothenburg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/invocation/transmission_main_example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/invocation/transmission_main_example__raman
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 225cafa

Please sign in to comment.