Skip to content

Commit

Permalink
Parametrize verbose in autodesign
Browse files Browse the repository at this point in the history
transmission-main-example and path-request-run functions implement an
on-the-fly redesign based on p_span_i.
Since we remove p_span_i from elements, we will need to properly call
redesign several times before each propagation, to keep the same
behaviour of these functions.

in this commit we simply enable the possibility to mute warnings.

Signed-off-by: EstherLerouzic <[email protected]>
Change-Id: I3aa3d8fc87325033ef69641078bdd7213e0409eb
  • Loading branch information
EstherLerouzic committed Nov 2, 2023
1 parent 0e9763f commit 7a903b7
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions gnpy/core/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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é
"""
Expand Down Expand Up @@ -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:
Expand All @@ -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')
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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 '
Expand Down Expand Up @@ -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)]
Expand All @@ -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))]:
Expand Down

0 comments on commit 7a903b7

Please sign in to comment.