Skip to content

Commit

Permalink
Refactor amp default in parameters
Browse files Browse the repository at this point in the history
default parameters are shared between json and network function,
so it is better to have them on the parameters to avoid circular
dependency when importing modules

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: Ib9d41852e394586d36f74992c91f67f3330cc552
  • Loading branch information
EstherLerouzic committed Apr 25, 2024
1 parent 2b4a4ab commit be7ae35
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 35 deletions.
9 changes: 4 additions & 5 deletions gnpy/core/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
from gnpy.core.exceptions import ConfigurationError, NetworkTopologyError
from gnpy.core.utils import round2float, convert_length, psd2powerdbm, lin2db, watt2dbm, dbm2watt
from gnpy.core.info import ReferenceCarrier, create_input_spectral_information
from gnpy.tools import json_io
from gnpy.core.parameters import SimParams
from gnpy.core.parameters import SimParams, EdfaParams
from gnpy.core.science_utils import RamanSolver


Expand Down Expand Up @@ -540,7 +539,7 @@ def add_roadm_booster(network, roadm):
network.remove_edge(roadm, next_node)
amp = elements.Edfa(
uid=f'Edfa_booster_{roadm.uid}_to_{next_node.uid}',
params=json_io.Amp.default_values,
params=EdfaParams.default_values,
metadata={
'location': {
'latitude': roadm.lat,
Expand All @@ -566,7 +565,7 @@ def add_roadm_preamp(network, roadm):
network.remove_edge(prev_node, roadm)
amp = elements.Edfa(
uid=f'Edfa_preamp_{roadm.uid}_from_{prev_node.uid}',
params=json_io.Amp.default_values,
params=EdfaParams.default_values,
metadata={
'location': {
'latitude': roadm.lat,
Expand Down Expand Up @@ -595,7 +594,7 @@ def add_inline_amplifier(network, fiber):
network.remove_edge(fiber, next_node)
amp = elements.Edfa(
uid=f'Edfa_{fiber.uid}',
params=json_io.Amp.default_values,
params=EdfaParams.default_values,
metadata={
'location': {
'latitude': (fiber.lat + next_node.lat) / 2,
Expand Down
32 changes: 32 additions & 0 deletions gnpy/core/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,38 @@ def asdict(self):


class EdfaParams:
default_values = {
'f_min': 191.3e12,
'f_max': 196.1e12,
'multi_band': None,
'bands': [],
'type_variety': '',
'type_def': '',
'gain_flatmax': None,
'gain_min': None,
'p_max': None,
'nf_model': None,
'dual_stage_model': None,
'preamp_variety': None,
'booster_variety': None,
'nf_min': None,
'nf_max': None,
'nf_coef': None,
'nf0': None,
'nf_fit_coeff': None,
'nf_ripple': 0,
'dgt': None,
'gain_ripple': 0,
'tilt_ripple': 0,
'f_ripple_ref': None,
'out_voa_auto': False,
'allowed_for_design': False,
'raman': False,
'pmd': 0,
'pdl': 0,
'advance_configurations_from_json': None
}

def __init__(self, **params):
try:
self.type_variety = params['type_variety']
Expand Down
32 changes: 2 additions & 30 deletions gnpy/tools/json_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from gnpy.core.science_utils import estimate_nf_model
from gnpy.core.info import Carrier
from gnpy.core.utils import automatic_nch, automatic_fmax, merge_amplifier_restrictions
from gnpy.core.parameters import DEFAULT_RAMAN_COEFFICIENT
from gnpy.core.parameters import DEFAULT_RAMAN_COEFFICIENT, EdfaParams
from gnpy.topology.request import PathRequest, Disjunction, compute_spectrum_slot_vs_bandwidth
from gnpy.topology.spectrum_assignment import mvalue_to_slots
from gnpy.tools.convert import xls_to_json_data
Expand Down Expand Up @@ -180,35 +180,7 @@ class RamanFiber(Fiber):


class Amp(_JsonThing):
default_values = {
'f_min': 191.35e12,
'f_max': 196.1e12,
'type_variety': '',
'type_def': '',
'gain_flatmax': None,
'gain_min': None,
'p_max': None,
'nf_model': None,
'dual_stage_model': None,
'preamp_variety': None,
'booster_variety': None,
'nf_min': None,
'nf_max': None,
'nf_coef': None,
'nf0': None,
'nf_fit_coeff': None,
'nf_ripple': 0,
'dgt': None,
'gain_ripple': 0,
'tilt_ripple': 0,
'f_ripple_ref': None,
'out_voa_auto': False,
'allowed_for_design': False,
'raman': False,
'pmd': 0,
'pdl': 0,
'advance_configurations_from_json': None
}
default_values = EdfaParams.default_values

def __init__(self, **kwargs):
self.update_attr(self.default_values, kwargs, 'Amp')
Expand Down

0 comments on commit be7ae35

Please sign in to comment.