Commit Graph

25 Commits

Author SHA1 Message Date
AndreaDAmico
9a7f94a391 cleaning: minor changes and specific numpy imports in utils and science_utils.
Change-Id: I57cd9075dd0a523a90131fbd8747519cf6554900
2020-11-19 14:57:57 +00:00
Jan Kundrát
9e74e8b0a0 De-JSONify gnpy.core
Change-Id: I2657f3174209bef5912c7d0809fee876830ad11c
2020-05-23 20:44:51 +02:00
Jan Kundrát
07eb2dd13a Refactoring: conversion functions instead of gnpy.core.units.UNITS
The TL;DR behind this patch is that it's better to have a utility
conversion function instead of having multiplier LUT and open code which
implements the conversion.

The FiberParams handling looked fishy -- apparently, it was keeping the
multiplier around, but it was unconditionally setting the units to
meters, anyway. Given that the units were not being preserved anyway
(everything got converted to meters), and that the multipler was not
used anywhere, let's refactor the code to just convert to meters using
our new utility function, and remove the unused argument.

Change-Id: Id886d409a4046f980eed569265baefd97db841bd
2020-05-23 13:50:25 +02:00
Jan Kundrát
0823f8de46 Move automatic_nch, automatic_fmax into utils
I think that gnpy/core/equipment.py should contain only stuff which
prepares the equipment_config, not anything "lower level" that is reused
from other places.

Change-Id: I0cd593fd3e5558178ddd0ad8fff5c596e022894a
2020-05-23 13:08:24 +02:00
Jan Kundrát
46f89aa770 coding style: autopep8 in an aggressive mode (-aaaaaaaaaa)
I decided to skip the following chunk of the diff because I think that
it would actually made the code a bit harder to read:

diff --git gnpy/core/service_sheet.py gnpy/core/service_sheet.py
index 9965840..9834111 100644
--- gnpy/core/service_sheet.py
+++ gnpy/core/service_sheet.py
@@ -41,8 +41,22 @@ logger = getLogger(__name__)

 class Request(namedtuple('Request', 'request_id source destination trx_type mode \
     spacing power nb_channel disjoint_from nodes_list is_loose path_bandwidth')):
-    def __new__(cls, request_id, source, destination, trx_type,  mode=None, spacing=None, power=None, nb_channel=None, disjoint_from='',  nodes_list=None, is_loose='', path_bandwidth=None):
-        return super().__new__(cls, request_id, source, destination, trx_type, mode, spacing, power, nb_channel, disjoint_from,  nodes_list, is_loose, path_bandwidth)
+    def __new__(
+            cls,
+            request_id,
+            source,
+            destination,
+            trx_type,
+            mode=None,
+            spacing=None,
+            power=None,
+            nb_channel=None,
+            disjoint_from='',
+            nodes_list=None,
+            is_loose='',
+            path_bandwidth=None):
+        return super().__new__(cls, request_id, source, destination, trx_type, mode, spacing,
+                               power, nb_channel, disjoint_from, nodes_list, is_loose, path_bandwidth)

 # Type for output data:  // from dutc

diff --git tests/test_automaticmodefeature.py tests/test_automaticmodefeature.py
index 0e5f633..5ba5881 100644
--- tests/test_automaticmodefeature.py
+++ tests/test_automaticmodefeature.py
@@ -32,7 +32,26 @@ eqpt_library_name = Path(__file__).parent.parent / 'tests/data/eqpt_config.json'
 @pytest.mark.parametrize("net", [network_file_name])
 @pytest.mark.parametrize("eqpt", [eqpt_library_name])
 @pytest.mark.parametrize("serv", [service_file_name])
-@pytest.mark.parametrize("expected_mode", [['16QAM', 'PS_SP64_1', 'PS_SP64_1', 'PS_SP64_1', 'mode 2 - fake', 'mode 2', 'PS_SP64_1', 'mode 3', 'PS_SP64_1', 'PS_SP64_1', '16QAM', 'mode 1', 'PS_SP64_1', 'PS_SP64_1', 'mode 1', 'mode 2', 'mode 1', 'mode 2', 'nok']])
+@pytest.mark.parametrize("expected_mode",
+                         [['16QAM',
+                           'PS_SP64_1',
+                           'PS_SP64_1',
+                           'PS_SP64_1',
+                           'mode 2 - fake',
+                           'mode 2',
+                           'PS_SP64_1',
+                           'mode 3',
+                           'PS_SP64_1',
+                           'PS_SP64_1',
+                           '16QAM',
+                           'mode 1',
+                           'PS_SP64_1',
+                           'PS_SP64_1',
+                           'mode 1',
+                           'mode 2',
+                           'mode 1',
+                           'mode 2',
+                           'nok']])
 def test_automaticmodefeature(net, eqpt, serv, expected_mode):
     equipment = load_equipment(eqpt)
     network = load_network(net, equipment)

