mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-11-02 02:57:52 +00:00
* adding rrc filter, temporarily putting it in utilities.py * added some docstring stuff * added a simple loss class for fiber and cleaned up some duplicate convenience access properties * Changed Carrier to Channel to reflect correct nomenclature for multi-carrier/superchannels * in process fixes for main.py. adding in amp spacings and spans to convert to start adding additional noded to Coronet network * some simple additions to utilites * adding stand alone edfa model
120 lines
3.1 KiB
Python
120 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Created on Fri Nov 10 17:50:46 2017
|
|
|
|
@author: briantaylor
|
|
"""
|
|
import numpy as np
|
|
from numpy import pi, cos, sqrt, log10
|
|
|
|
def c():
|
|
"""
|
|
Returns the speed of light in meters per second
|
|
"""
|
|
return 299792458.0
|
|
|
|
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 h():
|
|
"""
|
|
Returns plank's constant in J*s
|
|
"""
|
|
return 6.62607004e-34
|
|
|
|
def lin2db(value):
|
|
return 10*log10(value)
|
|
|
|
|
|
def db2lin(value):
|
|
return 10**(value/10)
|
|
|
|
|
|
def wavelength2freq(value):
|
|
""" Converts wavelength units to frequeuncy units.
|
|
"""
|
|
return c()/value
|
|
|
|
|
|
def freq2wavelength(value):
|
|
""" Converts frequency units to wavelength units.
|
|
"""
|
|
return c()/value
|
|
|
|
|
|
def deltawl2deltaf(delta_wl, wavelength):
|
|
""" deltawl2deltaf(delta_wl, wavelength):
|
|
delta_wl is BW in wavelength units
|
|
wavelength is the center wl
|
|
units for delta_wl and wavelength must be same
|
|
|
|
|
|
|
|
:param delta_wl: delta wavelength BW in same units as wavelength
|
|
:param wavelength: wavelength BW is relevant for
|
|
:type delta_wl: float or numpy.ndarray
|
|
:type wavelength: float
|
|
:return: The BW in frequency units
|
|
:rtype: float or ndarray
|
|
|
|
"""
|
|
f = wavelength2freq(wavelength)
|
|
return delta_wl*f/wavelength
|
|
|
|
|
|
def deltaf2deltawl(delta_f, frequency):
|
|
""" deltawl2deltaf(delta_f, frequency):
|
|
converts delta frequency to delta wavelength
|
|
units for delta_wl and wavelength must be same
|
|
|
|
|
|
:param delta_f: delta frequency in same units as frequency
|
|
:param frequency: frequency BW is relevant for
|
|
:type delta_f: float or numpy.ndarray
|
|
:type frequency: float
|
|
:return: The BW in wavelength units
|
|
:rtype: float or ndarray
|
|
|
|
"""
|
|
wl = freq2wavelength(frequency)
|
|
return delta_f*wl/frequency
|
|
|
|
|
|
def rrc(ffs, baud_rate, alpha):
|
|
""" rrc(ffs, baud_rate, alpha): computes the root-raised cosine filter
|
|
function.
|
|
|
|
:param ffs: A numpy array of frequencies
|
|
:param baud_rate: The Baud Rate of the System
|
|
:param alpha: The roll-off factor of the filter
|
|
:type ffs: numpy.ndarray
|
|
:type baud_rate: float
|
|
:type alpha: float
|
|
:return: hf a numpy array of the filter shape
|
|
:rtype: numpy.ndarray
|
|
|
|
"""
|
|
Ts = 1/baud_rate
|
|
l_lim = (1 - alpha)/(2 * Ts)
|
|
r_lim = (1 + alpha)/(2 * Ts)
|
|
hf = np.zeros(np.shape(ffs))
|
|
slope_inds = np.where(
|
|
np.logical_and(np.abs(ffs) > l_lim, np.abs(ffs) < r_lim))
|
|
hf[slope_inds] = 0.5 * (1 + cos((pi * Ts / alpha) *
|
|
(np.abs(ffs[slope_inds]) - l_lim)))
|
|
p_inds = np.where(np.logical_and(np.abs(ffs) > 0, np.abs(ffs) < l_lim))
|
|
hf[p_inds] = 1
|
|
return sqrt(hf) |