Files
oopt-gnpy/tests/test_science_utils.py
AndreaDAmico def82b6515 Simulation Parameters
This change siplifies the structure of the simulation parameters, removing the gnpy.science_utils.simulation layer, provides some documentation of the parameters and define a mock fixture for testing in safe mode

Change-Id: If5ef341e0585586127d5dae3f39dca2c232236f1
2021-09-15 17:56:19 +02:00

47 lines
1.8 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Checks that RamanFiber propagates properly the spectral information. In this way, also the RamanSolver and the NliSolver
are tested.
"""
from pathlib import Path
from pandas import read_csv
from numpy.testing import assert_allclose
from gnpy.core.info import create_input_spectral_information
from gnpy.core.elements import RamanFiber
from gnpy.tools.json_io import load_json
from tests.test_parameters import MockSimParams, set_sim_params
TEST_DIR = Path(__file__).parent
def test_raman_fiber(set_sim_params):
""" Test the accuracy of propagating the RamanFiber."""
# spectral information generation
power = 1e-3
eqpt_params = load_json(TEST_DIR / 'data' / 'eqpt_config.json')
spectral_info_params = eqpt_params['SI'][0]
spectral_info_params.pop('power_dbm')
spectral_info_params.pop('power_range_db')
spectral_info_params.pop('tx_osnr')
spectral_info_params.pop('sys_margins')
spectral_info_input = create_input_spectral_information(power=power, **spectral_info_params)
MockSimParams.set_params(load_json(TEST_DIR / 'data' / 'sim_params.json'))
fiber = RamanFiber(**load_json(TEST_DIR / 'data' / 'raman_fiber_config.json'))
# propagation
spectral_info_out = fiber(spectral_info_input)
p_signal = [carrier.power.signal for carrier in spectral_info_out.carriers]
p_ase = [carrier.power.ase for carrier in spectral_info_out.carriers]
p_nli = [carrier.power.nli for carrier in spectral_info_out.carriers]
expected_results = read_csv(TEST_DIR / 'data' / 'test_science_utils_expected_results.csv')
assert_allclose(p_signal, expected_results['signal'], rtol=1e-3)
assert_allclose(p_ase, expected_results['ase'], rtol=1e-3)
assert_allclose(p_nli, expected_results['nli'], rtol=1e-3)