diff --git a/gnpy/core/network.py b/gnpy/core/network.py index e8ff99592..6e7a59737 100644 --- a/gnpy/core/network.py +++ b/gnpy/core/network.py @@ -32,7 +32,7 @@ def edfa_nf(gain_target, variety_type, equipment): return amp._calc_nf(True) -def select_edfa(raman_allowed, gain_target, power_target, equipment, uid, restrictions=None): +def select_edfa(raman_allowed, gain_target, power_target, equipment, uid, restrictions=None, verbose=True): """amplifer selection algorithm @Orange Jean-Luc Augé """ @@ -90,10 +90,11 @@ def select_edfa(raman_allowed, gain_target, power_target, equipment, uid, restri please increase span fiber padding') else: # TODO: convert to logging - print( - f'{ansi_escapes.red}WARNING:{ansi_escapes.reset} target gain in node {uid} is below all available amplifiers min gain: \ - amplifier input padding will be assumed, consider increase span fiber padding instead' - ) + if verbose: + print( + f'{ansi_escapes.red}WARNING:{ansi_escapes.reset} target gain in node {uid} is below all available amplifiers min gain: \ + amplifier input padding will be assumed, consider increase span fiber padding instead' + ) acceptable_gain_min_list = edfa_list # filter on gain+power limitation: @@ -114,7 +115,7 @@ def select_edfa(raman_allowed, gain_target, power_target, equipment, uid, restri selected_edfa = min(acceptable_power_list, key=attrgetter('nf')) # filter on NF # check what are the gain and power limitations of this amp power_reduction = min(selected_edfa.power, 0) - if power_reduction < -0.5: + if power_reduction < -0.5 and verbose: print(f'{ansi_escapes.red}WARNING:{ansi_escapes.reset} target gain and power in node {uid}\n' + ' is beyond all available amplifiers capabilities and/or extended_gain_range:\n' + f' a power reduction of {round(power_reduction, 2)} is applied\n') @@ -218,7 +219,7 @@ def set_amplifier_voa(amp, power_target, power_mode): amp.out_voa = voa -def set_egress_amplifier(network, this_node, equipment, pref_ch_db, pref_total_db): +def set_egress_amplifier(network, this_node, equipment, pref_ch_db, pref_total_db, verbose): """this node can be a transceiver or a ROADM (same function called in both cases)""" power_mode = equipment['Span']['default'].power_mode ref_carrier = ReferenceCarrier(baud_rate=equipment['SI']['default'].baud_rate, @@ -278,7 +279,7 @@ def set_egress_amplifier(network, this_node, equipment, pref_ch_db, pref_total_d restrictions = next_node.restrictions['preamp_variety_list'] else: restrictions = None - edfa_variety, power_reduction = select_edfa(raman_allowed, gain_target, power_target, equipment, node.uid, restrictions) + edfa_variety, power_reduction = select_edfa(raman_allowed, gain_target, power_target, equipment, node.uid, restrictions, verbose) extra_params = equipment['Edfa'][edfa_variety] node.params.update_params(extra_params.__dict__) dp += power_reduction @@ -303,7 +304,7 @@ def set_egress_amplifier(network, this_node, equipment, pref_ch_db, pref_total_d # if variety is imposed by user, and if the gain_target (computed or imposed) is also above # variety max gain + extended range, then warn that gain > max_gain + extended range if gain_target - equipment['Edfa'][node.params.type_variety].gain_flatmax - \ - equipment['Span']['default'].target_extended_gain > 1e-2: + equipment['Span']['default'].target_extended_gain > 1e-2 and verbose: # 1e-2 to allow a small margin according to round2float min step print(f'{ansi_escapes.red}WARNING{ansi_escapes.reset}: ' f'WARNING: effective gain in Node {node.uid} is above user ' @@ -652,7 +653,7 @@ def add_missing_fiber_attributes(network, equipment): add_fiber_padding(network, fibers, default_span_data.padding) -def build_network(network, equipment, pref_ch_db, pref_total_db, set_connector_losses=True): +def build_network(network, equipment, pref_ch_db, pref_total_db, set_connector_losses=True, verbose=True): """Set roadm equalization target and amplifier gain and power """ roadms = [r for r in network.nodes() if isinstance(r, elements.Roadm)] @@ -665,7 +666,7 @@ def build_network(network, equipment, pref_ch_db, pref_total_db, set_connector_l set_roadm_per_degree_targets(roadm, network) # then set amplifiers gain, delta_p and out_voa on each OMS for roadm in roadms + transceivers: - set_egress_amplifier(network, roadm, equipment, pref_ch_db, pref_total_db) + set_egress_amplifier(network, roadm, equipment, pref_ch_db, pref_total_db, verbose) for roadm in roadms: set_roadm_input_powers(network, roadm, equipment, pref_ch_db) for fiber in [f for f in network.nodes() if isinstance(f, (elements.Fiber, elements.RamanFiber))]: