diff --git a/examples/eqpt_config.json b/examples/eqpt_config.json index de18b84d..753aa759 100644 --- a/examples/eqpt_config.json +++ b/examples/eqpt_config.json @@ -31,7 +31,7 @@ "type_def": "fixed_gain", "gain_flatmax": 20, "gain_min": 20, - "p_max": 20, + "p_max": 21, "nf0": 5.5, "allowed_for_design": true }, diff --git a/gnpy/core/network.py b/gnpy/core/network.py index f4e84efb..f4551c82 100644 --- a/gnpy/core/network.py +++ b/gnpy/core/network.py @@ -87,15 +87,24 @@ def select_edfa(gain_target, power_target, equipment): for edfa_variety, edfa in edfa_dict.items() if edfa.allowed_for_design] - acceptable_gain_list = list(filter(lambda x : x.gain>-TARGET_EXTENDED_GAIN, edfa_list)) + acceptable_gain_list = \ + list(filter(lambda x : x.gain>-TARGET_EXTENDED_GAIN, edfa_list)) if len(acceptable_gain_list) < 1: #no amplifier satisfies the required gain, so pick the highest gain: - return max(edfa_list, key=itemgetter(2)).variety #filter on gain - acceptable_power_list = list(filter(lambda x : x.power>=0, acceptable_gain_list)) - if len(acceptable_power_list) < 1: + gain_max = max(edfa_list, key=itemgetter(2)).gain + #pick up all amplifiers that share this max gain: + acceptable_gain_list = \ + list(filter(lambda x : x.gain-gain_max>-0.1, edfa_list)) + acceptable_power_list = \ + list(filter(lambda x : x.power>=0, acceptable_gain_list)) + if len(acceptable_power_list) < 1: #no amplifier satisfies the required power, so pick the highest power: - return max(acceptable_gain_list, key=itemgetter(1)).variety #filter on power - # gain and power requirements are satisfied: + power_max = \ + max(acceptable_gain_list, key=itemgetter(1)).power + #pick up all amplifiers that share this max gain: + acceptable_power_list = \ + list(filter(lambda x : x.power-power_max>-0.1, acceptable_gain_list)) + # gain and power requirements are resolved, # =>chose the amp with the best NF among the acceptable ones: return min(acceptable_power_list, key=itemgetter(3)).variety #filter on NF