mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-11-01 18:47:48 +00:00
Merge pull request #340 from Orange-OpenSource/correction_test_amplifier
Correction test amplifier Fixes #324, #321
This commit is contained in:
@@ -6,8 +6,9 @@
|
|||||||
from gnpy.core.elements import Edfa
|
from gnpy.core.elements import Edfa
|
||||||
from numpy import zeros, array
|
from numpy import zeros, array
|
||||||
from json import load
|
from json import load
|
||||||
|
from gnpy.core import elements
|
||||||
from gnpy.core.elements import Transceiver, Fiber, Edfa
|
from gnpy.core.elements import Transceiver, Fiber, Edfa
|
||||||
from gnpy.core.utils import lin2db, db2lin
|
from gnpy.core.utils import lin2db, db2lin, merge_amplifier_restrictions
|
||||||
from gnpy.core.info import create_input_spectral_information, SpectralInformation, Channel, Power, Pref
|
from gnpy.core.info import create_input_spectral_information, SpectralInformation, Channel, Power, Pref
|
||||||
from gnpy.core.equipment import load_equipment, automatic_fmax, automatic_nch
|
from gnpy.core.equipment import load_equipment, automatic_fmax, automatic_nch
|
||||||
from gnpy.core.network import build_network, load_network
|
from gnpy.core.network import build_network, load_network
|
||||||
@@ -118,32 +119,75 @@ def test_compare_nf_models(gain, setup_edfa_variable_gain, si):
|
|||||||
pin = pin/db2lin(gain)
|
pin = pin/db2lin(gain)
|
||||||
baud_rates = array([c.baud_rate for c in si.carriers])
|
baud_rates = array([c.baud_rate for c in si.carriers])
|
||||||
edfa.operational.gain_target = gain
|
edfa.operational.gain_target = gain
|
||||||
|
# edfa is variable gain type
|
||||||
pref = Pref(0, -gain, lin2db(len(frequencies)))
|
pref = Pref(0, -gain, lin2db(len(frequencies)))
|
||||||
edfa.interpol_params(frequencies, pin, baud_rates, pref)
|
edfa.interpol_params(frequencies, pin, baud_rates, pref)
|
||||||
nf_model = edfa.nf[0]
|
nf_model = edfa.nf[0]
|
||||||
|
|
||||||
|
|
||||||
|
# change edfa type variety to a polynomial
|
||||||
|
el_config = {
|
||||||
|
"uid": "Edfa1",
|
||||||
|
"operational": {
|
||||||
|
"gain_target": gain,
|
||||||
|
"tilt_target": 0
|
||||||
|
},
|
||||||
|
"metadata": {
|
||||||
|
"location": {
|
||||||
|
"region": "",
|
||||||
|
"latitude": 2,
|
||||||
|
"longitude": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
equipment = load_equipment(eqpt_library)
|
||||||
|
extra_params = equipment['Edfa']['CienaDB_medium_gain']
|
||||||
|
temp = el_config.setdefault('params', {})
|
||||||
|
temp = merge_amplifier_restrictions(temp, extra_params.__dict__)
|
||||||
|
el_config['params'] = temp
|
||||||
|
cls = getattr(elements, 'Edfa')
|
||||||
|
edfa = cls(**el_config)
|
||||||
|
|
||||||
|
# edfa is variable gain type
|
||||||
edfa.interpol_params(frequencies, pin, baud_rates, pref)
|
edfa.interpol_params(frequencies, pin, baud_rates, pref)
|
||||||
nf_poly = edfa.nf[0]
|
nf_poly = edfa.nf[0]
|
||||||
|
print(nf_poly, nf_model)
|
||||||
assert pytest.approx(nf_model, abs=0.5) == nf_poly
|
assert pytest.approx(nf_model, abs=0.5) == nf_poly
|
||||||
|
|
||||||
@pytest.mark.parametrize("gain", [13, 15, 17, 19, 21, 23, 25, 27])
|
@pytest.mark.parametrize("gain", [13, 15, 17, 19, 21, 23, 25, 27])
|
||||||
def test_ase_noise(gain, si, setup_edfa_variable_gain, setup_trx, bw):
|
def test_ase_noise(gain, si, setup_trx, bw):
|
||||||
"""testing 3 different ways of calculating osnr:
|
"""testing 3 different ways of calculating osnr:
|
||||||
1-pin-edfa.nf+58 vs
|
1-pin-edfa.nf+58 vs
|
||||||
2-pout/pase afet propagate
|
2-pout/pase afet propagate
|
||||||
3-Transceiver osnr_ase_01nm
|
3-Transceiver osnr_ase_01nm
|
||||||
=> unitary test for Edfa.noise_profile (Edfa.interpol_params, Edfa.propagate)"""
|
=> unitary test for Edfa.noise_profile (Edfa.interpol_params, Edfa.propagate)"""
|
||||||
edfa = setup_edfa_variable_gain
|
equipment = load_equipment(eqpt_library)
|
||||||
|
network = load_network(test_network, equipment)
|
||||||
|
edfa = next(n for n in network.nodes() if n.uid == 'Edfa1')
|
||||||
|
span = next(n for n in network.nodes() if n.uid == 'Span1')
|
||||||
|
# update span1 and Edfa1 according to new gain before building network
|
||||||
|
# updating span 1 avoids to overload amp
|
||||||
|
span.length = gain*1e3 / 0.2
|
||||||
|
edfa.operational.gain_target = gain
|
||||||
|
build_network(network, equipment,0, 20)
|
||||||
|
edfa.gain_ripple = zeros(96)
|
||||||
|
edfa.interpol_nf_ripple = zeros(96)
|
||||||
|
#propagate in span1 to have si with the correct power level
|
||||||
|
si = span(si)
|
||||||
|
print(span)
|
||||||
|
|
||||||
frequencies = array([c.frequency for c in si.carriers])
|
frequencies = array([c.frequency for c in si.carriers])
|
||||||
pin = array([c.power.signal+c.power.nli+c.power.ase for c in si.carriers])
|
pin = array([c.power.signal+c.power.nli+c.power.ase for c in si.carriers])
|
||||||
baud_rates = array([c.baud_rate for c in si.carriers])
|
baud_rates = array([c.baud_rate for c in si.carriers])
|
||||||
edfa.operational.gain_target = gain
|
pref = Pref(0, -gain, lin2db(len(frequencies)))
|
||||||
pref = Pref(0, 0, lin2db(len(frequencies)))
|
|
||||||
edfa.interpol_params(frequencies, pin, baud_rates, pref)
|
edfa.interpol_params(frequencies, pin, baud_rates, pref)
|
||||||
nf = edfa.nf
|
nf = edfa.nf
|
||||||
|
print('nf', nf)
|
||||||
pin = lin2db(pin[0]*1e3)
|
pin = lin2db(pin[0]*1e3)
|
||||||
osnr_expected = pin - nf[0] + 58
|
osnr_expected = pin - nf[0] + 58
|
||||||
|
|
||||||
si = edfa(si)
|
si = edfa(si)
|
||||||
|
print(edfa)
|
||||||
pout = array([c.power.signal for c in si.carriers])
|
pout = array([c.power.signal for c in si.carriers])
|
||||||
pase = array([c.power.ase for c in si.carriers])
|
pase = array([c.power.ase for c in si.carriers])
|
||||||
osnr = lin2db(pout[0] / pase[0]) - lin2db(12.5e9/bw)
|
osnr = lin2db(pout[0] / pase[0]) - lin2db(12.5e9/bw)
|
||||||
|
|||||||
Reference in New Issue
Block a user