From a211e305c3948b6e112cae0551324eb18df70d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20M=C3=A5rtensson?= Date: Wed, 21 Apr 2021 12:59:24 +0200 Subject: [PATCH] Define tilt target over the full amplifier bandwidth MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the tilt_target defined by a user is applied over the band of propagating channels. This means for example that if only two channels are propagated, the difference in gain between the two channels will be equal to the tilt_target, independently of how close the two channels are in frequency. I think it makes more sense to always define the tilt_target over the full operational bandwidth of the amplifier. Signed-off-by: Jonas MÃ¥rtensson Change-Id: I4f29de2edc4d0de239b34e0d8d678d964b6a0af3 --- gnpy/core/elements.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/gnpy/core/elements.py b/gnpy/core/elements.py index 5968a54a3..11353017c 100644 --- a/gnpy/core/elements.py +++ b/gnpy/core/elements.py @@ -805,24 +805,21 @@ def _gain_profile(self, pin, err_tolerance=1.0e-11, simple_opt=True): if len(self.interpol_dgt) == 1: return array([self.effective_gain]) - nb_channel = arange(len(self.interpol_dgt)) - # TODO|jla: find a way to use these or lose them. Primarily we should have # a way to determine if exceeding the gain or output power of the amp tot_in_power_db = self.pin_db # Pin in W # linear fit to get the - p = polyfit(nb_channel, self.interpol_dgt, 1) + p = polyfit(self.channel_freq, self.interpol_dgt, 1) dgt_slope = p[0] - # Calculate the target slope - currently assumes equal spaced channels - # TODO|jla: support arbitrary channel spacing - targ_slope = self.tilt_target / (len(nb_channel) - 1) + # Calculate the target slope + targ_slope = self.tilt_target / (self.params.f_max - self.params.f_min) # first estimate of DGT scaling - if abs(dgt_slope) > 0.001: # check for zero value due to flat dgt + try: dgts1 = targ_slope / dgt_slope - else: + except ZeroDivisionError: dgts1 = 0 # when simple_opt is true, make 2 attempts to compute gain and