From 5a4a7a28ee8d0f8e26f60a78d46e78f3d762c53a Mon Sep 17 00:00:00 2001 From: EstherLerouzic Date: Tue, 27 Feb 2024 15:18:42 +0100 Subject: [PATCH] feat: enable different sim_param vectors for multiple requests Signed-off-by: EstherLerouzic Change-Id: Ia800a7b98b33b795cc3553500116be61c612e45c --- gnpy/core/parameters.py | 3 ++- gnpy/core/science_utils.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gnpy/core/parameters.py b/gnpy/core/parameters.py index e23accc19..ef6ccd8c9 100644 --- a/gnpy/core/parameters.py +++ b/gnpy/core/parameters.py @@ -49,7 +49,7 @@ def __init__(self, flag=False, result_spatial_resolution=10e3, solver_spatial_re class NLIParams(Parameters): def __init__(self, method='gn_model_analytic', dispersion_tolerance=1, phase_shift_tolerance=0.1, - computed_channels=None): + computed_channels=None, computed_number_of_channels=None): """Simulation parameters used within the Nli Solver :params method: formula for NLI calculation @@ -61,6 +61,7 @@ def __init__(self, method='gn_model_analytic', dispersion_tolerance=1, phase_shi self.dispersion_tolerance = dispersion_tolerance self.phase_shift_tolerance = phase_shift_tolerance self.computed_channels = computed_channels + self.computed_number_of_channels = computed_number_of_channels class SimParams(Parameters): diff --git a/gnpy/core/science_utils.py b/gnpy/core/science_utils.py index 071747198..612eb47b2 100644 --- a/gnpy/core/science_utils.py +++ b/gnpy/core/science_utils.py @@ -305,6 +305,10 @@ def compute_nli(spectral_info: SpectralInformation, srs: StimulatedRamanScatteri elif 'ggn_spectrally_separated' in sim_params.nli_params.method: if sim_params.nli_params.computed_channels is not None: cut_indices = array(sim_params.nli_params.computed_channels) - 1 + elif sim_params.nli_params.computed_number_of_channels is not None: + nb_ch_computed = sim_params.nli_params.computed_number_of_channels + nb_ch = len(spectral_info.channel_number) + cut_indices = array([round(i * (nb_ch - 1) / (nb_ch_computed - 1)) for i in range(0, nb_ch_computed)]) else: cut_indices = array(spectral_info.channel_number) - 1