mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-11-03 03:28:04 +00:00
example network visualisation
This commit is contained in:
25
core/elements.py
Normal file
25
core/elements.py
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python
|
||||
from collections import namedtuple
|
||||
|
||||
class City(namedtuple('City', 'id city region latitude longitude')):
|
||||
def __call__(self, spectral_info):
|
||||
return spectral_info.copy()
|
||||
|
||||
class Fiber:
|
||||
UNITS = {'m': 1, 'km': 1e3}
|
||||
def __init__(self, id, length, units, latitude, longitude):
|
||||
self.id = id
|
||||
self._length = length
|
||||
self._units = units
|
||||
self.latitude = latitude
|
||||
self.longitude = longitude
|
||||
|
||||
def __repr__(self):
|
||||
return f'{type(self).__name__}(id={self.id}, length={self.length})'
|
||||
|
||||
@property
|
||||
def length(self):
|
||||
return self._length * self.UNITS[self._units]
|
||||
|
||||
def __call__(self, spectral_info):
|
||||
return spectral_info.copy()
|
||||
Reference in New Issue
Block a user