Example #1
0
def select_edfa(gain_target, power_target, equipment):
    """amplifer selection algorithm
    @Orange Jean-Luc Augé
    """
    Edfa_list = namedtuple('Edfa_list', 'variety power gain nf')
    TARGET_EXTENDED_GAIN = 2.1
    #MAX_EXTENDED_GAIN = 5
    edfa_dict = equipment['Edfa']
    pin = power_target - gain_target

    edfa_list = [Edfa_list(
                variety=edfa_variety,
                power=min(
                    pin
                    +edfa.gain_flatmax
                    +TARGET_EXTENDED_GAIN,
                    edfa.p_max
                    )
                    -power_target,
                gain=edfa.gain_flatmax-gain_target,
                nf=edfa_nf(gain_target, edfa_variety, 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))
    if len(acceptable_gain_list) < 1:
        #no amplifier satisfies the required gain, so pick the highest gain:
        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:
        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
Example #2
0
def select_edfa(raman_allowed, gain_target, power_target, equipment, uid):
    """amplifer selection algorithm
    @Orange Jean-Luc Augé
    """
    Edfa_list = namedtuple('Edfa_list', 'variety power gain_min nf')
    TARGET_EXTENDED_GAIN = equipment['Span']['default'].target_extended_gain
    edfa_dict = equipment['Edfa']
    pin = power_target - gain_target

    #create 2 list of available amplifiers with relevant attributs for their selection

    #edfa list with :
    #extended gain min allowance of 3dB: could be parametrized, but a bit complex
    #extended gain max allowance TARGET_EXTENDED_GAIN is coming from eqpt_config.json
    #power attribut include power AND gain limitations
    edfa_list = [Edfa_list(
                variety=edfa_variety,
                power=min(
                    pin
                    +edfa.gain_flatmax
                    +TARGET_EXTENDED_GAIN,
                    edfa.p_max
                    )
                    -power_target,
                gain_min=
                    gain_target+3
                    -edfa.gain_min,
                nf=edfa_nf(gain_target, edfa_variety, equipment)) \
                for edfa_variety, edfa in edfa_dict.items()
                if (edfa.allowed_for_design and not edfa.raman)]

    #consider a Raman list because of different gain_min requirement: 
    #do not allow extended gain min for Raman
    raman_list = [Edfa_list(
                variety=edfa_variety,
                power=min(
                    pin
                    +edfa.gain_flatmax
                    +TARGET_EXTENDED_GAIN,
                    edfa.p_max
                    )
                    -power_target,
                gain_min=
                    gain_target
                    -edfa.gain_min,
                nf=edfa_nf(gain_target, edfa_variety, equipment))
                for edfa_variety, edfa in edfa_dict.items()
                if (edfa.allowed_for_design and edfa.raman)] \
                if raman_allowed else []

    #merge raman and edfa lists
    amp_list = edfa_list + raman_list

    #filter on min gain limitation: 
    acceptable_gain_min_list = [x for x in amp_list if x.gain_min>0]

    if len(acceptable_gain_min_list) < 1:
        #do not take this empty list into account for the rest of the code
        #but issue a warning to the user and do not consider Raman
        #Raman below min gain should not be allowed because i is meant to be a design requirement
        #and raman padding at the amplifier input is impossible!

        if len(edfa_list) < 1:
            print(
                f'\x1b[1;31;40m'\
                + f'CRITICAL _ ABORT: auto_design could not find any amplifier \
                    to satisfy min gain requirement in node {uid} \
                    please increase span fiber padding'\
                + '\x1b[0m'
                )
            exit()
        else:
            print(
                f'\x1b[1;31;40m'\
                + f'WARNING: target gain in node {uid} is below all available amplifiers min gain: \
                    amplifier input padding will be assumed, consider increase span fiber padding instead'\
                + '\x1b[0m'
                )
            acceptable_gain_min_list = edfa_list

    #filter on gain+power limitation:
    #this list checks both the gain and the power requirement
    #because of the way .power is calculated in the list
    acceptable_power_list = [x for x in acceptable_gain_min_list if x.power>0]
    if len(acceptable_power_list) < 1:
        #no amplifier satisfies the required power, so pick the highest power(s):
        power_max = max(acceptable_gain_min_list, key=attrgetter('power')).power
        #check and pick if other amplifiers may have a similar gain/power
        #allow a 0.3dB power range 
        #this allows to chose an amplifier with a better NF subsequentely
        acceptable_power_list = [x for x in acceptable_gain_min_list
                                 if x.power-power_max>-0.3]

    
    # gain and power requirements are resolved,
    #       =>chose the amp with the best NF among the acceptable ones:
    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 = round(min(selected_edfa.power, 0),2)
    if power_reduction < -0.5:
        print(
            f'\x1b[1;31;40m'\
            + f'WARNING: target gain and power in node {uid}\n \
    is beyond all available amplifiers capabilities and/or extended_gain_range:\n\
    a power reduction of {power_reduction} is applied\n'\
            + '\x1b[0m'
            )


    return selected_edfa.variety, power_reduction