gnpy.tools
Processing of data via json_io.
Utilities for Excel conversion in convert and service_sheet.
Example code in cli_examples and plots.
gnpy.tools.cli_examples
Common code for CLI examples
- gnpy.tools.cli_examples._add_common_options(parser: ArgumentParser, network_default: Path)
Add common command-line options to the argument parser.
- Parameters:
parser (argparse.ArgumentParser) – The argument parser to which options will be added.
network_default (Path) – The default path for the network topology file.
- gnpy.tools.cli_examples._get_nodes_from_path(path_list: List[str], all_roadms: Dict) List[str]
Return a Nodes-list made from the parsed ‘path_string’ and which are part of ‘all_roadms’.
- Parameters:
path_list (List[str]) – A list of path elements to check.
all_roadms (dict) – A dictionary of all ROADMs in the network.
- Returns:
A list of nodes corresponding to the path elements.
- Return type:
List[str]
- Raises:
exceptions.NetworkTopologyError – If some elements in the requested path could not be resolved.
- gnpy.tools.cli_examples._get_params_from_path(path_raw: List[str], network, source: Transceiver, destination: Transceiver, args_source: str, args_destination: str) Tuple[Transceiver, Transceiver, List[str], List[str]]
Extract the explicit path from the provided raw path argument.
- Parameters:
path_raw (List[str]) – A list of raw path elements.
network (Any) – The network object.
source (elementTransceiver) – The source Transceiver object.
destination (elementTransceiver) – The destination elementTransceiver object.
args_source (str) – The command-line argument for the source node.
args_destination (str) – The command-line argument for the destination node.
- Returns:
A tuple containing the source, destination, nodes list, and loose list.
- Return type:
Tuple[elementTransceiver, elementTransceiver, List[str], List[str]]
- Raises:
exceptions.NetworkTopologyError – If some elements in the requested path could not be resolved.
- gnpy.tools.cli_examples._get_rq_from_service(service: Path, route_id: str, network, equipment, args_topology: Path) Tuple[Transceiver, Transceiver, PathRequest]
Retrieve the request from the service file.
- Parameters:
service (Path) – The path to the service request file.
route_id (str) – The ID of the route to retrieve.
network (Any) – The network object.
equipment (Any) – The equipment configuration.
args_topology (Path) – The path to the topology file.
- Returns:
A tuple containing the source and destination Transceiver objects, and the request.
- Return type:
Tuple[elementTransceiver, elementTransceiver, PathRequest]
- Raises:
exceptions.ServiceError – If the requested route_id could not be found.
- gnpy.tools.cli_examples._infer_trx(target_roadm_uid: str, all_roadms: Dict, network: DiGraph)
Return the ‘trx’ of the ‘target_roadm’ (uid) among ‘all_roadm’s (dict) of ‘network’.
- Parameters:
target_roadm_uid (str) – The UID of the target ROADM.
all_roadms (Dict) – A dictionary of all ROADMs in the network.
network (DiGraph) – The network object.
- Returns:
The Transceiver object associated with the target ROADM.
- Raises:
exceptions.NetworkTopologyError – If no transceiver can be associated with the target ROADM.
- gnpy.tools.cli_examples._path_result_json(pathresult)
- gnpy.tools.cli_examples._setup_logging(args: Namespace)
Set up logging based on verbosity level.
- Parameters:
args (argparse.Namespace) – The parsed command-line arguments.
- gnpy.tools.cli_examples.load_common_data(equipment_filename: Path, extra_equipment_filenames: List[Path], extra_config_filenames: List[Path], topology_filename: Path, simulation_filename: Path, save_raw_network_filename: Path)
Load common configuration from JSON files, merging additional equipment if provided.
- Parameters:
equipment_filename (Path) – Path to the main equipment configuration file.
extra_equipment_filenames (List[Path]) – List of additional equipment configuration files.
extra_config_filenames (List[Path]) – List of additional configuration files.
topology_filename (Path) – Path to the network topology file.
simulation_filename (Path) – Path to the simulation parameters file.
save_raw_network_filename (Path) – Path to save the raw network configuration.
- Raises:
exceptions.EquipmentConfigError – If there is a configuration error in the equipment library.
exceptions.NetworkTopologyError – If the network definition is invalid.
exceptions.ParametersError – If there is an error with simulation parameters.
exceptions.ConfigurationError – If there is a general configuration error.
exceptions.ServiceError – If there is a service-related error.
- gnpy.tools.cli_examples.path_requests_run(args=None)
Main script running several services simulations. It returns a summary of the average performance for each service.
- Parameters:
args (Union[List[str], None]) – Command-line arguments (default is None).
- gnpy.tools.cli_examples.show_example_data_dir()
Print the example data directory path.
- gnpy.tools.cli_examples.transmission_main_example(args: List[str] | None = None)
Main script running a single simulation. It returns the detailed power across crossed elements and average performance accross all channels.
- Parameters:
args (Union[List[str], None]) – Command-line arguments (default is None).
gnpy.tools.convert
This module contains utilities for converting between XLS and JSON.
The input XLS file must contain sheets named “Nodes” and “Links”. It may optionally contain a sheet named “Eqpt”.
In the “Nodes” sheet, only the “City” column is mandatory. The column “Type” can be determined automatically given the topology (e.g., if degree 2, ILA; otherwise, ROADM.) Incorrectly specified types (e.g., ILA for node of degree ≠ 2) will be automatically corrected.
In the “Links” sheet, only the first three columns (“Node A”, “Node Z” and “east Distance (km)”) are mandatory. Missing “west” information is copied from the “east” information so that it is possible to input undirected data.
- class gnpy.tools.convert.Eqpt(**kwargs)
Bases:
objectEquipment data class representing amplifiers or other equipment.
- Variables:
from_city (str) – The city where the equipment is located.
to_city (str) – The city where the equipment connects to.
east_amp_type (str) – The type of amplifier in the east direction.
east_amp_gain (float) – The gain of the amplifier in the east direction.
east_amp_dp (float) – The delta power of the amplifier in the east direction.
east_tilt_vs_wavelength (float) – Tilt of the amplifier versus wavelength in the east direction.
east_att_out (float) – Output attenuation in the east direction.
east_att_in (float) – Input attenuation in the east direction.
- default_values = {'east_amp_dp': None, 'east_amp_gain': None, 'east_amp_type': '', 'east_att_in': 0, 'east_att_out': None, 'east_tilt_vs_wavelength': None, 'from_city': '', 'to_city': ''}
- update_attr(kwargs)
Updates the attributes of the equipment based on provided keyword arguments.
- Parameters:
kwargs – A dictionary of attributes to update.
- class gnpy.tools.convert.Link(**kwargs)
Bases:
objectLink data class representing a connection between nodes.
- Variables:
from_city (str) – The city where the link starts.
to_city (str) – The city where the link ends.
east_distance (float) – The distance of the link in the east direction.
east_fiber (str) – The type of fiber used in the east direction.
east_lineic (float) – The linear attenuation in the east direction.
east_con_in (str) – Connection input in the east direction.
east_con_out (str) – Connection output in the east direction.
east_pmd (float) – Polarization mode dispersion in the east direction.
east_cable (str) – The cable identifier in the east direction.
distance_units (str) – The units of distance (default is ‘km’).
- default_values = {'east_cable': '', 'east_con_in': None, 'east_con_out': None, 'east_distance': 80, 'east_fiber': 'SSMF', 'east_lineic': 0.2, 'east_pmd': None, 'from_city': '', 'to_city': ''}
- update_attr(kwargs)
Updates the attributes of the link based on provided keyword arguments.
- Parameters:
kwargs – A dictionary of attributes to update.
- class gnpy.tools.convert.Node(**kwargs)
Bases:
objectNode data class representing a network node.
- Variables:
city (str) – The city where the node is located.
state (str) – The state where the node is located.
country (str) – The country where the node is located.
region (str) – The region where the node is located.
latitude (float) – The latitude of the node’s location.
longitude (float) – The longitude of the node’s location.
node_type (str) – The type of the node (e.g., ILA, ROADM).
booster_restriction (str) – Restrictions on booster amplifiers.
preamp_restriction (str) – Restrictions on preamplifiers.
- default_values = {'booster_restriction': '', 'city': '', 'country': '', 'latitude': 0, 'longitude': 0, 'node_type': 'ILA', 'preamp_restriction': '', 'region': '', 'state': ''}
- update_attr(kwargs)
Updates the attributes of the node based on provided keyword arguments.
- Parameters:
kwargs – A dictionary of attributes to update.
- class gnpy.tools.convert.Roadm(**kwargs)
Bases:
objectROADM data class representing a reconfigurable optical add-drop multiplexer.
- Variables:
from_node (str) – The starting node of the ROADM.
to_node (str) – The ending node of the ROADM.
target_pch_out_db (float) – Target output power per channel in dBm.
type_variety (str) – The type variety of the ROADM.
from_degrees (str) – Degrees from the starting node.
impairment_ids (str) – Impairment identifiers associated with the ROADM.
- default_values = {'from_degrees': None, 'from_node': '', 'impairment_ids': None, 'target_pch_out_db': None, 'to_node': '', 'type_variety': None}
- update_attr(kwargs)
Updates the attributes of the ROADM based on provided keyword arguments.
- Parameters:
kwargs (dict) – A dictionary of attributes to update.
- gnpy.tools.convert._do_convert()
Main function for xls(x) topology conversion to JSON format
- gnpy.tools.convert._format_items(items: List[str])
Format a list of items into a string.
- Parameters:
items (List[str]) – A list of items to format.
- Returns:
A formatted string with each item on a new line.
- Return type:
str
- gnpy.tools.convert.connect_eqpt(from_: str, in_: str, to_: str) List[dict]
Create the topology connection JSON dict between in and to.
- Parameters:
from (str) – The starting node identifier.
in (str) – The intermediate node identifier.
to (str) – The ending node identifier.
- Returns:
A list of connection dictionaries.
- Return type:
List[dict]
- gnpy.tools.convert.convert_file(input_filename: Path, filter_region: List[str] = None, output_json_file_name: Path = None) Path
Convert the input XLS file to JSON format and save it.
- Parameters:
input_filename (Path) – The path to the input XLS file.
filter_region (List[str]) – A list of regions to filter the nodes (default is None).
output_json_file_name (Path) – The path to save the output JSON file (default is None).
- Returns:
The path to the saved JSON file.
- Return type:
Path
- gnpy.tools.convert.corresp_names(input_filename: Path, network: DiGraph) Tuple[dict, dict, dict]
Build the correspondence between names given in the Excel and names used in the JSON.
- Parameters:
input_filename (Path) – The path to the input XLS file.
network (DiGraph) – The network graph object.
- Returns:
A tuple containing dictionaries for ROADMs, fused nodes, and ILAs.
- Return type:
Tuple[dict, dict, dict]
- gnpy.tools.convert.corresp_next_node(network: DiGraph, corresp_ila: dict, corresp_roadm: dict) Tuple[dict, dict]
Find the next node in the network for each name in the correspondence dictionaries. For each name in corresp dictionnaries find the next node in network and its name given by user in excel. for meshTopology_exampleV2.xls: user ILA name Stbrieuc covers the two direction. convert.py creates 2 different ILA with possible names (depending on the direction and if the eqpt was defined in eqpt sheet) for an ILA and if it is defined in eqpt:
east edfa in Stbrieuc to Rennes_STA
west edfa in Stbrieuc to Rennes_STA
for an ILA and if it is notdefined in eqpt:
east edfa in Stbrieuc
west edfa in Stbrieuc
for a roadm
“Edfa_preamp_roadm node1_from_fiber (siteE → node1)-CABLES#19”
“Edfa_booster_roadm node1_to_fiber (node1 → siteE)-CABLES#19”
next_nodes finds the user defined name of next node to be able to map the path constraints
east edfa in Stbrieuc to Rennes_STA next node = Rennes_STA
west edfa in Stbrieuc to Rennes_STA next node = Lannion_CAS
the function supports fiber splitting, fused nodes and shall only be called if excel format is used for both network and service
- Parameters:
network (DiGraph) – The network graph object.
corresp_ila (dict) – A dictionary mapping city names to lists of ILA names.
corresp_roadm (dict) – A dictionary mapping city names to lists of ROADM names.
- Returns:
A tuple containing updated correspondence for ILAs and the next node mapping.
- Return type:
Tuple[dict, dict]
- gnpy.tools.convert.create_east_eqpt_element(node: Node, nodes_by_city: Dict[str, Node]) dict
Create amplifiers json elements for the east direction. this includes the case where the case of a fused element defined instead of an ILA in eqpt sheet.
- gnpy.tools.convert.create_east_fiber_element(fiber: Node, nodes_by_city: Dict[str, Node]) Dict
Create fibers json elements for the east direction.
- gnpy.tools.convert.create_roadm_element(node: Node, roadms_by_city: DefaultDict[str, List[Roadm]]) Dict
Create the json element for a roadm node, including the different cases:
if there are restrictions
if there are per degree target power defined on a direction
direction is defined by the booster name, so that booster must also be created in eqpt sheet if the direction is defined in roadm.
- gnpy.tools.convert.create_west_eqpt_element(node: Node, nodes_by_city: Dict[str, Node]) dict
Create amplifiers json elements for the west direction. this includes the case where the case of a fused element defined instead of an ILA in eqpt sheet.
- gnpy.tools.convert.create_west_fiber_element(fiber: Node, nodes_by_city: Dict[str, Node]) Dict
Create fibers json elements for the west direction.
- gnpy.tools.convert.eqpt_connection_by_city(city_name: str, eqpts_by_city: DefaultDict[str, List[Eqpt]], links_by_city: DefaultDict[str, List[Link]], nodes_by_city: Dict[str, Node]) list
Returns the list of equipment installed in the specified city.
- Parameters:
city_name (str) – The name of the city to check for equipment.
eqpts_by_city (DefaultDict[str, List[Eqpt]]) – A defaultdict mapping city names to lists of Eqpt objects.
links_by_city (DefaultDict[str, List[Link]]) – A defaultdict mapping city names to lists of Link objects.
nodes_by_city (Dict[str, Node]) – A dictionary mapping city names to Node objects.
- Returns:
A list of connection dictionaries for the specified city.
- Return type:
list
- gnpy.tools.convert.eqpt_in_city_to_city(in_city: str, to_city: str, eqpts_by_city: DefaultDict[str, List[Eqpt]], nodes_by_city: Dict[str, Node], direction: str = 'east') str
Returns the formatted string corresponding to in_city types and direction.
- Parameters:
in_city (str) – The city where the equipment is located.
to_city (str) – The city where the equipment connects to.
eqpts_by_city (DefaultDict[str, List[Eqpt]]) – A defaultdict mapping city names to lists of Eqpt objects.
nodes_by_city (Dict[str, Node]) – A dictionary mapping city names to Node objects.
direction (str) – The direction of the equipment (default is ‘east’).
- Returns:
A formatted string representing the equipment in the specified direction.
- Return type:
str
- gnpy.tools.convert.fiber_dest_from_source(city_name: str, links_by_city: DefaultDict[str, List[Link]]) List[str]
Returns the list of cities connected to the specified city.
- Parameters:
city_name (str) – The name of the city to check for connections.
links_by_city (DefaultDict[str, List[Link]]) – A defaultdict mapping city names to lists of Link objects.
- Returns:
A list of city names that are connected to the specified city.
- Return type:
List[str]
- gnpy.tools.convert.fiber_link(from_city: str, to_city: str, links_by_city: DefaultDict[str, List[Link]]) str
Returns the formatted UID for fibers between two cities.
- Parameters:
from_city (str) – The starting city name.
to_city (str) – The destination city name.
links_by_city (DefaultDict[str, List[Link]]) – A defaultdict mapping city names to lists of Link objects.
- Returns:
A formatted string representing the fiber link.
- Return type:
str
- gnpy.tools.convert.midpoint(city_a: Node, city_b: Node) dict
Computes the midpoint coordinates between two cities.
- gnpy.tools.convert.parse_excel(input_filename: Path) Tuple[List[Node], List[Link], List[Eqpt], List[Roadm]]
Reads XLS(X) sheets among Nodes, Eqpts, Links, Roadms and parses the data.
- Parameters:
input_filename (Path) – The path to the input XLS file.
- Returns:
A tuple containing lists of Node, Link, Eqpt, and Roadm objects.
- Return type:
- Raises:
NetworkTopologyError – If any issues are found during parsing.
- gnpy.tools.convert.parse_headers(my_sheet: Worksheet | Sheet, is_xlsx: bool, input_headers_dict: Dict, headers: Dict[int, str], start_line: int, slice_in: Tuple[int, int]) Dict[int, str]
return a dict of header_slice
key = column index
value = header name
- Parameters:
my_sheet (SheetType) – The sheet object from which to read headers.
input_headers_dict (dict) – A dictionary mapping expected headers to internal names.
headers (Dict[int, str]) – A dictionary to store the header slices.
start_line (int) – The starting line to search for headers.
slice_in (Tuple[int, int]) – A tuple specifying the start and end column indices.
- Returns:
A dictionary mapping column indices to header names.
- Return type:
Dict[int, str]
- gnpy.tools.convert.parse_row(row, headers)
Parse a row of data into a dictionary based on headers.
- Parameters:
row – The row object to parse.
headers – A dictionary mapping header names to column indices.
- Returns:
A dictionary mapping header names to their corresponding values in the row.
- gnpy.tools.convert.parse_sheet(my_sheet: Worksheet | Sheet, is_xlsx: bool, input_headers_dict: Dict, header_line: int, start_line: int, column: int) Generator[Dict[str, str], None, None]
Parse a sheet and yield rows as dictionaries.
- Parameters:
my_sheet (xlrd.sheet.Sheet) – The sheet object to parse.
input_headers_dict (dict) – A dictionary mapping expected headers to internal names.
header_line (int) – The line number where headers are located.
start_line (int) – The starting line number for data rows.
column (int) – The number of columns to read.
- Returns:
A generator yielding parsed rows as dictionaries.
- gnpy.tools.convert.read_header(my_sheet: Worksheet | Sheet, is_xlsx: bool, line: int, slice_: Tuple[int, int]) List[namedtuple]
Return the list of headers in a specified range.
header_i = [(header, header_column_index), …] in a {line, slice1_x, slice_y} range
- Parameters:
my_sheet (SheetType) – The sheet object from which to read headers.
line (int) – The row index to read headers from.
slice (Tuple[int, int]) – A tuple specifying the start and end column indices.
- Returns:
A list of namedtuples containing headers and their column indices.
- Return type:
List[namedtuple]
- gnpy.tools.convert.read_slice(my_sheet: Worksheet | Sheet, is_xlsx: bool, line: int, slice_: Tuple[int, int], header: str) Tuple[int, int]
return the slice range of a given header in a defined range {line, slice_x, slice_y}
- Parameters:
my_sheet (xlrd.sheet.Sheet) – The sheet object from which to read the header.
line (int) – The row index to read from.
slice (Tuple[int, int]) – A tuple specifying the start and end column indices.
header – The header name to search for.
- Returns:
A tuple representing the start and end indices of the slice.
- Return type:
Tuple[int, int]
- gnpy.tools.convert.sanity_check(nodes: List[Node], links: List[Link], nodes_by_city: Dict[str, Node], links_by_city: DefaultDict[str, List[Link]], eqpts_by_city: DefaultDict[str, List[Eqpt]]) Tuple[List[Node], List[Link]]
Perform sanity checks on nodes and links. Raise correct issues if xls(x) is not correct, Correct type to ROADM if more tha 2-degrees, checks duplicate links, unreferenced nodes in links, in eqpts, unreferenced link in eqpts, duplicate items
- Parameters:
nodes (List[Node]) – A list of Node objects.
links (List[Link]) – A list of Link objects.
nodes_by_city (Dict[str, Node]) – A dictionary mapping city names to Node objects.
links_by_city (DefaultDict[str, List[Link]]) – A defaultdict mapping city names to lists of Link objects.
eqpts_by_city (DefaultDict[str, List[Eqpt]]) – A defaultdict mapping city names to lists of Eqpt objects.
- Returns:
A tuple containing the validated lists of nodes and links.
- Return type:
- Raises:
NetworkTopologyError – If any issues are found during validation.
- gnpy.tools.convert.xls_to_json_data(input_filename: Path, filter_region: List[str] = None) dict
Read the Excel sheets and produce the JSON dict in GNPy format (legacy).
- Parameters:
input_filename (Path) – The path to the input XLS file.
filter_region (List[str]) – A list of regions to filter the nodes (default is None).
- Returns:
A dictionary representing the JSON data.
- Return type:
dict
gnpy.tools.json_io
Loading and saving data from JSON files in GNPy’s internal data format
- class gnpy.tools.json_io.Amp(**kwargs)
Bases:
_JsonThingList of amplifiers with their specs
- default_values = {'advance_configurations_from_json': None, 'allowed_for_design': False, 'bands': None, 'booster_variety': None, 'dgt': None, 'dual_stage_model': None, 'f_max': None, 'f_min': None, 'f_ripple_ref': None, 'gain_flatmax': None, 'gain_min': None, 'gain_ripple': 0, 'multi_band': None, 'nf0': None, 'nf_coef': None, 'nf_fit_coeff': None, 'nf_max': None, 'nf_min': None, 'nf_model': None, 'nf_ripple': 0, 'out_voa_auto': False, 'p_max': None, 'pdl': 0, 'pmd': 0, 'preamp_variety': None, 'raman': False, 'tilt_ripple': 0, 'type_def': '', 'type_variety': ''}
- classmethod from_json(extra_configs, **kwargs)
- class gnpy.tools.json_io.Fiber(**kwargs)
Bases:
_JsonThingFiber default settings
- default_values = {'dispersion': None, 'effective_area': None, 'pmd_coef': 0, 'type_variety': ''}
- class gnpy.tools.json_io.Model_dual_stage(preamp_variety, booster_variety)
Bases:
tuple- _asdict()
Return a new dict which maps field names to their values.
- _field_defaults = {}
- _fields = ('preamp_variety', 'booster_variety')
- classmethod _make(iterable)
Make a new Model_dual_stage object from a sequence or iterable
- _replace(**kwds)
Return a new Model_dual_stage object replacing specified fields with new values
- booster_variety
Alias for field number 1
- preamp_variety
Alias for field number 0
- class gnpy.tools.json_io.Model_fg(nf0)
Bases:
tuple- _asdict()
Return a new dict which maps field names to their values.
- _field_defaults = {}
- _fields = ('nf0',)
- classmethod _make(iterable)
Make a new Model_fg object from a sequence or iterable
- _replace(**kwds)
Return a new Model_fg object replacing specified fields with new values
- nf0
Alias for field number 0
- class gnpy.tools.json_io.Model_hybrid(nf_ram, gain_ram, edfa_variety)
Bases:
tuple- _asdict()
Return a new dict which maps field names to their values.
- _field_defaults = {}
- _fields = ('nf_ram', 'gain_ram', 'edfa_variety')
- classmethod _make(iterable)
Make a new Model_hybrid object from a sequence or iterable
- _replace(**kwds)
Return a new Model_hybrid object replacing specified fields with new values
- edfa_variety
Alias for field number 2
- gain_ram
Alias for field number 1
- nf_ram
Alias for field number 0
- class gnpy.tools.json_io.Model_openroadm_booster
Bases:
objectclass to hold nf model specific to OpenROADM booster
- class gnpy.tools.json_io.Model_openroadm_ila(nf_coef)
Bases:
tuple- _asdict()
Return a new dict which maps field names to their values.
- _field_defaults = {}
- _fields = ('nf_coef',)
- classmethod _make(iterable)
Make a new Model_openroadm_ila object from a sequence or iterable
- _replace(**kwds)
Return a new Model_openroadm_ila object replacing specified fields with new values
- nf_coef
Alias for field number 0
- class gnpy.tools.json_io.Model_openroadm_preamp
Bases:
objectclass to hold nf model specific to OpenROADM preamp
- class gnpy.tools.json_io.Model_vg(nf1, nf2, delta_p, orig_nf_min, orig_nf_max)
Bases:
tuple- _asdict()
Return a new dict which maps field names to their values.
- _field_defaults = {}
- _fields = ('nf1', 'nf2', 'delta_p', 'orig_nf_min', 'orig_nf_max')
- classmethod _make(iterable)
Make a new Model_vg object from a sequence or iterable
- _replace(**kwds)
Return a new Model_vg object replacing specified fields with new values
- delta_p
Alias for field number 2
- nf1
Alias for field number 0
- nf2
Alias for field number 1
- orig_nf_max
Alias for field number 4
- orig_nf_min
Alias for field number 3
- class gnpy.tools.json_io.Roadm(**kwargs)
Bases:
_JsonThingList of ROADM and their specs
- default_values = {'add_drop_osnr': 100, 'pdl': 0, 'pmd': 0, 'restrictions': {'booster_variety_list': [], 'preamp_variety_list': []}, 'roadm-path-impairments': [], 'type_variety': 'default'}
- class gnpy.tools.json_io.SI(**kwargs)
Bases:
_JsonThingSpectrum Information
- default_values = {'baud_rate': 32000000000.0, 'f_max': 196100000000000.0, 'f_min': 191350000000000.0, 'power_dbm': 0, 'power_range_db': [0, 0, 0.5], 'roll_off': 0.15, 'spacing': 50000000000.0, 'sys_margins': 0, 'tx_osnr': 45, 'tx_power_dbm': None, 'use_si_channel_count_for_design': False}
- class gnpy.tools.json_io.Span(**kwargs)
Bases:
_JsonThingSpan simulations definition
- default_values = {'EOL': 0, 'con_in': 0, 'con_out': 0, 'delta_power_range_db': None, 'length_units': 'km', 'max_fiber_lineic_loss_for_raman': 0.25, 'max_length': 150, 'max_loss': None, 'padding': 10, 'power_mode': True, 'power_slope': 0.3, 'span_loss_ref': 20.0, 'target_extended_gain': 2.5, 'voa_margin': 1, 'voa_step': 0.5}
- class gnpy.tools.json_io.Transceiver(**kwargs)
Bases:
_JsonThingList of transceivers and their modes
- default_values = {'frequency': None, 'mode': {}, 'type_variety': None}
- class gnpy.tools.json_io._JsonThing
Bases:
objectBase class for json equipment
- update_attr(default_values, kwargs, name)
Build the attributes based on kwargs dict
- gnpy.tools.json_io._check_fiber_vs_raman_fiber(equipment: dict)
Ensure that Fiber and RamanFiber with the same name define common properties equally
- gnpy.tools.json_io._check_one_request(params: dict, f_max_from_si: float)
Checks that the requested parameters are consistant (spacing vs nb channel vs transponder mode…)
- gnpy.tools.json_io._cls_for(equipment_type)
- gnpy.tools.json_io._equipment_from_json(json_data: dict, extra_configs: Dict[str, Dict]) Dict
build global dictionnary eqpt_library that stores all eqpt characteristics: edfa type type_variety, fiber type_variety from the eqpt_config.json (filename parameter) also read advanced_config_from_json file parameters for edfa if they are available: typically nf_ripple, dfg gain ripple, dgt and nf polynomial nf_fit_coeff if advanced_config_from_json file parameter is not present: use nf_model: requires nf_min and nf_max values boundaries of the edfa gain range
- gnpy.tools.json_io._roadm_restrictions_sanity_check(equipment: dict)
verifies that booster and preamp restrictions specified in roadm equipment are listed in the edfa.
- gnpy.tools.json_io._si_sanity_check(equipment)
Check that ‘default’ key correctly exists in SI list. (There must be at list one element and it must be default) If not create one entry in the list with this key.
- gnpy.tools.json_io._spectrum_from_json(json_data: dict)
JSON_data is a list of spectrum partitions each with {f_min, f_max, baud_rate, roll_off, delta_pdb, slot_width, tx_osnr, label} Creates the per freq Carrier’s dict. f_min, f_max, baud_rate, slot_width and roll_off are mandatory label, tx_osnr and delta_pdb are created if not present label should be different for each partition >>> json_data = {‘spectrum’: [{‘f_min’: 193.2e12, ‘f_max’: 193.4e12, ‘slot_width’: 50e9, ‘baud_rate’: 32e9, ‘roll_off’: 0.15, ‘delta_pdb’: 1, ‘tx_osnr’: 45, ‘tx_power_dbm’: -7}, {‘f_min’: 193.4625e12, ‘f_max’: 193.9875e12, ‘slot_width’: 75e9, ‘baud_rate’: 64e9, ‘roll_off’: 0.15}, {‘f_min’: 194.075e12, ‘f_max’: 194.075e12, ‘slot_width’: 100e9, ‘baud_rate’: 90e9, ‘roll_off’: 0.15}, {‘f_min’: 194.2e12, ‘f_max’: 194.35e12, ‘slot_width’: 50e9, ‘baud_rate’: 32e9, ‘roll_off’: 0.15}]} >>> spectrum = _spectrum_from_json(json_data[‘spectrum’]) >>> for k, v in spectrum.items(): … print(f’{k}: {v}’) … 193200000000000.0: Carrier(delta_pdb=1, baud_rate=32000000000.0, slot_width=50000000000.0, roll_off=0.15, tx_osnr=45, tx_power=0.00019952623149688798, label=’0-32.00G’) 193250000000000.0: Carrier(delta_pdb=1, baud_rate=32000000000.0, slot_width=50000000000.0, roll_off=0.15, tx_osnr=45, tx_power=0.00019952623149688798, label=’0-32.00G’) 193300000000000.0: Carrier(delta_pdb=1, baud_rate=32000000000.0, slot_width=50000000000.0, roll_off=0.15, tx_osnr=45, tx_power=0.00019952623149688798, label=’0-32.00G’) 193350000000000.0: Carrier(delta_pdb=1, baud_rate=32000000000.0, slot_width=50000000000.0, roll_off=0.15, tx_osnr=45, tx_power=0.00019952623149688798, label=’0-32.00G’) 193400000000000.0: Carrier(delta_pdb=1, baud_rate=32000000000.0, slot_width=50000000000.0, roll_off=0.15, tx_osnr=45, tx_power=0.00019952623149688798, label=’0-32.00G’) 193462500000000.0: Carrier(delta_pdb=0, baud_rate=64000000000.0, slot_width=75000000000.0, roll_off=0.15, tx_osnr=40, tx_power=0.001, label=’1-64.00G’) 193537500000000.0: Carrier(delta_pdb=0, baud_rate=64000000000.0, slot_width=75000000000.0, roll_off=0.15, tx_osnr=40, tx_power=0.001, label=’1-64.00G’) 193612500000000.0: Carrier(delta_pdb=0, baud_rate=64000000000.0, slot_width=75000000000.0, roll_off=0.15, tx_osnr=40, tx_power=0.001, label=’1-64.00G’) 193687500000000.0: Carrier(delta_pdb=0, baud_rate=64000000000.0, slot_width=75000000000.0, roll_off=0.15, tx_osnr=40, tx_power=0.001, label=’1-64.00G’) 193762500000000.0: Carrier(delta_pdb=0, baud_rate=64000000000.0, slot_width=75000000000.0, roll_off=0.15, tx_osnr=40, tx_power=0.001, label=’1-64.00G’) 193837500000000.0: Carrier(delta_pdb=0, baud_rate=64000000000.0, slot_width=75000000000.0, roll_off=0.15, tx_osnr=40, tx_power=0.001, label=’1-64.00G’) 193912500000000.0: Carrier(delta_pdb=0, baud_rate=64000000000.0, slot_width=75000000000.0, roll_off=0.15, tx_osnr=40, tx_power=0.001, label=’1-64.00G’) 193987500000000.0: Carrier(delta_pdb=0, baud_rate=64000000000.0, slot_width=75000000000.0, roll_off=0.15, tx_osnr=40, tx_power=0.001, label=’1-64.00G’) 194075000000000.0: Carrier(delta_pdb=0, baud_rate=90000000000.0, slot_width=100000000000.0, roll_off=0.15, tx_osnr=40, tx_power=0.001, label=’2-90.00G’) 194200000000000.0: Carrier(delta_pdb=0, baud_rate=32000000000.0, slot_width=50000000000.0, roll_off=0.15, tx_osnr=40, tx_power=0.001, label=’3-32.00G’) 194250000000000.0: Carrier(delta_pdb=0, baud_rate=32000000000.0, slot_width=50000000000.0, roll_off=0.15, tx_osnr=40, tx_power=0.001, label=’3-32.00G’) 194300000000000.0: Carrier(delta_pdb=0, baud_rate=32000000000.0, slot_width=50000000000.0, roll_off=0.15, tx_osnr=40, tx_power=0.001, label=’3-32.00G’) 194350000000000.0: Carrier(delta_pdb=0, baud_rate=32000000000.0, slot_width=50000000000.0, roll_off=0.15, tx_osnr=40, tx_power=0.001, label=’3-32.00G’)
- gnpy.tools.json_io._update_band(equipment: dict)
Creates a list of bands for this amplifier, and remove other parameters which are not applicable
- gnpy.tools.json_io._update_dual_stage(equipment: dict)
Update attributes of all dual stage amps with the preamp and booster attributes (defined in the equipment dictionary)
Returns the updated equiment dictionary
- gnpy.tools.json_io.convert_service_sheet(input_filename: Path, eqpt: dict, network: DiGraph, network_filename: Path | None = None, output_filename: str = '', bidir: bool = False)
Converts xls into json format services
- Parameters:
input_filename – xls(x) file containing the service sheet
eqpt – equipment library
network – network for which these services apply (required for xls inputs to correct names)
network_filename – optional network file name that was used for network creation (required for xls inputs to correct names)
output_filename – name of the file where converted data are savec
bidir – set all services bidir attribute with this bool
- gnpy.tools.json_io.disjunctions_from_json(json_data: dict) List[Disjunction]
reads the disjunction requests from the json dict and create the list of requested disjunctions for this set of requests
- gnpy.tools.json_io.find_equalisation(params: Dict, equalization_types: List[str])
Find the equalization(s) defined in params. params can be a dict or a Roadm object.
>>> roadm = {'add_drop_osnr': 100, 'pmd': 1, 'pdl': 0.5, ... 'restrictions': {'preamp_variety_list': ['a'], 'booster_variety_list': ['b']}, ... 'target_psd_out_mWperGHz': 4e-4} >>> equalization_types = ['target_pch_out_db', 'target_psd_out_mWperGHz'] >>> find_equalisation(roadm, equalization_types) {'target_pch_out_db': False, 'target_psd_out_mWperGHz': True}
- gnpy.tools.json_io.load_eqpt_topo_from_json(eqpt: dict, topology: dict, extra_equipments: Dict[str, Dict] | None = None, extra_configs: Dict[str, Dict] = {'Juniper-BoosterHG.json': {'dgt': [1.0, 1.03941448941778, 1.07773189112355, 1.11575888725852, 1.15209185089701, 1.18632744096844, 1.21911100318577, 1.24931318255134, 1.27657903892303, 1.30069883494415, 1.32210817897091, 1.3405812000038, 1.35690844654118, 1.3710092503689, 1.38430337205545, 1.3966294751726, 1.40864903907609, 1.42089447397912, 1.43476940680732, 1.44977369463316, 1.46637521309853, 1.48420288841848, 1.50335352244996, 1.5242627235492, 1.54578500307573, 1.56750088631614, 1.58973304612691, 1.61073904908309, 1.63068023161292, 1.64799163036252, 1.66286684904577, 1.6761448370895, 1.68845480656382, 1.70379790088896, 1.72461030013125, 1.75428006928365, 1.79748596476494, 1.85543800978691, 1.92915262384742, 2.01414465424155, 2.10336369905543, 2.19013043016015, 2.26678136721453, 2.33147727493671, 2.38192717604575, 2.41879254989742, 2.44342862248888, 2.4553191172498], 'f_max': 196100000000000.0, 'f_min': 191400000000000.0, 'gain_ripple': [-0.15656302345061, -0.22244242043552, -0.25188965661642, -0.23575900335007, -0.20897508375209, -0.19440221943049, -0.18324644053602, -0.18053287269681, -0.17113588777219, -0.15460322445561, -0.13550774706866, -0.10606051088777, -0.0765630234506, -0.04962835008375, -0.01319618927973, 0.01027114740367, 0.03378873534338, 0.04961788107202, 0.04494451423784, 0.0399193886097, 0.01584903685091, -0.00420121440538, -0.01847257118928, -0.02475397822447, -0.01053287269681, 0.01509526800668, 0.05921587102177, 0.1191656197655, 0.18147717755444, 0.23579878559464, 0.26941687604691, 0.27836159966498, 0.26956762981574, 0.23826109715241, 0.18936662479061, 0.1204721524288, 0.0453465242881, -0.00877407872698, -0.02199015912898, 0.00107516750419, 0.02795958961474, 0.02740682579566, -0.01028161641541, -0.05982935510889, -0.06701528475711, 0.00223094639866, 0.14157768006701, 0.15017064489112], 'nf_fit_coeff': [0.0008, 0.0272, -0.2249, 6.4902], 'nf_ripple': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}, 'std_medium_gain_advanced_config.json': {'dgt': [1.0, 1.017807767853702, 1.0356155337864215, 1.0534217504465226, 1.0712204022764056, 1.0895983485572227, 1.108555289615659, 1.1280891949729075, 1.1476135933863398, 1.1672278304018044, 1.1869318618366975, 1.2067249615595257, 1.2264996957264114, 1.2428104897182262, 1.2556591482982988, 1.2650555289898042, 1.2744470198196236, 1.2838336236692311, 1.2932153453410835, 1.3040618749785347, 1.316383926863083, 1.3301807335621048, 1.3439818461440451, 1.3598972673004606, 1.3779439775587023, 1.3981208704326855, 1.418273806730323, 1.4340878115214444, 1.445565137158368, 1.45273959485914, 1.4599103316162523, 1.4670307626366115, 1.474100442252211, 1.48111939735681, 1.488134243479226, 1.495145456062699, 1.502153039909686, 1.5097346239790443, 1.5178910621476225, 1.5266220576235803, 1.5353620432989845, 1.545374152761467, 1.5566577309558969, 1.569199764184379, 1.5817353179379183, 1.5986915141218316, 1.6201194134191075, 1.6460167077689267, 1.6719047669939942, 1.6918150918099673, 1.7057507692361864, 1.7137640932265894, 1.7217732861435076, 1.7297783508684146, 1.737780757913635, 1.7459181197626403, 1.7541903672600494, 1.7625959636196327, 1.7709972329654864, 1.7793941781790852, 1.7877868031023945, 1.7961751115773796, 1.8045606557581335, 1.8139629377087627, 1.824381436842932, 1.835814081380705, 1.847275503201129, 1.862235672444246, 1.8806927939516411, 1.9026104247588487, 1.9245345552113182, 1.9482128147680253, 1.9736443063300082, 2.0008103857988204, 2.0279625371819305, 2.055100772005235, 2.082225099873648, 2.1183028432496016, 2.16337565384239, 2.2174389328192197, 2.271520771371253, 2.322373696229342, 2.3699990328716107, 2.414398437185221, 2.4587748041127506, 2.499446286796604, 2.5364027376452056, 2.5696460593920065, 2.602860350286428, 2.630396440815385, 2.6521732021128046, 2.6681935771243177, 2.6841217449620203, 2.6947834587664494, 2.705443819238505, 2.714526681131686], 'f_max': 196125000000000.0, 'f_min': 191275000000000.0, 'gain_ripple': [0.07704745697916238, 0.06479749697916048, 0.05257029697916238, 0.040326236979161934, 0.028098946979159933, 0.01393231697916164, -0.0021726530208390216, -0.01819858302084043, -0.03218106302083967, -0.042428283020839785, -0.05095282302083959, -0.05947139302083926, -0.06968090302083851, -0.07844600302084004, -0.08407607302083875, -0.0865687230208394, -0.08906007302083907, -0.0913487130208388, -0.09343261302083761, -0.09717347302083823, -0.1027863830208382, -0.11089282302084058, -0.11963431302083904, -0.1279646530208396, -0.13525493302083902, -0.1409032730208395, -0.14591937302083835, -0.14823350302084037, -0.1484450830208388, -0.1455411330208385, -0.14160178302083892, -0.1353792530208402, -0.12789859302083784, -0.11916081302083725, -0.11041488302083735, -0.10103437302083762, -0.09101254302083817, -0.07868024302083754, -0.06468462302083822, -0.051112303020840244, -0.039618433020837784, -0.028748483020837767, -0.016475303020840215, -0.006936193020838033, -0.0015763130208377163, 0.0007104669791608842, 0.0040435869791615175, 0.006965146979162284, 0.00842583697916055, 0.00874012697916271, 0.00936596697916059, 0.01030063697916006, 0.011234826979162449, 0.013321846979160057, 0.01659282697915998, 0.023488786979161347, 0.03285456697916089, 0.04072968697916224, 0.04467697697916151, 0.04551704697916037, 0.04717897697916129, 0.04946107697915991, 0.05154489697916276, 0.05447361697916264, 0.05848224697916038, 0.06916723697916183, 0.08548825697916129, 0.10802383697916085, 0.13114358697916018, 0.15216302697916007, 0.17037189697916233, 0.1767381569791624, 0.1739275269791598, 0.15945681697916214, 0.14239527697916188, 0.12276252697916235, 0.10313984697916112, 0.08731066697916035, 0.07533675697916209, 0.07114372697916238, 0.07094413697916124, 0.07091459697916136, 0.0670723869791594, 0.054956336979159914, 0.038328296979159404, 0.017572956979162058, -0.0028138630208403015, -0.016792253020838643, -0.0246928330208398, -0.018326963020840026, -0.0036199830208403228, 0.02602813697916062, 0.06245819697916133, 0.09542181697916163, 0.11822862697916037, 0.1359703369791596], 'nf_fit_coeff': [0.000168241, 0.0469961, 0.0359549, 5.82851], 'nf_ripple': [0.4372876328262819, 0.4372876328262819, 0.41270842850729195, 0.38814205928193013, 0.36358851509924695, 0.3390191214858807, 0.30474360397422756, 0.27048596623174515, 0.23624619427167134, 0.202035284929368, 0.1694483010211072, 0.13687829834471027, 0.1043252636301016, 0.07184040799914815, 0.061288823415841555, 0.050742731588695494, 0.04020212822983975, 0.029667009055877668, 0.01913736978785662, 0.00861320615127981, -0.010157321677553965, -0.028982516728038848, -0.04779792991567815, -0.06660356886269536, -0.06256260169582961, -0.05832916277634124, -0.05409792133358102, -0.04990610405914272, -0.05078533294804249, -0.05166410580536087, -0.05254242298580185, -0.05342028484370278, -0.051742390657545205, -0.050039429413028365, -0.048337350303318156, -0.04663615264317309, -0.04493583574805963, -0.043236398934156144, -0.035622012697103154, -0.027999803010447587, -0.02038153550619876, -0.012779471908040341, -0.006436207679519103, -9.622162373026585e-05, 0.006240488799898697, 0.012573926129294415, 0.021418708618354456, 0.030289222542492025, 0.03915515813685565, 0.047899419704645264, 0.04256372893215024, 0.03723078993416436, 0.03190060058247842, 0.02657315875107553, 0.021248462316134083, 0.01605877647020772, 0.02326948274513522, 0.03047647598902483, 0.037679759069084225, 0.044883315610536455, 0.052470799141237305, 0.06005437964543287, 0.0676340601339394, 0.07521193198077789, 0.08415906712621996, 0.09310160456603413, 0.1020395478432815, 0.11079585523492333, 0.1018180306253394, 0.09284481475528361, 0.0838762040768461, 0.07482015390297145, 0.05670549786742816, 0.03860013139908377, 0.020504047353947653, 0.0024172385953583004, -0.015660302006048, -0.03372858157230583, -0.07037375788020579, -0.10709599992470213, -0.14379944379052215, -0.18048410390821285, -0.20911178784023846, -0.23772399031437283, -0.26632156113294336, -0.2949045115165272, -0.30206775396360075, -0.30915729645781326, -0.31624321721895354, -0.3233255190215882, -0.32037911876162584, -0.3172854168606314, -0.31419329378173544, -0.31110274831665313, -0.3110761646066259, -0.3110761646066259]}}) Tuple[dict, DiGraph]
Loads equipment configuration and network topology from JSON data.
- Parameters:
eqpt (dict) – Dictionary containing the equipment configuration in JSON format. It includes details about the devices to be processed and structured.
topology (dict) – Dictionary representing the network topology in JSON format, defining the structure of the network and its connections.
extra_equipments (Optional[Dict[str, Dict]]) – dictionary containing additional libraries (eg for pluggables). Key can be the file Path or any other string.
extra_configs (Dict[str, Dict]) – Additional configurations for amplifiers in the library
- Returns:
A tuple containing:
A dictionary with the processed equipment configuration.
A directed graph (DiGraph) representing the network topology, where nodes correspond to equipment and edges define their connections.
- gnpy.tools.json_io.load_equipment(filename: Path, extra_configs: Dict[str, Dict] = {'Juniper-BoosterHG.json': {'dgt': [1.0, 1.03941448941778, 1.07773189112355, 1.11575888725852, 1.15209185089701, 1.18632744096844, 1.21911100318577, 1.24931318255134, 1.27657903892303, 1.30069883494415, 1.32210817897091, 1.3405812000038, 1.35690844654118, 1.3710092503689, 1.38430337205545, 1.3966294751726, 1.40864903907609, 1.42089447397912, 1.43476940680732, 1.44977369463316, 1.46637521309853, 1.48420288841848, 1.50335352244996, 1.5242627235492, 1.54578500307573, 1.56750088631614, 1.58973304612691, 1.61073904908309, 1.63068023161292, 1.64799163036252, 1.66286684904577, 1.6761448370895, 1.68845480656382, 1.70379790088896, 1.72461030013125, 1.75428006928365, 1.79748596476494, 1.85543800978691, 1.92915262384742, 2.01414465424155, 2.10336369905543, 2.19013043016015, 2.26678136721453, 2.33147727493671, 2.38192717604575, 2.41879254989742, 2.44342862248888, 2.4553191172498], 'f_max': 196100000000000.0, 'f_min': 191400000000000.0, 'gain_ripple': [-0.15656302345061, -0.22244242043552, -0.25188965661642, -0.23575900335007, -0.20897508375209, -0.19440221943049, -0.18324644053602, -0.18053287269681, -0.17113588777219, -0.15460322445561, -0.13550774706866, -0.10606051088777, -0.0765630234506, -0.04962835008375, -0.01319618927973, 0.01027114740367, 0.03378873534338, 0.04961788107202, 0.04494451423784, 0.0399193886097, 0.01584903685091, -0.00420121440538, -0.01847257118928, -0.02475397822447, -0.01053287269681, 0.01509526800668, 0.05921587102177, 0.1191656197655, 0.18147717755444, 0.23579878559464, 0.26941687604691, 0.27836159966498, 0.26956762981574, 0.23826109715241, 0.18936662479061, 0.1204721524288, 0.0453465242881, -0.00877407872698, -0.02199015912898, 0.00107516750419, 0.02795958961474, 0.02740682579566, -0.01028161641541, -0.05982935510889, -0.06701528475711, 0.00223094639866, 0.14157768006701, 0.15017064489112], 'nf_fit_coeff': [0.0008, 0.0272, -0.2249, 6.4902], 'nf_ripple': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}, 'std_medium_gain_advanced_config.json': {'dgt': [1.0, 1.017807767853702, 1.0356155337864215, 1.0534217504465226, 1.0712204022764056, 1.0895983485572227, 1.108555289615659, 1.1280891949729075, 1.1476135933863398, 1.1672278304018044, 1.1869318618366975, 1.2067249615595257, 1.2264996957264114, 1.2428104897182262, 1.2556591482982988, 1.2650555289898042, 1.2744470198196236, 1.2838336236692311, 1.2932153453410835, 1.3040618749785347, 1.316383926863083, 1.3301807335621048, 1.3439818461440451, 1.3598972673004606, 1.3779439775587023, 1.3981208704326855, 1.418273806730323, 1.4340878115214444, 1.445565137158368, 1.45273959485914, 1.4599103316162523, 1.4670307626366115, 1.474100442252211, 1.48111939735681, 1.488134243479226, 1.495145456062699, 1.502153039909686, 1.5097346239790443, 1.5178910621476225, 1.5266220576235803, 1.5353620432989845, 1.545374152761467, 1.5566577309558969, 1.569199764184379, 1.5817353179379183, 1.5986915141218316, 1.6201194134191075, 1.6460167077689267, 1.6719047669939942, 1.6918150918099673, 1.7057507692361864, 1.7137640932265894, 1.7217732861435076, 1.7297783508684146, 1.737780757913635, 1.7459181197626403, 1.7541903672600494, 1.7625959636196327, 1.7709972329654864, 1.7793941781790852, 1.7877868031023945, 1.7961751115773796, 1.8045606557581335, 1.8139629377087627, 1.824381436842932, 1.835814081380705, 1.847275503201129, 1.862235672444246, 1.8806927939516411, 1.9026104247588487, 1.9245345552113182, 1.9482128147680253, 1.9736443063300082, 2.0008103857988204, 2.0279625371819305, 2.055100772005235, 2.082225099873648, 2.1183028432496016, 2.16337565384239, 2.2174389328192197, 2.271520771371253, 2.322373696229342, 2.3699990328716107, 2.414398437185221, 2.4587748041127506, 2.499446286796604, 2.5364027376452056, 2.5696460593920065, 2.602860350286428, 2.630396440815385, 2.6521732021128046, 2.6681935771243177, 2.6841217449620203, 2.6947834587664494, 2.705443819238505, 2.714526681131686], 'f_max': 196125000000000.0, 'f_min': 191275000000000.0, 'gain_ripple': [0.07704745697916238, 0.06479749697916048, 0.05257029697916238, 0.040326236979161934, 0.028098946979159933, 0.01393231697916164, -0.0021726530208390216, -0.01819858302084043, -0.03218106302083967, -0.042428283020839785, -0.05095282302083959, -0.05947139302083926, -0.06968090302083851, -0.07844600302084004, -0.08407607302083875, -0.0865687230208394, -0.08906007302083907, -0.0913487130208388, -0.09343261302083761, -0.09717347302083823, -0.1027863830208382, -0.11089282302084058, -0.11963431302083904, -0.1279646530208396, -0.13525493302083902, -0.1409032730208395, -0.14591937302083835, -0.14823350302084037, -0.1484450830208388, -0.1455411330208385, -0.14160178302083892, -0.1353792530208402, -0.12789859302083784, -0.11916081302083725, -0.11041488302083735, -0.10103437302083762, -0.09101254302083817, -0.07868024302083754, -0.06468462302083822, -0.051112303020840244, -0.039618433020837784, -0.028748483020837767, -0.016475303020840215, -0.006936193020838033, -0.0015763130208377163, 0.0007104669791608842, 0.0040435869791615175, 0.006965146979162284, 0.00842583697916055, 0.00874012697916271, 0.00936596697916059, 0.01030063697916006, 0.011234826979162449, 0.013321846979160057, 0.01659282697915998, 0.023488786979161347, 0.03285456697916089, 0.04072968697916224, 0.04467697697916151, 0.04551704697916037, 0.04717897697916129, 0.04946107697915991, 0.05154489697916276, 0.05447361697916264, 0.05848224697916038, 0.06916723697916183, 0.08548825697916129, 0.10802383697916085, 0.13114358697916018, 0.15216302697916007, 0.17037189697916233, 0.1767381569791624, 0.1739275269791598, 0.15945681697916214, 0.14239527697916188, 0.12276252697916235, 0.10313984697916112, 0.08731066697916035, 0.07533675697916209, 0.07114372697916238, 0.07094413697916124, 0.07091459697916136, 0.0670723869791594, 0.054956336979159914, 0.038328296979159404, 0.017572956979162058, -0.0028138630208403015, -0.016792253020838643, -0.0246928330208398, -0.018326963020840026, -0.0036199830208403228, 0.02602813697916062, 0.06245819697916133, 0.09542181697916163, 0.11822862697916037, 0.1359703369791596], 'nf_fit_coeff': [0.000168241, 0.0469961, 0.0359549, 5.82851], 'nf_ripple': [0.4372876328262819, 0.4372876328262819, 0.41270842850729195, 0.38814205928193013, 0.36358851509924695, 0.3390191214858807, 0.30474360397422756, 0.27048596623174515, 0.23624619427167134, 0.202035284929368, 0.1694483010211072, 0.13687829834471027, 0.1043252636301016, 0.07184040799914815, 0.061288823415841555, 0.050742731588695494, 0.04020212822983975, 0.029667009055877668, 0.01913736978785662, 0.00861320615127981, -0.010157321677553965, -0.028982516728038848, -0.04779792991567815, -0.06660356886269536, -0.06256260169582961, -0.05832916277634124, -0.05409792133358102, -0.04990610405914272, -0.05078533294804249, -0.05166410580536087, -0.05254242298580185, -0.05342028484370278, -0.051742390657545205, -0.050039429413028365, -0.048337350303318156, -0.04663615264317309, -0.04493583574805963, -0.043236398934156144, -0.035622012697103154, -0.027999803010447587, -0.02038153550619876, -0.012779471908040341, -0.006436207679519103, -9.622162373026585e-05, 0.006240488799898697, 0.012573926129294415, 0.021418708618354456, 0.030289222542492025, 0.03915515813685565, 0.047899419704645264, 0.04256372893215024, 0.03723078993416436, 0.03190060058247842, 0.02657315875107553, 0.021248462316134083, 0.01605877647020772, 0.02326948274513522, 0.03047647598902483, 0.037679759069084225, 0.044883315610536455, 0.052470799141237305, 0.06005437964543287, 0.0676340601339394, 0.07521193198077789, 0.08415906712621996, 0.09310160456603413, 0.1020395478432815, 0.11079585523492333, 0.1018180306253394, 0.09284481475528361, 0.0838762040768461, 0.07482015390297145, 0.05670549786742816, 0.03860013139908377, 0.020504047353947653, 0.0024172385953583004, -0.015660302006048, -0.03372858157230583, -0.07037375788020579, -0.10709599992470213, -0.14379944379052215, -0.18048410390821285, -0.20911178784023846, -0.23772399031437283, -0.26632156113294336, -0.2949045115165272, -0.30206775396360075, -0.30915729645781326, -0.31624321721895354, -0.3233255190215882, -0.32037911876162584, -0.3172854168606314, -0.31419329378173544, -0.31110274831665313, -0.3110761646066259, -0.3110761646066259]}}) Dict
Load equipment, returns equipment dict
- gnpy.tools.json_io.load_equipments_and_configs(equipment_filename: Path, extra_equipment_filenames: List[Path], extra_config_filenames: List[Path]) Dict
Loads equipment configurations and merge with additional equipment and configuration files.
- Parameters:
equipment_filename (Path) – The path to the primary equipment configuration file.
extra_equipment_filenames (List[Path]) – A list of paths to additional equipment configuration files to merge.
extra_config_filenames (List[Path]) – A list of paths to additional configuration files to include.
- Returns:
A dictionary containing the loaded equipment configurations.
- Return type:
Dict
- Notes:
If no equipment filename is provided, a default equipment configuration will be used. Additional configurations from extra_config_filenames will override the default configurations. If extra_equipment_filenames are provided, their contents will be merged into the loaded equipment.
- gnpy.tools.json_io.load_gnpy_json(filename: Path) dict
load json data. It supports both legacy ang yang formatted inputs based on yang models.
- Parameters:
filename – Path to the file to convert
- Returns:
json data in a dictionnary
- Return type:
Dict
- gnpy.tools.json_io.load_initial_spectrum(filename: Path) dict
Load spectrum to propagate, returns spectrum dict
- gnpy.tools.json_io.load_json(filename: Path) dict
load json data
- Parameters:
filename – Path to the file to convert
- Returns:
json data in a dictionnary
- Return type:
Dict
- gnpy.tools.json_io.load_network(filename: Path, equipment: dict) DiGraph
load network json or excel
- Parameters:
filename – input file to read from
equipment – equipment library
- gnpy.tools.json_io.load_requests(filename: Path, eqpt: dict, bidir: bool, network: DiGraph, network_filename: str) dict
loads the requests from a json or an excel file into a data string
- gnpy.tools.json_io.merge_equalization(params: dict, extra_params: dict) dict | None
params contains ROADM element config and extra_params default values from equipment library. If equalization is not defined in ROADM element use the one defined in equipment library. Only one type of equalization must be defined: power (target_pch_out_db) or PSD (target_psd_out_mWperGHz) or PSW (target_out_mWperSlotWidth) params and extra_params are dict
- gnpy.tools.json_io.merge_equipment(equipment: Dict, extra_equipments: Dict[str, Dict], extra_configs: Dict[str, Dict])
Merge additional equipment libraries into the base equipment dictionary. Typical case is the use of third party transceivers which are not part of a the supplier library.
raise warnings if the same reference is used on two different libraries
- gnpy.tools.json_io.network_from_json(json_data: dict, equipment: dict) DiGraph
create digraph based on json input dict and using equipment library to fill in the gaps
- gnpy.tools.json_io.network_to_json(network: DiGraph) dict
Export network graph as a json dict
- gnpy.tools.json_io.requests_from_json(json_data: dict, equipment: dict) List[PathRequest]
Extract list of requests from data parsed from JSON
- gnpy.tools.json_io.results_to_json(pathresults: List[ResultElement])
Converts a list of ResultElement objects into a JSON-compatible dictionary.
- Parameters:
pathresults – List of ResultElement objects to be converted.
- Returns:
A dictionary with a single key “response”, containing a list of the json attributes of the provided ResultElement objects.
- gnpy.tools.json_io.save_gnpy_json(obj: dict, filename: Path)
Save in json format. Export yang formatted data (RFC7951)
- Parameters:
obj (Dict) – data to be saved
filename (Path) – Path of the file where to save the data
- gnpy.tools.json_io.save_json(obj: Dict, filename: Path)
Save in json format.
- Parameters:
obj (Dict) – data to be saved
filename (Path) – Path of the file where to save the data
- gnpy.tools.json_io.save_network(network: DiGraph, filename: str)
Dump the network into a JSON file
- Parameters:
network – network to work on
filename – file to write to
gnpy.tools.plots
Graphs and plots usable from a CLI application
- gnpy.tools.plots._try_city(node)
- gnpy.tools.plots.plot_baseline(network)
- gnpy.tools.plots.plot_results(network, path, source, destination)
gnpy.tools.service_sheet
XLS parser that can be called to create a JSON request file in accordance with Yang model for requesting path computation.
See: draft-ietf-teas-yang-path-computation-01.txt
- class gnpy.tools.service_sheet.Element(uid)
Bases:
object
- class gnpy.tools.service_sheet.Request(**kwargs)
Bases:
objectDATA class for a request.
- Params request_id (int):
The unique identifier for the request.
- Params source (str):
The source node for the communication.
- Params destination (str):
The destination node for the communication.
- Params trx_type (str):
The type of transmission for the communication.
- Params mode (str, optional):
The mode of transmission. Defaults to None.
- Params spacing (float, optional):
The spacing between channels. Defaults to None.
- Params power (float, optional):
The power level for the communication. Defaults to None.
- Params nb_channel (int, optional):
The number of channels required for the communication. Defaults to None.
- Params disjoint_from (str, optional):
The node to be disjoint from. Defaults to ‘’.
- Params nodes_list (list, optional):
The list of nodes involved in the communication. Defaults to None.
- Params is_loose (str, optional):
Indicates if the communication is loose. Defaults to ‘’.
- Params path_bandwidth (float, optional):
The bandwidth required for the communication. Defaults to None.
- default_values = {'destination': None, 'disjoint_from': '', 'is_loose': None, 'mode': None, 'nb_channel': None, 'nodes_list': '', 'path_bandwidth': None, 'power': None, 'request_id': None, 'source': None, 'spacing': None, 'trx_type': None}
- update_attr(kwargs)
Updates the attributes of the node based on provided keyword arguments.
- Parameters:
kwargs – A dictionary of attributes to update.
- class gnpy.tools.service_sheet.Request_element(request_param: Request, equipment: Dict, bidir: bool)
Bases:
ElementClass that generate the request in the json format
- Params request_param (Request):
The request object containing the information for the element.
- Params equipment (dict):
The equipment configuration for the communication.
- Params bidir (bool):
Indicates if the communication is bidirectional.
- Attributes:
request_id (str): The unique identifier for the request. source (str): The source node for the communication. destination (str): The destination node for the communication. srctpid (str): The source TP ID for the communication. dsttpid (str): The destination TP ID for the communication. bidir (bool): Indicates if the communication is bidirectional. trx_type (str): The type of transmission for the communication. mode (str): The mode of transmission for the communication. spacing (float): The spacing between channels for the communication. power (float): The power level for the communication. nb_channel (int): The number of channels required for the communication. disjoint_from (list): The list of nodes to be disjoint from. nodes_list (list): The list of nodes involved in the communication. loose (str): Indicates if the communication is loose or strict. path_bandwidth (float): The bandwidth required for the communication.
- property json
Returns the json dictionnary for requests and for synchronisation vector
- property pathrequest
Creates json dictionnary for the request
- property pathsync
Creates json dictionnary for disjunction list (synchronization vector)
- gnpy.tools.service_sheet.check_end_points(pathreq: Request_element, network: DiGraph)
Raise error if end point is not correct
- gnpy.tools.service_sheet.correct_xls_route_list(network_filename: Path, network: DiGraph, pathreqlist: List[Request_element]) List[Request_element]
prepares the format of route list of nodes to be consistant with nodes names: remove wrong names, find correct names for ila, roadm and fused if the entry was xls. if it was not xls, all names in list should be exact name in the network.
- gnpy.tools.service_sheet.find_node_sugestion(n_id, corresp_roadm, corresp_fused, corresp_ila, network)
- gnpy.tools.service_sheet.parse_excel(input_filename: Path) List[Request]
Open xls_file and reads ‘Service’ sheet Returns the list of services data in Request class
- gnpy.tools.service_sheet.parse_service_sheet(service_sheet, is_xlsx) Generator[Request, None, None]
reads each column according to authorized fieldnames. order is not important.
- gnpy.tools.service_sheet.read_service_sheet(input_filename: Path, eqpt: Dict, network: DiGraph, network_filename: Path = None, bidir: bool = False) Dict
converts a service sheet into a json structure
gnpy.tools.worker_utils
Common code for CLI examples and API
- gnpy.tools.worker_utils.check_request_path_ids(rqs: List[PathRequest])
check that request ids are unique. Non unique ids, may mess the computation: better to stop the computation
- gnpy.tools.worker_utils.designed_network(equipment: dict, network: DiGraph, source: str = None, destination: str = None, nodes_list: List[str] = None, loose_list: List[str] = None, initial_spectrum: dict = None, no_insert_edfas: bool = False, args_power: str | float | int = None, service_req: PathRequest = None) Tuple[DiGraph, PathRequest, PathRequest]
Build the reference channels based on inputs and design the network for this reference channel, and build the channel to be propagated for the single transmission script.
Reference channel (target input power in spans, nb of channels, transceiver output power) is built using equipment[‘SI’] information. If indicated, with target input power in spans is updated with args_power. Channel to be propagated is using the same channel reference, except if different settings are provided with service_req and initial_spectrum. The service to be propagated uses specified source, destination and list nodes_list of include nodes constraint except if the service_req is specified.
Args: - equipment: a dictionary containing equipment information. - network: a directed graph representing the initial network. - no_insert_edfas: a boolean indicating whether to insert EDFAs in the network. - args_power: the power to be used for the network design. - service_req: the service request the user wants to propagate. - source: the source node for the channel to be propagated if no service_req is specified. - destination: the destination node for the channel to be propagated if no service_req is specified. - nodes_list: a list of nodes to be included ifor the channel to be propagated if no service_req is specified. - loose_list: a list of loose nodes to be included in the network design. - initial_spectrum: a dictionary representing the initial spectrum to propagate.
Returns: - The designed network. - The channel to propagate. - The reference channel used for the design.
- gnpy.tools.worker_utils.planning(network: DiGraph, equipment: dict, data: dict, redesign: bool = False, user_policy: str = 'first_fit') Tuple[List[OMS], List, List, List[PathRequest], List[Disjunction], List[ResultElement]]
Run planning data contain the service dict from json redesign True means that network is redesign using each request as reference channel when False it means that the design is made once and successive propagation use the settings computed with this design.
- gnpy.tools.worker_utils.transmission_simulation(equipment: dict, network: DiGraph, req: PathRequest, ref_req: PathRequest) Tuple[list, List[list], List[float | int], SpectralInformation]
Run simulation and returms the propagation result for each power sweep iteration. Args: - equipment: a dictionary containing equipment information. - network: network after being designed using ref_req. Any missing information (amp gain or delta_p) must have been filled using ref_req as reference channel previuos to this function. - req: channel to be propagated. - ref_req: the reference channel used for filling missing information in the network. In case of power sweep, network is redesigned using ref_req whose target input power in span is updated with the power step.
Returns a tuple containing: - path: last propagated path. Power sweep is not possible with gain mode (as gain targets are used) - propagations: list of propagated path for each power iteration - powers_dbm: list of power used for the power sweep - infos: last propagated spectral information