example network visualisation

This commit is contained in:
James Powell
2017-11-08 14:54:58 -05:00
parent 7f378e5479
commit dc7a459697
3 changed files with 92 additions and 0 deletions

25
core/elements.py Normal file
View 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()