Change-Id: I522c45c079b3a9540568657e2ae0a4bfc5fb1272
2020-05-19 12:53:11 +02:00
Jan Kundrát
3548ed74e2 coding style: autopep --in-place --recursive --jobs 4 --max-line-length 120 gnpy/ tests/
Change-Id: I2f0fca5aa1314f9bb546a3e6dc712a42580cd562
2020-05-19 12:40:00 +02:00
Jan Kundrát
7ab93e7cd9 tests: frequency to wavelength
I decided to keep it around because I know that some people would like
to see those nanometers. Let's make sure it works.

Change-Id: Ib279cc8380a77f478da7a2bbc1e045a718446404
2020-04-30 17:30:55 +02:00
Jan Kundrát
9a54dbab43 Remove unused functions
Given that everything else just uses these constants as imported from
numpy, there's no point keeping these wrappers around.

Change-Id: I0e19e05f40dc79d8005e915cf3ffb5e36328421a
2020-04-30 17:30:55 +02:00
Jan Kundrát
fc03be8bbe tests: use doctest instead of an explicit runner
...and expand the coverage a wee bit while we're at it as well.

Change-Id: I0de8445dc29f46e5f238bff0ca0e1f63fe19712d
2020-04-30 17:30:55 +02:00
Jan Kundrát
5a1e3f30b3 docs: Fix all sphinx warnings
...and also enforce a warning-free build within the CI.

Change-Id: Ia406a0a1ca2e89ceaa0288ae82128fa9427fe066
2020-03-27 15:07:19 +01:00
Jan Kundrát
029bac4b03 utils: more descriptive name for itufl
This might have nothing to do with the ITU frequency grid (it's really
just about a uniform distribution), so let's give it a more readable
name and more readable parameters.
2019-10-06 20:43:50 +02:00
Jan Kundrát
a27ad57220 Do not use confusing default values
This looks like the root cause of bug #243, the default values suggested
that this function works in THz.

These defaults are not used anywhere, so let's get rid of something
which adds no value and actively confuses people.
2019-10-06 20:38:31 +02:00
Jan Kundrát
8d31d924f2 Remove unused function 2019-10-06 20:37:24 +02:00
Jan Kundrát
22acd88d44 Utility functions for pruning and merging
Co-authored-by: Esther Le Rouzic <esther.lerouzic@orange.com>
2019-06-06 11:42:05 +02:00
Jean-Luc Auge
94ff8e6beb Advanced amplifier model improvement
-add f_min & f_max frequency definition in amplifier json
-improve interpolation algorithm to support length differences between the spectrum information and the amplifier ripple and dgt frequency definition

Signed-off-by: Jean-Luc Auge <jeanluc.auge@orange.com>
2019-04-04 17:14:25 +02:00
Jean-Luc Auge
46d25df241 add Tx_osnr at the end of the transmission
Signed-off-by: Jean-Luc Auge <jeanluc.auge@orange.com>
2019-01-22 18:05:19 +01:00
James Powell
4f4f05abdf allow JSON to encode UTF-8 2018-10-29 11:17:13 -04:00
James Powell
bcf93e1d9f enforce utf-8 encoding for reading/writing JSON 2018-10-29 11:14:31 -04:00
James Powell
83444b329e strip whitespace 2018-10-14 20:54:22 -04:00
Jean-Luc Auge
310d32dcea Generic write_csv in utils to save simulation results
tranmsission_main simulation results are saved to simulation_result.csv

Signed-off-by: Jean-Luc Auge <jeanluc.auge@orange.com>
2018-09-13 14:30:33 +02:00
Jean-Luc Auge
225fb1ec0c Save network to json after build (auto design)
-Promote incremental and iterative network design
-Automatic saving of a "network-name_auto_design.json" file
-Results of the autodesign (additional amplifiers, configuration) are
saved to this ..._auto_design.json file
-This file can then be used to run a new simulation just like a normal
json input file

Signed-off-by: Jean-Luc Auge <jeanluc.auge@orange.com>
2018-09-04 09:34:57 +02:00
Jean-Luc Auge
d1c7489768 Automatic design Delta power / span
* automatic design (when amplifiers are missing from network topology
input) finds the optimum power difference between spans
* The range of this optimum power difference is defined in
eqpt_config[Spans][delta_power_range_db] = [min, max, step]

Signed-off-by: Jean-Luc Auge <jeanluc.auge@orange.com>
2018-08-02 12:30:05 +02:00
James Powell
c9ece6ad7c use scipy.constants 2018-03-20 22:44:17 -04:00
James Powell
a6265c1b8d document modules 2018-03-20 21:32:02 -04:00
Gilad Goldfarb
ca7b993d95 edfa model, json config loading, added utils (#26) 2018-02-13 12:11:10 -05:00