From 5448cabcbbb7a041ef1bcec924b6a472f3d52433 Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Thu, 4 Jul 2024 17:47:40 +0200 Subject: [PATCH 1/7] Added visualization to documentation --- doc/source/API/Post.rst | 23 -------------- doc/source/API/Visualization.rst | 48 +++++++++++++++++++++++++++++ doc/source/API/index.rst | 1 + pyaedt/generic/plot.py | 9 ++++-- pyaedt/generic/touchstone_parser.py | 10 +++--- 5 files changed, 61 insertions(+), 30 deletions(-) create mode 100644 doc/source/API/Visualization.rst diff --git a/doc/source/API/Post.rst b/doc/source/API/Post.rst index 440c8251794..4254e148217 100644 --- a/doc/source/API/Post.rst +++ b/doc/source/API/Post.rst @@ -21,9 +21,6 @@ plots in AEDT. They are accessible through the ``post`` property. :nosignatures: AdvancedPostProcessing.PostProcessor - solutions.SolutionData - solutions.FieldPlot - solutions.FfdSolutionData .. code:: python @@ -77,26 +74,6 @@ PyAEDT has classes for manipulating any report property. report_templates.Spectral -Plot fields and data outside AEDT -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -PyAEDT supports external report capabilities available with installed third-party -packages like `numpy `_, -`pandas `_, `matplotlib `_, -and `pyvista `_. - -.. currentmodule:: pyaedt.modules - -.. autosummary:: - :toctree: _autosummary - :nosignatures: - - - solutions.SolutionData - solutions.FieldPlot - solutions.FfdSolutionData - AdvancedPostProcessing.ModelPlotter - - Icepak monitors ~~~~~~~~~~~~~~~ diff --git a/doc/source/API/Visualization.rst b/doc/source/API/Visualization.rst new file mode 100644 index 00000000000..0d0be39084f --- /dev/null +++ b/doc/source/API/Visualization.rst @@ -0,0 +1,48 @@ +Visualization +============= +This section lists modules for creating and editing data outside AEDT. + +Plot fields and data outside AEDT +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +PyAEDT supports external report capabilities available with installed third-party +packages like `numpy `_, +`pandas `_, `matplotlib `_, +and `pyvista `_. + + +.. currentmodule:: pyaedt.modules + +.. autosummary:: + :toctree: _autosummary + :nosignatures: + + solutions.SolutionData + solutions.FieldPlot + solutions.FfdSolutionData + + +.. currentmodule:: pyaedt.generic + +.. autosummary:: + :toctree: _autosummary + :nosignatures: + + plot.ModelPlotter + touchstone_parser.TouchstoneData + + +.. code:: python + + from pyaedt.generic.touchstone_parser import TouchstoneData + + ts1 = TouchstoneData(touchstone_file=os.path.join(test_T44_dir, "port_order_1234.s8p")) + assert ts1.get_mixed_mode_touchstone_data() + ts2 = TouchstoneData(touchstone_file=os.path.join(test_T44_dir, "port_order_1324.s8p")) + assert ts2.get_mixed_mode_touchstone_data(port_ordering="1324") + + assert ts1.plot_insertion_losses(plot=False) + assert ts1.get_worst_curve(curve_list=ts1.get_return_loss_index(), plot=False) + ... + + + diff --git a/doc/source/API/index.rst b/doc/source/API/index.rst index 923dfa7880e..c1b534367df 100644 --- a/doc/source/API/index.rst +++ b/doc/source/API/index.rst @@ -89,6 +89,7 @@ Example with ``Desktop`` class implicit initialization: Mesh Setup Post + Visualization DesktopMessenger Optimetrics Variables diff --git a/pyaedt/generic/plot.py b/pyaedt/generic/plot.py index 549f7550a6c..b5aa99ba256 100644 --- a/pyaedt/generic/plot.py +++ b/pyaedt/generic/plot.py @@ -1733,8 +1733,13 @@ def s_callback(): # pragma: no cover self.pv.screenshot(exp, return_img=False) self.pv.add_key_event("s", s_callback) - if export_image_path: - self.pv.show(screenshot=export_image_path, full_screen=True) + if export_image_path: # pragma: no cover + supported_export = [".svg", ".pdf", ".eps", ".ps", ".tex"] + extension = os.path.splitext(export_image_path)[1] + if extension in supported_export: + self.pv.save_graphic(export_image_path, raster=raster, painter=painter) + else: + self.pv.show(screenshot=export_image_path, full_screen=True) elif show and self.is_notebook: # pragma: no cover self.pv.show() # pragma: no cover elif show: diff --git a/pyaedt/generic/touchstone_parser.py b/pyaedt/generic/touchstone_parser.py index bed51504ac1..54e74754739 100644 --- a/pyaedt/generic/touchstone_parser.py +++ b/pyaedt/generic/touchstone_parser.py @@ -70,7 +70,7 @@ def _parse_ports_name(file): class TouchstoneData(rf.Network): - """Contains data information from Touchstone Read call""" + """Contains data information from Touchstone Read call.""" def __init__(self, solution_data=None, touchstone_file=None): if solution_data is not None: @@ -239,7 +239,7 @@ def get_mixed_mode_touchstone_data(self, num_of_diff_ports=None, port_ordering=" Returns ------- - TouchstoneData + class:`pyaedt.generic.touchstone_parser.TouchstoneData` """ ts_diff = copy(self) @@ -309,8 +309,6 @@ def get_insertion_loss_index_from_prefix(self, tx_prefix, rx_prefix): Parameters ---------- - expressions : - list of Drivers to include or all nets tx_prefix : str Prefix for TX (eg. "DIE"). rx_prefix : str @@ -336,7 +334,7 @@ def get_insertion_loss_index_from_prefix(self, tx_prefix, rx_prefix): def get_next_xtalk_index(self, tx_prefix=""): """Get the list of all the Near End XTalk a list of excitation. Optionally prefix can be used to retrieve driver names. - Example: excitation_names ["1", "2", "3"] output ["S(1,2)", "S(1,3)", "S(2,3)"] + Example: excitation_names ["1", "2", "3"] output ["S(1,2)", "S(1,3)", "S(2,3)"]. Parameters ---------- @@ -448,6 +446,8 @@ def get_worst_curve(self, freq_min=None, freq_max=None, worst_is_higher=True, cu boolean. if True, the worst curve is the one with higher mean value. Default value is ``None``. curve_list : list List of [m,n] index of curves on which to search. None to search on all curves. Default value is ``None``. + plot : bool, optional + Whether to plot or not the chart. Returns ------- From 9e8916396d9765999c872abe750005692b9ced47 Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Thu, 4 Jul 2024 17:58:45 +0200 Subject: [PATCH 2/7] Added visualization to documentation --- doc/source/API/Visualization.rst | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/source/API/Visualization.rst b/doc/source/API/Visualization.rst index 0d0be39084f..3c057ebc266 100644 --- a/doc/source/API/Visualization.rst +++ b/doc/source/API/Visualization.rst @@ -21,14 +21,24 @@ and `pyvista `_. solutions.FfdSolutionData -.. currentmodule:: pyaedt.generic + +.. currentmodule:: pyaedt.generic.plot .. autosummary:: :toctree: _autosummary :nosignatures: - plot.ModelPlotter - touchstone_parser.TouchstoneData + ModelPlotter + + +.. currentmodule:: pyaedt.generic.touchstone_parser + +.. autosummary:: + :toctree: _autosummary + :nosignatures: + + TouchstoneData + .. code:: python From 4edc110483b0b3f0c0a6acbb357c13615aa147f1 Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Thu, 4 Jul 2024 18:01:20 +0200 Subject: [PATCH 3/7] Added visualization to documentation --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index d3ad8da3d0f..c07884e2481 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -122,6 +122,8 @@ doc-no-examples = [ #"sphinx-notfound-page", #"sphinxcontrib-websupport", "sphinx_design>=0.4.0,<0.7", + "matplotlib>=3.5.0,<3.9", + "scikit-rf>=0.30.0,<1.2", ] all = [ "imageio>=2.30.0,<2.35", From 203a3783838b1596b188f5ebe953dfd09b6bfbec Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Thu, 4 Jul 2024 18:12:10 +0200 Subject: [PATCH 4/7] Added visualization to documentation --- doc/source/API/Visualization.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/API/Visualization.rst b/doc/source/API/Visualization.rst index 3c057ebc266..9d041e73d7e 100644 --- a/doc/source/API/Visualization.rst +++ b/doc/source/API/Visualization.rst @@ -35,6 +35,7 @@ and `pyvista `_. .. autosummary:: :toctree: _autosummary + :no-inherited-members: :nosignatures: TouchstoneData From 2abdc31aa313d3c7edf54ac067b35ff88df0e00c Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Thu, 4 Jul 2024 20:49:46 +0200 Subject: [PATCH 5/7] Added visualization to documentation --- doc/source/API/Visualization.rst | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/doc/source/API/Visualization.rst b/doc/source/API/Visualization.rst index 9d041e73d7e..3453314bf3f 100644 --- a/doc/source/API/Visualization.rst +++ b/doc/source/API/Visualization.rst @@ -33,13 +33,7 @@ and `pyvista `_. .. currentmodule:: pyaedt.generic.touchstone_parser -.. autosummary:: - :toctree: _autosummary - :no-inherited-members: - :nosignatures: - - TouchstoneData - +.. autoclass:: TouchstoneData .. code:: python @@ -55,5 +49,3 @@ and `pyvista `_. assert ts1.get_worst_curve(curve_list=ts1.get_return_loss_index(), plot=False) ... - - From 1aa1d623f1b122a790720bcd9dc64c80971f9d45 Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Thu, 4 Jul 2024 21:00:48 +0200 Subject: [PATCH 6/7] Added visualization to documentation --- doc/source/API/Visualization.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/source/API/Visualization.rst b/doc/source/API/Visualization.rst index 3453314bf3f..34e763ecabc 100644 --- a/doc/source/API/Visualization.rst +++ b/doc/source/API/Visualization.rst @@ -21,6 +21,9 @@ and `pyvista `_. solutions.FfdSolutionData +ModelPlotter is a class that benefits of `pyvista `_ package and allows to generate +models and 3D plots. + .. currentmodule:: pyaedt.generic.plot @@ -31,11 +34,16 @@ and `pyvista `_. ModelPlotter +The class TouchstoneData instead, is based on `scikit-rf `_, + + .. currentmodule:: pyaedt.generic.touchstone_parser .. autoclass:: TouchstoneData +Here an example on how to use TouchstoneData class. + .. code:: python from pyaedt.generic.touchstone_parser import TouchstoneData From d4b0c8328ce955c4ccad95037c1db1da76c5e8d7 Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Thu, 11 Jul 2024 16:26:34 +0200 Subject: [PATCH 7/7] fixed bug --- pyaedt/generic/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/generic/plot.py b/pyaedt/generic/plot.py index b5aa99ba256..c39cdfd18ef 100644 --- a/pyaedt/generic/plot.py +++ b/pyaedt/generic/plot.py @@ -1737,7 +1737,7 @@ def s_callback(): # pragma: no cover supported_export = [".svg", ".pdf", ".eps", ".ps", ".tex"] extension = os.path.splitext(export_image_path)[1] if extension in supported_export: - self.pv.save_graphic(export_image_path, raster=raster, painter=painter) + self.pv.save_graphic(export_image_path) else: self.pv.show(screenshot=export_image_path, full_screen=True) elif show and self.is_notebook: # pragma: no cover