mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-10-30 17:47:50 +00:00
* JSON file based on Orange operator typical input Signed-off-by: Jean-Luc Auge <jeanluc.auge@orange.com> * update of the standalone edfa model creation of a new amlifier2.py = v2 creation of a json parser build_oa_json.py the parser takes OA.json as input and newOA.json as output creation of a pytest verification module amplifier_pytest.py Signed-off-by: Jean-Luc Auge <jeanluc.auge@orange.com> * put the code together and transmission example script -basic dijkstra propagation -ase noise propagation based on amplifier model -fake nli noise propagation -integration of the amplifier model -interpolation function in the edfa class -code cleaning and units harmonization Signed-off-by: Jean-Luc Auge <jeanluc.auge@orange.com> * mv transmission_main_example and rm _main__ Signed-off-by: Jean-Luc Auge <jeanluc.auge@orange.com> * 2nd edfa model and build_oa_json file add a dual coil stages edfa model in case the nf polynomial fit is not known add a build_oa_json file that convert the input files in edfa_config.json file and pre-calculate the nf_model nf1, nf2 and delta_p parameters adding power violation check and input padding (below minimum gain) in the edfa model class Signed-off-by: Jean-Luc Auge <jeanluc.auge@orange.com>
61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
#! /bin/usr/python3
|
|
|
|
from uuid import uuid4
|
|
from gnpy.core.utils import load_json
|
|
|
|
|
|
class ConfigStruct:
|
|
|
|
def __init__(self, **config):
|
|
if config is None:
|
|
return None
|
|
if 'config_from_json' in config:
|
|
json_config = load_json(config['config_from_json'])
|
|
self.set_config_attr(json_config)
|
|
|
|
self.set_config_attr(config)
|
|
|
|
def set_config_attr(self, config):
|
|
for k, v in config.items():
|
|
setattr(self, k, ConfigStruct(**v)
|
|
if isinstance(v, dict) else v)
|
|
|
|
def __repr__(self):
|
|
return f'{self.__dict__}'
|
|
|
|
|
|
class Node:
|
|
|
|
def __init__(self, config=None):
|
|
self.config = ConfigStruct(**config)
|
|
if self.config is None or not hasattr(self.config, 'uid'):
|
|
self.uid = uuid4()
|
|
else:
|
|
self.uid = self.config.uid
|
|
if hasattr(self.config, 'params'):
|
|
self.params = self.config.params
|
|
if hasattr(self.config, 'metadata'):
|
|
self.metadata = self.config.metadata
|
|
if hasattr(self.config, 'operational'):
|
|
self.operational = self.config.operational
|
|
|
|
@property
|
|
def coords(self):
|
|
return tuple(self.lng, self.lat)
|
|
|
|
@property
|
|
def location(self):
|
|
return self.config.metadata.location
|
|
|
|
@property
|
|
def loc(self): # Aliases .location
|
|
return self.location
|
|
|
|
@property
|
|
def lng(self):
|
|
return self.config.metadata.location.longitude
|
|
|
|
@property
|
|
def lat(self):
|
|
return self.config.metadata.location.latitude
|