.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\07-Circuit\Reports.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_07-Circuit_Reports.py: Circuit: automatic report creation ---------------------------------- This example shows how you can use PyAEDT to create reports automatically using a JSON file. .. GENERATED FROM PYTHON SOURCE LINES 8-11 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports and set the local path to the path for PyAEDT. .. GENERATED FROM PYTHON SOURCE LINES 11-20 .. code-block:: Python import os from IPython.display import Image import pyaedt # Set local path to path for PyAEDT temp_folder = pyaedt.generate_unique_folder_name() project_path = pyaedt.downloads.download_custom_reports(destination=temp_folder) .. GENERATED FROM PYTHON SOURCE LINES 21-24 Set AEDT version ~~~~~~~~~~~~~~~~ Set AEDT version. .. GENERATED FROM PYTHON SOURCE LINES 24-27 .. code-block:: Python aedt_version = "2024.1" .. GENERATED FROM PYTHON SOURCE LINES 28-34 Set non-graphical mode ~~~~~~~~~~~~~~~~~~~~~~ Set non-graphical mode. You can set ``non_graphical`` either to ``True`` or ``False``. The Boolean parameter ``new_thread`` defines whether to create a new instance of AEDT or try to connect to an existing instance of it. .. GENERATED FROM PYTHON SOURCE LINES 34-38 .. code-block:: Python non_graphical = True NewThread = True .. GENERATED FROM PYTHON SOURCE LINES 39-43 Launch AEDT with Circuit ~~~~~~~~~~~~~~~~~~~~~~~~ Launch AEDT with Circuit. The :class:`pyaedt.Desktop` class initializes AEDT and starts the specified version in the specified mode. .. GENERATED FROM PYTHON SOURCE LINES 43-51 .. code-block:: Python cir = pyaedt.Circuit(projectname=os.path.join(project_path, 'CISPR25_Radiated_Emissions_Example23R1.aedtz'), non_graphical=non_graphical, specified_version=aedt_version, new_desktop_session=True ) cir.analyze() .. rst-class:: sphx-glr-script-out .. code-block:: none C:\actions-runner\_work\_tool\Python\3.10.9\x64\lib\subprocess.py:1072: ResourceWarning: subprocess 7760 is still running _warn("subprocess %s is still running" % self.pid, C:\actions-runner\_work\pyaedt\pyaedt\testenv\lib\site-packages\pyaedt\generic\settings.py:368: ResourceWarning: unclosed file <_io.TextIOWrapper name='D:\\Temp\\pyaedt_ansys.log' mode='a' encoding='cp1252'> self._logger = val True .. GENERATED FROM PYTHON SOURCE LINES 52-59 Create spectrum report ~~~~~~~~~~~~~~~~~~~~~~ Create a spectrum report. You can use a JSON file to create a simple setup or a fully customized one. The following code creates a simple setup and changes the JSON file to customize it. In a spectrum report, you can add limitilines and notes and edit axes, the grid, and the legend. You can create custom reports in non-graphical mode in AEDT 2023 R2 and later. .. GENERATED FROM PYTHON SOURCE LINES 59-64 .. code-block:: Python report1 = cir.post.create_report_from_configuration(os.path.join(project_path,'Spectrum_CISPR_Basic.json')) out = cir.post.export_report_to_jpg(cir.working_directory, report1.plot_name) Image(out) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 65-68 Create spectrum report ~~~~~~~~~~~~~~~~~~~~~~ Every aspect of the report can be customized. .. GENERATED FROM PYTHON SOURCE LINES 68-72 .. code-block:: Python report1_full = cir.post.create_report_from_configuration(os.path.join(project_path,'Spectrum_CISPR_Custom.json')) out = cir.post.export_report_to_jpg(cir.working_directory, report1_full.plot_name) Image(out) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 73-79 Create transient report ~~~~~~~~~~~~~~~~~~~~~~~ Create a transient report. You can read and modify the JSON file before running the script. The following code modifies the traces before generating the report. You can create custom reports in non-graphical mode in AEDT 2023 R2 and later. .. GENERATED FROM PYTHON SOURCE LINES 79-87 .. code-block:: Python props = pyaedt.general_methods.read_json(os.path.join(project_path, 'Transient_CISPR_Custom.json')) report2 = cir.post.create_report_from_configuration(input_dict=props, solution_name="NexximTransient") out = cir.post.export_report_to_jpg(cir.working_directory, report2.plot_name) Image(out) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 88-92 Create transient report ~~~~~~~~~~~~~~~~~~~~~~~ Property dictionary can be customized in any aspect and new report can be created easily. In this example the curve name is customized. .. GENERATED FROM PYTHON SOURCE LINES 92-99 .. code-block:: Python props["expressions"] = {"V(Battery)": {}, "V(U1_VDD)": {}} props["plot_name"] = "Battery Voltage" report3 = cir.post.create_report_from_configuration(input_dict=props, solution_name="NexximTransient") out = cir.post.export_report_to_jpg(cir.working_directory, report3.plot_name) Image(out) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 100-104 Create eye diagram ~~~~~~~~~~~~~~~~~~ Create an eye diagram. If the JSON file contains an eye mask, you can create an eye diagram and fully customize it. .. GENERATED FROM PYTHON SOURCE LINES 104-109 .. code-block:: Python report4 = cir.post.create_report_from_configuration(os.path.join(project_path, 'EyeDiagram_CISPR_Basic.json')) out = cir.post.export_report_to_jpg(cir.working_directory, report4.plot_name) Image(out) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 110-114 Create eye diagram ~~~~~~~~~~~~~~~~~~ You can create custom reports in non-graphical mode in AEDT 2023 R2 and later. .. GENERATED FROM PYTHON SOURCE LINES 114-119 .. code-block:: Python report4_full = cir.post.create_report_from_configuration(os.path.join(project_path, 'EyeDiagram_CISPR_Custom.json')) out = cir.post.export_report_to_jpg(cir.working_directory, report4_full.plot_name) Image(out) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 120-122 This is how the spectrum looks like .. image:: Resources/spectrum_plot.png .. GENERATED FROM PYTHON SOURCE LINES 124-127 Save project and close AEDT ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Save the project and close AEDT. .. GENERATED FROM PYTHON SOURCE LINES 127-131 .. code-block:: Python cir.save_project() print("Project Saved in {}".format(cir.project_path)) cir.release_desktop() .. rst-class:: sphx-glr-script-out .. code-block:: none Project Saved in D:/Temp/pyaedt_prj_KH7/custom_reports/ True .. rst-class:: sphx-glr-timing **Total running time of the script:** (1 minutes 15.128 seconds) .. _sphx_glr_download_examples_07-Circuit_Reports.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Reports.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Reports.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_