Skip to content

Commit

Permalink
Merge pull request #312 from jktjkt/fixes
Browse files Browse the repository at this point in the history
Small refactoring for itufs/utifl
  • Loading branch information
jktjkt authored Oct 16, 2019
2 parents 0ccbb29 + 029bac4 commit a21f3fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
4 changes: 2 additions & 2 deletions gnpy/core/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from gnpy.core.node import Node
from gnpy.core.units import UNITS
from gnpy.core.utils import lin2db, db2lin, itufs, itufl, snr_sum
from gnpy.core.utils import lin2db, db2lin, arrange_frequencies, snr_sum
from gnpy.core.science_utils import propagate_raman_fiber, _psi

class Transceiver(Node):
Expand Down Expand Up @@ -615,7 +615,7 @@ def interpol_params(self, frequencies, pin, baud_rates, pref):
self.channel_freq, self.nf, self.interpol_dgt and self.interpol_gain_ripple
"""
# TODO|jla: read amplifier actual frequencies from additional params in json
amplifier_freq = itufl(len(self.params.dgt), self.params.f_min, self.params.f_max) # Hz
amplifier_freq = arrange_frequencies(len(self.params.dgt), self.params.f_min, self.params.f_max) # Hz
self.channel_freq = frequencies
self.interpol_dgt = interp(self.channel_freq, amplifier_freq, self.params.dgt)

Expand Down
32 changes: 8 additions & 24 deletions gnpy/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,35 +73,19 @@ def c():
return constants.c


def itufs(spacing, startf=191.35, stopf=196.10):
"""Creates an array of frequencies whose default range is
191.35-196.10 THz
:param spacing: Frequency spacing in THz
:param starf: Start frequency in THz
:param stopf: Stop frequency in THz
:type spacing: float
:type startf: float
:type stopf: float
:return an array of frequnecies determined by the spacing parameter
:rtype: numpy.ndarray
"""
return np.arange(startf, stopf + spacing / 2, spacing)

def itufl(length, startf=191.35, stopf=196.10):
"""Creates an array of frequencies whose default range is
191.35-196.10 THz
def arrange_frequencies(length, start, stop):
"""Create an array of frequencies
:param length: number of elements
:param starf: Start frequency in THz
:param stopf: Stop frequency in THz
:param star: Start frequency in THz
:param stop: Stop frequency in THz
:type length: integer
:type startf: float
:type stopf: float
:return an array of frequnecies determined by the spacing parameter
:type start: float
:type stop: float
:return an array of frequencies determined by the spacing parameter
:rtype: numpy.ndarray
"""
return np.linspace(startf, stopf, length)
return np.linspace(start, stop, length)

def h():
"""
Expand Down

0 comments on commit a21f3fe

Please sign in to comment.