mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-11-01 18:47:48 +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
43 lines
1.8 KiB
Python
43 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
|
|
from collections import namedtuple
|
|
|
|
class ConvenienceAccess:
|
|
def __init_subclass__(cls):
|
|
for abbrev, field in getattr(cls, '_ABBREVS', {}).items():
|
|
setattr(cls, abbrev, property(lambda self, f=field: getattr(self, f)))
|
|
|
|
def update(self, **kwargs):
|
|
for abbrev, field in getattr(self, '_ABBREVS', {}).items():
|
|
if abbrev in kwargs:
|
|
kwargs[field] = kwargs.pop(abbrev)
|
|
return self._replace(**kwargs)
|
|
|
|
class Power(namedtuple('Power', 'signal nonlinear_interference amplified_spontaneous_emission'), ConvenienceAccess):
|
|
_ABBREVS = {'nli': 'nonlinear_interference',
|
|
'ase': 'amplified_spontaneous_emission',}
|
|
|
|
class Channel(namedtuple('Channel', 'channel_number frequency modulation baud_rate alpha power'), ConvenienceAccess):
|
|
_ABBREVS = {'channel': 'channel_number',
|
|
'num_chan': 'channel_number',
|
|
'num_carriers': 'num_carriers',
|
|
'ffs': 'frequency',
|
|
'freq': 'frequency',}
|
|
|
|
class SpectralInformation(namedtuple('SpectralInformation', 'carriers'), ConvenienceAccess):
|
|
def __new__(cls, *carriers):
|
|
return super().__new__(cls, carriers)
|
|
|
|
if __name__ == '__main__':
|
|
si = SpectralInformation(
|
|
Channel(1, 193.95e12, '16-qam', 32e9, 0, # 193.95 THz, 32 Gbaud
|
|
Power(1e-3, 1e-6, 1e-6)), # 1 mW, 1uW, 1uW
|
|
Channel(1, 195.95e12, '16-qam', 32e9, 0, # 195.95 THz, 32 Gbaud
|
|
Power(1.2e-3, 1e-6, 1e-6)), # 1.2 mW, 1uW, 1uW
|
|
)
|
|
print(f'si = {si}')
|
|
print(f'si = {si.carriers[0].power.nli}')
|
|
si2 = si.update(carriers=tuple(c.update(power = c.power.update(nli = c.power.nli * 1e5))
|
|
for c in si.carriers))
|
|
print(f'si2 = {si2}')
|