mirror of
				https://github.com/Telecominfraproject/oopt-gnpy.git
				synced 2025-10-30 17:47:50 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			727 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			727 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| #!/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()
 | 
