From ece10db12b7ad4c1807d70a9b48909e23fa6c579 Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Mon, 25 Mar 2024 15:33:55 +0100 Subject: [PATCH 01/22] fix typos --- doc/source/User_guide/postprocessing.rst | 2 +- .../03-Maxwell/Maxwell2D_Electrostatic.py | 3 +- .../Maxwell2D_PMSynchronousMotor.py | 7 +- examples/03-Maxwell/Maxwell3DTeam7.py | 6 +- .../03-Maxwell/Maxwell3D_Team3_bath_plate.py | 2 +- examples/05-Q3D/Q3D_DC_IR.py | 2 +- examples/06-Multiphysics/MRI.py | 12 +- .../Maxwell3D_Icepak_2Way_Coupling.py | 14 +- pyaedt/modules/AdvancedPostProcessing.py | 4 +- pyaedt/modules/PostProcessor.py | 153 ++++++++++-------- pyaedt/modules/solutions.py | 36 +++-- 11 files changed, 128 insertions(+), 113 deletions(-) diff --git a/doc/source/User_guide/postprocessing.rst b/doc/source/User_guide/postprocessing.rst index 401acf4b5a9..3f1a2d5c583 100644 --- a/doc/source/User_guide/postprocessing.rst +++ b/doc/source/User_guide/postprocessing.rst @@ -68,7 +68,7 @@ You can plot the field plot directly in HFSS and export it to image files. plot1 = hfss.post.create_fieldplot_cutplane(objlist=cutlist, quantityName=quantity_name, setup_name=setup_name, - intrinsincDict=intrinsic) + intrinsic_dict=intrinsic) .. image:: ../Resources/field_plot.png diff --git a/examples/03-Maxwell/Maxwell2D_Electrostatic.py b/examples/03-Maxwell/Maxwell2D_Electrostatic.py index c25959d110c..e6c315df8cd 100644 --- a/examples/03-Maxwell/Maxwell2D_Electrostatic.py +++ b/examples/03-Maxwell/Maxwell2D_Electrostatic.py @@ -177,8 +177,7 @@ # and as ``In surface objects`` only the region. plot = M2D.post.create_fieldplot_line_traces(seeding_faces=["Ground", "Electrode", "Region"], - in_volume_tracing_objs="Region", - plot_name="LineTracesTest") + in_volume_tracing_objs="Region", plot_name="LineTracesTest") ################################################################################### # Update Field Line Traces Plot diff --git a/examples/03-Maxwell/Maxwell2D_PMSynchronousMotor.py b/examples/03-Maxwell/Maxwell2D_PMSynchronousMotor.py index b49e9ca4360..4f66e4e6df1 100644 --- a/examples/03-Maxwell/Maxwell2D_PMSynchronousMotor.py +++ b/examples/03-Maxwell/Maxwell2D_PMSynchronousMotor.py @@ -723,11 +723,8 @@ def create_cs_magnets(pm_id, cs_name, point_direction): # formerly created when the section is applied. faces_reg = mod2D.get_object_faces(object_list[1].name) # Region -plot1 = M2D.post.create_fieldplot_surface(objlist=faces_reg, - quantityName='Flux_Lines', - intrinsincDict={ - "Time": M2D.variable_manager.variables["StopTime"].evaluated_value}, - plot_name="Flux_Lines") +plot1 = M2D.post.create_fieldplot_surface(objlist=faces_reg, quantityName='Flux_Lines', intrinsic_dict={ + "Time": M2D.variable_manager.variables["StopTime"].evaluated_value}, plot_name="Flux_Lines") ########################################################## # Export a field plot to an image file diff --git a/examples/03-Maxwell/Maxwell3DTeam7.py b/examples/03-Maxwell/Maxwell3DTeam7.py index 08c7ce89066..2fcda779b29 100644 --- a/examples/03-Maxwell/Maxwell3DTeam7.py +++ b/examples/03-Maxwell/Maxwell3DTeam7.py @@ -424,9 +424,9 @@ surf_list = m3d.modeler.get_object_faces("Plate") intrinsic_dict = {"Freq": "200Hz", "Phase": "0deg"} -m3d.post.create_fieldplot_surface(surf_list, "Mag_J", intrinsincDict=intrinsic_dict, plot_name="Mag_J") -m3d.post.create_fieldplot_surface(surf_list, "Mag_B", intrinsincDict=intrinsic_dict, plot_name="Mag_B") -m3d.post.create_fieldplot_surface(surf_list, "Mesh", intrinsincDict=intrinsic_dict, plot_name="Mesh") +m3d.post.create_fieldplot_surface(surf_list, "Mag_J", intrinsic_dict=intrinsic_dict, plot_name="Mag_J") +m3d.post.create_fieldplot_surface(surf_list, "Mag_B", intrinsic_dict=intrinsic_dict, plot_name="Mag_B") +m3d.post.create_fieldplot_surface(surf_list, "Mesh", intrinsic_dict=intrinsic_dict, plot_name="Mesh") #################################################################################################### # Release AEDT and clean up temporary directory diff --git a/examples/03-Maxwell/Maxwell3D_Team3_bath_plate.py b/examples/03-Maxwell/Maxwell3D_Team3_bath_plate.py index d4a1479bb86..2411dbcc1ce 100644 --- a/examples/03-Maxwell/Maxwell3D_Team3_bath_plate.py +++ b/examples/03-Maxwell/Maxwell3D_Team3_bath_plate.py @@ -237,7 +237,7 @@ ladder_plate = m3d.modeler.objects_by_name["LadderPlate"] intrinsic_dict = {"Freq": "50Hz", "Phase": "0deg"} -m3d.post.create_fieldplot_surface(ladder_plate.faces, "Mag_J", intrinsincDict=intrinsic_dict, plot_name="Mag_J") +m3d.post.create_fieldplot_surface(ladder_plate.faces, "Mag_J", intrinsic_dict=intrinsic_dict, plot_name="Mag_J") ############################################################################### # Release AEDT diff --git a/examples/05-Q3D/Q3D_DC_IR.py b/examples/05-Q3D/Q3D_DC_IR.py index f727bdb2559..b565d1a2576 100644 --- a/examples/05-Q3D/Q3D_DC_IR.py +++ b/examples/05-Q3D/Q3D_DC_IR.py @@ -215,7 +215,7 @@ # Compute ACL solutions and plot them. plot1 = q3d.post.create_fieldplot_surface(q3d.modeler.get_objects_by_material("copper"), quantityName=drop_name, - intrinsincDict={"Freq": "1GHz"}) + intrinsic_dict={"Freq": "1GHz"}) q3d.post.plot_field_from_fieldplot( plot1.name, diff --git a/examples/06-Multiphysics/MRI.py b/examples/06-Multiphysics/MRI.py index c251debc3b1..8b2ebeddab4 100644 --- a/examples/06-Multiphysics/MRI.py +++ b/examples/06-Multiphysics/MRI.py @@ -107,9 +107,7 @@ # Draw Point1 at origin of the implant coordinate system hfss.sar_setup(-1, Average_SAR_method=1, TissueMass=1, MaterialDensity=1, ) -hfss.post.create_fieldplot_cutplane(objlist="implant:YZ", - quantityName="Average_SAR", - filter_objects=["implant_box"]) +hfss.post.create_fieldplot_cutplane(objlist="implant:YZ", quantityName="Average_SAR", filter_objects=["implant_box"]) hfss.modeler.set_working_coordinate_system("implant") hfss.modeler.create_point([0, 0, 0], name="Point1") @@ -214,8 +212,8 @@ # Plot Temperature on cut plane. # Plot Temperature on point. -mech.post.create_fieldplot_cutplane("implant:YZ", "Temperature", filter_objects=["implant_box"], - intrinsincDict={"Time": "10s"}) +mech.post.create_fieldplot_cutplane("implant:YZ", "Temperature", intrinsic_dict={"Time": "10s"}, + filter_objects=["implant_box"]) mech.save_project() data = mech.post.get_solution_data("Temperature", primary_sweep_variable="Time", context="Point1", @@ -305,8 +303,8 @@ # Plot Temperature on monitor point. ipk.analyze(num_cores=4,num_tasks=4) -ipk.post.create_fieldplot_cutplane("implant:YZ", "Temperature", filter_objects=["implant_box"], - intrinsincDict={"Time": "0s"}) +ipk.post.create_fieldplot_cutplane("implant:YZ", "Temperature", intrinsic_dict={"Time": "0s"}, + filter_objects=["implant_box"]) ipk.save_project() data = ipk.post.get_solution_data("Point1.Temperature", primary_sweep_variable="Time", report_category="Monitor") diff --git a/examples/06-Multiphysics/Maxwell3D_Icepak_2Way_Coupling.py b/examples/06-Multiphysics/Maxwell3D_Icepak_2Way_Coupling.py index 44c2322a664..b3c843a56a2 100644 --- a/examples/06-Multiphysics/Maxwell3D_Icepak_2Way_Coupling.py +++ b/examples/06-Multiphysics/Maxwell3D_Icepak_2Way_Coupling.py @@ -255,17 +255,11 @@ for name in ["Coil", "Core"]: surface_list.extend(ipk.modeler.get_object_faces(name)) -surf_temperature = ipk.post.create_fieldplot_surface( - surface_list, - quantityName="SurfTemperature", - plot_name="Surface Temperature" -) +surf_temperature = ipk.post.create_fieldplot_surface(surface_list, quantityName="SurfTemperature", + plot_name="Surface Temperature") -velocity_cutplane = ipk.post.create_fieldplot_cutplane( - objlist=["Global:XZ"], - quantityName="Velocity Vectors", - plot_name="Velocity Vectors" - ) +velocity_cutplane = ipk.post.create_fieldplot_cutplane(objlist=["Global:XZ"], quantityName="Velocity Vectors", + plot_name="Velocity Vectors") surf_temperature.export_image() velocity_cutplane.export_image(orientation="right") diff --git a/pyaedt/modules/AdvancedPostProcessing.py b/pyaedt/modules/AdvancedPostProcessing.py index e88ed21ce0a..32f141dc18e 100644 --- a/pyaedt/modules/AdvancedPostProcessing.py +++ b/pyaedt/modules/AdvancedPostProcessing.py @@ -776,8 +776,8 @@ def animate_fields_from_aedtplt( if not project_path: project_path = self._app.working_directory for el in variation_list: - if plotname in self.field_plots and variation_variable in self.field_plots[plotname].intrinsincList: - self.field_plots[plotname].intrinsincList[variation_variable] = el + if plotname in self.field_plots and variation_variable in self.field_plots[plotname].intrinsics: + self.field_plots[plotname].intrinsics[variation_variable] = el self.field_plots[plotname].update() else: self._app._odesign.ChangeProperty( diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index 949bc22a783..100779341c7 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -2260,7 +2260,7 @@ def _get_fields_plot(self): plots[plot_name].quantityName = self.ofieldsreporter.GetFieldPlotQuantityName( setups_data[setup]["PlotName"] ) - plots[plot_name].intrinsincList = self._get_intrinsic(setup) + plots[plot_name].intrinsics = self._get_intrinsic(setup) list_objs = setups_data[setup]["FieldPlotGeometry"][1:] while list_objs: id = list_objs[0] @@ -2977,43 +2977,27 @@ def _create_fieldplot( plot_name = quantityName + "_" + "".join(random.sample(char_set, 6)) if listtype == "CutPlane": plot = FieldPlot( - self, - cutplanelist=objlist, - solutionName=setup_name, - quantityName=quantityName, - intrinsincList=intrinsics, + self, cutplanelist=objlist, solutionName=setup_name, quantityName=quantityName, intrinsics=intrinsics ) elif listtype == "FacesList": plot = FieldPlot( - self, - surfacelist=objlist, - solutionName=setup_name, - quantityName=quantityName, - intrinsincList=intrinsics, + self, surfacelist=objlist, solutionName=setup_name, quantityName=quantityName, intrinsics=intrinsics ) elif listtype == "ObjList": plot = FieldPlot( - self, - objlist=objlist, - solutionName=setup_name, - quantityName=quantityName, - intrinsincList=intrinsics, + self, objlist=objlist, solutionName=setup_name, quantityName=quantityName, intrinsics=intrinsics ) elif listtype == "Line": plot = FieldPlot( - self, - linelist=objlist, - solutionName=setup_name, - quantityName=quantityName, - intrinsincList=intrinsics, + self, linelist=objlist, solutionName=setup_name, quantityName=quantityName, intrinsics=intrinsics ) elif listtype.startswith("Layer"): plot = FieldPlot( self, - layers_nets=objlist, solutionName=setup_name, quantityName=quantityName, - intrinsincList=intrinsics, + intrinsics=intrinsics, + layers_nets=objlist, layers_plot_type=listtype, ) if self._app.design_type == "Q3D Extractor": # pragma: no cover @@ -3065,7 +3049,7 @@ def _create_fieldplot_line_traces( surfacelist=surface_tracing_ids, solutionName=setup_name, quantityName=quantityName, - intrinsincList=intrinsics, + intrinsics=intrinsics, seedingFaces=seeding_faces_ids, ) if field_type: @@ -3084,7 +3068,14 @@ def _create_fieldplot_line_traces( @pyaedt_function_handler() def create_fieldplot_line( - self, objlist, quantityName, setup_name=None, intrinsincDict=None, plot_name=None, field_type="DC R/L Fields" + self, + objlist, + quantityName, + setup_name=None, + intrinsics=None, + plot_name=None, + field_type="DC R/L Fields", + **kwargs, ): """Create a field plot of the line. @@ -3098,7 +3089,7 @@ def create_fieldplot_line( Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. - intrinsincDict : dict, optional + intrinsics : dict, optional Dictionary containing all intrinsic variables. The default is ``{}``. plot_name : str, optional @@ -3116,13 +3107,16 @@ def create_fieldplot_line( >>> oModule.CreateFieldPlot """ - if intrinsincDict is None: - intrinsincDict = {} + if "intrinsincDict" in kwargs: + self.logger.warning("``intrinsincDict`` is deprecated, please use ``intrinsics`` instead.") + intrinsics = kwargs["intrinsincDict"] + if intrinsics is None: + intrinsics = {} if plot_name and plot_name in list(self.field_plots.keys()): self.logger.info("Plot {} exists. returning the object.".format(plot_name)) return self.field_plots[plot_name] return self._create_fieldplot( - objlist, quantityName, setup_name, intrinsincDict, "Line", plot_name, field_type=field_type + objlist, quantityName, setup_name, intrinsics, "Line", plot_name, field_type=field_type ) @pyaedt_function_handler() @@ -3132,9 +3126,10 @@ def create_fieldplot_line_traces( in_volume_tracing_objs=None, surface_tracing_objs=None, setup_name=None, - intrinsinc_dict=None, + intrinsics=None, plot_name=None, field_type="DC R/L Fields", + **kwargs, ): """ Create a field plot of the line. @@ -3150,7 +3145,7 @@ def create_fieldplot_line_traces( setup_name : str, optional Name of the setup in the format ``"setupName : sweepName"``. The default is ``None``. - intrinsinc_dict : dict, optional + intrinsics : dict, optional Dictionary containing all intrinsic variables. The default is ``{}``. plot_name : str, optional @@ -3171,8 +3166,11 @@ def create_fieldplot_line_traces( if self._app.solution_type != "Electrostatic": self.logger.error("Field line traces is valid only for electrostatic solution") return False - if intrinsinc_dict is None: - intrinsinc_dict = {} + if "intrinsinc_dict" in kwargs: + self.logger.warning("``intrinsincDict`` is deprecated, please use ``intrinsics`` instead.") + intrinsics = kwargs["intrinsinc_dict"] + if intrinsics is None: + intrinsics = {} if plot_name and plot_name in list(self.field_plots.keys()): self.logger.info("Plot {} exists. returning the object.".format(plot_name)) return self.field_plots[plot_name] @@ -3228,7 +3226,7 @@ def create_fieldplot_line_traces( surface_tracing_ids, "FieldLineTrace", setup_name, - intrinsinc_dict, + intrinsics, plot_name, field_type=field_type, ) @@ -3300,7 +3298,14 @@ def create_fieldplot_layers_nets( @pyaedt_function_handler() def create_fieldplot_surface( - self, objlist, quantityName, setup_name=None, intrinsincDict=None, plot_name=None, field_type="DC R/L Fields" + self, + objlist, + quantityName, + setup_name=None, + intrinsics=None, + plot_name=None, + field_type="DC R/L Fields", + **kwargs, ): """Create a field plot of surfaces. @@ -3314,7 +3319,7 @@ def create_fieldplot_surface( Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. - intrinsincDict : dict, optional + intrinsics : dict, optional Dictionary containing all intrinsic variables. The default is ``{}``. plot_name : str, optional @@ -3332,8 +3337,11 @@ def create_fieldplot_surface( >>> oModule.CreateFieldPlot """ - if intrinsincDict is None: - intrinsincDict = {} + if "intrinsincDict" in kwargs: + self.logger.warning("``intrinsincDict`` is deprecated, please use ``intrinsics`` instead.") + intrinsics = kwargs["intrinsincDict"] + if intrinsics is None: + intrinsics = {} if plot_name and plot_name in list(self.field_plots.keys()): self.logger.info("Plot {} exists. returning the object.".format(plot_name)) return self.field_plots[plot_name] @@ -3346,7 +3354,7 @@ def create_fieldplot_surface( elif self._app.modeler[obj]: new_obj_list.extend([face for face in self._app.modeler[obj].faces if face.id not in new_obj_list]) return self._create_fieldplot( - new_obj_list, quantityName, setup_name, intrinsincDict, "FacesList", plot_name, field_type=field_type + new_obj_list, quantityName, setup_name, intrinsics, "FacesList", plot_name, field_type=field_type ) @pyaedt_function_handler() @@ -3355,10 +3363,11 @@ def create_fieldplot_cutplane( objlist, quantityName, setup_name=None, - intrinsincDict=None, + intrinsics=None, plot_name=None, - filter_objects=[], + filter_objects=None, field_type="DC R/L Fields", + **kwargs, ): """Create a field plot of cut planes. @@ -3372,13 +3381,14 @@ def create_fieldplot_cutplane( Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. - intrinsincDict : dict, optional + intrinsics : dict, optional Dictionary containing all intrinsic variables. The default is ``{}``. plot_name : str, optional Name of the fieldplot to create. filter_objects : list, optional Objects list on which filter the plot. + The default value is ``None`` in which case an empty list is passed. field_type : str, optional Field type to plot. Valid only for Q3D Field plots. @@ -3392,8 +3402,11 @@ def create_fieldplot_cutplane( >>> oModule.CreateFieldPlot """ - if intrinsincDict is None: - intrinsincDict = {} + if "intrinsincDict" in kwargs: + self.logger.warning("``intrinsincDict`` is deprecated, please use ``intrinsics`` instead.") + intrinsics = kwargs["intrinsincDict"] + if intrinsics is None: + intrinsics = {} if plot_name and plot_name in list(self.field_plots.keys()): self.logger.info("Plot {} exists. returning the object.".format(plot_name)) return self.field_plots[plot_name] @@ -3403,7 +3416,7 @@ def create_fieldplot_cutplane( objlist, quantityName, setup_name, - intrinsincDict, + intrinsics, "CutPlane", plot_name, filter_boxes=filter_objects, @@ -3416,9 +3429,10 @@ def create_fieldplot_volume( objlist, quantityName, setup_name=None, - intrinsincDict=None, + intrinsics=None, plot_name=None, field_type="DC R/L Fields", + **kwargs, ): """Create a field plot of volumes. @@ -3432,7 +3446,7 @@ def create_fieldplot_volume( Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. - intrinsincDict : dict, optional + intrinsics : dict, optional Dictionary containing all intrinsic variables. The default is ``{}``. plot_name : str, optional @@ -3448,13 +3462,16 @@ def create_fieldplot_volume( >>> oModule.CreateFieldPlot """ - if intrinsincDict is None: - intrinsincDict = {} + if "intrinsincDict" in kwargs: + self.logger.warning("``intrinsincDict`` is deprecated, please use ``intrinsics`` instead.") + intrinsics = kwargs["intrinsincDict"] + if intrinsics is None: + intrinsics = {} if plot_name and plot_name in list(self.field_plots.keys()): self.logger.info("Plot {} exists. returning the object.".format(plot_name)) return self.field_plots[plot_name] return self._create_fieldplot( - objlist, quantityName, setup_name, intrinsincDict, "ObjList", plot_name, field_type=field_type + objlist, quantityName, setup_name, intrinsics, "ObjList", plot_name, field_type=field_type ) @pyaedt_function_handler() @@ -3815,7 +3832,7 @@ def export_model_obj(self, obj_list=None, export_path=None, export_as_single_obj return [[fname, "aquamarine", 0.3]] @pyaedt_function_handler() - def export_mesh_obj(self, setup_name=None, intrinsic_dict=None): + def export_mesh_obj(self, setup_name=None, intrinsics=None): """Export the mesh in ``aedtplt`` format. The mesh has to be available in the selected setup. If a parametric model is provided user can choose the mesh to export providing a specific set of variations. @@ -3829,7 +3846,7 @@ def export_mesh_obj(self, setup_name=None, intrinsic_dict=None): Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. - intrinsic_dict : dict, optional. + intrinsics : dict, optional. Intrinsic dictionary that is needed for the export. The default is ``{}`` which assumes no variables are present in the dict or nominal values are used. @@ -3844,12 +3861,12 @@ def export_mesh_obj(self, setup_name=None, intrinsic_dict=None): >>> hfss = Hfss() >>> hfss.analyze() >>> # Export report using defaults. - >>> hfss.post.export_mesh_obj(setup_name=None, intrinsic_dict=None) + >>> hfss.post.export_mesh_obj(setup_name=None, intrinsics=None) >>> # Export report using arguments. - >>> hfss.post.export_mesh_obj(setup_name="MySetup : LastAdaptive", intrinsic_dict={"w1":"5mm", "l1":"3mm"}) + >>> hfss.post.export_mesh_obj(setup_name="MySetup : LastAdaptive", intrinsics={"w1":"5mm", "l1":"3mm"}) """ - if intrinsic_dict is None: - intrinsic_dict = {} + if intrinsics is None: + intrinsics = {} project_path = self._app.working_directory if not setup_name: @@ -3860,7 +3877,7 @@ def export_mesh_obj(self, setup_name=None, intrinsic_dict=None): object3d = self._app.modeler[el] if not object3d.is3d or object3d.material_name not in ["vacuum", "air"]: face_lists += [i.id for i in object3d.faces] - plot = self.create_fieldplot_surface(face_lists, "Mesh", setup_name, intrinsic_dict) + plot = self.create_fieldplot_surface(face_lists, "Mesh", setup_name, intrinsics) if plot: file_to_add = self.export_field_plot(plot.name, project_path) plot.delete() @@ -4317,10 +4334,7 @@ def create_creeping_point_visual_ray_tracing( """ if custom_location is None: custom_location = [0, 0, 0] - vrt = VRTFieldPlot( - self, - is_creeping_wave=True, - ) + vrt = VRTFieldPlot(self, is_creeping_wave=True) vrt.max_frequency = max_frequency vrt.sample_density = sample_density vrt.ray_density = ray_density @@ -5120,7 +5134,9 @@ def add_calculation( return True @pyaedt_function_handler() - def get_field_summary_data(self, setup_name=None, design_variation={}, intrinsic_value="", pandas_output=False): + def get_field_summary_data( + self, setup_name=None, design_variation={}, intrinsics="", pandas_output=False, **kwargs + ): """ Get field summary output computation. @@ -5132,7 +5148,7 @@ def get_field_summary_data(self, setup_name=None, design_variation={}, intrinsic design_variation : dict, optional Dictionary containing the design variation to use for the computation. The default is ``{}``, in which case nominal variation is used. - intrinsic_value : str, optional + intrinsics : str, optional Intrinsic values to use for the computation. The default is ``""``, suitable when no frequency needs to be selected. pandas_output : bool, optional @@ -5145,9 +5161,12 @@ def get_field_summary_data(self, setup_name=None, design_variation={}, intrinsic Output type depending on the Boolean ``pandas_output`` parameter. The output consists of information exported from the field summary. """ + if "intrinsic_value" in kwargs: + self._app.logger.warning("``intrinsincDict`` is deprecated, please use ``intrinsics`` instead.") + intrinsics = kwargs["intrinsic_value"] with tempfile.NamedTemporaryFile(mode="w+", delete=False) as temp_file: temp_file.close() - self.export_csv(temp_file.name, setup_name, design_variation, intrinsic_value) + self.export_csv(temp_file.name, setup_name, design_variation, intrinsics) with open(temp_file.name, "r") as f: for _ in range(4): _ = next(f) @@ -5164,7 +5183,7 @@ def get_field_summary_data(self, setup_name=None, design_variation={}, intrinsic return out_dict @pyaedt_function_handler() - def export_csv(self, filename, setup_name=None, design_variation={}, intrinsic_value=""): + def export_csv(self, filename, setup_name=None, design_variation={}, intrinsics=""): """ Get the field summary output computation. @@ -5178,7 +5197,7 @@ def export_csv(self, filename, setup_name=None, design_variation={}, intrinsic_v design_variation : dict, optional Dictionary containing the design variation to use for the computation. The default is ``{}``, in which case the nominal variation is used. - intrinsic_value : str, optional + intrinsics : str, optional Intrinsic values to use for the computation. The default is ``""``, suitable when no frequency needs to be selected. @@ -5202,7 +5221,7 @@ def export_csv(self, filename, setup_name=None, design_variation={}, intrinsic_v "ExportFileName:=", filename, "IntrinsicValue:=", - intrinsic_value, + intrinsics, ] ) return True diff --git a/pyaedt/modules/solutions.py b/pyaedt/modules/solutions.py index 37844785cfd..34282ddddc7 100644 --- a/pyaedt/modules/solutions.py +++ b/pyaedt/modules/solutions.py @@ -2626,7 +2626,7 @@ class FieldPlot: Name of the solution. quantityName : str Name of the plot or the name of the object. - intrinsincList : dict, optional + intrinsics : dict, optional Name of the intrinsic dictionary. The default is ``{}``. """ @@ -2640,10 +2640,11 @@ def __init__( cutplanelist=[], solutionName="", quantityName="", - intrinsincList={}, + intrinsics={}, seedingFaces=[], layers_nets=[], layers_plot_type="LayerNetsExtFace", + **kwargs, ): self._postprocessor = postprocessor self.oField = postprocessor.ofieldsreporter @@ -2656,7 +2657,10 @@ def __init__( self.seeding_faces = seedingFaces self.solutionName = solutionName self.quantityName = quantityName - self.intrinsincList = intrinsincList + if "intrinsincList" in kwargs: + self._postprocessor.logger.warning("``intrinsincList`` is deprecated, please use ``intrinsics`` instead.") + self.intrinsics = kwargs["intrinsicList"] + self.intrinsics = intrinsics self.name = "Field_Plot" self.plotFolder = "Field_Plot" self.Filled = False @@ -2786,18 +2790,18 @@ def intrinsicVar(self): List or dictionary of the variables for the field plot. """ var = "" - if type(self.intrinsincList) is list: + if type(self.intrinsics) is list: l = 0 - while l < len(self.intrinsincList): - val = self.intrinsincList[l + 1] - if ":=" in self.intrinsincList[l] and isinstance(self.intrinsincList[l + 1], list): - val = self.intrinsincList[l + 1][0] - ll = self.intrinsincList[l].split(":=") + while l < len(self.intrinsics): + val = self.intrinsics[l + 1] + if ":=" in self.intrinsics[l] and isinstance(self.intrinsics[l + 1], list): + val = self.intrinsics[l + 1][0] + ll = self.intrinsics[l].split(":=") var += ll[0] + "='" + str(val) + "' " l += 2 else: - for a in self.intrinsincList: - var += a + "='" + str(self.intrinsincList[a]) + "' " + for a in self.intrinsics: + var += a + "='" + str(self.intrinsics[a]) + "' " return var @property @@ -3339,7 +3343,7 @@ class VRTFieldPlot: Ray Density. The default is ``2``. bounces : int, optional Maximum number of bounces. The default is ``5``. - intrinsinc_list : dict, optional + intrinsics : dict, optional Name of the intrinsic dictionary. The default is ``{}``. """ @@ -3352,13 +3356,17 @@ def __init__( max_frequency="1GHz", ray_density=2, bounces=5, - intrinsinc_list={}, + intrinsics={}, + **kwargs, ): self.is_creeping_wave = is_creeping_wave self._postprocessor = postprocessor self._ofield = postprocessor.ofieldsreporter self.quantity_name = quantity_name - self.intrinsics = intrinsinc_list + if "intrinsinc_list" in kwargs: + self._postprocessor.logger.warning("``intrinsinc_list`` is deprecated, please use ``intrinsics`` instead.") + self.intrinsics = kwargs["intrinsics"] + self.intrinsics = intrinsics self.name = "Field_Plot" self.plot_folder = "Field_Plot" self.max_frequency = max_frequency From 4f57c5affe0f204be5f4f87499bceedb4a6f01b5 Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Mon, 25 Mar 2024 15:36:43 +0100 Subject: [PATCH 02/22] fix typos --- doc/source/User_guide/postprocessing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/User_guide/postprocessing.rst b/doc/source/User_guide/postprocessing.rst index 3f1a2d5c583..eddf2db1235 100644 --- a/doc/source/User_guide/postprocessing.rst +++ b/doc/source/User_guide/postprocessing.rst @@ -68,7 +68,7 @@ You can plot the field plot directly in HFSS and export it to image files. plot1 = hfss.post.create_fieldplot_cutplane(objlist=cutlist, quantityName=quantity_name, setup_name=setup_name, - intrinsic_dict=intrinsic) + intrinsics=intrinsic) .. image:: ../Resources/field_plot.png From 7c874b87e9a87d3979449543600beb088f102f85 Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Tue, 26 Mar 2024 09:07:46 +0100 Subject: [PATCH 03/22] fix typos and refactoring --- _unittest_solvers/test_01_pdf.py | 2 +- examples/03-Maxwell/Maxwell2D_DCConduction.py | 2 +- .../06-Multiphysics/Hfss_Icepak_Coupling.py | 2 +- pyaedt/generic/general_methods.py | 2 +- pyaedt/generic/pdf.py | 8 ++++++-- pyaedt/icepak.py | 13 ++++++++----- pyaedt/mechanical.py | 4 ++-- pyaedt/modeler/cad/Primitives.py | 11 +++++++---- pyaedt/modeler/cad/object3d.py | 4 ++-- pyaedt/modeler/geometry_operators.py | 2 +- pyaedt/modeler/modeler3d.py | 5 +---- pyaedt/modeler/pcb/object3dlayout.py | 18 +++++++++--------- pyaedt/modules/PostProcessor.py | 15 ++++++++++----- 13 files changed, 50 insertions(+), 38 deletions(-) diff --git a/_unittest_solvers/test_01_pdf.py b/_unittest_solvers/test_01_pdf.py index a7d4be96c1e..d5a649143c6 100644 --- a/_unittest_solvers/test_01_pdf.py +++ b/_unittest_solvers/test_01_pdf.py @@ -21,7 +21,7 @@ def aedtapp(add_app): class TestClass(object): def test_create_pdf(self, local_scratch): - report = AnsysReport(project_name="Coaxial", design_name="Design1") + report = AnsysReport(design_name="Design1", project_name="Coaxial") report.aedt_version = desktop_version assert "AnsysTemplate" in report.template_name report.template_name = "AnsysTemplate" diff --git a/examples/03-Maxwell/Maxwell2D_DCConduction.py b/examples/03-Maxwell/Maxwell2D_DCConduction.py index 6655291464d..c4ab0634b3e 100644 --- a/examples/03-Maxwell/Maxwell2D_DCConduction.py +++ b/examples/03-Maxwell/Maxwell2D_DCConduction.py @@ -227,7 +227,7 @@ # ~~~~~~~~~~~~~~~~~~~ # Generate a PDF report with output of simulation. -pdf_report = AnsysReport(project_name=m2d.project_name, design_name=m2d.design_name, version=aedt_version) +pdf_report = AnsysReport(version=aedt_version, design_name=m2d.design_name, project_name=m2d.project_name) # Customize text font. diff --git a/examples/06-Multiphysics/Hfss_Icepak_Coupling.py b/examples/06-Multiphysics/Hfss_Icepak_Coupling.py index 6dac5618f11..ba059d46d58 100644 --- a/examples/06-Multiphysics/Hfss_Icepak_Coupling.py +++ b/examples/06-Multiphysics/Hfss_Icepak_Coupling.py @@ -335,7 +335,7 @@ # Generate pdf report # ~~~~~~~~~~~~~~~~~~~ # Generate a pdf report with output of simultion. -report = AnsysReport(project_name=aedtapp.project_name, design_name=aedtapp.design_name, version=aedt_version) +report = AnsysReport(version=aedt_version, design_name=aedtapp.design_name, project_name=aedtapp.project_name) report.create() report.add_section() report.add_chapter("Hfss Results") diff --git a/pyaedt/generic/general_methods.py b/pyaedt/generic/general_methods.py index c01df453d4d..abf96c8e0e3 100644 --- a/pyaedt/generic/general_methods.py +++ b/pyaedt/generic/general_methods.py @@ -258,7 +258,7 @@ def decorating_function(user_function): def check_numeric_equivalence(a, b, relative_tolerance=1e-7): """Check if two numeric values are equivalent to within a relative tolerance. - Paraemters + Parameters ---------- a : int, float Reference value to compare to. diff --git a/pyaedt/generic/pdf.py b/pyaedt/generic/pdf.py index 9c067177a3b..b0d75cad2e9 100644 --- a/pyaedt/generic/pdf.py +++ b/pyaedt/generic/pdf.py @@ -49,10 +49,14 @@ class ReportSpec: class AnsysReport(FPDF): - def __init__(self, version="2023R2", design_name="design1", project_name="AnsysProject", tempplate_json_file=None): + def __init__( + self, version="2023R2", design_name="design1", project_name="AnsysProject", template_json_file=None, **kwargs + ): super().__init__() self.report_specs = ReportSpec() - self.read_template(tempplate_json_file) + if "tempplate_json_file" in kwargs.keys(): + template_json_file = kwargs["tempplate_json_file"] + self.read_template(template_json_file) self.report_specs.ansys_version = version self.report_specs.design_name = design_name self.report_specs.project_name = project_name diff --git a/pyaedt/icepak.py b/pyaedt/icepak.py index 626d01ec959..7b0161621c1 100644 --- a/pyaedt/icepak.py +++ b/pyaedt/icepak.py @@ -223,12 +223,12 @@ def assign_grille( air_faces, free_loss_coeff=True, free_area_ratio=0.8, - resistance_type=0, external_temp="AmbientTemp", - expternal_pressure="AmbientPressure", + external_pressure="AmbientPressure", x_curve=["0", "1", "2"], y_curve=["0", "1", "2"], boundary_name=None, + **kwargs, ): """Assign grille to a face or list of faces. @@ -251,7 +251,7 @@ def assign_grille( The default is ``0`` for ``"Perforated Thin Vent"``. external_temp : str, optional External temperature. The default is ``"AmbientTemp"``. - expternal_pressure : str, optional + external_pressure : str, optional External pressure. The default is ``"AmbientPressure"``. x_curve : list, optional List of X curves in m_per_sec. The default is ``["0", "1", "2"]``. @@ -271,6 +271,9 @@ def assign_grille( >>> oModule.AssignGrilleBoundary """ + if "expternal_pressure" in kwargs: + self.logger.warning("``expternal_pressure`` is deprecated, please use ``external_pressure`` instead.") + external_pressure = kwargs["expternal_pressure"] if boundary_name is None: boundary_name = generate_unique_name("Grille") @@ -283,12 +286,12 @@ def assign_grille( props["Pressure Loss Type"] = "Coeff" props["Free Area Ratio"] = str(free_area_ratio) props["External Rad. Temperature"] = external_temp - props["External Total Pressure"] = expternal_pressure + props["External Total Pressure"] = external_pressure else: props["Pressure Loss Type"] = "Curve" props["External Rad. Temperature"] = external_temp - props["External Total Pressure"] = expternal_pressure + props["External Total Pressure"] = external_pressure props["X"] = x_curve props["Y"] = y_curve diff --git a/pyaedt/mechanical.py b/pyaedt/mechanical.py index 8dc0a4816c6..87715e69f12 100644 --- a/pyaedt/mechanical.py +++ b/pyaedt/mechanical.py @@ -184,7 +184,7 @@ def assign_em_losses( assert "Thermal" in self.solution_type, "This method works only in a Mechanical Thermal analysis." - self.logger.info("Mapping HFSS EM Lossess") + self.logger.info("Mapping HFSS EM Loss") oName = self.project_name if oName == source_project_name or source_project_name is None: projname = "This Project*" @@ -282,7 +282,7 @@ def assign_thermal_map( assert self.solution_type == "Structural", "This method works only in a Mechanical Structural analysis." - self.logger.info("Mapping HFSS EM Lossess") + self.logger.info("Mapping HFSS EM Loss") oName = self.project_name if oName == source_project_name or source_project_name is None: projname = "This Project*" diff --git a/pyaedt/modeler/cad/Primitives.py b/pyaedt/modeler/cad/Primitives.py index 343e5f83db5..e7f9ad52921 100644 --- a/pyaedt/modeler/cad/Primitives.py +++ b/pyaedt/modeler/cad/Primitives.py @@ -4562,7 +4562,8 @@ def import_3d_cad( create_group=True, separate_disjoints_lumped_object=False, import_free_surfaces=False, - point_coicidence_tolerance=1e-6, + point_coincidence_tolerance=1e-6, + **kwargs, ): """Import a CAD model. @@ -4592,7 +4593,7 @@ def import_3d_cad( Either to automatically separate disjoint parts. The default is ``False``. import_free_surfaces : bool, optional Either to import free surfaces parts. The default is ``False``. - point_coicidence_tolerance : float, optional + point_coincidence_tolerance : float, optional Tolerance on point. Default is ``1e-6``. Returns @@ -4605,7 +4606,9 @@ def import_3d_cad( >>> oEditor.Import """ - + if "point_coicidence_tolerance" in kwargs: + self.logger.warning("point_coicidence_tolerance is deprecated, please use instead.") + point_coincidence_tolerance = kwargs["point_coicidence_tolerance"] if str(healing) in ["0", "1"]: warnings.warn( "Assigning `0` or `1` to `healing` option is deprecated. Assign `True` or `False` instead.", @@ -4621,7 +4624,7 @@ def import_3d_cad( vArg1.append("CreateGroup:="), vArg1.append(create_group) vArg1.append("STLFileUnit:="), vArg1.append("Auto") vArg1.append("MergeFacesAngle:="), vArg1.append(-1) - vArg1.append("PointCoincidenceTol:="), vArg1.append(point_coicidence_tolerance) + vArg1.append("PointCoincidenceTol:="), vArg1.append(point_coincidence_tolerance) vArg1.append("CreateLightweightPart:="), vArg1.append(create_lightweigth_part) vArg1.append("ImportMaterialNames:="), vArg1.append(import_materials) vArg1.append("SeparateDisjointLumps:="), vArg1.append(separate_disjoints_lumped_object) diff --git a/pyaedt/modeler/cad/object3d.py b/pyaedt/modeler/cad/object3d.py index da0f3420f36..afefc30a48d 100644 --- a/pyaedt/modeler/cad/object3d.py +++ b/pyaedt/modeler/cad/object3d.py @@ -2,11 +2,11 @@ """ This module contains these classes: `Components3DLayout`,`CircuitComponent', `EdgePrimitive`, `EdgeTypePrimitive`, `FacePrimitive`, `Geometries3DLayout`, -`Nets3DLayout`, `Objec3DLayout`, `Object3d`, `Padstack`, `PDSHole`, `PDSLayer`, +`Nets3DLayout`, `Object3DLayout`, `Object3d`, `Padstack`, `PDSHole`, `PDSLayer`, `Pins3DLayout', and `VertexPrimitive`. This module provides methods and data structures for managing all properties of -objects (points, lines, sheeets, and solids) within the AEDT 3D Modeler. +objects (points, lines, sheets, and solids) within the AEDT 3D Modeler. """ from __future__ import absolute_import # noreorder diff --git a/pyaedt/modeler/geometry_operators.py b/pyaedt/modeler/geometry_operators.py index 51d68d124ca..8d972deae08 100644 --- a/pyaedt/modeler/geometry_operators.py +++ b/pyaedt/modeler/geometry_operators.py @@ -712,7 +712,7 @@ def is_projection_inside(a1, a2, b1, b2): Returns ------- bool - ``True`` when the projected segment is inside the other segmennt, ``False`` otherwise. + ``True`` when the projected segment is inside the other segment, ``False`` otherwise. """ if not GeometryOperators.is_parallel(a1, a2, b1, b2): diff --git a/pyaedt/modeler/modeler3d.py b/pyaedt/modeler/modeler3d.py index a80ad83d5be..bbf1639580e 100644 --- a/pyaedt/modeler/modeler3d.py +++ b/pyaedt/modeler/modeler3d.py @@ -1267,10 +1267,7 @@ def import_from_openstreet_map( if not os.path.exists(parts_dict[part]["file_name"]): continue obj_names = [i for i in self.object_names] - self.import_3d_cad( - parts_dict[part]["file_name"], - create_lightweigth_part=create_lightweigth_part, - ) + self.import_3d_cad(parts_dict[part]["file_name"], create_lightweigth_part=create_lightweigth_part) added_objs = [i for i in self.object_names if i not in obj_names] if part == "terrain": transparency = 0.2 diff --git a/pyaedt/modeler/pcb/object3dlayout.py b/pyaedt/modeler/pcb/object3dlayout.py index 602d0e480b0..7e4ade3965c 100644 --- a/pyaedt/modeler/pcb/object3dlayout.py +++ b/pyaedt/modeler/pcb/object3dlayout.py @@ -15,7 +15,7 @@ from pyaedt.modeler.geometry_operators import GeometryOperators -class Objec3DLayout(object): +class Object3DLayout(object): """Manages properties of objects in HFSS 3D Layout. Parameters @@ -431,11 +431,11 @@ def is_parallel(self): return self.rlc_model_type[6] -class Components3DLayout(Objec3DLayout, object): +class Components3DLayout(Object3DLayout, object): """Contains components in HFSS 3D Layout.""" def __init__(self, primitives, name="", edb_object=None): - Objec3DLayout.__init__(self, primitives, "component") + Object3DLayout.__init__(self, primitives, "component") self.name = name self.edb_object = edb_object @@ -789,11 +789,11 @@ def components(self): return comps -class Pins3DLayout(Objec3DLayout, object): +class Pins3DLayout(Object3DLayout, object): """Contains the pins in HFSS 3D Layout.""" def __init__(self, primitives, name="", component_name=None, is_pin=True): - Objec3DLayout.__init__(self, primitives, "pin" if is_pin else "via") + Object3DLayout.__init__(self, primitives, "pin" if is_pin else "via") self.componentname = "-".join(name.split("-")[:-1]) if not component_name else component_name self.name = name self.is_pin = is_pin @@ -847,11 +847,11 @@ def holediam(self): return self._oeditor.GetPropertyValue("BaseElementTab", self.name, "HoleDiameter") -class Geometries3DLayout(Objec3DLayout, object): +class Geometries3DLayout(Object3DLayout, object): """Contains geometries in HFSS 3D Layout.""" def __init__(self, primitives, name, prim_type="poly", is_void=False): - Objec3DLayout.__init__(self, primitives, prim_type) + Object3DLayout.__init__(self, primitives, prim_type) self.is_void = is_void self._name = name @@ -1655,7 +1655,7 @@ def move(self, new_position): return True -class ComponentsSubCircuit3DLayout(Objec3DLayout, object): +class ComponentsSubCircuit3DLayout(Object3DLayout, object): """Contains 3d Components in HFSS 3D Layout. Parameters @@ -1668,7 +1668,7 @@ class ComponentsSubCircuit3DLayout(Objec3DLayout, object): """ def __init__(self, primitives, name=""): - Objec3DLayout.__init__(self, primitives, "component") + Object3DLayout.__init__(self, primitives, "component") self.name = name @property diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index 100779341c7..55d53fb1588 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -3107,9 +3107,14 @@ def create_fieldplot_line( >>> oModule.CreateFieldPlot """ - if "intrinsincDict" in kwargs: - self.logger.warning("``intrinsincDict`` is deprecated, please use ``intrinsics`` instead.") - intrinsics = kwargs["intrinsincDict"] + new_args = {"intrinsincDict": intrinsics} + for k in kwargs: + if k in new_args: + self.logger.warning("``{}`` is deprecated, please use ``{}`` instead.".format(k, str(new_args[k]))) + new_args[k] = kwargs[k] + else: + raise TypeError("create_fieldplot_line() got an unexpected keyword argument ``{}``".format(k)) + if intrinsics is None: intrinsics = {} if plot_name and plot_name in list(self.field_plots.keys()): @@ -5040,7 +5045,7 @@ def sample_ami_waveform( "MassFlowRate", "VolumeFlowRate", "MassFlux", - "ViscocityRatio", + "ViscosityRatio", "WallYPlus", "TKE", "Epsilon", @@ -5162,7 +5167,7 @@ def get_field_summary_data( The output consists of information exported from the field summary. """ if "intrinsic_value" in kwargs: - self._app.logger.warning("``intrinsincDict`` is deprecated, please use ``intrinsics`` instead.") + self._app.logger.warning("``intrinsic_value`` is deprecated, please use ``intrinsics`` instead.") intrinsics = kwargs["intrinsic_value"] with tempfile.NamedTemporaryFile(mode="w+", delete=False) as temp_file: temp_file.close() From e760c9de89fbd3fcf54404ede1f9a74f465723f9 Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Tue, 26 Mar 2024 11:43:50 +0100 Subject: [PATCH 04/22] decorator + test --- _unittest/test_01_general_methods.py | 11 +++++ pyaedt/generic/general_methods.py | 42 ++++++++++++++++ pyaedt/modules/PostProcessor.py | 74 ++++++++-------------------- pyaedt/modules/solutions.py | 11 ++--- 4 files changed, 77 insertions(+), 61 deletions(-) diff --git a/_unittest/test_01_general_methods.py b/_unittest/test_01_general_methods.py index 6b53e40f0ca..fd2eb09ac6d 100644 --- a/_unittest/test_01_general_methods.py +++ b/_unittest/test_01_general_methods.py @@ -1,6 +1,7 @@ import pytest from pyaedt.generic.DataHandlers import str_to_bool +from pyaedt.generic.general_methods import deprecated_alias from pyaedt.generic.general_methods import number_aware_string_key @@ -9,6 +10,11 @@ def desktop(): return +@deprecated_alias(t="n") +def operation(n, m): + return n + m + + class TestClass(object): def test_00_number_aware_string_key(self): assert number_aware_string_key("C1") == ("C", 1) @@ -30,3 +36,8 @@ def test_02_str_to_bool(self): assert True in list(map(str_to_bool, test_list_1)) test_list_2 = ["Stop", "go", "run", "crawl", "False"] assert False in list(map(str_to_bool, test_list_2)) + + def test_03_argument_decorator(self): + assert operation(n=2, m=3) == 5 + assert operation(t=2, m=3) == 5 + pass diff --git a/pyaedt/generic/general_methods.py b/pyaedt/generic/general_methods.py index abf96c8e0e3..40f6dada8ce 100644 --- a/pyaedt/generic/general_methods.py +++ b/pyaedt/generic/general_methods.py @@ -8,6 +8,7 @@ import datetime import difflib import fnmatch +import functools from functools import update_wrapper import inspect import itertools @@ -21,6 +22,9 @@ import tempfile import time import traceback +from typing import Callable +from typing import Dict +import warnings from pyaedt.aedt_logger import pyaedt_logger from pyaedt.generic.constants import CSS4_COLORS @@ -2086,3 +2090,41 @@ def developer_forum(self): # property = Property online_help = Help() + + +def deprecated_alias(**aliases: str) -> Callable: + """Decorator for deprecated function and method arguments. + + Use as follows: + + @deprecated_alias(old_arg='new_arg') + def myfunc(new_arg): + ... + + """ + + def deco(f: Callable): + @functools.wraps(f) + def wrapper(*args, **kwargs): + rename_kwargs(f.__name__, kwargs, aliases) + return f(*args, **kwargs) + + return wrapper + + return deco + + +def rename_kwargs(func_name: str, kwargs: Dict[str, str], aliases: Dict[str, str]): + """Helper function for deprecating function arguments.""" + for alias, new in aliases.items(): + if alias in kwargs: + if new in kwargs: + raise TypeError( + f"{func_name} received both {alias} and {new} as arguments!" + f" {alias} is deprecated, use {new} instead." + ) + warnings.warn( + message=(f"`{alias}` is deprecated as an argument to `{func_name}`; use" f" `{new}` instead."), + category=DeprecationWarning, + ) + kwargs[new] = kwargs.pop(alias) diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index 55d53fb1588..1c76fe2a835 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -21,6 +21,7 @@ from pyaedt.generic.DataHandlers import _dict_items_to_list_items from pyaedt.generic.constants import unit_converter from pyaedt.generic.general_methods import check_and_download_file +from pyaedt.generic.general_methods import deprecated_alias from pyaedt.generic.general_methods import generate_unique_name from pyaedt.generic.general_methods import open_file from pyaedt.generic.general_methods import pyaedt_function_handler @@ -2954,7 +2955,15 @@ def change_field_plot_scale(self, plot_name, minimum_value, maximum_value, is_lo @pyaedt_function_handler() def _create_fieldplot( - self, objlist, quantityName, setup_name, intrinsics, listtype, plot_name=None, filter_boxes=[], field_type=None + self, + objlist, + quantityName, + setup_name, + intrinsics, + listtype, + plot_name=None, + filter_boxes=None, + field_type=None, ): if not listtype.startswith("Layer") and self._app.design_type != "HFSS 3D Layout Design": objlist = self._app.modeler.convert_to_selections(objlist, True) @@ -2975,6 +2984,7 @@ def _create_fieldplot( char_set = string.ascii_uppercase + string.digits if not plot_name: plot_name = quantityName + "_" + "".join(random.sample(char_set, 6)) + filter_boxes = [] if filter_boxes is None else filter_boxes if listtype == "CutPlane": plot = FieldPlot( self, cutplanelist=objlist, solutionName=setup_name, quantityName=quantityName, intrinsics=intrinsics @@ -3067,15 +3077,9 @@ def _create_fieldplot_line_traces( return False @pyaedt_function_handler() + @deprecated_alias(IntrinsincDict="intrinsics") def create_fieldplot_line( - self, - objlist, - quantityName, - setup_name=None, - intrinsics=None, - plot_name=None, - field_type="DC R/L Fields", - **kwargs, + self, objlist, quantityName, setup_name=None, intrinsics=None, plot_name=None, field_type="DC R/L Fields" ): """Create a field plot of the line. @@ -3107,14 +3111,6 @@ def create_fieldplot_line( >>> oModule.CreateFieldPlot """ - new_args = {"intrinsincDict": intrinsics} - for k in kwargs: - if k in new_args: - self.logger.warning("``{}`` is deprecated, please use ``{}`` instead.".format(k, str(new_args[k]))) - new_args[k] = kwargs[k] - else: - raise TypeError("create_fieldplot_line() got an unexpected keyword argument ``{}``".format(k)) - if intrinsics is None: intrinsics = {} if plot_name and plot_name in list(self.field_plots.keys()): @@ -3125,6 +3121,7 @@ def create_fieldplot_line( ) @pyaedt_function_handler() + @deprecated_alias(IntrinsincDict="intrinsics") def create_fieldplot_line_traces( self, seeding_faces, @@ -3134,7 +3131,6 @@ def create_fieldplot_line_traces( intrinsics=None, plot_name=None, field_type="DC R/L Fields", - **kwargs, ): """ Create a field plot of the line. @@ -3171,9 +3167,6 @@ def create_fieldplot_line_traces( if self._app.solution_type != "Electrostatic": self.logger.error("Field line traces is valid only for electrostatic solution") return False - if "intrinsinc_dict" in kwargs: - self.logger.warning("``intrinsincDict`` is deprecated, please use ``intrinsics`` instead.") - intrinsics = kwargs["intrinsinc_dict"] if intrinsics is None: intrinsics = {} if plot_name and plot_name in list(self.field_plots.keys()): @@ -3302,15 +3295,9 @@ def create_fieldplot_layers_nets( return self._create_fieldplot(layers_nets, quantity_name, setup_name, intrinsics, plot_type, plot_name) @pyaedt_function_handler() + @deprecated_alias(IntrinsincDict="intrinsics") def create_fieldplot_surface( - self, - objlist, - quantityName, - setup_name=None, - intrinsics=None, - plot_name=None, - field_type="DC R/L Fields", - **kwargs, + self, objlist, quantityName, setup_name=None, intrinsics=None, plot_name=None, field_type="DC R/L Fields" ): """Create a field plot of surfaces. @@ -3342,9 +3329,6 @@ def create_fieldplot_surface( >>> oModule.CreateFieldPlot """ - if "intrinsincDict" in kwargs: - self.logger.warning("``intrinsincDict`` is deprecated, please use ``intrinsics`` instead.") - intrinsics = kwargs["intrinsincDict"] if intrinsics is None: intrinsics = {} if plot_name and plot_name in list(self.field_plots.keys()): @@ -3363,6 +3347,7 @@ def create_fieldplot_surface( ) @pyaedt_function_handler() + @deprecated_alias(IntrinsincDict="intrinsics") def create_fieldplot_cutplane( self, objlist, @@ -3372,7 +3357,6 @@ def create_fieldplot_cutplane( plot_name=None, filter_objects=None, field_type="DC R/L Fields", - **kwargs, ): """Create a field plot of cut planes. @@ -3407,9 +3391,6 @@ def create_fieldplot_cutplane( >>> oModule.CreateFieldPlot """ - if "intrinsincDict" in kwargs: - self.logger.warning("``intrinsincDict`` is deprecated, please use ``intrinsics`` instead.") - intrinsics = kwargs["intrinsincDict"] if intrinsics is None: intrinsics = {} if plot_name and plot_name in list(self.field_plots.keys()): @@ -3429,15 +3410,9 @@ def create_fieldplot_cutplane( ) @pyaedt_function_handler() + @deprecated_alias(IntrinsincDict="intrinsics") def create_fieldplot_volume( - self, - objlist, - quantityName, - setup_name=None, - intrinsics=None, - plot_name=None, - field_type="DC R/L Fields", - **kwargs, + self, objlist, quantityName, setup_name=None, intrinsics=None, plot_name=None, field_type="DC R/L Fields" ): """Create a field plot of volumes. @@ -3467,9 +3442,6 @@ def create_fieldplot_volume( >>> oModule.CreateFieldPlot """ - if "intrinsincDict" in kwargs: - self.logger.warning("``intrinsincDict`` is deprecated, please use ``intrinsics`` instead.") - intrinsics = kwargs["intrinsincDict"] if intrinsics is None: intrinsics = {} if plot_name and plot_name in list(self.field_plots.keys()): @@ -5139,9 +5111,8 @@ def add_calculation( return True @pyaedt_function_handler() - def get_field_summary_data( - self, setup_name=None, design_variation={}, intrinsics="", pandas_output=False, **kwargs - ): + @deprecated_alias(IntrinsincDict="intrinsics") + def get_field_summary_data(self, setup_name=None, design_variation={}, intrinsics="", pandas_output=False): """ Get field summary output computation. @@ -5166,9 +5137,6 @@ def get_field_summary_data( Output type depending on the Boolean ``pandas_output`` parameter. The output consists of information exported from the field summary. """ - if "intrinsic_value" in kwargs: - self._app.logger.warning("``intrinsic_value`` is deprecated, please use ``intrinsics`` instead.") - intrinsics = kwargs["intrinsic_value"] with tempfile.NamedTemporaryFile(mode="w+", delete=False) as temp_file: temp_file.close() self.export_csv(temp_file.name, setup_name, design_variation, intrinsics) diff --git a/pyaedt/modules/solutions.py b/pyaedt/modules/solutions.py index 34282ddddc7..18d2734b4b0 100644 --- a/pyaedt/modules/solutions.py +++ b/pyaedt/modules/solutions.py @@ -17,6 +17,7 @@ from pyaedt.generic.constants import unit_converter from pyaedt.generic.general_methods import check_and_download_folder from pyaedt.generic.general_methods import conversion_function +from pyaedt.generic.general_methods import deprecated_alias from pyaedt.generic.general_methods import open_file from pyaedt.generic.general_methods import write_csv from pyaedt.generic.plot import get_structured_mesh @@ -2631,6 +2632,7 @@ class FieldPlot: """ + @deprecated_alias(IntrinsincList="intrinsics") def __init__( self, postprocessor, @@ -2644,7 +2646,6 @@ def __init__( seedingFaces=[], layers_nets=[], layers_plot_type="LayerNetsExtFace", - **kwargs, ): self._postprocessor = postprocessor self.oField = postprocessor.ofieldsreporter @@ -2657,9 +2658,6 @@ def __init__( self.seeding_faces = seedingFaces self.solutionName = solutionName self.quantityName = quantityName - if "intrinsincList" in kwargs: - self._postprocessor.logger.warning("``intrinsincList`` is deprecated, please use ``intrinsics`` instead.") - self.intrinsics = kwargs["intrinsicList"] self.intrinsics = intrinsics self.name = "Field_Plot" self.plotFolder = "Field_Plot" @@ -3348,6 +3346,7 @@ class VRTFieldPlot: """ + @deprecated_alias(IntrinsincList="intrinsics") def __init__( self, postprocessor, @@ -3357,15 +3356,11 @@ def __init__( ray_density=2, bounces=5, intrinsics={}, - **kwargs, ): self.is_creeping_wave = is_creeping_wave self._postprocessor = postprocessor self._ofield = postprocessor.ofieldsreporter self.quantity_name = quantity_name - if "intrinsinc_list" in kwargs: - self._postprocessor.logger.warning("``intrinsinc_list`` is deprecated, please use ``intrinsics`` instead.") - self.intrinsics = kwargs["intrinsics"] self.intrinsics = intrinsics self.name = "Field_Plot" self.plot_folder = "Field_Plot" From 0603b5ee25c2bd3c3397b9fd6201153cc8ed498d Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Tue, 26 Mar 2024 11:53:30 +0100 Subject: [PATCH 05/22] remove pass --- _unittest/test_01_general_methods.py | 1 - 1 file changed, 1 deletion(-) diff --git a/_unittest/test_01_general_methods.py b/_unittest/test_01_general_methods.py index fd2eb09ac6d..d4e9d1adf29 100644 --- a/_unittest/test_01_general_methods.py +++ b/_unittest/test_01_general_methods.py @@ -40,4 +40,3 @@ def test_02_str_to_bool(self): def test_03_argument_decorator(self): assert operation(n=2, m=3) == 5 assert operation(t=2, m=3) == 5 - pass From 9fd0110945d18ec6c4c095a1b25095ce4a27267a Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Tue, 26 Mar 2024 16:42:18 +0100 Subject: [PATCH 06/22] add decorator in pyaedt_function_handler --- _unittest/test_01_general_methods.py | 10 --- .../Maxwell2D_PMSynchronousMotor.py | 2 +- examples/03-Maxwell/Maxwell3DTeam7.py | 6 +- .../03-Maxwell/Maxwell3D_Team3_bath_plate.py | 2 +- pyaedt/generic/general_methods.py | 65 ++++++------------- pyaedt/generic/pdf.py | 8 +-- pyaedt/icepak.py | 20 ++---- pyaedt/modeler/cad/Primitives.py | 10 +-- pyaedt/modules/PostProcessor.py | 14 ++-- pyaedt/modules/solutions.py | 2 +- 10 files changed, 40 insertions(+), 99 deletions(-) diff --git a/_unittest/test_01_general_methods.py b/_unittest/test_01_general_methods.py index d4e9d1adf29..6b53e40f0ca 100644 --- a/_unittest/test_01_general_methods.py +++ b/_unittest/test_01_general_methods.py @@ -1,7 +1,6 @@ import pytest from pyaedt.generic.DataHandlers import str_to_bool -from pyaedt.generic.general_methods import deprecated_alias from pyaedt.generic.general_methods import number_aware_string_key @@ -10,11 +9,6 @@ def desktop(): return -@deprecated_alias(t="n") -def operation(n, m): - return n + m - - class TestClass(object): def test_00_number_aware_string_key(self): assert number_aware_string_key("C1") == ("C", 1) @@ -36,7 +30,3 @@ def test_02_str_to_bool(self): assert True in list(map(str_to_bool, test_list_1)) test_list_2 = ["Stop", "go", "run", "crawl", "False"] assert False in list(map(str_to_bool, test_list_2)) - - def test_03_argument_decorator(self): - assert operation(n=2, m=3) == 5 - assert operation(t=2, m=3) == 5 diff --git a/examples/03-Maxwell/Maxwell2D_PMSynchronousMotor.py b/examples/03-Maxwell/Maxwell2D_PMSynchronousMotor.py index 4f66e4e6df1..11234daaa11 100644 --- a/examples/03-Maxwell/Maxwell2D_PMSynchronousMotor.py +++ b/examples/03-Maxwell/Maxwell2D_PMSynchronousMotor.py @@ -723,7 +723,7 @@ def create_cs_magnets(pm_id, cs_name, point_direction): # formerly created when the section is applied. faces_reg = mod2D.get_object_faces(object_list[1].name) # Region -plot1 = M2D.post.create_fieldplot_surface(objlist=faces_reg, quantityName='Flux_Lines', intrinsic_dict={ +plot1 = M2D.post.create_fieldplot_surface(objlist=faces_reg, quantityName='Flux_Lines', intrinsics={ "Time": M2D.variable_manager.variables["StopTime"].evaluated_value}, plot_name="Flux_Lines") ########################################################## diff --git a/examples/03-Maxwell/Maxwell3DTeam7.py b/examples/03-Maxwell/Maxwell3DTeam7.py index 2fcda779b29..16c6c090b06 100644 --- a/examples/03-Maxwell/Maxwell3DTeam7.py +++ b/examples/03-Maxwell/Maxwell3DTeam7.py @@ -424,9 +424,9 @@ surf_list = m3d.modeler.get_object_faces("Plate") intrinsic_dict = {"Freq": "200Hz", "Phase": "0deg"} -m3d.post.create_fieldplot_surface(surf_list, "Mag_J", intrinsic_dict=intrinsic_dict, plot_name="Mag_J") -m3d.post.create_fieldplot_surface(surf_list, "Mag_B", intrinsic_dict=intrinsic_dict, plot_name="Mag_B") -m3d.post.create_fieldplot_surface(surf_list, "Mesh", intrinsic_dict=intrinsic_dict, plot_name="Mesh") +m3d.post.create_fieldplot_surface(surf_list, "Mag_J", intrinsics=intrinsic_dict, plot_name="Mag_J") +m3d.post.create_fieldplot_surface(surf_list, "Mag_B", intrinsics=intrinsic_dict, plot_name="Mag_B") +m3d.post.create_fieldplot_surface(surf_list, "Mesh", intrinsics=intrinsic_dict, plot_name="Mesh") #################################################################################################### # Release AEDT and clean up temporary directory diff --git a/examples/03-Maxwell/Maxwell3D_Team3_bath_plate.py b/examples/03-Maxwell/Maxwell3D_Team3_bath_plate.py index 2411dbcc1ce..73f264480f0 100644 --- a/examples/03-Maxwell/Maxwell3D_Team3_bath_plate.py +++ b/examples/03-Maxwell/Maxwell3D_Team3_bath_plate.py @@ -237,7 +237,7 @@ ladder_plate = m3d.modeler.objects_by_name["LadderPlate"] intrinsic_dict = {"Freq": "50Hz", "Phase": "0deg"} -m3d.post.create_fieldplot_surface(ladder_plate.faces, "Mag_J", intrinsic_dict=intrinsic_dict, plot_name="Mag_J") +m3d.post.create_fieldplot_surface(ladder_plate.faces, "Mag_J", intrinsics=intrinsic_dict, plot_name="Mag_J") ############################################################################### # Release AEDT diff --git a/pyaedt/generic/general_methods.py b/pyaedt/generic/general_methods.py index 40f6dada8ce..cd78989d610 100644 --- a/pyaedt/generic/general_methods.py +++ b/pyaedt/generic/general_methods.py @@ -8,7 +8,6 @@ import datetime import difflib import fnmatch -import functools from functools import update_wrapper import inspect import itertools @@ -22,9 +21,6 @@ import tempfile import time import traceback -from typing import Callable -from typing import Dict -import warnings from pyaedt.aedt_logger import pyaedt_logger from pyaedt.generic.constants import CSS4_COLORS @@ -202,8 +198,10 @@ def _check_types(arg): return "" -def _function_handler_wrapper(user_function): +def _function_handler_wrapper(user_function, **deprecated_kwargs): def wrapper(*args, **kwargs): + if deprecated_kwargs and kwargs: + rename_kwargs(user_function.__name__, kwargs, deprecated_kwargs) if not settings.enable_error_handler: result = user_function(*args, **kwargs) return result @@ -236,7 +234,20 @@ def wrapper(*args, **kwargs): return wrapper -def pyaedt_function_handler(direct_func=None): +def rename_kwargs(func_name, kwargs, aliases): + """Helper function for deprecating function arguments.""" + for alias, new in aliases.items(): + if alias in kwargs: + if new in kwargs: + raise TypeError( + f"{func_name} received both {alias} and {new} as arguments!" + f" {alias} is deprecated, use {new} instead." + ) + pyaedt_logger.warning(f"`{alias}` is deprecated as an argument to `{func_name}`; use" f" `{new}` instead.") + kwargs[new] = kwargs.pop(alias) + + +def pyaedt_function_handler(direct_func=None, **deprecated_kwargs): """Provides an exception handler, logging mechanism, and argument converter for client-server communications. @@ -246,13 +257,13 @@ def pyaedt_function_handler(direct_func=None): """ if callable(direct_func): user_function = direct_func - wrapper = _function_handler_wrapper(user_function) + wrapper = _function_handler_wrapper(user_function, **deprecated_kwargs) return update_wrapper(wrapper, user_function) elif direct_func is not None: raise TypeError("Expected first argument to be a callable, or None") def decorating_function(user_function): - wrapper = _function_handler_wrapper(user_function) + wrapper = _function_handler_wrapper(user_function, **deprecated_kwargs) return update_wrapper(wrapper, user_function) return decorating_function @@ -2090,41 +2101,3 @@ def developer_forum(self): # property = Property online_help = Help() - - -def deprecated_alias(**aliases: str) -> Callable: - """Decorator for deprecated function and method arguments. - - Use as follows: - - @deprecated_alias(old_arg='new_arg') - def myfunc(new_arg): - ... - - """ - - def deco(f: Callable): - @functools.wraps(f) - def wrapper(*args, **kwargs): - rename_kwargs(f.__name__, kwargs, aliases) - return f(*args, **kwargs) - - return wrapper - - return deco - - -def rename_kwargs(func_name: str, kwargs: Dict[str, str], aliases: Dict[str, str]): - """Helper function for deprecating function arguments.""" - for alias, new in aliases.items(): - if alias in kwargs: - if new in kwargs: - raise TypeError( - f"{func_name} received both {alias} and {new} as arguments!" - f" {alias} is deprecated, use {new} instead." - ) - warnings.warn( - message=(f"`{alias}` is deprecated as an argument to `{func_name}`; use" f" `{new}` instead."), - category=DeprecationWarning, - ) - kwargs[new] = kwargs.pop(alias) diff --git a/pyaedt/generic/pdf.py b/pyaedt/generic/pdf.py index b0d75cad2e9..9c067177a3b 100644 --- a/pyaedt/generic/pdf.py +++ b/pyaedt/generic/pdf.py @@ -49,14 +49,10 @@ class ReportSpec: class AnsysReport(FPDF): - def __init__( - self, version="2023R2", design_name="design1", project_name="AnsysProject", template_json_file=None, **kwargs - ): + def __init__(self, version="2023R2", design_name="design1", project_name="AnsysProject", tempplate_json_file=None): super().__init__() self.report_specs = ReportSpec() - if "tempplate_json_file" in kwargs.keys(): - template_json_file = kwargs["tempplate_json_file"] - self.read_template(template_json_file) + self.read_template(tempplate_json_file) self.report_specs.ansys_version = version self.report_specs.design_name = design_name self.report_specs.project_name = project_name diff --git a/pyaedt/icepak.py b/pyaedt/icepak.py index 7b0161621c1..992fae06786 100644 --- a/pyaedt/icepak.py +++ b/pyaedt/icepak.py @@ -224,11 +224,10 @@ def assign_grille( free_loss_coeff=True, free_area_ratio=0.8, external_temp="AmbientTemp", - external_pressure="AmbientPressure", + expternal_pressure="AmbientPressure", x_curve=["0", "1", "2"], y_curve=["0", "1", "2"], boundary_name=None, - **kwargs, ): """Assign grille to a face or list of faces. @@ -241,17 +240,9 @@ def assign_grille( the free loss coefficient is not used. free_area_ratio : float, str Free loss coefficient value. The default is ``0.8``. - resistance_type : int, optional - Type of the resistance. Options are: - - - ``0`` for ``"Perforated Thin Vent"`` - - ``1`` for ``"Circular Metal Wire Screen"`` - - ``2`` for ``"Two-Plane Screen Cyl. Bars"`` - - The default is ``0`` for ``"Perforated Thin Vent"``. external_temp : str, optional External temperature. The default is ``"AmbientTemp"``. - external_pressure : str, optional + expternal_pressure : str, optional External pressure. The default is ``"AmbientPressure"``. x_curve : list, optional List of X curves in m_per_sec. The default is ``["0", "1", "2"]``. @@ -271,9 +262,6 @@ def assign_grille( >>> oModule.AssignGrilleBoundary """ - if "expternal_pressure" in kwargs: - self.logger.warning("``expternal_pressure`` is deprecated, please use ``external_pressure`` instead.") - external_pressure = kwargs["expternal_pressure"] if boundary_name is None: boundary_name = generate_unique_name("Grille") @@ -286,12 +274,12 @@ def assign_grille( props["Pressure Loss Type"] = "Coeff" props["Free Area Ratio"] = str(free_area_ratio) props["External Rad. Temperature"] = external_temp - props["External Total Pressure"] = external_pressure + props["External Total Pressure"] = expternal_pressure else: props["Pressure Loss Type"] = "Curve" props["External Rad. Temperature"] = external_temp - props["External Total Pressure"] = external_pressure + props["External Total Pressure"] = expternal_pressure props["X"] = x_curve props["Y"] = y_curve diff --git a/pyaedt/modeler/cad/Primitives.py b/pyaedt/modeler/cad/Primitives.py index e7f9ad52921..2c4c58c84b8 100644 --- a/pyaedt/modeler/cad/Primitives.py +++ b/pyaedt/modeler/cad/Primitives.py @@ -4562,8 +4562,7 @@ def import_3d_cad( create_group=True, separate_disjoints_lumped_object=False, import_free_surfaces=False, - point_coincidence_tolerance=1e-6, - **kwargs, + point_coicidence_tolerance=1e-6, ): """Import a CAD model. @@ -4593,7 +4592,7 @@ def import_3d_cad( Either to automatically separate disjoint parts. The default is ``False``. import_free_surfaces : bool, optional Either to import free surfaces parts. The default is ``False``. - point_coincidence_tolerance : float, optional + point_coicidence_tolerance : float, optional Tolerance on point. Default is ``1e-6``. Returns @@ -4606,9 +4605,6 @@ def import_3d_cad( >>> oEditor.Import """ - if "point_coicidence_tolerance" in kwargs: - self.logger.warning("point_coicidence_tolerance is deprecated, please use instead.") - point_coincidence_tolerance = kwargs["point_coicidence_tolerance"] if str(healing) in ["0", "1"]: warnings.warn( "Assigning `0` or `1` to `healing` option is deprecated. Assign `True` or `False` instead.", @@ -4624,7 +4620,7 @@ def import_3d_cad( vArg1.append("CreateGroup:="), vArg1.append(create_group) vArg1.append("STLFileUnit:="), vArg1.append("Auto") vArg1.append("MergeFacesAngle:="), vArg1.append(-1) - vArg1.append("PointCoincidenceTol:="), vArg1.append(point_coincidence_tolerance) + vArg1.append("PointCoincidenceTol:="), vArg1.append(point_coicidence_tolerance) vArg1.append("CreateLightweightPart:="), vArg1.append(create_lightweigth_part) vArg1.append("ImportMaterialNames:="), vArg1.append(import_materials) vArg1.append("SeparateDisjointLumps:="), vArg1.append(separate_disjoints_lumped_object) diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index 1c76fe2a835..2418f2119a5 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -3076,18 +3076,17 @@ def _create_fieldplot_line_traces( else: return False - @pyaedt_function_handler() - @deprecated_alias(IntrinsincDict="intrinsics") + @pyaedt_function_handler(objlist="objects", quantityName="quantity") def create_fieldplot_line( - self, objlist, quantityName, setup_name=None, intrinsics=None, plot_name=None, field_type="DC R/L Fields" + self, objects, quantity, setup_name=None, intrinsics=None, plot_name=None, field_type="DC R/L Fields" ): """Create a field plot of the line. Parameters ---------- - objlist : list + objects : list List of polyline to plot. - quantityName : str + quantity : str Name of the quantity to plot. setup_name : str, optional Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. @@ -3117,7 +3116,7 @@ def create_fieldplot_line( self.logger.info("Plot {} exists. returning the object.".format(plot_name)) return self.field_plots[plot_name] return self._create_fieldplot( - objlist, quantityName, setup_name, intrinsics, "Line", plot_name, field_type=field_type + objects, quantity, setup_name, intrinsics, "Line", plot_name, field_type=field_type ) @pyaedt_function_handler() @@ -3346,8 +3345,7 @@ def create_fieldplot_surface( new_obj_list, quantityName, setup_name, intrinsics, "FacesList", plot_name, field_type=field_type ) - @pyaedt_function_handler() - @deprecated_alias(IntrinsincDict="intrinsics") + @pyaedt_function_handler(IntrinsincDict="intrinsics") def create_fieldplot_cutplane( self, objlist, diff --git a/pyaedt/modules/solutions.py b/pyaedt/modules/solutions.py index 18d2734b4b0..54daa00bf2b 100644 --- a/pyaedt/modules/solutions.py +++ b/pyaedt/modules/solutions.py @@ -2632,7 +2632,7 @@ class FieldPlot: """ - @deprecated_alias(IntrinsincList="intrinsics") + @pyaedt_function_handler(IntrinsincList="intrinsics") def __init__( self, postprocessor, From 1da55dd1932c4cf7d08fda478bedc78f9634bf9d Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Wed, 27 Mar 2024 09:29:12 +0100 Subject: [PATCH 07/22] refactoring Post-Processing --- _unittest/test_12_1_PostProcessing.py | 24 +- _unittest/test_12_PostProcessing.py | 32 +- _unittest_solvers/test_00_analyze.py | 99 ++---- examples/02-HFSS/HFSS_Dipole.py | 10 +- examples/02-HFSS/HFSS_FSS_unitcell.py | 12 +- examples/02-SBR+/SBR_Example.py | 10 +- examples/03-Maxwell/Maxwell2D_DCConduction.py | 11 +- .../03-Maxwell/Maxwell2D_Electrostatic.py | 2 +- .../Maxwell2D_PMSynchronousMotor.py | 8 +- examples/03-Maxwell/Maxwell2D_Transient.py | 5 +- examples/03-Maxwell/Maxwell3DTeam7.py | 10 +- .../03-Maxwell/Maxwell3D_Team3_bath_plate.py | 10 +- examples/05-Q3D/Q3D_DC_IR.py | 3 +- examples/05-Q3D/Q3D_Example.py | 2 +- examples/06-Multiphysics/Hfss_Mechanical.py | 2 +- examples/06-Multiphysics/MRI.py | 8 +- .../Maxwell3D_Icepak_2Way_Coupling.py | 4 +- pyaedt/circuit.py | 7 +- pyaedt/hfss.py | 2 +- pyaedt/hfss3dlayout.py | 2 +- pyaedt/modules/AdvancedPostProcessing.py | 4 +- pyaedt/modules/PostProcessor.py | 311 +++++++++--------- pyaedt/modules/SolveSetup.py | 22 +- 23 files changed, 250 insertions(+), 350 deletions(-) diff --git a/_unittest/test_12_1_PostProcessing.py b/_unittest/test_12_1_PostProcessing.py index 609f128c44c..3de76837d15 100644 --- a/_unittest/test_12_1_PostProcessing.py +++ b/_unittest/test_12_1_PostProcessing.py @@ -136,9 +136,7 @@ def test_02_export_fields(self): plot2 = self.aedtapp.post.create_fieldplot_volume(vollist, quantity_name2, setup_name, intrinsic) self.aedtapp.post.export_field_jpg( - os.path.join(self.local_scratch.path, "prova2.jpg"), - plot2.name, - plot2.plotFolder, + os.path.join(self.local_scratch.path, "prova2.jpg"), plot2.name, plot2.plotFolder ) assert os.path.exists(os.path.join(self.local_scratch.path, "prova2.jpg")) assert os.path.exists( @@ -225,7 +223,7 @@ def test_07_export_fields_from_Calculator(self): os.path.join(self.local_scratch.path, "Efield.fld"), grid_stop=[5, 5, 5], grid_step=[0.5, 0.5, 0.5], - isvector=True, + is_vector=True, intrinsics="5GHz", ) assert os.path.exists(os.path.join(self.local_scratch.path, "Efield.fld")) @@ -235,10 +233,10 @@ def test_07_export_fields_from_Calculator(self): "Setup1 : LastAdaptive", self.aedtapp.available_variations.nominal_w_values_dict, os.path.join(self.local_scratch.path, "MagEfieldSph.fld"), - gridtype="Spherical", + grid_type="Spherical", grid_stop=[5, 300, 300], grid_step=[5, 50, 50], - isvector=False, + is_vector=False, intrinsics="5GHz", ) assert os.path.exists(os.path.join(self.local_scratch.path, "MagEfieldSph.fld")) @@ -248,10 +246,10 @@ def test_07_export_fields_from_Calculator(self): "Setup1 : LastAdaptive", self.aedtapp.available_variations.nominal_w_values_dict, os.path.join(self.local_scratch.path, "MagEfieldCyl.fld"), - gridtype="Cylindrical", + grid_type="Cylindrical", grid_stop=[5, 300, 5], grid_step=[5, 50, 5], - isvector=False, + is_vector=False, intrinsics="5GHz", ) assert os.path.exists(os.path.join(self.local_scratch.path, "MagEfieldCyl.fld")) @@ -271,12 +269,12 @@ def test_09_manipulate_report(self): assert self.aedtapp.post.create_report("dB(S(1,1))") assert self.aedtapp.post.create_report( expressions="MaxMagDeltaS", - variations={"Pass": ["All"]}, setup_sweep_name="Setup1 : AdaptivePass", + variations={"Pass": ["All"]}, primary_sweep_variable="Pass", report_category="Modal Solution Data", plot_type="Rectangular Plot", - plotname="Solution Convergence Plot", + plot_name="Solution Convergence Plot", ) new_report = self.aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") assert new_report.create() @@ -582,11 +580,11 @@ def test_15_export_plot(self): def test_16_create_field_plot(self): cutlist = ["Global:XY"] plot = self.aedtapp.post._create_fieldplot( - objlist=cutlist, - quantityName="Mag_E", + objects=cutlist, + quantity="Mag_E", setup_name=self.aedtapp.nominal_adaptive, intrinsics={}, - listtype="CutPlane", + list_type="CutPlane", ) assert plot diff --git a/_unittest/test_12_PostProcessing.py b/_unittest/test_12_PostProcessing.py index 8e3a906e7ab..982d8c53d8b 100644 --- a/_unittest/test_12_PostProcessing.py +++ b/_unittest/test_12_PostProcessing.py @@ -124,9 +124,9 @@ def test_09_manipulate_report(self, field_test): variations=variations, primary_sweep_variable="Phi", secondary_sweep_variable="Theta", + report_category="Far Fields", plot_type="3D Polar Plot", context=context, - report_category="Far Fields", ) assert field_test.post.create_report( "db(GainTotal)", @@ -134,9 +134,9 @@ def test_09_manipulate_report(self, field_test): variations=variations, primary_sweep_variable="Phi", secondary_sweep_variable="Theta", + report_category="Far Fields", plot_type="3D Polar Plot", context="3D", - report_category="Far Fields", ) report = AnsysReport() report.create() @@ -205,10 +205,7 @@ def test_09_manipulate_report_D(self, field_test): assert len(data.data_magnitude("GainTotal")) > 0 assert not data.data_magnitude("GainTotal2") assert field_test.post.create_report( - "S(1,1)", - field_test.nominal_sweep, - variations=variations, - plot_type="Smith Chart", + "S(1,1)", field_test.nominal_sweep, variations=variations, plot_type="Smith Chart" ) def test_09_manipulate_report_E(self, field_test): @@ -216,10 +213,7 @@ def test_09_manipulate_report_E(self, field_test): variations2 = field_test.available_variations.nominal_w_values_dict assert field_test.setups[0].create_report( - "Mag_E", - primary_sweep_variable="Distance", - context="Poly1", - report_category="Fields", + "Mag_E", primary_sweep_variable="Distance", report_category="Fields", context="Poly1" ) new_report = field_test.post.reports_by_category.fields("Mag_H", field_test.nominal_adaptive) new_report.variations = variations2 @@ -238,11 +232,11 @@ def test_09_manipulate_report_E(self, field_test): assert data.units_sweeps["Phase"] == "deg" assert field_test.post.get_far_field_data( - setup_sweep_name=field_test.nominal_adaptive, expression="RealizedGainTotal", domain="3D" + expression="RealizedGainTotal", setup_sweep_name=field_test.nominal_adaptive, domain="3D" ) data_farfield2 = field_test.post.get_far_field_data( - setup_sweep_name=field_test.nominal_adaptive, expression="RealizedGainTotal", + setup_sweep_name=field_test.nominal_adaptive, domain={"Context": "3D", "SourceContext": "1:1"}, ) assert data_farfield2.plot(math_formula="db20", is_polar=True) @@ -311,7 +305,7 @@ def test_17_circuit(self, circuit_test): new_report.plot_continous_spectrum = False assert new_report.create() assert circuit_test.post.create_report( - ["dB(V(net_11))", "dB(V(Port1))"], domain="Spectrum", setup_sweep_name="Transient" + ["dB(V(net_11))", "dB(V(Port1))"], setup_sweep_name="Transient", domain="Spectrum" ) new_report = circuit_test.post.reports_by_category.spectral(None, "Transient") new_report.window = "Hanning" @@ -898,7 +892,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post): scalar_function="Integrate", solution=None, variation_dict={"power_block": "0.25W", "power_source": "0.075W"}, - isvector=False, + is_vector=False, intrinsics=None, phase=None, object_name="cube2", @@ -910,7 +904,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post): scalar_function="Integrate", solution=None, variation_dict={"power_block": "0.6W", "power_source": "0.15W"}, - isvector=False, + is_vector=False, intrinsics=None, phase=None, object_name="cube2", @@ -922,7 +916,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post): scalar_function="Integrate", solution=None, variation_dict={"power_block": "0.6W", "power_source": "0.15W"}, - isvector=False, + is_vector=False, intrinsics=None, phase=None, object_name="cube2", @@ -934,7 +928,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post): scalar_function="Maximum", solution=None, variation_dict={"power_block": "0.6W", "power_source": "0.15W"}, - isvector=False, + is_vector=False, intrinsics=None, phase=None, object_name="cube1", @@ -946,7 +940,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post): scalar_function="Maximum", solution=None, variation_dict={"power_block": "0.6W", "power_source": "0.15W"}, - isvector=False, + is_vector=False, intrinsics=None, phase=None, object_name="cube2", @@ -958,7 +952,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post): scalar_function="Value", solution=None, variation_dict=None, - isvector=False, + is_vector=False, intrinsics=None, phase=None, object_name="Point1", diff --git a/_unittest_solvers/test_00_analyze.py b/_unittest_solvers/test_00_analyze.py index 4a5e93d7120..5f3b7639569 100644 --- a/_unittest_solvers/test_00_analyze.py +++ b/_unittest_solvers/test_00_analyze.py @@ -194,14 +194,12 @@ def test_02_hfss_export_results(self, hfss_app): assert len(exported_files) > 0 fld_file1 = os.path.join(self.local_scratch.path, "test_fld_hfss1.fld") - assert hfss_app.post.export_field_file( - quantity_name="Mag_E", filename=fld_file1, obj_list="Box1", intrinsics="1GHz", phase="5deg" - ) + assert hfss_app.post.export_field_file(quantity_name="Mag_E", filename=fld_file1, objects="Box1", + intrinsics="1GHz", phase="5deg") assert os.path.exists(fld_file1) fld_file2 = os.path.join(self.local_scratch.path, "test_fld_hfss2.fld") - assert hfss_app.post.export_field_file( - quantity_name="Mag_E", filename=fld_file2, obj_list="Box1", intrinsics="1GHz" - ) + assert hfss_app.post.export_field_file(quantity_name="Mag_E", filename=fld_file2, objects="Box1", + intrinsics="1GHz") assert os.path.exists(fld_file2) def test_03a_icepak_analyze_and_export_summary(self): @@ -302,48 +300,30 @@ def test_03d_icepak_eval_tempc(self): def test_03e_icepak_ExportFLDFil(self): fld_file = os.path.join(self.local_scratch.path, "test_fld.fld") - self.icepak_app.post.export_field_file( - quantity_name="Temp", - solution=self.icepak_app.nominal_sweep, - variation_dict={}, - filename=fld_file, - obj_list="box", - ) + self.icepak_app.post.export_field_file(quantity_name="Temp", solution=self.icepak_app.nominal_sweep, + variation_dict={}, filename=fld_file, objects="box") assert os.path.exists(fld_file) fld_file_1 = os.path.join(self.local_scratch.path, "test_fld_1.fld") sample_points_file = os.path.join(local_path, "example_models", test_subfolder, "temp_points.pts") - self.icepak_app.post.export_field_file( - quantity_name="Temp", - solution=self.icepak_app.nominal_sweep, - variation_dict=self.icepak_app.available_variations.nominal_w_values_dict, - filename=fld_file_1, - obj_list="box", - sample_points_file=sample_points_file, - ) + self.icepak_app.post.export_field_file(quantity_name="Temp", solution=self.icepak_app.nominal_sweep, + variation_dict=self.icepak_app.available_variations.nominal_w_values_dict, + filename=fld_file_1, objects="box", + sample_points_file=sample_points_file) assert os.path.exists(fld_file_1) fld_file_2 = os.path.join(self.local_scratch.path, "test_fld_2.fld") - self.icepak_app.post.export_field_file( - quantity_name="Temp", - solution=self.icepak_app.nominal_sweep, - variation_dict=self.icepak_app.available_variations.nominal_w_values_dict, - filename=fld_file_2, - obj_list="box", - sample_points_lists=[[0, 0, 0], [3, 6, 8], [4, 7, 9]], - ) + self.icepak_app.post.export_field_file(quantity_name="Temp", solution=self.icepak_app.nominal_sweep, + variation_dict=self.icepak_app.available_variations.nominal_w_values_dict, + filename=fld_file_2, objects="box", + sample_points_lists=[[0, 0, 0], [3, 6, 8], [4, 7, 9]]) assert os.path.exists(fld_file_2) cs = self.icepak_app.modeler.create_coordinate_system() fld_file_3 = os.path.join(self.local_scratch.path, "test_fld_3.fld") - self.icepak_app.post.export_field_file( - quantity_name="Temp", - solution=self.icepak_app.nominal_sweep, - variation_dict=self.icepak_app.available_variations.nominal_w_values_dict, - filename=fld_file_3, - obj_list="box", - sample_points_lists=[[0, 0, 0], [3, 6, 8], [4, 7, 9]], - reference_coordinate_system=cs.name, - export_in_si_system=False, - export_field_in_reference=False, - ) + self.icepak_app.post.export_field_file(quantity_name="Temp", solution=self.icepak_app.nominal_sweep, + variation_dict=self.icepak_app.available_variations.nominal_w_values_dict, + filename=fld_file_3, objects="box", + sample_points_lists=[[0, 0, 0], [3, 6, 8], [4, 7, 9]], + reference_coordinate_system=cs.name, export_in_si_system=False, + export_field_in_reference=False) assert os.path.exists(fld_file_3) def test_04a_3dl_generate_mesh(self): @@ -406,14 +386,9 @@ def test_05a_circuit_add_3dlayout_component(self, circuit_app): tx = ports rx = ports insertions = ["dB(S({},{}))".format(i.name, j.name) for i, j in zip(tx, rx)] - assert circuit_app.post.create_report( - insertions, - circuit_app.nominal_adaptive, - plotname="Insertion Losses", - plot_type="Rectangular Plot", - report_category="Standard", - subdesign_id=myedb.id, - ) + assert circuit_app.post.create_report(insertions, circuit_app.nominal_adaptive, report_category="Standard", + plot_type="Rectangular Plot", subdesign_id=myedb.id, + plot_name="Insertion Losses") new_report = circuit_app.post.reports_by_category.standard(insertions) new_report.sub_design_id = myedb.id assert new_report.create() @@ -455,30 +430,18 @@ def test_06_m3d_harmonic_forces(self, m3dtransient): def test_07_export_maxwell_fields(self, m3dtransient): m3dtransient.analyze(m3dtransient.active_setup, num_cores=2) fld_file_3 = os.path.join(self.local_scratch.path, "test_fld_3.fld") - assert m3dtransient.post.export_field_file( - quantity_name="Mag_B", - solution=m3dtransient.nominal_sweep, - variation_dict={}, - filename=fld_file_3, - obj_list="Coil_A2", - intrinsics="10ms", - obj_type="Surf", - ) + assert m3dtransient.post.export_field_file(quantity_name="Mag_B", solution=m3dtransient.nominal_sweep, + variation_dict={}, filename=fld_file_3, objects="Coil_A2", + objects_type="Surf", intrinsics="10ms") assert os.path.exists(fld_file_3) fld_file_4 = os.path.join(self.local_scratch.path, "test_fld_4.fld") - assert not m3dtransient.post.export_field_file( - quantity_name="Mag_B", - solution=m3dtransient.nominal_sweep, - variation_dict=m3dtransient.available_variations.nominal_w_values_dict, - filename=fld_file_4, - obj_list="Coil_A2", - obj_type="invalid", - ) + assert not m3dtransient.post.export_field_file(quantity_name="Mag_B", solution=m3dtransient.nominal_sweep, + variation_dict=m3dtransient.available_variations.nominal_w_values_dict, + filename=fld_file_4, objects="Coil_A2", objects_type="invalid") setup = m3dtransient.setups[0] m3dtransient.setups[0].delete() - assert not m3dtransient.post.export_field_file( - quantity_name="Mag_B", variation_dict={}, filename=fld_file_4, obj_list="Coil_A2" - ) + assert not m3dtransient.post.export_field_file(quantity_name="Mag_B", variation_dict={}, filename=fld_file_4, + objects="Coil_A2") new_setup = m3dtransient.create_setup(setupname=setup.name, setuptype=setup.setuptype) new_setup.props = setup.props diff --git a/examples/02-HFSS/HFSS_Dipole.py b/examples/02-HFSS/HFSS_Dipole.py index cf2a2313798..0010f3d64c2 100644 --- a/examples/02-HFSS/HFSS_Dipole.py +++ b/examples/02-HFSS/HFSS_Dipole.py @@ -120,14 +120,8 @@ variations["Freq"] = ["1GHz"] variations["Theta"] = ["All"] variations["Phi"] = ["All"] -hfss.post.create_report( - "db(GainTotal)", - hfss.nominal_adaptive, - variations, - primary_sweep_variable="Theta", - context="3D", - report_category="Far Fields", -) +hfss.post.create_report("db(GainTotal)", hfss.nominal_adaptive, variations, primary_sweep_variable="Theta", + report_category="Far Fields", context="3D") ############################################################################### # Create far fields report using report objects diff --git a/examples/02-HFSS/HFSS_FSS_unitcell.py b/examples/02-HFSS/HFSS_FSS_unitcell.py index caac56f878b..c673e43b07c 100644 --- a/examples/02-HFSS/HFSS_FSS_unitcell.py +++ b/examples/02-HFSS/HFSS_FSS_unitcell.py @@ -137,16 +137,8 @@ str_mag.append("mag(" + i + ")") str_ang.append("ang_deg(" + i + ")") -hfss.post.create_report( - expressions=str_mag, - variations=variation, - plotname="magnitude_plot", -) -hfss.post.create_report( - expressions=str_ang, - variations=variation, - plotname="phase_plot", -) +hfss.post.create_report(expressions=str_mag, variations=variation, plot_name="magnitude_plot") +hfss.post.create_report(expressions=str_ang, variations=variation, plot_name="phase_plot") ############################################################################### # Save and run simulation diff --git a/examples/02-SBR+/SBR_Example.py b/examples/02-SBR+/SBR_Example.py index 21536df865a..7839e01318d 100644 --- a/examples/02-SBR+/SBR_Example.py +++ b/examples/02-SBR+/SBR_Example.py @@ -96,14 +96,8 @@ variations["Freq"] = ["10GHz"] variations["Theta"] = ["All"] variations["Phi"] = ["All"] -target.post.create_report( - "db(GainTotal)", - target.nominal_adaptive, - variations=variations, - primary_sweep_variable="Theta", - context="ATK_3D", - report_category="Far Fields", -) +target.post.create_report("db(GainTotal)", target.nominal_adaptive, variations=variations, + primary_sweep_variable="Theta", report_category="Far Fields", context="ATK_3D") ############################################################################### # Plot results outside AEDT diff --git a/examples/03-Maxwell/Maxwell2D_DCConduction.py b/examples/03-Maxwell/Maxwell2D_DCConduction.py index c4ab0634b3e..b64bfff4217 100644 --- a/examples/03-Maxwell/Maxwell2D_DCConduction.py +++ b/examples/03-Maxwell/Maxwell2D_DCConduction.py @@ -136,14 +136,9 @@ # Create R. vs. material report variations = {"MaterialIndex": ["All"], "MaterialThickness": ["Nominal"]} -report = m2d.post.create_report( - expressions="1/Matrix1.G(1V,1V)/MaterialThickness", - primary_sweep_variable="MaterialIndex", - report_category="DCConduction", - plot_type="Data Table", - variations=variations, - plotname="Resistance vs. Material", -) +report = m2d.post.create_report(expressions="1/Matrix1.G(1V,1V)/MaterialThickness", variations=variations, + primary_sweep_variable="MaterialIndex", report_category="DCConduction", + plot_type="Data Table", plot_name="Resistance vs. Material") ############################################################################### # Get solution data diff --git a/examples/03-Maxwell/Maxwell2D_Electrostatic.py b/examples/03-Maxwell/Maxwell2D_Electrostatic.py index e6c315df8cd..dd37e9fafbc 100644 --- a/examples/03-Maxwell/Maxwell2D_Electrostatic.py +++ b/examples/03-Maxwell/Maxwell2D_Electrostatic.py @@ -196,7 +196,7 @@ # Export field line traces plot. # For field lint traces plot, the export file format is ``.fldplt``. -M2D.post.export_field_plot(plotname="LineTracesTest", filepath=M2D.toolkit_directory, file_format="fldplt") +M2D.post.export_field_plot(plot_name="LineTracesTest", file_path=M2D.toolkit_directory, file_format="fldplt") ########################################################## # Export a field plot to an image file diff --git a/examples/03-Maxwell/Maxwell2D_PMSynchronousMotor.py b/examples/03-Maxwell/Maxwell2D_PMSynchronousMotor.py index 11234daaa11..81f8862d987 100644 --- a/examples/03-Maxwell/Maxwell2D_PMSynchronousMotor.py +++ b/examples/03-Maxwell/Maxwell2D_PMSynchronousMotor.py @@ -692,9 +692,9 @@ def create_cs_magnets(pm_id, cs_name, point_direction): for k, v in post_params.items(): M2D.post.create_report(expressions=k, setup_sweep_name="", domain="Sweep", variations=None, - primary_sweep_variable="Time", secondary_sweep_variable=None, - report_category=None, plot_type="Rectangular Plot", context=None, subdesign_id=None, - polyline_points=1001, plotname=v) + primary_sweep_variable="Time", secondary_sweep_variable=None, report_category=None, + plot_type="Rectangular Plot", context=None, subdesign_id=None, polyline_points=1001, + plot_name=v) ########################################################## # Create multiplot report @@ -723,7 +723,7 @@ def create_cs_magnets(pm_id, cs_name, point_direction): # formerly created when the section is applied. faces_reg = mod2D.get_object_faces(object_list[1].name) # Region -plot1 = M2D.post.create_fieldplot_surface(objlist=faces_reg, quantityName='Flux_Lines', intrinsics={ +plot1 = M2D.post.create_fieldplot_surface(objects=faces_reg, quantity='Flux_Lines', intrinsics={ "Time": M2D.variable_manager.variables["StopTime"].evaluated_value}, plot_name="Flux_Lines") ########################################################## diff --git a/examples/03-Maxwell/Maxwell2D_Transient.py b/examples/03-Maxwell/Maxwell2D_Transient.py index 69e7d25de63..8725c14986d 100644 --- a/examples/03-Maxwell/Maxwell2D_Transient.py +++ b/examples/03-Maxwell/Maxwell2D_Transient.py @@ -106,9 +106,8 @@ # ~~~~~~~~~~~~~~~~~~~~~~~ # Create a rectangular plot. -maxwell_2d.post.create_report( - "InputCurrent(PHA)", domain="Time", primary_sweep_variable="Time", plotname="Winding Plot 1" -) +maxwell_2d.post.create_report("InputCurrent(PHA)", domain="Time", primary_sweep_variable="Time", + plot_name="Winding Plot 1") ############################################################################### # Solve model diff --git a/examples/03-Maxwell/Maxwell3DTeam7.py b/examples/03-Maxwell/Maxwell3DTeam7.py index 16c6c090b06..cdb5952a941 100644 --- a/examples/03-Maxwell/Maxwell3DTeam7.py +++ b/examples/03-Maxwell/Maxwell3DTeam7.py @@ -398,14 +398,8 @@ "Phase": ["0deg", "90deg"], "Coil_Excitation": ["All"], } - report = m3d.post.create_report( - plotname=plot_name, - report_category="Fields", - context="Line_" + t[3:8], - primary_sweep_variable="Distance", - variations=variations, - expressions=t[0:2], - ) + report = m3d.post.create_report(expressions=t[0:2], variations=variations, primary_sweep_variable="Distance", + report_category="Fields", context="Line_" + t[3:8], plot_name=plot_name) file_path = os.path.join(temp_dir.name, str(dataset[i]) + ".csv") report.import_traces(file_path, plot_name) diff --git a/examples/03-Maxwell/Maxwell3D_Team3_bath_plate.py b/examples/03-Maxwell/Maxwell3D_Team3_bath_plate.py index 73f264480f0..c71e2072117 100644 --- a/examples/03-Maxwell/Maxwell3D_Team3_bath_plate.py +++ b/examples/03-Maxwell/Maxwell3D_Team3_bath_plate.py @@ -192,14 +192,8 @@ # Plot mag(Bz) as a function of frequency for both coil positions. variations = {"Distance": ["All"], "Freq": ["All"], "Phase": ["0deg"], "Coil_Position": ["All"]} -m3d.post.create_report( - expressions="mag(Bz)", - report_category="Fields", - context="Line_AB", - variations=variations, - primary_sweep_variable="Distance", - plotname="mag(Bz) Along 'Line_AB' Coil", -) +m3d.post.create_report(expressions="mag(Bz)", variations=variations, primary_sweep_variable="Distance", + report_category="Fields", context="Line_AB", plot_name="mag(Bz) Along 'Line_AB' Coil") ############################################################################### # Get simulation results from a solved setup diff --git a/examples/05-Q3D/Q3D_DC_IR.py b/examples/05-Q3D/Q3D_DC_IR.py index b565d1a2576..39fd21e8be2 100644 --- a/examples/05-Q3D/Q3D_DC_IR.py +++ b/examples/05-Q3D/Q3D_DC_IR.py @@ -214,8 +214,7 @@ # ~~~~~~~~ # Compute ACL solutions and plot them. -plot1 = q3d.post.create_fieldplot_surface(q3d.modeler.get_objects_by_material("copper"), quantityName=drop_name, - intrinsic_dict={"Freq": "1GHz"}) +plot1 = q3d.post.create_fieldplot_surface(q3d.modeler.get_objects_by_material("copper"), quantity=drop_name) q3d.post.plot_field_from_fieldplot( plot1.name, diff --git a/examples/05-Q3D/Q3D_Example.py b/examples/05-Q3D/Q3D_Example.py index a062303fd4d..793ff31dd24 100644 --- a/examples/05-Q3D/Q3D_Example.py +++ b/examples/05-Q3D/Q3D_Example.py @@ -147,7 +147,7 @@ # Create a rectangular plot and a data table. q.post.create_report(expressions=data_plot_self) -q.post.create_report(expressions=data_plot_mutual, context="Original", plot_type="Data Table") +q.post.create_report(expressions=data_plot_mutual, plot_type="Data Table", context="Original") ############################################################################### # Solve setup diff --git a/examples/06-Multiphysics/Hfss_Mechanical.py b/examples/06-Multiphysics/Hfss_Mechanical.py index ed08b23ebe4..6c42724257b 100644 --- a/examples/06-Multiphysics/Hfss_Mechanical.py +++ b/examples/06-Multiphysics/Hfss_Mechanical.py @@ -158,7 +158,7 @@ surfaces = [] for name in mech.get_all_conductors_names(): surfaces.extend(mech.modeler.get_object_faces(name)) -mech.post.create_fieldplot_surface(objlist=surfaces, quantityName="Temperature") +mech.post.create_fieldplot_surface(objects=surfaces, quantity="Temperature") ############################################################################### # Release AEDT diff --git a/examples/06-Multiphysics/MRI.py b/examples/06-Multiphysics/MRI.py index 8b2ebeddab4..d50dddbeca9 100644 --- a/examples/06-Multiphysics/MRI.py +++ b/examples/06-Multiphysics/MRI.py @@ -107,7 +107,7 @@ # Draw Point1 at origin of the implant coordinate system hfss.sar_setup(-1, Average_SAR_method=1, TissueMass=1, MaterialDensity=1, ) -hfss.post.create_fieldplot_cutplane(objlist="implant:YZ", quantityName="Average_SAR", filter_objects=["implant_box"]) +hfss.post.create_fieldplot_cutplane(objects="implant:YZ", quantity="Average_SAR", filter_objects=["implant_box"]) hfss.modeler.set_working_coordinate_system("implant") hfss.modeler.create_point([0, 0, 0], name="Point1") @@ -212,8 +212,7 @@ # Plot Temperature on cut plane. # Plot Temperature on point. -mech.post.create_fieldplot_cutplane("implant:YZ", "Temperature", intrinsic_dict={"Time": "10s"}, - filter_objects=["implant_box"]) +mech.post.create_fieldplot_cutplane("implant:YZ", "Temperature", filter_objects=["implant_box"]) mech.save_project() data = mech.post.get_solution_data("Temperature", primary_sweep_variable="Time", context="Point1", @@ -303,8 +302,7 @@ # Plot Temperature on monitor point. ipk.analyze(num_cores=4,num_tasks=4) -ipk.post.create_fieldplot_cutplane("implant:YZ", "Temperature", intrinsic_dict={"Time": "0s"}, - filter_objects=["implant_box"]) +ipk.post.create_fieldplot_cutplane("implant:YZ", "Temperature", filter_objects=["implant_box"]) ipk.save_project() data = ipk.post.get_solution_data("Point1.Temperature", primary_sweep_variable="Time", report_category="Monitor") diff --git a/examples/06-Multiphysics/Maxwell3D_Icepak_2Way_Coupling.py b/examples/06-Multiphysics/Maxwell3D_Icepak_2Way_Coupling.py index b3c843a56a2..4f5e9b12bd6 100644 --- a/examples/06-Multiphysics/Maxwell3D_Icepak_2Way_Coupling.py +++ b/examples/06-Multiphysics/Maxwell3D_Icepak_2Way_Coupling.py @@ -255,10 +255,10 @@ for name in ["Coil", "Core"]: surface_list.extend(ipk.modeler.get_object_faces(name)) -surf_temperature = ipk.post.create_fieldplot_surface(surface_list, quantityName="SurfTemperature", +surf_temperature = ipk.post.create_fieldplot_surface(surface_list, quantity="SurfTemperature", plot_name="Surface Temperature") -velocity_cutplane = ipk.post.create_fieldplot_cutplane(objlist=["Global:XZ"], quantityName="Velocity Vectors", +velocity_cutplane = ipk.post.create_fieldplot_cutplane(objects=["Global:XZ"], quantity="Velocity Vectors", plot_name="Velocity Vectors") surf_temperature.export_image() diff --git a/pyaedt/circuit.py b/pyaedt/circuit.py index a9b1ac80009..341b2d8e69a 100644 --- a/pyaedt/circuit.py +++ b/pyaedt/circuit.py @@ -1019,7 +1019,12 @@ def create_touchstone_report( if differential_pairs: dif = "Differential Pairs" return self.post.create_report( - curvenames, solution_name, variations=variations, plotname=plot_name, context=dif, subdesign_id=subdesign_id + curvenames, + solution_name, + variations=variations, + context=dif, + subdesign_id=subdesign_id, + plot_name=plot_name, ) @pyaedt_function_handler() diff --git a/pyaedt/hfss.py b/pyaedt/hfss.py index 8b68f560eb9..dae55bc901d 100644 --- a/pyaedt/hfss.py +++ b/pyaedt/hfss.py @@ -4346,7 +4346,7 @@ def create_scattering( port_excited = port_names traces = ["dB(S(" + p + "," + q + "))" for p, q in zip(list(port_names), list(port_excited))] return self.post.create_report( - traces, sweep_name, variations=variations, report_category=solution_data, plotname=plot_name + traces, sweep_name, variations=variations, report_category=solution_data, plot_name=plot_name ) @pyaedt_function_handler() diff --git a/pyaedt/hfss3dlayout.py b/pyaedt/hfss3dlayout.py index fd8adb2738b..4101090476f 100644 --- a/pyaedt/hfss3dlayout.py +++ b/pyaedt/hfss3dlayout.py @@ -769,7 +769,7 @@ def create_scattering( port_excited = port_names traces = ["dB(S(" + p + "," + q + "))" for p, q in zip(list(port_names), list(port_excited))] return self.post.create_report( - traces, sweep_name, variations=variations, report_category=solution_data, plotname=plot_name + traces, sweep_name, variations=variations, report_category=solution_data, plot_name=plot_name ) @pyaedt_function_handler() diff --git a/pyaedt/modules/AdvancedPostProcessing.py b/pyaedt/modules/AdvancedPostProcessing.py index a5fd328e2e9..21d03254647 100644 --- a/pyaedt/modules/AdvancedPostProcessing.py +++ b/pyaedt/modules/AdvancedPostProcessing.py @@ -135,7 +135,7 @@ def get_efields_data(self, setup_sweep_name="", ff_setup="Infinite Sphere1", fre trace_name = "rETheta" solnData = self.get_far_field_data( - setup_sweep_name=setup_sweep_name, domain=ff_setup, expression=trace_name + expression=trace_name, setup_sweep_name=setup_sweep_name, domain=ff_setup ) data = solnData.nominal_variation @@ -152,7 +152,7 @@ def get_efields_data(self, setup_sweep_name="", ff_setup="Infinite Sphere1", fre trace_name = "rEPhi" solnData = self.get_far_field_data( - setup_sweep_name=setup_sweep_name, domain=ff_setup, expression=trace_name + expression=trace_name, setup_sweep_name=setup_sweep_name, domain=ff_setup ) data = solnData.nominal_variation diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index 2418f2119a5..39fefa62bc6 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -21,7 +21,6 @@ from pyaedt.generic.DataHandlers import _dict_items_to_list_items from pyaedt.generic.constants import unit_converter from pyaedt.generic.general_methods import check_and_download_file -from pyaedt.generic.general_methods import deprecated_alias from pyaedt.generic.general_methods import generate_unique_name from pyaedt.generic.general_methods import open_file from pyaedt.generic.general_methods import pyaedt_function_handler @@ -1094,13 +1093,13 @@ def all_report_names(self): """ return list(self.oreportsetup.GetAllReportNames()) - @pyaedt_function_handler() - def copy_report_data(self, PlotName): + @pyaedt_function_handler(PlotName="plot_name") + def copy_report_data(self, plot_name): """Copy report data as static data. Parameters ---------- - PlotName : str + plot_name : str Name of the report. Returns @@ -1114,7 +1113,7 @@ def copy_report_data(self, PlotName): >>> oModule.CopyReportsData >>> oModule.PasteReports """ - self.oreportsetup.CopyReportsData([PlotName]) + self.oreportsetup.CopyReportsData([plot_name]) self.oreportsetup.PasteReports() return True @@ -1183,27 +1182,27 @@ def rename_report(self, plot_name, new_name): except: return False - @pyaedt_function_handler() + @pyaedt_function_handler(soltype="solution_type", ctxt="context", expression="expressions") def get_solution_data_per_variation( - self, soltype="Far Fields", setup_sweep_name="", ctxt=None, sweeps=None, expression="" + self, solution_type="Far Fields", setup_sweep_name="", context=None, sweeps=None, expressions="" ): """Retrieve solution data for each variation. Parameters ---------- - soltype : str, optional + solution_type : str, optional Type of the solution. For example, ``"Far Fields"`` or ``"Modal Solution Data"``. The default is ``"Far Fields"``. setup_sweep_name : str, optional Name of the setup for computing the report. The default is ``""``, in which case ``"nominal adaptive"`` is used. - ctxt : list, optional + context : list, optional List of context variables. The default is ``None``. sweeps : dict, optional Dictionary of variables and values. The default is ``None``, in which case this list is used: ``{'Theta': 'All', 'Phi': 'All', 'Freq': 'All'}``. - expression : str or list, optional + expressions : str or list, optional One or more traces to include. The default is ``""``. Returns @@ -1218,16 +1217,18 @@ def get_solution_data_per_variation( """ if sweeps is None: sweeps = {"Theta": "All", "Phi": "All", "Freq": "All"} - if not ctxt: - ctxt = [] - if not isinstance(expression, list): - expression = [expression] + if not context: + context = [] + if not isinstance(expressions, list): + expressions = [expressions] if not setup_sweep_name: setup_sweep_name = self._app.nominal_adaptive sweep_list = _convert_dict_to_report_sel(sweeps) try: data = list( - self.oreportsetup.GetSolutionDataPerVariation(soltype, setup_sweep_name, ctxt, sweep_list, expression) + self.oreportsetup.GetSolutionDataPerVariation( + solution_type, setup_sweep_name, context, sweep_list, expressions + ) ) self.logger.info("Solution Data Correctly Loaded.") return SolutionData(data) @@ -1439,7 +1440,7 @@ def export_report_to_jpg(self, project_dir, plot_name, width=0, height=0): self.oreportsetup.ExportImageToFile(plot_name, file_name, width, height) return True - @pyaedt_function_handler() + @pyaedt_function_handler(plotname="plot_name") def _get_report_inputs( self, expressions, @@ -1453,7 +1454,7 @@ def _get_report_inputs( context=None, subdesign_id=None, polyline_points=0, - plotname=None, + plot_name=None, only_get_method=False, ): ctxt = [] @@ -1564,8 +1565,8 @@ def _get_report_inputs( modal_data = self._app.design_solutions.report_type else: modal_data = report_category - if not plotname: - plotname = generate_unique_name("Plot") + if not plot_name: + plot_name = generate_unique_name("Plot") arg = ["X Component:=", primary_sweep_variable, "Y Component:=", expressions] if plot_type in ["3D Polar Plot", "3D Spherical Plot"]: @@ -1596,9 +1597,9 @@ def _get_report_inputs( "Z Component:=", expressions, ] - return [plotname, modal_data, plot_type, setup_sweep_name, ctxt, families_input, arg] + return [plot_name, modal_data, plot_type, setup_sweep_name, ctxt, families_input, arg] - @pyaedt_function_handler() + @pyaedt_function_handler(plotname="plot_name") def create_report( self, expressions=None, @@ -1612,7 +1613,7 @@ def create_report( context=None, subdesign_id=None, polyline_points=1001, - plotname=None, + plot_name=None, ): """Create a report in AEDT. It can be a 2D plot, 3D plot, polar plots or data tables. @@ -1643,7 +1644,7 @@ def create_report( The default is ``None``. It can be `None`, `"Differential Pairs"`,`"RL"`, `"Sources"`, `"Vias"`,`"Bondwires"`, `"Probes"` for Hfss3dLayout or Reduce Matrix Name for Q2d/Q3d solution or Infinite Sphere name for Far Fields Plot. - plotname : str, optional + plot_name : str, optional Name of the plot. The default is ``None``. polyline_points : int, optional, Number of points on which create the report for plots on polylines. @@ -1673,29 +1674,23 @@ def create_report( >>> variations["Theta"] = ["All"] >>> variations["Phi"] = ["All"] >>> variations["Freq"] = ["30GHz"] - >>> aedtapp.post.create_report( - ... "db(GainTotal)", - ... aedtapp.nominal_adaptive, - ... variations=variations, - ... primary_sweep_variable="Phi", - ... secondary_sweep_variable="Theta", - ... plot_type="3D Polar Plot", - ... context="3D", - ... report_category="Far Fields", - ...) + >>> aedtapp.post.create_report(expressions="db(GainTotal)", + ... setup_sweep_name=aedtapp.nominal_adaptive, + ... variations=variations, + ... primary_sweep_variable="Phi", + ... secondary_sweep_variable="Theta", + ... report_category="Far Fields", + ... plot_type="3D Polar Plot", + ... context="3D") - >>> aedtapp.post.create_report( - ... "S(1,1)", - ... aedtapp.nominal_sweep, - ... variations=variations, - ... plot_type="Smith Chart", - ...) + >>> aedtapp.post.create_report("S(1,1)",aedtapp.nominal_sweep,variations=variations,plot_type="Smith Chart") >>> from pyaedt import Maxwell2d >>> maxwell_2d = Maxwell2d() - >>> maxwell_2d.post.create_report( - ... "InputCurrent(PHA)", domain="Time", primary_sweep_variable="Time", plotname="Winding Plot 1" - ... ) + >>> maxwell_2d.post.create_report(expressions="InputCurrent(PHA)", + ... domain="Time", + ... primary_sweep_variable="Time", + ... plot_name="Winding Plot 1") """ if not setup_sweep_name: setup_sweep_name = self._app.nominal_sweep @@ -1788,7 +1783,7 @@ def create_report( if context in self.modeler.line_names or context in self.modeler.point_names: report.polyline = context - result = report.create(plotname) + result = report.create(plot_name) if result: return report return False @@ -2194,21 +2189,21 @@ def _get_intrinsic(self, setup): intr_dict[intr[0]] = intr[1].replace("\\", "").replace("'", "") return intr_dict - @pyaedt_function_handler() - def _get_volume_objects(self, list_objs): + @pyaedt_function_handler(list_objs="objects") + def _get_volume_objects(self, objects): if self._app.solution_type not in ["HFSS3DLayout", "HFSS 3D Layout Design"]: obj_list = [] editor = self._app._odesign.SetActiveEditor("3D Modeler") - for obj in list_objs: + for obj in objects: obj_list.append(editor.GetObjectNameByID(int(obj))) if obj_list: return obj_list else: - return list_objs + return objects - @pyaedt_function_handler() - def _get_surface_objects(self, list_objs): - faces = [int(i) for i in list_objs] + @pyaedt_function_handler(list_objs="objects") + def _get_surface_objects(self, objects): + faces = [int(i) for i in objects] if self._app.solution_type not in ["HFSS3DLayout", "HFSS 3D Layout Design"]: planes = self._get_cs_plane_ids() objs = [] @@ -2330,17 +2325,17 @@ def volumetric_loss(self, object_name): oModule.AddNamedExpression(name, "Fields") return name - @pyaedt_function_handler() - def change_field_property(self, plotname, propertyname, propertyval): + @pyaedt_function_handler(plotname="plot_name", propertyname="property_name", propertyval="property_value") + def change_field_property(self, plot_name, property_name, property_value): """Modify a field plot property. Parameters ---------- - plotname : str + plot_name : str Name of the field plot. - propertyname : str + property_name : str Name of the property. - propertyval : + property_value : Value for the property. Returns @@ -2358,20 +2353,20 @@ def change_field_property(self, plotname, propertyname, propertyval): "NAME:AllTabs", [ "NAME:FieldsPostProcessorTab", - ["NAME:PropServers", "FieldsReporter:" + plotname], - ["NAME:ChangedProps", ["NAME:" + propertyname, "Value:=", propertyval]], + ["NAME:PropServers", "FieldsReporter:" + plot_name], + ["NAME:ChangedProps", ["NAME:" + property_name, "Value:=", property_value]], ], ] ) - @pyaedt_function_handler() + @pyaedt_function_handler(isvector="is_vector") def get_scalar_field_value( self, quantity_name, scalar_function="Maximum", solution=None, variation_dict=None, - isvector=False, + is_vector=False, intrinsics=None, phase=None, object_name="AllObjects", @@ -2393,7 +2388,7 @@ def get_scalar_field_value( Dictionary of all variation variables with their values. e.g. ``['power_block:=', ['0.6W'], 'power_source:=', ['0.15W']]`` The default is ``None``. - isvector : bool, optional + is_vector : bool, optional Whether the quantity is a vector. The default is ``False``. intrinsics : str, optional This parameter is mandatory for a frequency field @@ -2430,7 +2425,7 @@ def get_scalar_field_value( if not solution: solution = self._app.existing_analysis_sweeps[0] self.ofieldsreporter.CalcStack("clear") - if isvector: + if is_vector: try: self.ofieldsreporter.EnterQty(quantity_name) except: @@ -2491,19 +2486,19 @@ def get_scalar_field_value( self.ofieldsreporter.CalcStack("clear") return float(value) - @pyaedt_function_handler() + @pyaedt_function_handler(gridtype="grid_type", isvector="is_vector") def export_field_file_on_grid( self, quantity_name, solution=None, variation_dict=None, filename=None, - gridtype="Cartesian", + grid_type="Cartesian", grid_center=None, grid_start=None, grid_stop=None, grid_step=None, - isvector=False, + is_vector=False, intrinsics=None, phase=None, export_with_sample_points=True, @@ -2525,7 +2520,7 @@ def export_field_file_on_grid( filename : str, optional Full path and name to save the file to. The default is ``None`` which export file in working_directory. - gridtype : str, optional + grid_type : str, optional Type of the grid to export. The default is ``"Cartesian"``. grid_center : list, optional The ``[x, y, z]`` coordinates for the center of the grid. @@ -2540,7 +2535,7 @@ def export_field_file_on_grid( grid_step : list, optional The ``[x, y, z]`` coordinates for the step size of the grid. The default is ``[0, 0, 0]``. - isvector : bool, optional + is_vector : bool, optional Whether the quantity is a vector. The default is ``False``. intrinsics : str, optional This parameter is mandatory for a frequency field @@ -2582,7 +2577,7 @@ def export_field_file_on_grid( >>> var = hfss.available_variations.nominal_w_values >>> setup = "Setup1 : LastAdaptive" >>> path = "Field.fld" - >>> hfss.post.export_field_file_on_grid("E", setup, var, path, 'Cartesian', [0, 0, 0], intrinsics="8GHz") + >>> hfss.post.export_field_file_on_grid("E",setup,var,path,'Cartesian',[0, 0, 0],intrinsics="8GHz") """ if grid_step is None: grid_step = [0, 0, 0] @@ -2606,7 +2601,7 @@ def export_field_file_on_grid( self.ofieldsreporter.EnterQty(quantity_name) except: self.ofieldsreporter.CopyNamedExprToStack(quantity_name) - if isvector: + if is_vector: self.ofieldsreporter.CalcOp("Smooth") if phase: self.ofieldsreporter.EnterScalar(0) @@ -2614,17 +2609,17 @@ def export_field_file_on_grid( self.ofieldsreporter.CalcOp("Mag") units = self.modeler.model_units ang_units = "deg" - if gridtype == "Cartesian": + if grid_type == "Cartesian": grid_center = ["0mm", "0mm", "0mm"] grid_start_wu = [str(i) + units for i in grid_start] grid_stop_wu = [str(i) + units for i in grid_stop] grid_step_wu = [str(i) + units for i in grid_step] - elif gridtype == "Cylindrical": + elif grid_type == "Cylindrical": grid_center = [str(i) + units for i in grid_center] grid_start_wu = [str(grid_start[0]) + units, str(grid_start[1]) + ang_units, str(grid_start[2]) + units] grid_stop_wu = [str(grid_stop[0]) + units, str(grid_stop[1]) + ang_units, str(grid_stop[2]) + units] grid_step_wu = [str(grid_step[0]) + units, str(grid_step[1]) + ang_units, str(grid_step[2]) + units] - elif gridtype == "Spherical": + elif grid_type == "Spherical": grid_center = [str(i) + units for i in grid_center] grid_start_wu = [str(grid_start[0]) + units, str(grid_start[1]) + ang_units, str(grid_start[2]) + ang_units] grid_stop_wu = [str(grid_stop[0]) + units, str(grid_stop[1]) + ang_units, str(grid_stop[2]) + ang_units] @@ -2674,7 +2669,7 @@ def export_field_file_on_grid( solution, variation, export_options, - gridtype, + grid_type, grid_center, False, ) @@ -2682,15 +2677,15 @@ def export_field_file_on_grid( return filename return False # pragma: no cover - @pyaedt_function_handler() + @pyaedt_function_handler(obj_list="objects", obj_type="objects_type") def export_field_file( self, quantity_name, solution=None, variation_dict=None, filename=None, - obj_list="AllObjects", - obj_type="Vol", + objects="AllObjects", + objects_type="Vol", intrinsics=None, phase=None, sample_points_file=None, @@ -2715,9 +2710,9 @@ def export_field_file( filename : str, optional Full path and name to save the file to. The default is ``None`` which export file in working_directory. - obj_list : str, optional + objects : str, optional List of objects to export. The default is ``"AllObjects"``. - obj_type : str, optional + objects_type : str, optional Type of objects to export. Options are ``"Vol"`` for volume and ``"Surf"`` for surface. The default is ``"Vol"``. intrinsics : str, optional @@ -2797,10 +2792,10 @@ def export_field_file( else: variation.append("0deg") if not sample_points_file and not sample_points_lists: - if obj_type == "Vol": - self.ofieldsreporter.EnterVol(obj_list) - elif obj_type == "Surf": - self.ofieldsreporter.EnterSurf(obj_list) + if objects_type == "Vol": + self.ofieldsreporter.EnterVol(objects) + elif objects_type == "Surf": + self.ofieldsreporter.EnterSurf(objects) else: self.logger.error("No correct choice.") return False @@ -2854,19 +2849,19 @@ def export_field_file( return filename return False # pragma: no cover - @pyaedt_function_handler() - def export_field_plot(self, plotname, filepath, filename="", file_format="aedtplt"): + @pyaedt_function_handler(plotname="plot_name", filepath="file_path", filename="file_name") + def export_field_plot(self, plot_name, file_path, file_name="", file_format="aedtplt"): """Export a field plot. Parameters ---------- - plotname : str + plot_name : str Name of the plot. - filepath : str + file_path : str Path for saving the file. - filename : str, optional + file_name : str, optional Name of the file. The default is ``""``. file_format : str, optional @@ -2881,15 +2876,15 @@ def export_field_plot(self, plotname, filepath, filename="", file_format="aedtpl ---------- >>> oModule.ExportFieldPlot """ - if not filename: - filename = plotname - filepath = os.path.join(filepath, filename + "." + file_format) + if not file_name: + file_name = plot_name + file_path = os.path.join(file_path, file_name + "." + file_format) try: - self.ofieldsreporter.ExportFieldPlot(plotname, False, filepath) + self.ofieldsreporter.ExportFieldPlot(plot_name, False, file_path) if settings.remote_rpc_session_temp_folder: # pragma: no cover - local_path = os.path.join(settings.remote_rpc_session_temp_folder, filename + "." + file_format) - filepath = check_and_download_file(local_path, filepath) - return filepath + local_path = os.path.join(settings.remote_rpc_session_temp_folder, file_name + "." + file_format) + file_path = check_and_download_file(local_path, file_path) + return file_path except: # pragma: no cover self.logger.error("{} file format is not supported for this plot.".format(file_format)) return False @@ -2953,20 +2948,20 @@ def change_field_plot_scale(self, plot_name, minimum_value, maximum_value, is_lo self.ofieldsreporter.SetPlotFolderSettings(plot_name, args) return True - @pyaedt_function_handler() + @pyaedt_function_handler(objlist="objects", quantityName="quantity", listtype="list_type") def _create_fieldplot( self, - objlist, - quantityName, + objects, + quantity, setup_name, intrinsics, - listtype, + list_type, plot_name=None, filter_boxes=None, field_type=None, ): - if not listtype.startswith("Layer") and self._app.design_type != "HFSS 3D Layout Design": - objlist = self._app.modeler.convert_to_selections(objlist, True) + if not list_type.startswith("Layer") and self._app.design_type != "HFSS 3D Layout Design": + objects = self._app.modeler.convert_to_selections(objects, True) if not setup_name: setup_name = self._app.existing_analysis_sweeps[0] if not intrinsics: @@ -2983,32 +2978,32 @@ def _create_fieldplot( char_set = string.ascii_uppercase + string.digits if not plot_name: - plot_name = quantityName + "_" + "".join(random.sample(char_set, 6)) + plot_name = quantity + "_" + "".join(random.sample(char_set, 6)) filter_boxes = [] if filter_boxes is None else filter_boxes - if listtype == "CutPlane": + if list_type == "CutPlane": plot = FieldPlot( - self, cutplanelist=objlist, solutionName=setup_name, quantityName=quantityName, intrinsics=intrinsics + self, cutplanelist=objects, solutionName=setup_name, quantityName=quantity, intrinsics=intrinsics ) - elif listtype == "FacesList": + elif list_type == "FacesList": plot = FieldPlot( - self, surfacelist=objlist, solutionName=setup_name, quantityName=quantityName, intrinsics=intrinsics + self, surfacelist=objects, solutionName=setup_name, quantityName=quantity, intrinsics=intrinsics ) - elif listtype == "ObjList": + elif list_type == "ObjList": plot = FieldPlot( - self, objlist=objlist, solutionName=setup_name, quantityName=quantityName, intrinsics=intrinsics + self, objlist=objects, solutionName=setup_name, quantityName=quantity, intrinsics=intrinsics ) - elif listtype == "Line": + elif list_type == "Line": plot = FieldPlot( - self, linelist=objlist, solutionName=setup_name, quantityName=quantityName, intrinsics=intrinsics + self, linelist=objects, solutionName=setup_name, quantityName=quantity, intrinsics=intrinsics ) - elif listtype.startswith("Layer"): + elif list_type.startswith("Layer"): plot = FieldPlot( self, solutionName=setup_name, - quantityName=quantityName, + quantityName=quantity, intrinsics=intrinsics, - layers_nets=objlist, - layers_plot_type=listtype, + layers_nets=objects, + layers_plot_type=list_type, ) if self._app.design_type == "Q3D Extractor": # pragma: no cover plot.field_type = field_type @@ -3024,13 +3019,13 @@ def _create_fieldplot( else: return False - @pyaedt_function_handler() + @pyaedt_function_handler(quantityName="quantity") def _create_fieldplot_line_traces( self, seeding_faces_ids, in_volume_tracing_ids, surface_tracing_ids, - quantityName, + quantity, setup_name, intrinsics, plot_name=None, @@ -3052,13 +3047,13 @@ def _create_fieldplot_line_traces( char_set = string.ascii_uppercase + string.digits if not plot_name: - plot_name = quantityName + "_" + "".join(random.sample(char_set, 6)) + plot_name = quantity + "_" + "".join(random.sample(char_set, 6)) plot = FieldPlot( self, objlist=in_volume_tracing_ids, surfacelist=surface_tracing_ids, solutionName=setup_name, - quantityName=quantityName, + quantityName=quantity, intrinsics=intrinsics, seedingFaces=seeding_faces_ids, ) @@ -3119,8 +3114,7 @@ def create_fieldplot_line( objects, quantity, setup_name, intrinsics, "Line", plot_name, field_type=field_type ) - @pyaedt_function_handler() - @deprecated_alias(IntrinsincDict="intrinsics") + @pyaedt_function_handler(IntrinsincDict="intrinsics") def create_fieldplot_line_traces( self, seeding_faces, @@ -3293,18 +3287,17 @@ def create_fieldplot_layers_nets( plot_type = "LayerNets" return self._create_fieldplot(layers_nets, quantity_name, setup_name, intrinsics, plot_type, plot_name) - @pyaedt_function_handler() - @deprecated_alias(IntrinsincDict="intrinsics") + @pyaedt_function_handler(objlist="objects", quantityName="quantity", IntrinsincDict="intrinsics") def create_fieldplot_surface( - self, objlist, quantityName, setup_name=None, intrinsics=None, plot_name=None, field_type="DC R/L Fields" + self, objects, quantity, setup_name=None, intrinsics=None, plot_name=None, field_type="DC R/L Fields" ): """Create a field plot of surfaces. Parameters ---------- - objlist : list + objects : list List of surfaces to plot. - quantityName : str + quantity : str Name of the quantity to plot. setup_name : str, optional Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. @@ -3333,23 +3326,23 @@ def create_fieldplot_surface( if plot_name and plot_name in list(self.field_plots.keys()): self.logger.info("Plot {} exists. returning the object.".format(plot_name)) return self.field_plots[plot_name] - if not isinstance(objlist, (list, tuple)): - objlist = [objlist] + if not isinstance(objects, (list, tuple)): + objects = [objects] new_obj_list = [] - for obj in objlist: + for obj in objects: if isinstance(obj, (int, FacePrimitive)): new_obj_list.append(obj) elif self._app.modeler[obj]: new_obj_list.extend([face for face in self._app.modeler[obj].faces if face.id not in new_obj_list]) return self._create_fieldplot( - new_obj_list, quantityName, setup_name, intrinsics, "FacesList", plot_name, field_type=field_type + new_obj_list, quantity, setup_name, intrinsics, "FacesList", plot_name, field_type=field_type ) - @pyaedt_function_handler(IntrinsincDict="intrinsics") + @pyaedt_function_handler(objlist="objects", quantityName="quantity", IntrinsincDict="intrinsics") def create_fieldplot_cutplane( self, - objlist, - quantityName, + objects, + quantity, setup_name=None, intrinsics=None, plot_name=None, @@ -3360,9 +3353,9 @@ def create_fieldplot_cutplane( Parameters ---------- - objlist : list + objects : list List of cut planes to plot. - quantityName : str + quantity : str Name of the quantity to plot. setup_name : str, optional Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. @@ -3397,8 +3390,8 @@ def create_fieldplot_cutplane( if filter_objects: filter_objects = self._app.modeler.convert_to_selections(filter_objects, True) return self._create_fieldplot( - objlist, - quantityName, + objects, + quantity, setup_name, intrinsics, "CutPlane", @@ -3407,18 +3400,17 @@ def create_fieldplot_cutplane( field_type=field_type, ) - @pyaedt_function_handler() - @deprecated_alias(IntrinsincDict="intrinsics") + @pyaedt_function_handler(objlist="objects", quantityName="quantity", IntrinsincDict="intrinsics") def create_fieldplot_volume( - self, objlist, quantityName, setup_name=None, intrinsics=None, plot_name=None, field_type="DC R/L Fields" + self, objects, quantity, setup_name=None, intrinsics=None, plot_name=None, field_type="DC R/L Fields" ): """Create a field plot of volumes. Parameters ---------- - objlist : list + objects : list List of volumes to plot. - quantityName : + quantity : Name of the quantity to plot. setup_name : str, optional Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. @@ -3446,15 +3438,15 @@ def create_fieldplot_volume( self.logger.info("Plot {} exists. returning the object.".format(plot_name)) return self.field_plots[plot_name] return self._create_fieldplot( - objlist, quantityName, setup_name, intrinsics, "ObjList", plot_name, field_type=field_type + objects, quantity, setup_name, intrinsics, "ObjList", plot_name, field_type=field_type ) - @pyaedt_function_handler() + @pyaedt_function_handler(fileName="file_name", plotName="plot_name", foldername="folder_name") def export_field_jpg( self, - fileName, - plotName, - foldername, + file_name, + plot_name, + folder_name, orientation="isometric", width=1920, height=1080, @@ -3469,11 +3461,11 @@ def export_field_jpg( Parameters ---------- - fileName : str + file_name : str Full path and name to save the JPG file to. - plotName : str + plot_name : str Name of the plot. - foldername : str + folder_name : str Name of the folder plot. orientation : str, optional Name of the orientation to apply. The default is ``"isometric"``. @@ -3527,15 +3519,15 @@ def export_field_jpg( ] view = orientation_to_view.get(orientation, "iso") cs = self.modeler.create_coordinate_system(origin=center, mode="view", view=view) - self.ofieldsreporter.ExportPlotImageToFile(fileName, foldername, plotName, cs.name) + self.ofieldsreporter.ExportPlotImageToFile(file_name, folder_name, plot_name, cs.name) cs.delete() else: self.export_model_picture( - full_name=fileName, + full_name=file_name, width=width, height=height, orientation=orientation, - field_selections=plotName, + field_selections=plot_name, selections=selections, show_axis=show_axis, show_grid=show_grid, @@ -3547,7 +3539,7 @@ def export_field_jpg( self._primitives[solid].display_wireframe = False else: self.ofieldsreporter.ExportPlotImageWithViewToFile( - fileName, foldername, plotName, width, height, orientation + file_name, folder_name, plot_name, width, height, orientation ) return True @@ -3694,10 +3686,8 @@ def export_model_picture( self.oeditor.ExportModelImageToFile(full_name, width, height, arg) return full_name - @pyaedt_function_handler() - def get_far_field_data( - self, expression="GainTotal", setup_sweep_name="", domain="Infinite Sphere1", families_dict=None - ): + @pyaedt_function_handler(families_dict="sweeps") + def get_far_field_data(self, expression="GainTotal", setup_sweep_name="", domain="Infinite Sphere1", sweeps=None): """Generate far field data using ``GetSolutionDataPerVariation``. This method returns the data ``solData``, ``ThetaVals``, @@ -3713,7 +3703,7 @@ def get_far_field_data( in which case the nominal sweep is used. domain : str, dict, optional Context type (sweep or time). The default is ``"Infinite Sphere1"``. - families_dict : dict, optional + sweeps : dict, optional Dictionary of variables and values. The default is ``{"Freq": ["All"]}``. Returns @@ -3729,15 +3719,15 @@ def get_far_field_data( expression = [expression] if not setup_sweep_name: setup_sweep_name = self._app.nominal_adaptive - if families_dict is None: - families_dict = {"Theta": ["All"], "Phi": ["All"], "Freq": ["All"]} + if sweeps is None: + sweeps = {"Theta": ["All"], "Phi": ["All"], "Freq": ["All"]} context = ["Context:=", domain] if isinstance(domain, dict): if "Context" in domain.keys() and "SourceContext" in domain.keys(): context = ["Context:=", domain["Context"], "Context:=", domain["SourceContext"]] solution_data = self.get_solution_data_per_variation( - "Far Fields", setup_sweep_name, context, families_dict, expression + "Far Fields", setup_sweep_name, context, sweeps, expression ) if not solution_data: print("No Data Available. Check inputs") @@ -5108,8 +5098,7 @@ def add_calculation( ) # TODO : last argument not documented return True - @pyaedt_function_handler() - @deprecated_alias(IntrinsincDict="intrinsics") + @pyaedt_function_handler(IntrinsincDict="intrinsics") def get_field_summary_data(self, setup_name=None, design_variation={}, intrinsics="", pandas_output=False): """ Get field summary output computation. diff --git a/pyaedt/modules/SolveSetup.py b/pyaedt/modules/SolveSetup.py index da7e9f80ce6..6bb5bd27c97 100644 --- a/pyaedt/modules/SolveSetup.py +++ b/pyaedt/modules/SolveSetup.py @@ -422,17 +422,9 @@ def create_report( >>> aedtapp.post.create_report("dB(S(1,1))") >>> variations = aedtapp.available_variations.nominal_w_values_dict - >>> aedtapp.post.setups[0].create_report( - ... "dB(S(1,1))", - ... variations=variations, - ... primary_sweep_variable="Freq", - ...) + >>> aedtapp.post.setups[0].create_report("dB(S(1,1))",variations=variations,primary_sweep_variable="Freq") - >>> aedtapp.post.create_report( - ... "S(1,1)", - ... variations=variations, - ... plot_type="Smith Chart", - ...) + >>> aedtapp.post.create_report("S(1,1)",variations=variations,plot_type="Smith Chart") """ if sweep_name: setup_sweep_name = [ @@ -443,6 +435,7 @@ def create_report( if setup_sweep_name: return self._app.post.create_report( expressions=expressions, + setup_sweep_name=setup_sweep_name[0], domain=domain, variations=variations, primary_sweep_variable=primary_sweep_variable, @@ -451,8 +444,7 @@ def create_report( plot_type=plot_type, context=context, polyline_points=polyline_points, - plotname=plotname, - setup_sweep_name=setup_sweep_name[0], + plot_name=plotname, ) return None @@ -1686,6 +1678,7 @@ def create_report( """ return self._app.post.create_report( expressions=expressions, + setup_sweep_name=self.name, domain=domain, variations=variations, primary_sweep_variable=primary_sweep_variable, @@ -1693,10 +1686,9 @@ def create_report( report_category=report_category, plot_type=plot_type, context=context, - polyline_points=polyline_points, - plotname=plotname, subdesign_id=subdesign_id, - setup_sweep_name=self.name, + polyline_points=polyline_points, + plot_name=plotname, ) From cf8487008159d51dcf8715a235c3d90a5c6d60d9 Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Wed, 27 Mar 2024 13:05:17 +0100 Subject: [PATCH 08/22] refactoring Post-Processing --- _unittest/test_21_Circuit.py | 10 +-- examples/07-Circuit/Circuit_AMI.py | 2 +- pyaedt/hfss.py | 5 +- pyaedt/modules/AdvancedPostProcessing.py | 4 +- pyaedt/modules/PostProcessor.py | 109 ++++++++++++----------- 5 files changed, 67 insertions(+), 63 deletions(-) diff --git a/_unittest/test_21_Circuit.py b/_unittest/test_21_Circuit.py index ecd03f8ee77..540363079bb 100644 --- a/_unittest/test_21_Circuit.py +++ b/_unittest/test_21_Circuit.py @@ -250,9 +250,9 @@ def test_20_create_AMI_plots(self, add_app): "b_input_15", ami_design.available_variations.nominal, plot_type="Rectangular Stacked Plot", - plot_final_response=True, plot_intermediate_response=True, - plotname=report_name, + plot_final_response=True, + plot_name=report_name, ) == report_name ) @@ -262,7 +262,7 @@ def test_20_create_AMI_plots(self, add_app): assert ami_design.create_setup(setup_name, "NexximQuickEye") assert ( ami_design.post.create_ami_statistical_eye_plot( - "AMIAnalysis", "b_output4_14", ami_design.available_variations.nominal, plotname="MyReport1" + "AMIAnalysis", "b_output4_14", ami_design.available_variations.nominal, plot_name="MyReport1" ) == "MyReport1" ) @@ -271,7 +271,7 @@ def test_20_create_AMI_plots(self, add_app): "Dom_Quick", "b_input_15.int_ami_rx.eye_probe", ami_design.available_variations.nominal, - plotname="MyReportQ", + plot_name="MyReportQ", ) == "MyReportQ" ) @@ -283,7 +283,7 @@ def test_20B_create_AMI_plots(self): "Dom_Verify", "b_input_15.int_ami_rx.eye_probe", self.aedtapp.available_variations.nominal, - plotname="MyReportV", + plot_name="MyReportV", ) == "MyReportV" ) diff --git a/examples/07-Circuit/Circuit_AMI.py b/examples/07-Circuit/Circuit_AMI.py index 2801fadb066..d9b2ee7e8b7 100644 --- a/examples/07-Circuit/Circuit_AMI.py +++ b/examples/07-Circuit/Circuit_AMI.py @@ -89,7 +89,7 @@ setup_name = "AMIAnalysis" ignore_bits = 100 unit_interval = 0.1e-9 -sample_waveform = cir.post.sample_ami_waveform(setupname=setup_name, probe_name=probe_name, source_name=source_name, +sample_waveform = cir.post.sample_ami_waveform(setup_name=setup_name, probe_name=probe_name, source_name=source_name, variation_list_w_value=cir.available_variations.nominal, unit_interval=unit_interval, ignore_bits=ignore_bits, plot_type=plot_type) diff --git a/pyaedt/hfss.py b/pyaedt/hfss.py index dae55bc901d..62afab1f473 100644 --- a/pyaedt/hfss.py +++ b/pyaedt/hfss.py @@ -6093,10 +6093,7 @@ def get_hdm_plotter(self, filename=None): from pyaedt.sbrplus.plot import HDMPlotter hdm = HDMPlotter() - files = self.post.export_model_obj( - export_as_single_objects=True, - air_objects=False, - ) + files = self.post.export_model_obj(export_as_single_objects=True, air_objects=False) for file in files: hdm.add_cad_model(file[0], file[1], file[2], self.modeler.model_units) hdm.add_hdm_bundle_from_file(filename) diff --git a/pyaedt/modules/AdvancedPostProcessing.py b/pyaedt/modules/AdvancedPostProcessing.py index 21d03254647..8fc1859b625 100644 --- a/pyaedt/modules/AdvancedPostProcessing.py +++ b/pyaedt/modules/AdvancedPostProcessing.py @@ -208,9 +208,7 @@ def get_model_plotter_geometries( files = [] if get_objects_from_aedt and self._app.solution_type not in ["HFSS3DLayout", "HFSS 3D Layout Design"]: files = self.export_model_obj( - obj_list=objects, - export_as_single_objects=plot_as_separate_objects, - air_objects=plot_air_objects, + objects=objects, export_as_single_objects=plot_as_separate_objects, air_objects=plot_air_objects ) model = ModelPlotter() diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index 39fefa62bc6..ab634e92077 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -3734,18 +3734,18 @@ def get_far_field_data(self, expression="GainTotal", setup_sweep_name="", domain return False return solution_data - @pyaedt_function_handler() - def export_model_obj(self, obj_list=None, export_path=None, export_as_single_objects=False, air_objects=False): + @pyaedt_function_handler(obj_list="objects") + def export_model_obj(self, objects=None, export_path=None, export_as_single_objects=False, air_objects=False): """Export the model. Parameters ---------- - obj_list : list, optional + objects : list, optional List of objects to export. Export every model object except 3D ones, vacuum and air objects. export_path : str, optional Full path of the exported obj file. export_as_single_objects : bool, optional - Define if the model will be exported as single obj or list of objs for each object. + Define if the model will be exported as single object or list of objects for each object. air_objects : bool, optional Define if air and vacuum objects will be exported. @@ -3754,19 +3754,19 @@ def export_model_obj(self, obj_list=None, export_path=None, export_as_single_obj list Files obj path. """ - if obj_list and not isinstance(obj_list, (list, tuple)): - obj_list = [obj_list] + if objects and not isinstance(objects, (list, tuple)): + objects = [objects] assert self._app._aedt_version >= "2021.2", self.logger.error("Object is supported from AEDT 2021 R2.") if not export_path: export_path = self._app.working_directory - if not obj_list: + if not objects: self._app.modeler.refresh_all_ids() non_model = self._app.modeler.non_model_objects[:] - obj_list = [i for i in self._app.modeler.object_names if i not in non_model] + objects = [i for i in self._app.modeler.object_names if i not in non_model] if not air_objects: - obj_list = [ + objects = [ i - for i in obj_list + for i in objects if not self._app.modeler[i].is3d or ( self._app.modeler[i].material_name.lower() != "vacuum" @@ -3775,7 +3775,7 @@ def export_model_obj(self, obj_list=None, export_path=None, export_as_single_obj ] if export_as_single_objects: files_exported = [] - for el in obj_list: + for el in objects: fname = os.path.join(export_path, "{}.obj".format(el)) self._app.modeler.oeditor.ExportModelMeshToFile(fname, [el]) if settings.remote_rpc_session_temp_folder: @@ -3793,7 +3793,7 @@ def export_model_obj(self, obj_list=None, export_path=None, export_as_single_obj return files_exported else: fname = os.path.join(export_path, "Model_AllObjs_AllMats.obj") - self._app.modeler.oeditor.ExportModelMeshToFile(fname, obj_list) + self._app.modeler.oeditor.ExportModelMeshToFile(fname, objects) return [[fname, "aquamarine", 0.3]] @pyaedt_function_handler() @@ -4218,6 +4218,7 @@ def extract_dataset_info(boundary_obj, units_input="W", boundary="Power"): self.logger.info("The total power is {} {}".format(str(round(sum(power_dict_obj.values()), 3)), units)) return power_dict_obj, sum(power_dict_obj.values()), power_dict, sum(power_dict.values()) + @pyaedt_function_handler() def create_creeping_plane_visual_ray_tracing( self, max_frequency="1GHz", @@ -4267,6 +4268,7 @@ def create_creeping_plane_visual_ray_tracing( vrt.create() return vrt + @pyaedt_function_handler() def create_creeping_point_visual_ray_tracing( self, max_frequency="1GHz", @@ -4310,6 +4312,7 @@ def create_creeping_point_visual_ray_tracing( vrt.create() return vrt + @pyaedt_function_handler() def create_sbr_plane_visual_ray_tracing( self, max_frequency="1GHz", @@ -4383,6 +4386,7 @@ def create_sbr_plane_visual_ray_tracing( vrt.create() return vrt + @pyaedt_function_handler() def create_sbr_point_visual_ray_tracing( self, max_frequency="1GHz", @@ -4470,22 +4474,23 @@ class CircuitPostProcessor(PostProcessorCommon, object): def __init__(self, app): PostProcessorCommon.__init__(self, app) + @pyaedt_function_handler(setupname="setup_name", plotname="plot_name") def create_ami_initial_response_plot( self, - setupname, + setup_name, ami_name, variation_list_w_value, plot_type="Rectangular Plot", plot_initial_response=True, plot_intermediate_response=False, plot_final_response=False, - plotname=None, + plot_name=None, ): """Create an AMI initial response plot. Parameters ---------- - setupname : str + setup_name : str Name of the setup. ami_name : str AMI probe name to use. @@ -4501,7 +4506,7 @@ def create_ami_initial_response_plot( Set whether to plot the intermediate input response. Default is ``False``. plot_final_response : bool, optional Set whether to plot the final input response. Default is ``False``. - plotname : str, optional + plot_name : str, optional The plot name. Default is a unique name. Returns @@ -4509,8 +4514,8 @@ def create_ami_initial_response_plot( str Name of the plot. """ - if not plotname: - plotname = generate_unique_name("AMIAnalysis") + if not plot_name: + plot_name = generate_unique_name("AMIAnalysis") variations = ["__InitialTime:=", ["All"]] i = 0 for a in variation_list_w_value: @@ -4533,10 +4538,10 @@ def create_ami_initial_response_plot( if plot_final_response: ycomponents.append("FinalImpulseResponse<{}.int_ami_rx>".format(ami_name)) self.oreportsetup.CreateReport( - plotname, + plot_name, "Standard", plot_type, - setupname, + setup_name, [ "NAME:Context", "SimValueContext:=", @@ -4575,16 +4580,17 @@ def create_ami_initial_response_plot( variations, ["X Component:=", "__InitialTime", "Y Component:=", ycomponents], ) - return plotname + return plot_name + @pyaedt_function_handler(setupname="setup_name", plotname="plot_name") def create_ami_statistical_eye_plot( - self, setupname, ami_name, variation_list_w_value, ami_plot_type="InitialEye", plotname=None + self, setup_name, ami_name, variation_list_w_value, ami_plot_type="InitialEye", plot_name=None ): """Create an AMI statistical eye plot. Parameters ---------- - setupname : str + setup_name : str Name of the setup. ami_name : str AMI probe name to use. @@ -4593,7 +4599,7 @@ def create_ami_statistical_eye_plot( ami_plot_type : str, optional String containing the report AMI type. Default is ``"InitialEye"``. It can be ``"EyeAfterSource"``, ``"EyeAfterChannel"`` or ``"EyeAfterProbe"``. - plotname : str, optional + plot_name : str, optional The name of the plot. Defaults to a unique name starting with ``"Plot"``. Returns @@ -4606,8 +4612,8 @@ def create_ami_statistical_eye_plot( >>> oModule.CreateReport """ - if not plotname: - plotname = generate_unique_name("AMYAanalysis") + if not plot_name: + plot_name = generate_unique_name("AMYAanalysis") variations = [ "__UnitInterval:=", ["All"], @@ -4642,10 +4648,10 @@ def create_ami_statistical_eye_plot( elif ami_plot_type == "EyeAfterProbe": ami_id = "3" self.oreportsetup.CreateReport( - plotname, + plot_name, "Statistical Eye", "Statistical Eye Plot", - setupname, + setup_name, [ "NAME:Context", "SimValueContext:=", @@ -4681,20 +4687,21 @@ def create_ami_statistical_eye_plot( variations, ["X Component:=", "__UnitInterval", "Y Component:=", "__Amplitude", "Eye Diagram Component:=", ycomponents], ) - return plotname + return plot_name - def create_statistical_eye_plot(self, setupname, probe_names, variation_list_w_value, plotname=None): + @pyaedt_function_handler(setupname="setup_name", plotname="plot_name") + def create_statistical_eye_plot(self, setup_name, probe_names, variation_list_w_value, plot_name=None): """Create a statistical QuickEye, VerifEye, and/or Statistical Eye plot. Parameters ---------- - setupname : str + setup_name : str Name of the setup. probe_names : str or list Name of the probe to plot in the EYE diagram. variation_list_w_value : list List of variations with relative values. - plotname : str, optional + plot_name : str, optional The name of the plot. Returns @@ -4707,8 +4714,8 @@ def create_statistical_eye_plot(self, setupname, probe_names, variation_list_w_v >>> oModule.CreateReport """ - if not plotname: - plotname = generate_unique_name("AMIAanalysis") + if not plot_name: + plot_name = generate_unique_name("AMIAanalysis") variations = [ "__UnitInterval:=", ["All"], @@ -4734,10 +4741,10 @@ def create_statistical_eye_plot(self, setupname, probe_names, variation_list_w_v ycomponents = [probe_names] self.oreportsetup.CreateReport( - plotname, + plot_name, "Statistical Eye", "Statistical Eye Plot", - setupname, + setup_name, [ "NAME:Context", "SimValueContext:=", @@ -4773,8 +4780,9 @@ def create_statistical_eye_plot(self, setupname, probe_names, variation_list_w_v variations, ["X Component:=", "__UnitInterval", "Y Component:=", "__Amplitude", "Eye Diagram Component:=", ycomponents], ) - return plotname + return plot_name + @pyaedt_function_handler() def sample_waveform( self, waveform_data, @@ -4813,7 +4821,7 @@ def sample_waveform( Examples -------- >>> aedtapp = Circuit() - >>> aedtapp.post.sample_ami_waveform(setup_name, probe_name, source_name, aedtapp.available_variations.nominal) + >>> aedtapp.post.sample_ami_waveform(setup_name,probe_name,source_name,aedtapp.available_variations.nominal) """ @@ -4862,9 +4870,10 @@ def sample_waveform( return pd.Series(new_voltage, index=tic_in_s) return outputdata + @pyaedt_function_handler(setupname="setup_name") def sample_ami_waveform( self, - setupname, + setup_name, probe_name, source_name, variation_list_w_value, @@ -4877,7 +4886,7 @@ def sample_ami_waveform( Parameters ---------- - setupname : str + setup_name : str Name of the setup. probe_name : str Name of the AMI probe. @@ -4905,7 +4914,7 @@ def sample_ami_waveform( Examples -------- >>> aedtapp = Circuit() - >>> aedtapp.post.sample_ami_waveform(setupname, probe_name, source_name, aedtapp.available_variations.nominal) + >>> aedtapp.post.sample_ami_waveform(setupname,probe_name,source_name,aedtapp.available_variations.nominal) """ initial_solution_type = self.post_solution_type @@ -4928,7 +4937,7 @@ def sample_ami_waveform( waveform_sweep_unit = [] for exp in plot_expression: waveform_data = self.get_solution_data( - expressions=exp, setup_sweep_name=setupname, domain="Time", variations=variation_list_w_value + expressions=exp, setup_sweep_name=setup_name, domain="Time", variations=variation_list_w_value ) samples_per_bit = 0 for sample in waveform_data.primary_sweep_values: @@ -4954,7 +4963,7 @@ def sample_ami_waveform( clock_expression = "ClockTics<" + probe_name + ".int_ami_rx>" clock_tic = self.get_solution_data( expressions=clock_expression, - setup_sweep_name=setupname, + setup_sweep_name=setup_name, domain="Clock Times", variations=variation_list_w_value, ) @@ -5142,19 +5151,19 @@ def get_field_summary_data(self, setup_name=None, design_variation={}, intrinsic return pd.DataFrame.from_dict(out_dict) return out_dict - @pyaedt_function_handler() - def export_csv(self, filename, setup_name=None, design_variation={}, intrinsics=""): + @pyaedt_function_handler(filename="file_name", design_variation="variations") + def export_csv(self, file_name, setup_name=None, variations={}, intrinsics=""): """ Get the field summary output computation. Parameters ---------- - filename : str + file_name : str Path and filename to write the output file to. setup_name : str, optional Setup name to use for the computation. The default is ``None``, in which case the nominal variation is used. - design_variation : dict, optional + variations : dict, optional Dictionary containing the design variation to use for the computation. The default is ``{}``, in which case the nominal variation is used. intrinsics : str, optional @@ -5169,8 +5178,8 @@ def export_csv(self, filename, setup_name=None, design_variation={}, intrinsics= if not setup_name: setup_name = self._app.nominal_sweep dv_string = "" - for el in design_variation: - dv_string += el + "='" + design_variation[el] + "' " + for el in variations: + dv_string += el + "='" + variations[el] + "' " self._create_field_summary(setup_name, dv_string) self._app.osolution.ExportFieldsSummary( [ @@ -5179,7 +5188,7 @@ def export_csv(self, filename, setup_name=None, design_variation={}, intrinsics= "DesignVariationKey:=", dv_string, "ExportFileName:=", - filename, + file_name, "IntrinsicValue:=", intrinsics, ] From 096df9d834a1377c8805ddc950bb73c8831a80ec Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Thu, 28 Mar 2024 09:30:11 +0100 Subject: [PATCH 09/22] fix doc --- doc/source/API/Post.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/API/Post.rst b/doc/source/API/Post.rst index 22cc06f0075..440c8251794 100644 --- a/doc/source/API/Post.rst +++ b/doc/source/API/Post.rst @@ -37,7 +37,7 @@ plots in AEDT. They are accessible through the ``post`` property. post = app.post # This call returns a FieldPlot object - plotf = post.create_fieldplot_volume(object_list, quantityname, setup_name, intrinsic_dict) + plotf = post.create_fieldplot_volume(objects, quantity_name, setup_name, intrinsics) # This call returns a SolutionData object my_data = post.get_solution_data(expressions=trace_names) From 4258b13636f22d7f44ba882a3987126090bb2541 Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Thu, 28 Mar 2024 09:50:24 +0100 Subject: [PATCH 10/22] remove import --- pyaedt/modules/solutions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyaedt/modules/solutions.py b/pyaedt/modules/solutions.py index 371a0447ded..f7f41c00534 100644 --- a/pyaedt/modules/solutions.py +++ b/pyaedt/modules/solutions.py @@ -17,7 +17,6 @@ from pyaedt.generic.constants import unit_converter from pyaedt.generic.general_methods import check_and_download_folder from pyaedt.generic.general_methods import conversion_function -from pyaedt.generic.general_methods import deprecated_alias from pyaedt.generic.general_methods import open_file from pyaedt.generic.general_methods import write_csv from pyaedt.generic.plot import get_structured_mesh From 91ca32b5d7c91e38bf1aca6279255070142df4ed Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Thu, 28 Mar 2024 09:56:11 +0100 Subject: [PATCH 11/22] remove import --- pyaedt/modules/solutions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyaedt/modules/solutions.py b/pyaedt/modules/solutions.py index f7f41c00534..cbde938ed40 100644 --- a/pyaedt/modules/solutions.py +++ b/pyaedt/modules/solutions.py @@ -3345,7 +3345,6 @@ class VRTFieldPlot: """ - @deprecated_alias(IntrinsincList="intrinsics") def __init__( self, postprocessor, From c88ad78e240ff1cd75b2ab96b02a90fa5b9ad7b6 Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Thu, 28 Mar 2024 10:29:44 +0100 Subject: [PATCH 12/22] refacto AdvancedPostProcessing.py --- _unittest/test_12_1_PostProcessing.py | 30 +- _unittest/test_12_PostProcessing.py | 6 +- _unittest/test_98_Icepak.py | 2 +- examples/02-HFSS/Waveguide_Filter.py | 10 +- examples/02-SBR+/SBR_Time_Plot.py | 7 +- examples/03-Maxwell/Maxwell2D_DCConduction.py | 15 +- examples/03-Maxwell/Maxwell2D_Transient.py | 13 +- examples/04-Icepak/Sherlock_Example.py | 2 +- examples/05-Q3D/Q3D_DC_IR.py | 12 +- .../06-Multiphysics/Hfss_Icepak_Coupling.py | 30 +- examples/06-Multiphysics/MRI.py | 22 +- pyaedt/modules/AdvancedPostProcessing.py | 266 +++++++++--------- 12 files changed, 179 insertions(+), 236 deletions(-) diff --git a/_unittest/test_12_1_PostProcessing.py b/_unittest/test_12_1_PostProcessing.py index 3de76837d15..7d3db7b530b 100644 --- a/_unittest/test_12_1_PostProcessing.py +++ b/_unittest/test_12_1_PostProcessing.py @@ -98,25 +98,25 @@ def test_01_Animate_plt(self): phases = [str(i * 5) + "deg" for i in range(2)] model_gif = self.aedtapp.post.plot_animated_field( quantity="Mag_E", - object_list=cutlist, + objects=cutlist, plot_type="CutPlane", setup_name=self.aedtapp.nominal_adaptive, intrinsics={"Freq": "5GHz", "Phase": "0deg"}, - export_path=self.local_scratch.path, variation_variable="Phase", - variation_list=phases, + variations=phases, show=False, export_gif=True, + export_path=self.local_scratch.path, ) assert os.path.exists(model_gif.gif_file) setup_name = self.aedtapp.existing_analysis_sweeps[0] intrinsic = {"Freq": "5GHz", "Phase": "180deg"} pl1 = self.aedtapp.post.create_fieldplot_volume("NewObject_IJD39Q", "Mag_E", setup_name, intrinsic) model_gif2 = self.aedtapp.post.animate_fields_from_aedtplt( - plotname=pl1.name, + plot_name=pl1.name, plot_folder=None, variation_variable="Phase", - variation_list=phases, + variations=phases, project_path="", export_gif=False, show=False, @@ -501,13 +501,13 @@ def test_14_Field_Ploton_cutplanedesignname(self): assert plot1.update_field_plot_settings() self.aedtapp.logger.info("Generating the image") plot_obj = self.aedtapp.post.plot_field_from_fieldplot( - plotname=plot1.name, + plot_name=plot1.name, project_path=self.local_scratch.path, - meshplot=False, - imageformat="jpg", + mesh_plot=False, + image_format="jpg", view="xy", - show=False, plot_label=plot1.name + " label", + show=False, ) assert os.path.exists(plot_obj.image_file) os.unlink(plot_obj.image_file) @@ -526,13 +526,13 @@ def test_14_Field_Ploton_cutplanedesignname(self): assert os.path.exists(plot_obj.image_file) plot_obj = self.aedtapp.post.plot_field_from_fieldplot( - plotname=plot1.name, + plot_name=plot1.name, project_path=self.local_scratch.path, - meshplot=False, - imageformat="jpg", + mesh_plot=False, + image_format="jpg", view="xy", - show=False, plot_label=plot1.name + " label", + show=False, file_format="aedtplt", ) assert os.path.exists(plot_obj.image_file) @@ -557,11 +557,11 @@ def test_14B_Field_Ploton_Vector(self): "CutPlane", setup_name=setup_name, intrinsics=intrinsic, - export_path=self.local_scratch.path, mesh_on_fields=False, - imageformat="jpg", view="isometric", show=False, + export_path=self.local_scratch.path, + image_format="jpg", ) assert os.path.exists(plot_obj.image_file) diff --git a/_unittest/test_12_PostProcessing.py b/_unittest/test_12_PostProcessing.py index bdd536ed9b0..59466278d46 100644 --- a/_unittest/test_12_PostProcessing.py +++ b/_unittest/test_12_PostProcessing.py @@ -403,11 +403,7 @@ def test_55_time_plot(self, sbr_test): ) assert os.path.exists(frames_list) sbr_test.post.plot_scene( - frames_list, - os.path.join(sbr_test.working_directory, "animation.gif"), - norm_index=5, - dy_rng=35, - show=False, + frames_list, os.path.join(sbr_test.working_directory, "animation.gif"), norm_index=5, dy_rng=35, show=False ) assert os.path.exists(os.path.join(sbr_test.working_directory, "animation.gif")) sbr_test.post.plot_scene( diff --git a/_unittest/test_98_Icepak.py b/_unittest/test_98_Icepak.py index 625c1a5e91d..6915cba5351 100644 --- a/_unittest/test_98_Icepak.py +++ b/_unittest/test_98_Icepak.py @@ -1244,7 +1244,7 @@ def test_62_get_fans_operating_point(self, add_app): assert len(list(op_dict.keys())) == 2 app.set_active_design("get_fan_op_point1") app.get_fans_operating_point() - app.get_fans_operating_point(timestep="0") + app.get_fans_operating_point(time_step="0") app.close_project() def test_63_generate_mesh(self): diff --git a/examples/02-HFSS/Waveguide_Filter.py b/examples/02-HFSS/Waveguide_Filter.py index b80ede20b16..0227024bdc1 100644 --- a/examples/02-HFSS/Waveguide_Filter.py +++ b/examples/02-HFSS/Waveguide_Filter.py @@ -224,13 +224,9 @@ def place_iris(zpos, dz, n): # The following command generates a field plot in HFSS and uses PyVista # to plot the field in Jupyter. -plot = hfss.post.plot_field(quantity="Mag_E", - object_list=["Global:XZ"], - plot_type="CutPlane", - setup_name=hfss.nominal_adaptive, - intrinsics={"Freq": "9.8GHz", "Phase": "0deg"}, - export_path=hfss.working_directory, - show=False) +plot = hfss.post.plot_field(quantity="Mag_E", objects=["Global:XZ"], plot_type="CutPlane", + setup_name=hfss.nominal_adaptive, intrinsics={"Freq": "9.8GHz", "Phase": "0deg"}, + show=False, export_path=hfss.working_directory) ############################################################################### # Save and close the desktop diff --git a/examples/02-SBR+/SBR_Time_Plot.py b/examples/02-SBR+/SBR_Time_Plot.py index 5abf89a49ad..6d1ed582ec6 100644 --- a/examples/02-SBR+/SBR_Time_Plot.py +++ b/examples/02-SBR+/SBR_Time_Plot.py @@ -71,10 +71,7 @@ # ~~~~~~~~~~ # Plot the scene to create the time plot animation -hfss.post.plot_scene(frames_list=frames_list_file, - output_gif_path=os.path.join(hfss.working_directory, "animation.gif"), - norm_index=15, - dy_rng=35, - show=False, view="xy", zoom=1) +hfss.post.plot_scene(frames=frames_list_file, gif_path=os.path.join(hfss.working_directory, "animation.gif"), + norm_index=15, dy_rng=35, show=False, view="xy", zoom=1) hfss.release_desktop() diff --git a/examples/03-Maxwell/Maxwell2D_DCConduction.py b/examples/03-Maxwell/Maxwell2D_DCConduction.py index b64bfff4217..9a5ee2c2377 100644 --- a/examples/03-Maxwell/Maxwell2D_DCConduction.py +++ b/examples/03-Maxwell/Maxwell2D_DCConduction.py @@ -178,7 +178,7 @@ # ~~~~~~~~~~~~~ # Plot electric field using pyvista and saving to an image -py_vista_plot = m2d.post.plot_field("Mag_E", conductor_surface, plot_cad_objs=False, show=False) +py_vista_plot = m2d.post.plot_field("Mag_E", conductor_surface, show=False, plot_cad_objs=False) py_vista_plot.isometric_view = False py_vista_plot.camera_position = [0, 0, 7] py_vista_plot.focal_point = [0, 0, 0] @@ -192,16 +192,9 @@ # ~~~~~~~~~~~~~~~ # Plot current density vs the Material index. -animated = m2d.post.plot_animated_field( - quantity="Mag_J", - object_list=conductor_surface, - export_path=results_folder, - variation_variable="MaterialIndex", - variation_list=[0,1,2,3], - show=False, - export_gif=False, - log_scale=True, -) +animated = m2d.post.plot_animated_field(quantity="Mag_J", objects=conductor_surface, variation_variable="MaterialIndex", + variations=[0, 1, 2, 3], show=False, log_scale=True, export_gif=False, + export_path=results_folder) animated.isometric_view = False animated.camera_position = [0, 0, 7] animated.focal_point = [0, 0, 0] diff --git a/examples/03-Maxwell/Maxwell2D_Transient.py b/examples/03-Maxwell/Maxwell2D_Transient.py index 8725c14986d..70e8af145bd 100644 --- a/examples/03-Maxwell/Maxwell2D_Transient.py +++ b/examples/03-Maxwell/Maxwell2D_Transient.py @@ -127,16 +127,9 @@ timesteps = [str(i * 2e-4) + "s" for i in range(11)] id_list = [f.id for f in face_lists] -gif = maxwell_2d.post.plot_animated_field( - quantity="Mag_B", - object_list=id_list, - plot_type="Surface", - intrinsics={"Time": "0s"}, - variation_variable="Time", - variation_list=timesteps, - show=False, - export_gif=False, -) +gif = maxwell_2d.post.plot_animated_field(quantity="Mag_B", objects=id_list, plot_type="Surface", + intrinsics={"Time": "0s"}, variation_variable="Time", variations=timesteps, + show=False, export_gif=False) gif.isometric_view = False gif.camera_position = [15, 15, 80] gif.focal_point = [15, 15, 0] diff --git a/examples/04-Icepak/Sherlock_Example.py b/examples/04-Icepak/Sherlock_Example.py index 1e474fd9721..56cd9407386 100644 --- a/examples/04-Icepak/Sherlock_Example.py +++ b/examples/04-Icepak/Sherlock_Example.py @@ -221,7 +221,7 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~ plot1 = ipk.post.create_fieldplot_surface(ipk.modeler["COMP_U10"].faces, "SurfTemperature") -ipk.post.plot_field("SurfPressure",ipk.modeler["COMP_U10"].faces,export_path=ipk.working_directory, show=False) +ipk.post.plot_field("SurfPressure", ipk.modeler["COMP_U10"].faces, show=False, export_path=ipk.working_directory) ############################################################################### diff --git a/examples/05-Q3D/Q3D_DC_IR.py b/examples/05-Q3D/Q3D_DC_IR.py index 39fd21e8be2..c1cbbd280b7 100644 --- a/examples/05-Q3D/Q3D_DC_IR.py +++ b/examples/05-Q3D/Q3D_DC_IR.py @@ -216,16 +216,8 @@ plot1 = q3d.post.create_fieldplot_surface(q3d.modeler.get_objects_by_material("copper"), quantity=drop_name) -q3d.post.plot_field_from_fieldplot( - plot1.name, - project_path=q3d.working_directory, - meshplot=False, - imageformat="jpg", - view="isometric", - show=False, - plot_cad_objs=False, - log_scale=False, -) +q3d.post.plot_field_from_fieldplot(plot1.name, project_path=q3d.working_directory, mesh_plot=False, image_format="jpg", + view="isometric", show=False, plot_cad_objs=False, log_scale=False) ############################################################################### # Computing Voltage on Source Circles diff --git a/examples/06-Multiphysics/Hfss_Icepak_Coupling.py b/examples/06-Multiphysics/Hfss_Icepak_Coupling.py index ba059d46d58..6252d6f8281 100644 --- a/examples/06-Multiphysics/Hfss_Icepak_Coupling.py +++ b/examples/06-Multiphysics/Hfss_Icepak_Coupling.py @@ -257,16 +257,8 @@ if not os.path.exists(results_folder): os.mkdir(results_folder) -aedtapp.post.plot_field_from_fieldplot( - plot1.name, - project_path=results_folder, - meshplot=False, - imageformat="jpg", - view="isometric", - show=False, - plot_cad_objs=False, - log_scale=False, -) +aedtapp.post.plot_field_from_fieldplot(plot1.name, project_path=results_folder, mesh_plot=False, image_format="jpg", + view="isometric", show=False, plot_cad_objs=False, log_scale=False) ################################################################################ # Generate animation from field plots @@ -279,19 +271,11 @@ cutlist = ["Global:XY"] phases = [str(i * 5) + "deg" for i in range(18)] -animated = aedtapp.post.plot_animated_field( - quantity="Mag_E", - object_list=cutlist, - plot_type="CutPlane", - setup_name=aedtapp.nominal_adaptive, - intrinsics={"Freq": "1GHz", "Phase": "0deg"}, - export_path=results_folder, - variation_variable="Phase", - variation_list=phases, - show=False, - export_gif=False, - log_scale=True, -) +animated = aedtapp.post.plot_animated_field(quantity="Mag_E", objects=cutlist, plot_type="CutPlane", + setup_name=aedtapp.nominal_adaptive, + intrinsics={"Freq": "1GHz", "Phase": "0deg"}, variation_variable="Phase", + variations=phases, show=False, log_scale=True, export_gif=False, + export_path=results_folder) animated.gif_file = os.path.join(aedtapp.working_directory, "animate.gif") # animated.camera_position = [0, 0, 300] # animated.focal_point = [0, 0, 0] diff --git a/examples/06-Multiphysics/MRI.py b/examples/06-Multiphysics/MRI.py index d50dddbeca9..0f8b7a8b40a 100644 --- a/examples/06-Multiphysics/MRI.py +++ b/examples/06-Multiphysics/MRI.py @@ -112,13 +112,8 @@ hfss.modeler.set_working_coordinate_system("implant") hfss.modeler.create_point([0, 0, 0], name="Point1") -hfss.post.plot_field(quantity="Average_SAR", - object_list="implant:YZ", - plot_type="CutPlane", - show_legend=False, - filter_objects=["implant_box"], - show=False - ) +hfss.post.plot_field(quantity="Average_SAR", objects="implant:YZ", plot_type="CutPlane", show=False, show_legend=False, + filter_objects=["implant_box"]) ############################################################################### # Adjust Input Power to MRI Coil @@ -219,15 +214,10 @@ report_category="Fields") #data.plot() -mech.post.plot_animated_field(quantity="Temperature", - object_list="implant:YZ", - plot_type="CutPlane", - intrinsics={"Time": "10s"}, - variation_variable="Time", - variation_list=["10s", "20s", "30s", "40s", "50s", "60s"], - filter_objects=["implant_box"], - show=False - ) +mech.post.plot_animated_field(quantity="Temperature", objects="implant:YZ", plot_type="CutPlane", + intrinsics={"Time": "10s"}, variation_variable="Time", + variations=["10s", "20s", "30s", "40s", "50s", "60s"], show=False, + filter_objects=["implant_box"]) ############################################################################### # Thermal Simulation diff --git a/pyaedt/modules/AdvancedPostProcessing.py b/pyaedt/modules/AdvancedPostProcessing.py index 8fc1859b625..2bbf2775e19 100644 --- a/pyaedt/modules/AdvancedPostProcessing.py +++ b/pyaedt/modules/AdvancedPostProcessing.py @@ -308,13 +308,13 @@ def plot_model_obj( model.clean_cache_and_files(clean_cache=False) return model - @pyaedt_function_handler() + @pyaedt_function_handler(plotname="plot_name", meshplot="mesh_plot", imageformat="image_format") def plot_field_from_fieldplot( self, - plotname, + plot_name, project_path="", - meshplot=False, - imageformat="jpg", + mesh_plot=False, + image_format="jpg", view="isometric", plot_label="Temperature", plot_folder=None, @@ -337,14 +337,14 @@ def plot_field_from_fieldplot( Parameters ---------- - plotname : str + plot_name : str Name of the field plot to export. project_path : str, optional Path for saving the image file. The default is ``""``. - meshplot : bool, optional + mesh_plot : bool, optional Whether to create and plot the mesh over the fields. The default is ``False``. - imageformat : str, optional + image_format : str, optional Format of the image file. Options are ``"jpg"``, ``"png"``, ``"svg"``, and ``"webp"``. The default is ``"jpg"``. @@ -396,9 +396,9 @@ def plot_field_from_fieldplot( else: self.ofieldsreporter.UpdateQuantityFieldsPlots(plot_folder) - if self.field_plots[plotname].field_type == "DC R/L Fields": + if self.field_plots[plot_name].field_type == "DC R/L Fields": file_format = "fldplt" - file_to_add = self.export_field_plot(plotname, self._app.working_directory, file_format=file_format) + file_to_add = self.export_field_plot(plot_name, self._app.working_directory, file_format=file_format) model = self.get_model_plotter_geometries( generate_mesh=False, get_objects_from_aedt=plot_cad_objs, @@ -414,7 +414,7 @@ def plot_field_from_fieldplot( model.add_field_from_file( file_to_add, coordinate_units=self.modeler.model_units, - show_edges=meshplot, + show_edges=mesh_plot, log_scale=log_scale, ) if plot_label: @@ -431,16 +431,16 @@ def plot_field_from_fieldplot( model.range_min = scale_min model.range_max = scale_max if project_path: - model.plot(os.path.join(project_path, plotname + "." + imageformat)) + model.plot(os.path.join(project_path, plot_name + "." + image_format)) elif show: model.plot() return model - @pyaedt_function_handler() + @pyaedt_function_handler(object_list="objects", imageformat="image_format") def plot_field( self, quantity, - object_list, + objects, plot_type="Surface", setup_name=None, intrinsics=None, @@ -453,7 +453,7 @@ def plot_field( plot_cad_objs=True, log_scale=False, export_path="", - imageformat="jpg", + image_format="jpg", keep_plot_after_generation=False, dark_mode=False, show_bounding=False, @@ -471,7 +471,7 @@ def plot_field( ---------- quantity : str Quantity to plot (e.g. ``"Mag_E"``). - object_list : str, list + objects : str, list Objects or faces to which apply the Field Plot. plot_type : str, optional Plot type. Options are ``"Surface"``, ``"Volume"``, ``"CutPlane"``. @@ -499,7 +499,7 @@ def plot_field( Whether to plot fields in log scale. The default is ``False``. export_path : str, optional Image export path. Default is ``None`` to not export the image. - imageformat : str, optional + image_format : str, optional Format of the image file. Options are ``"jpg"``, ``"png"``, ``"svg"``, and ``"webp"``. The default is ``"jpg"``. @@ -534,12 +534,12 @@ def plot_field( # file_to_add = [] if plot_type == "Surface": - plotf = self.create_fieldplot_surface(object_list, quantity, setup_name, intrinsics) + plotf = self.create_fieldplot_surface(objects, quantity, setup_name, intrinsics) elif plot_type == "Volume": - plotf = self.create_fieldplot_volume(object_list, quantity, setup_name, intrinsics) + plotf = self.create_fieldplot_volume(objects, quantity, setup_name, intrinsics) else: plotf = self.create_fieldplot_cutplane( - object_list, quantity, setup_name, intrinsics, filter_objects=filter_objects + objects, quantity, setup_name, intrinsics, filter_objects=filter_objects ) # if plotf: # file_to_add = self.export_field_plot(plotf.name, self._app.working_directory, plotf.name) @@ -548,7 +548,7 @@ def plot_field( plotf.name, export_path, mesh_on_fields, - imageformat, + image_format, view, plot_label if plot_label else quantity, None, @@ -567,16 +567,16 @@ def plot_field( plotf.delete() return model - @pyaedt_function_handler() + @pyaedt_function_handler(object_list="objects", variation_list="variations") def plot_animated_field( self, quantity, - object_list, + objects, plot_type="Surface", setup_name=None, intrinsics=None, variation_variable="Phi", - variation_list=["0deg"], + variations=["0deg"], view="isometric", show=True, scale_min=None, @@ -602,7 +602,7 @@ def plot_animated_field( ---------- quantity : str Quantity to plot (e.g. ``"Mag_E"``). - object_list : list, str + objects : list, str List of objects or faces to which apply the Field Plot. plot_type : str, optional Plot type. Options are ``"Surface"``, ``"Volume"``, ``"CutPlane"``. @@ -613,7 +613,7 @@ def plot_animated_field( The default is ``None`` which try to retrieve intrinsics from setup. variation_variable : str, optional Variable to vary. The default is ``"Phi"``. - variation_list : list, optional + variations : list, optional List of variation values with units. The default is ``["0deg"]``. view : str, optional @@ -668,18 +668,18 @@ def plot_animated_field( is_intrinsics = True if variation_variable in self._app.variable_manager.independent_variables: is_intrinsics = False - for el in variation_list: + for el in variations: if is_intrinsics: intrinsics[variation_variable] = el else: self._app[variation_variable] = el if plot_type == "Surface": - plotf = self.create_fieldplot_surface(object_list, quantity, setup_name, intrinsics) + plotf = self.create_fieldplot_surface(objects, quantity, setup_name, intrinsics) elif plot_type == "Volume": - plotf = self.create_fieldplot_volume(object_list, quantity, setup_name, intrinsics) + plotf = self.create_fieldplot_volume(objects, quantity, setup_name, intrinsics) else: plotf = self.create_fieldplot_cutplane( - object_list, quantity, setup_name, intrinsics, filter_objects=filter_objects + objects, quantity, setup_name, intrinsics, filter_objects=filter_objects ) if plotf: file_to_add = self.export_field_plot(plotf.name, export_path, plotf.name + str(v)) @@ -714,14 +714,13 @@ def plot_animated_field( model.animate() return model - @pyaedt_function_handler() + @pyaedt_function_handler(plotname="plot_name", variation_list="variations") def animate_fields_from_aedtplt( self, - plotname, + plot_name, plot_folder=None, - meshplot=False, variation_variable="Phase", - variation_list=["0deg"], + variations=["0deg"], project_path="", export_gif=False, show=True, @@ -736,20 +735,18 @@ def animate_fields_from_aedtplt( Parameters ---------- - plotname : str + plot_name : str Name of the plot or the name of the object. plot_folder : str, optional Name of the folder in which the plot resides. The default is ``None``. variation_variable : str, optional Variable to vary. The default is ``"Phase"``. - variation_list : list, optional + variations : list, optional List of variation values with units. The default is ``["0deg"]``. project_path : str, optional Path for the export. The default is ``""`` which export file in working_directory. - meshplot : bool, optional - The default is ``False``. Valid from Version 2021.2. export_gif : bool, optional The default is ``False``. show=False, @@ -775,24 +772,24 @@ def animate_fields_from_aedtplt( fields_to_add = [] if not project_path: project_path = self._app.working_directory - for el in variation_list: - if plotname in self.field_plots and variation_variable in self.field_plots[plotname].intrinsics: - self.field_plots[plotname].intrinsics[variation_variable] = el - self.field_plots[plotname].update() + for el in variations: + if plot_name in self.field_plots and variation_variable in self.field_plots[plot_name].intrinsics: + self.field_plots[plot_name].intrinsics[variation_variable] = el + self.field_plots[plot_name].update() else: self._app._odesign.ChangeProperty( [ "NAME:AllTabs", [ "NAME:FieldsPostProcessorTab", - ["NAME:PropServers", "FieldsReporter:" + plotname], + ["NAME:PropServers", "FieldsReporter:" + plot_name], ["NAME:ChangedProps", ["NAME:" + variation_variable, "Value:=", el]], ], ] ) fields_to_add.append( self.export_field_plot( - plotname, project_path, plotname + variation_variable + str(el), file_format="case" + plot_name, project_path, plot_name + variation_variable + str(el), file_format="case" ) ) @@ -811,17 +808,22 @@ def animate_fields_from_aedtplt( model.animate() return model - @pyaedt_function_handler() + @pyaedt_function_handler( + quantityname="quantity", + object_list="objects", + plottype="plot_type", + intrinsic_dict="intrinsics", + variation_list="variations", + ) def animate_fields_from_aedtplt_2( self, - quantityname, - object_list, - plottype, - meshplot=False, + quantity, + objects, + plot_type, setup_name=None, - intrinsic_dict={}, + intrinsics={}, variation_variable="Phi", - variation_list=["0deg"], + variations=["0deg"], project_path="", export_gif=False, show=True, @@ -836,7 +838,7 @@ def animate_fields_from_aedtplt_2( .. deprecated:: 0.6.83 No need to use primitives anymore. You can instantiate primitives methods directly from modeler instead. - .. note:: + .. note:: The PyVista module rebuilds the mesh and the overlap fields on the mesh. This method creates the plot and exports it. @@ -845,24 +847,22 @@ def animate_fields_from_aedtplt_2( Parameters ---------- - quantityname : str + quantity : str Name of the plot or the name of the object. - object_list : list, optional + objects : list, optional Name of the ``folderplot`` folder. - plottype : str + plot_type : str Type of the plot. Options are ``"Surface"``, ``"Volume"``, and ``"CutPlane"``. - meshplot : bool, optional - The default is ``False``. setup_name : str, optional Name of the setup (sweep) to use for the export. The default is ``None``. - intrinsic_dict : dict, optional + intrinsics : dict, optional Intrinsic dictionary that is needed for the export. The default is ``{}``. variation_variable : str, optional Variable to vary. The default is ``"Phi"``. - variation_list : list, option + variations : list, option List of variation values with units. The default is ``["0deg"]``. project_path : str, optional @@ -876,6 +876,12 @@ def animate_fields_from_aedtplt_2( Zoom factor. log_scale : bool, optional Whether to plot fields in log scale. The default is ``True``. + dark_mode : bool, optional + Whether to plot with dark mode. The default is ``False``. + show_grid : bool, optional + Whether to show grid on plot. The default is ``False``. + show_bounding : bool, optional + Whether to show bounding on plot. The default is ``False``. Returns ------- @@ -888,21 +894,21 @@ def animate_fields_from_aedtplt_2( ) return self.plot_animated_field( - quantity=quantityname, - object_list=object_list, - plot_type=plottype, + quantity=quantity, + objects=objects, + plot_type=plot_type, setup_name=setup_name, - intrinsics=intrinsic_dict, + intrinsics=intrinsics, variation_variable=variation_variable, - variation_list=variation_list, - export_path=project_path, - log_scale=log_scale, + variations=variations, show=show, - export_gif=export_gif, + log_scale=log_scale, zoom=zoom, - show_bounding=show_bounding, - show_grid=show_grid, + export_gif=export_gif, + export_path=project_path, dark_mode=dark_mode, + show_grid=show_grid, + show_bounding=show_bounding, ) @pyaedt_function_handler() @@ -935,11 +941,11 @@ def create_3d_plot( solution_data.primary_sweep = primary_sweep return solution_data.plot_3d(x_axis=primary_sweep, y_axis=secondary_sweep) - @pyaedt_function_handler() + @pyaedt_function_handler(frames_list="frames", output_gif_path="gif_path") def plot_scene( self, - frames_list, - output_gif_path, + frames, + gif_path, norm_index=0, dy_rng=0, fps=30, @@ -954,10 +960,10 @@ def plot_scene( Parameters ---------- - frames_list : list or str + frames : list or str File list containing animation frames to plot in csv format or path to a txt index file containing full path to csv files. - output_gif_path : str + gif_path : str Full path to output gif file. norm_index : int, optional Pick the frame to use to normalize your images. @@ -983,16 +989,16 @@ def plot_scene( ------- """ - if isinstance(frames_list, str) and os.path.exists(frames_list): - with open_file(frames_list, "r") as f: + if isinstance(frames, str) and os.path.exists(frames): + with open_file(frames, "r") as f: lines = f.read() temp_list = lines.splitlines() frames_paths_list = [i for i in temp_list] - elif isinstance(frames_list, str): + elif isinstance(frames, str): self.logger.error("Path doesn't exists") return False else: - frames_paths_list = frames_list + frames_paths_list = frames scene = self.get_model_plotter_geometries(generate_mesh=False) norm_data = np.loadtxt(frames_paths_list[norm_index], skiprows=1, delimiter=",") @@ -1016,7 +1022,7 @@ def plot_scene( scene.zoom = zoom scene.bounding_box = False scene.color_bar = False - scene.gif_file = output_gif_path # This gif may be a bit slower so we can speed it up a bit + scene.gif_file = gif_path # This gif may be a bit slower so we can speed it up a bit scene.convert_fields_in_db = convert_fields_in_db scene.log_multiplier = log_multiplier scene.animate() @@ -1030,8 +1036,8 @@ def __init__(self, app): def create_field_summary(self): return FieldSummary(self._app) - @pyaedt_function_handler() - def get_fans_operating_point(self, export_file=None, setup_name=None, timestep=None, design_variation=None): + @pyaedt_function_handler(timestep="time_step", design_variation="variation") + def get_fans_operating_point(self, export_file=None, setup_name=None, time_step=None, variation=None): """ Get the operating point of the fans in the design. @@ -1043,11 +1049,11 @@ def get_fans_operating_point(self, export_file=None, setup_name=None, timestep=N setup_name : str, optional Setup name to determine the operating point of the fans. The default is ``None``, in which case the first available setup is used. - timestep : str, optional + time_step : str, optional Time, with units, at which to determine the operating point of the fans. The default is ``None``, in which case the first available timestep is used. This parameter is only relevant in transient simulations. - design_variation : str, optional + variation : str, optional Design variation to determine the operating point of the fans from. The default is ``None``, in which case the nominal variation is used. @@ -1082,28 +1088,28 @@ def get_fans_operating_point(self, export_file=None, setup_name=None, timestep=N export_file = os.path.join(path, file_name + ".csv") if setup_name is None: setup_name = "{} : {}".format(self._app.get_setups()[0], self._app.solution_type) - if timestep is None: - timestep = "" + if time_step is None: + time_step = "" if self._app.solution_type == "Transient": self._app.logger.warning("No timestep is specified. First timestep is exported.") else: if not self._app.solution_type == "Transient": self._app.logger.warning("Simulation is steady-state. Timestep argument is ignored.") - timestep = "" - if design_variation is None: - design_variation = "" + time_step = "" + if variation is None: + variation = "" self._app.osolution.ExportFanOperatingPoint( [ "SolutionName:=", setup_name, "DesignVariationKey:=", - design_variation, + variation, "ExportFilePath:=", export_file, "Overwrite:=", True, "TimeStep:=", - timestep, + time_step, ] ) with open(export_file, "r") as f: @@ -1130,23 +1136,23 @@ def _parse_field_summary_content(self, fs, setup_name, design_variation, quantit return {i: content[i][0] for i in ["Total", "Unit"]} return {i: content[i][0] for i in ["Min", "Max", "Mean", "Stdev", "Unit"]} - @pyaedt_function_handler() + @pyaedt_function_handler(faces_list="faces", quantity_name="quantity", design_variation="variation") def evaluate_faces_quantity( self, - faces_list, - quantity_name, + faces, + quantity, side="Default", setup_name=None, - design_variation=None, + variations=None, ref_temperature="", ): """Export the field surface output. Parameters ---------- - faces_list : list + faces : list List of faces to apply. - quantity_name : str + quantity : str Name of the quantity to export. side : str, optional Which side of the mesh face to use. The default is ``Default``. @@ -1154,7 +1160,7 @@ def evaluate_faces_quantity( setup_name : str, optional Name of the setup and name of the sweep. For example, ``"IcepakSetup1 : SteatyState"``. The default is ``None``, in which case the active setup and active sweep are used. - design_variation : dict, optional + variations : dict, optional Dictionary of parameters defined for the specific setup with values. The default is ``{}``. ref_temperature: str, optional Reference temperature to use for heat transfer coefficient computation. The default is ``""``. @@ -1173,36 +1179,34 @@ def evaluate_faces_quantity( >>> oModule.ExportFieldsSummary """ - if design_variation is None: - design_variation = {} - facelist_name = generate_unique_name(quantity_name) - self._app.modeler.create_face_list(faces_list, facelist_name) + if variations is None: + variations = {} + facelist_name = generate_unique_name(quantity) + self._app.modeler.create_face_list(faces, facelist_name) fs = self.create_field_summary() - fs.add_calculation( - "Object", "Surface", facelist_name, quantity_name, side=side, ref_temperature=ref_temperature - ) - out = self._parse_field_summary_content(fs, setup_name, design_variation, quantity_name) + fs.add_calculation("Object", "Surface", facelist_name, quantity, side=side, ref_temperature=ref_temperature) + out = self._parse_field_summary_content(fs, setup_name, variations, quantity) self._app.oeditor.Delete(["NAME:Selections", "Selections:=", facelist_name]) return out - @pyaedt_function_handler() + @pyaedt_function_handler(boundary_name="boundary", quantity_name="quantity", design_variation="variations") def evaluate_boundary_quantity( self, - boundary_name, - quantity_name, + boundary, + quantity, side="Default", volume=False, setup_name=None, - design_variation=None, + variations=None, ref_temperature="", ): """Export the field output on a boundary. Parameters ---------- - boundary_name : str + boundary : str Name of boundary to perform the computation on. - quantity_name : str + quantity : str Name of the quantity to export. side : str, optional Side of the mesh face to use. The default is ``"Default"``. @@ -1214,7 +1218,7 @@ def evaluate_boundary_quantity( setup_name : str, optional Name of the setup and name of the sweep. For example, ``"IcepakSetup1 : SteatyState"``. The default is ``None``, in which case the active setup and active sweep are used. - design_variation : dict, optional + variations : dict, optional Dictionary of parameters defined for the specific setup with values. The default is ``{}``. ref_temperature: str, optional Reference temperature to use for heat transfer coefficient computation. The default is ``""``. @@ -1232,36 +1236,36 @@ def evaluate_boundary_quantity( >>> oModule.ExportFieldsSummary """ - if design_variation is None: - design_variation = {} + if variations is None: + variations = {} fs = self.create_field_summary() fs.add_calculation( "Boundary", ["Surface", "Volume"][int(volume)], - boundary_name, - quantity_name, + boundary, + quantity, side=side, ref_temperature=ref_temperature, ) - return self._parse_field_summary_content(fs, setup_name, design_variation, quantity_name) + return self._parse_field_summary_content(fs, setup_name, variations, quantity) - @pyaedt_function_handler() + @pyaedt_function_handler(monitor_name="monitor", quantity_name="quantity", design_variation="variations") def evaluate_monitor_quantity( self, - monitor_name, - quantity_name, + monitor, + quantity, side="Default", setup_name=None, - design_variation=None, + variations=None, ref_temperature="", ): """Export monitor field output. Parameters ---------- - monitor_name : str + monitor : str Name of monitor to perform the computation on. - quantity_name : str + quantity : str Name of the quantity to export. side : str, optional Side of the mesh face to use. The default is ``"Default"``. @@ -1269,7 +1273,7 @@ def evaluate_monitor_quantity( setup_name : str, optional Name of the setup and name of the sweep. For example, ``"IcepakSetup1 : SteatyState"``. The default is ``None``, in which case the active setup and active sweep are used. - design_variation : dict, optional + variations : dict, optional Dictionary of parameters defined for the specific setup with values. The default is ``{}``. ref_temperature: str, optional Reference temperature to use for heat transfer coefficient computation. The default is ``""``. @@ -1288,22 +1292,20 @@ def evaluate_monitor_quantity( >>> oModule.ExportFieldsSummary """ - if design_variation is None: - design_variation = {} + if variations is None: + variations = {} if settings.aedt_version < "2024.1": raise NotImplementedError("Monitors are not supported in field summary in versions earlier than 2024 R1.") else: # pragma: no cover - if self._app.monitor.face_monitors.get(monitor_name, None): + if self._app.monitor.face_monitors.get(monitor, None): field_type = "Surface" - elif self._app.monitor.point_monitors.get(monitor_name, None): + elif self._app.monitor.point_monitors.get(monitor, None): field_type = "Volume" else: - raise AttributeError("Monitor {} is not found in the design.".format(monitor_name)) + raise AttributeError("Monitor {} is not found in the design.".format(monitor)) fs = self.create_field_summary() - fs.add_calculation( - "Monitor", field_type, monitor_name, quantity_name, side=side, ref_temperature=ref_temperature - ) - return self._parse_field_summary_content(fs, setup_name, design_variation, quantity_name) + fs.add_calculation("Monitor", field_type, monitor, quantity, side=side, ref_temperature=ref_temperature) + return self._parse_field_summary_content(fs, setup_name, variations, quantity) @pyaedt_function_handler() def evaluate_object_quantity( From 61f43228c80344670bb8aaf2b5ea9ce4c5b22007 Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Thu, 28 Mar 2024 10:31:02 +0100 Subject: [PATCH 13/22] refacto AdvancedPostProcessing.py --- pyaedt/modules/AdvancedPostProcessing.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pyaedt/modules/AdvancedPostProcessing.py b/pyaedt/modules/AdvancedPostProcessing.py index 2bbf2775e19..5d8f0cb1f7f 100644 --- a/pyaedt/modules/AdvancedPostProcessing.py +++ b/pyaedt/modules/AdvancedPostProcessing.py @@ -1307,7 +1307,7 @@ def evaluate_monitor_quantity( fs.add_calculation("Monitor", field_type, monitor, quantity, side=side, ref_temperature=ref_temperature) return self._parse_field_summary_content(fs, setup_name, variations, quantity) - @pyaedt_function_handler() + @pyaedt_function_handler(design_variation="variations") def evaluate_object_quantity( self, object_name, @@ -1315,7 +1315,7 @@ def evaluate_object_quantity( side="Default", volume=False, setup_name=None, - design_variation=None, + variations=None, ref_temperature="", ): """Export the field output on or in an object. @@ -1334,7 +1334,7 @@ def evaluate_object_quantity( setup_name : str, optional Name of the setup and name of the sweep. For example, ``"IcepakSetup1 : SteatyState"``. The default is ``None``, in which case the active setup and active sweep are used. - design_variation : dict, optional + variations : dict, optional Dictionary of parameters defined for the specific setup with values. The default is ``{}``. ref_temperature: str, optional Reference temperature to use for heat transfer coefficient computation. The default is ``""``. @@ -1353,8 +1353,8 @@ def evaluate_object_quantity( >>> oModule.ExportFieldsSummary """ - if design_variation is None: - design_variation = {} + if variations is None: + variations = {} fs = self.create_field_summary() fs.add_calculation( "Boundary", @@ -1364,4 +1364,4 @@ def evaluate_object_quantity( side=side, ref_temperature=ref_temperature, ) - return self._parse_field_summary_content(fs, setup_name, design_variation, quantity_name) + return self._parse_field_summary_content(fs, setup_name, variations, quantity_name) From bf3cce5c06add248f4a592ed11f6948d1751ca70 Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Thu, 28 Mar 2024 11:07:55 +0100 Subject: [PATCH 14/22] refacto solutions.py --- _unittest/test_02_2D_modeler.py | 11 +- _unittest/test_12_1_PostProcessing.py | 2 +- _unittest/test_12_PostProcessing.py | 102 ++-- _unittest_solvers/test_00_analyze.py | 23 +- examples/01-HFSS3DLayout/HFSS3DLayout_Via.py | 2 +- examples/01-HFSS3DLayout/Hfss3DComponent.py | 4 +- examples/02-HFSS/Array.py | 18 +- examples/02-HFSS/HFSS_Dipole.py | 9 +- examples/02-HFSS/HFSS_Spiral.py | 2 +- examples/02-SBR+/SBR_Time_Plot.py | 2 +- examples/05-Q3D/Q2D_Example_Stripline.py | 2 +- .../06-Multiphysics/Hfss_Icepak_Coupling.py | 5 +- examples/07-Circuit/Circuit_AMI.py | 4 +- .../07-TwinBuilder/01-RC_Circuit_Example.py | 2 +- pyaedt/application/Analysis3D.py | 2 +- pyaedt/generic/pdf.py | 4 +- pyaedt/generic/plot.py | 2 +- pyaedt/modules/PostProcessor.py | 54 +- pyaedt/modules/solutions.py | 577 +++++++++--------- 19 files changed, 402 insertions(+), 425 deletions(-) diff --git a/_unittest/test_02_2D_modeler.py b/_unittest/test_02_2D_modeler.py index 0837a6394f8..2304fb5e8d4 100644 --- a/_unittest/test_02_2D_modeler.py +++ b/_unittest/test_02_2D_modeler.py @@ -166,16 +166,11 @@ def test_09_plot(self): self.aedtapp.modeler.create_regular_polygon( position=[0, 0, 0], start_point=[0, 0, 2], num_sides=3, name="MyPolygon", matname="Copper" ) - obj = self.aedtapp.plot( - show=False, - export_path=os.path.join(self.local_scratch.path, "image.jpg"), - show_bounding=True, - show_grid=True, - ) + obj = self.aedtapp.plot() assert os.path.exists(obj.image_file) - obj2 = self.aedtapp.plot(show=False, export_path=os.path.join(self.local_scratch.path, "image.jpg"), view="xy") + obj2 = self.aedtapp.plot() assert os.path.exists(obj2.image_file) - obj3 = self.aedtapp.plot(show=False, export_path=os.path.join(self.local_scratch.path, "image.jpg"), view="xy1") + obj3 = self.aedtapp.plot() assert filecmp.cmp(obj.image_file, obj3.image_file) def test_10_edit_menu_commands(self): diff --git a/_unittest/test_12_1_PostProcessing.py b/_unittest/test_12_1_PostProcessing.py index 7d3db7b530b..c44ba3ff455 100644 --- a/_unittest/test_12_1_PostProcessing.py +++ b/_unittest/test_12_1_PostProcessing.py @@ -136,7 +136,7 @@ def test_02_export_fields(self): plot2 = self.aedtapp.post.create_fieldplot_volume(vollist, quantity_name2, setup_name, intrinsic) self.aedtapp.post.export_field_jpg( - os.path.join(self.local_scratch.path, "prova2.jpg"), plot2.name, plot2.plotFolder + os.path.join(self.local_scratch.path, "prova2.jpg"), plot2.name, plot2.plot_folder ) assert os.path.exists(os.path.join(self.local_scratch.path, "prova2.jpg")) assert os.path.exists( diff --git a/_unittest/test_12_PostProcessing.py b/_unittest/test_12_PostProcessing.py index 59466278d46..7ffd64db834 100644 --- a/_unittest/test_12_PostProcessing.py +++ b/_unittest/test_12_PostProcessing.py @@ -239,7 +239,7 @@ def test_09_manipulate_report_E(self, field_test): setup_sweep_name=field_test.nominal_adaptive, domain={"Context": "3D", "SourceContext": "1:1"}, ) - assert data_farfield2.plot(math_formula="db20", is_polar=True) + assert data_farfield2.plot(formula="db20", is_polar=True) def test_09b_export_report_A(self, circuit_test): files = circuit_test.export_results() @@ -355,18 +355,18 @@ def test_18_diff_plot(self, diff_test): context="Differential Pairs", ) assert data1.primary_sweep == "Freq" - data1.plot(math_formula="db20") + data1.plot(formula="db20") data1.primary_sweep = "l1" assert data1.primary_sweep == "l1" assert len(data1.data_magnitude()) == 5 assert data1.plot("S(Diff1, Diff1)") - assert data1.plot(math_formula="db20") - assert data1.plot(math_formula="db10") - assert data1.plot(math_formula="mag") - assert data1.plot(math_formula="re") - assert data1.plot(math_formula="im") - assert data1.plot(math_formula="phasedeg") - assert data1.plot(math_formula="phaserad") + assert data1.plot(formula="db20") + assert data1.plot(formula="db10") + assert data1.plot(formula="mag") + assert data1.plot(formula="re") + assert data1.plot(formula="im") + assert data1.plot(formula="phasedeg") + assert data1.plot(formula="phaserad") assert diff_test.create_touchstone_report( plot_name="Diff_plot", @@ -399,7 +399,7 @@ def test_55_time_plot(self, sbr_test): t_matrix = solution_data.ifft("NearE", window=True) assert t_matrix.any() frames_list = solution_data.ifft_to_file( - coord_system_center=[-0.15, 0, 0], db_val=True, csv_dir=os.path.join(sbr_test.working_directory, "csv") + coord_system_center=[-0.15, 0, 0], db_val=True, csv_path=os.path.join(sbr_test.working_directory, "csv") ) assert os.path.exists(frames_list) sbr_test.post.plot_scene( @@ -585,13 +585,13 @@ def test_70_far_field_data(self): assert ffdata.origin == [0, 0, 1] img1 = os.path.join(self.local_scratch.path, "ff_2d1.jpg") - ffdata.plot_2d_cut(secondary_sweep_value="all", primary_sweep="Theta", export_image_path=img1) + ffdata.plot_2d_cut(primary_sweep="Theta", secondary_sweep_value="all", image_path=img1) assert os.path.exists(img1) img2 = os.path.join(self.local_scratch.path, "ff_2d2.jpg") - ffdata.plot_2d_cut(secondary_sweep_value=[0, 1], export_image_path=img2) + ffdata.plot_2d_cut(secondary_sweep_value=[0, 1], image_path=img2) assert os.path.exists(img2) img3 = os.path.join(self.local_scratch.path, "ff_2d2.jpg") - ffdata.plot_2d_cut(export_image_path=img3) + ffdata.plot_2d_cut(image_path=img3) assert os.path.exists(img3) curve_2d = ffdata.plot_2d_cut(show=False) assert len(curve_2d[0]) == 3 @@ -600,20 +600,16 @@ def test_70_far_field_data(self): img4 = os.path.join(self.local_scratch.path, "ff_3d1.jpg") ffdata.polar_plot_3d_pyvista( - farfield_quantity="RealizedGain", - convert_to_db=True, + quantity="RealizedGain", + image_path=img4, show=False, - export_image_path=img4, background=[255, 0, 0], show_geometry=False, + convert_to_db=True, ) assert os.path.exists(img4) data_pyvista = ffdata.polar_plot_3d_pyvista( - farfield_quantity="RealizedGain", - convert_to_db=True, - show=False, - background=[255, 0, 0], - show_geometry=False, + quantity="RealizedGain", show=False, background=[255, 0, 0], show_geometry=False, convert_to_db=True ) assert data_pyvista @@ -625,48 +621,46 @@ def test_71_antenna_plot(self, field_test): ffdata.phase_offset = [0] assert ffdata.phase_offset != [0.0] assert ffdata.plot_farfield_contour( - farfield_quantity="RealizedGain", - convert_to_db=True, + quantity="RealizedGain", title="Contour at {}Hz".format(ffdata.frequency), - export_image_path=os.path.join(self.local_scratch.path, "contour.jpg"), + image_path=os.path.join(self.local_scratch.path, "contour.jpg"), + convert_to_db=True, ) assert os.path.exists(os.path.join(self.local_scratch.path, "contour.jpg")) ffdata.plot_2d_cut( + quantity="RealizedGain", primary_sweep="theta", secondary_sweep_value=[-180, -75, 75], - farfield_quantity="RealizedGain", title="Azimuth at {}Hz".format(ffdata.frequency), - export_image_path=os.path.join(self.local_scratch.path, "2d1.jpg"), + image_path=os.path.join(self.local_scratch.path, "2d1.jpg"), ) assert os.path.exists(os.path.join(self.local_scratch.path, "2d1.jpg")) ffdata.plot_2d_cut( + quantity="RealizedGain", primary_sweep="phi", secondary_sweep_value=30, - farfield_quantity="RealizedGain", title="Azimuth at {}Hz".format(ffdata.frequency), - export_image_path=os.path.join(self.local_scratch.path, "2d2.jpg"), + image_path=os.path.join(self.local_scratch.path, "2d2.jpg"), ) assert os.path.exists(os.path.join(self.local_scratch.path, "2d2.jpg")) ffdata.polar_plot_3d( - farfield_quantity="RealizedGain", - convert_to_db=True, - export_image_path=os.path.join(self.local_scratch.path, "3d1.jpg"), + quantity="RealizedGain", image_path=os.path.join(self.local_scratch.path, "3d1.jpg"), convert_to_db=True ) assert os.path.exists(os.path.join(self.local_scratch.path, "3d1.jpg")) ffdata.polar_plot_3d_pyvista( - farfield_quantity="RealizedGain", - convert_to_db=True, + quantity="RealizedGain", + image_path=os.path.join(self.local_scratch.path, "3d2.jpg"), show=False, - export_image_path=os.path.join(self.local_scratch.path, "3d2.jpg"), + convert_to_db=True, ) assert os.path.exists(os.path.join(self.local_scratch.path, "3d2.jpg")) try: - p = ffdata.polar_plot_3d_pyvista(farfield_quantity="RealizedGain", convert_to_db=True, show=False) + p = ffdata.polar_plot_3d_pyvista(quantity="RealizedGain", show=False, convert_to_db=True) assert isinstance(p, object) except Exception: assert True @@ -676,51 +670,49 @@ def test_72_antenna_plot(self, array_test): ffdata = array_test.get_antenna_ffd_solution_data(frequencies=3.5e9, sphere_name="3D") ffdata.frequency = 3.5e9 assert ffdata.plot_farfield_contour( - farfield_quantity="RealizedGain", - convert_to_db=True, + quantity="RealizedGain", title="Contour at {}Hz".format(ffdata.frequency), - export_image_path=os.path.join(self.local_scratch.path, "contour.jpg"), + image_path=os.path.join(self.local_scratch.path, "contour.jpg"), + convert_to_db=True, ) assert os.path.exists(os.path.join(self.local_scratch.path, "contour.jpg")) ffdata.plot_2d_cut( + quantity="RealizedGain", primary_sweep="theta", secondary_sweep_value=[-180, -75, 75], - farfield_quantity="RealizedGain", title="Azimuth at {}Hz".format(ffdata.frequency), - export_image_path=os.path.join(self.local_scratch.path, "2d1.jpg"), + image_path=os.path.join(self.local_scratch.path, "2d1.jpg"), ) assert os.path.exists(os.path.join(self.local_scratch.path, "2d1.jpg")) ffdata.plot_2d_cut( + quantity="RealizedGain", primary_sweep="phi", secondary_sweep_value=30, - farfield_quantity="RealizedGain", title="Azimuth at {}Hz".format(ffdata.frequency), - export_image_path=os.path.join(self.local_scratch.path, "2d2.jpg"), + image_path=os.path.join(self.local_scratch.path, "2d2.jpg"), ) assert os.path.exists(os.path.join(self.local_scratch.path, "2d2.jpg")) ffdata.polar_plot_3d( - farfield_quantity="RealizedGain", - convert_to_db=True, - export_image_path=os.path.join(self.local_scratch.path, "3d1.jpg"), + quantity="RealizedGain", image_path=os.path.join(self.local_scratch.path, "3d1.jpg"), convert_to_db=True ) assert os.path.exists(os.path.join(self.local_scratch.path, "3d1.jpg")) ffdata.polar_plot_3d_pyvista( - farfield_quantity="RealizedGain", - convert_to_db=True, + quantity="RealizedGain", + image_path=os.path.join(self.local_scratch.path, "3d2.jpg"), show=False, - export_image_path=os.path.join(self.local_scratch.path, "3d2.jpg"), + convert_to_db=True, ) assert os.path.exists(os.path.join(self.local_scratch.path, "3d2.jpg")) ffdata1 = array_test.get_antenna_ffd_solution_data(frequencies=3.5e9, sphere_name="3D", overwrite=False) assert ffdata1.plot_farfield_contour( - farfield_quantity="RealizedGain", - convert_to_db=True, + quantity="RealizedGain", title="Contour at {}Hz".format(ffdata1.frequency), - export_image_path=os.path.join(self.local_scratch.path, "contour1.jpg"), + image_path=os.path.join(self.local_scratch.path, "contour1.jpg"), + convert_to_db=True, ) assert os.path.exists(os.path.join(self.local_scratch.path, "contour1.jpg")) @@ -853,15 +845,15 @@ def test_75_plot_field_line_traces(self, m2dtest): el_id = [obj.id for obj in m2dtest.modeler.object_list if obj.name == "Electrode"] plot.seeding_faces.append(el_id[0]) assert plot.update() - plot.volume_indexes.append(el_id[0]) + plot.volumes.append(el_id[0]) plot.update() - plot.surfaces_indexes.append(el_id[0]) + plot.surfaces.append(el_id[0]) plot.update() plot.seeding_faces.append(8) assert not plot.update() - plot.volume_indexes.append(8) + plot.volumes.append(8) assert not plot.update() - plot.surfaces_indexes.append(8) + plot.surfaces.append(8) assert not plot.update() def test_98_get_variations(self, field_test): diff --git a/_unittest_solvers/test_00_analyze.py b/_unittest_solvers/test_00_analyze.py index 5f3b7639569..b7d03f4c058 100644 --- a/_unittest_solvers/test_00_analyze.py +++ b/_unittest_solvers/test_00_analyze.py @@ -112,24 +112,15 @@ def test_01a_sbr_link_array(self, sbr_platform, array): ffdata = sbr_platform.get_antenna_ffd_solution_data(frequencies=12e9, sphere_name="3D") ffdata2 = sbr_platform.get_antenna_ffd_solution_data(frequencies=12e9, sphere_name="3D", overwrite=False) - ffdata.plot_2d_cut( - primary_sweep="theta", - secondary_sweep_value=[75], - theta_scan=20, - farfield_quantity="RealizedGain", - title="Azimuth at {}Hz".format(ffdata.frequency), - quantity_format="dB10", - export_image_path=os.path.join(self.local_scratch.path, "2d1_array.jpg"), - ) + ffdata.plot_2d_cut(quantity="RealizedGain", primary_sweep="theta", secondary_sweep_value=[75], theta=20, + title="Azimuth at {}Hz".format(ffdata.frequency), quantity_format="dB10", + image_path=os.path.join(self.local_scratch.path, "2d1_array.jpg")) assert os.path.exists(os.path.join(self.local_scratch.path, "2d1_array.jpg")) - ffdata2.polar_plot_3d_pyvista( - farfield_quantity="RealizedGain", - convert_to_db=True, - show=False, - rotation=[[1, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, 1.0, 0.0]], - export_image_path=os.path.join(self.local_scratch.path, "3d2_array.jpg"), - ) + ffdata2.polar_plot_3d_pyvista(quantity="RealizedGain", + rotation=[[1, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, 1.0, 0.0]], + image_path=os.path.join(self.local_scratch.path, "3d2_array.jpg"), show=False, + convert_to_db=True) assert os.path.exists(os.path.join(self.local_scratch.path, "3d2_array.jpg")) def test_01b_sbr_create_vrt(self, sbr_app): diff --git a/examples/01-HFSS3DLayout/HFSS3DLayout_Via.py b/examples/01-HFSS3DLayout/HFSS3DLayout_Via.py index 0ef1cb7852e..773ce5b128e 100644 --- a/examples/01-HFSS3DLayout/HFSS3DLayout_Via.py +++ b/examples/01-HFSS3DLayout/HFSS3DLayout_Via.py @@ -120,7 +120,7 @@ traces = h3d.get_traces_for_plot(first_element_filter="Port1", category="S") solutions = h3d.post.get_solution_data(expressions=traces) -solutions.plot(math_formula="db20") +solutions.plot(formula="db20") ############################################################################### # Close AEDT diff --git a/examples/01-HFSS3DLayout/Hfss3DComponent.py b/examples/01-HFSS3DLayout/Hfss3DComponent.py index 556920e7980..c4d0aca1791 100644 --- a/examples/01-HFSS3DLayout/Hfss3DComponent.py +++ b/examples/01-HFSS3DLayout/Hfss3DComponent.py @@ -156,7 +156,7 @@ traces = hfss.get_traces_for_plot(category="S") solutions = hfss.post.get_solution_data(traces) -solutions.plot(traces, math_formula="db20") +solutions.plot(traces, formula="db20") ############################################################################### # Hfss 3D Layout Example @@ -232,7 +232,7 @@ traces = h3d.get_traces_for_plot(category="S") solutions = h3d.post.get_solution_data(traces) -solutions.plot(traces, math_formula="db20") +solutions.plot(traces, formula="db20") h3d.save_project() h3d.release_desktop() diff --git a/examples/02-HFSS/Array.py b/examples/02-HFSS/Array.py index 31164948db8..304ba1ffd7a 100644 --- a/examples/02-HFSS/Array.py +++ b/examples/02-HFSS/Array.py @@ -101,8 +101,7 @@ # Generate a contour plot. You can define the Theta scan # and Phi scan. -ffdata.plot_farfield_contour(farfield_quantity='RealizedGain', - title='Contour at {}Hz'.format(ffdata.frequency)) +ffdata.plot_farfield_contour(quantity='RealizedGain', title='Contour at {}Hz'.format(ffdata.frequency)) ########################################################## # Release AEDT @@ -129,8 +128,7 @@ # Generate a contour plot. You can define the Theta scan # and Phi scan. -ffdata.plot_farfield_contour(farfield_quantity='RealizedGain', - title='Contour at {}Hz'.format(ffdata.frequency)) +ffdata.plot_farfield_contour(quantity='RealizedGain', title='Contour at {}Hz'.format(ffdata.frequency)) ########################################################## # Generate 2D cutout plots @@ -138,14 +136,10 @@ # Generate 2D cutout plots. You can define the Theta scan # and Phi scan. -ffdata.plot_2d_cut(primary_sweep='theta', secondary_sweep_value=[-180, -75, 75], - farfield_quantity='RealizedGain', - title='Azimuth at {}Hz'.format(ffdata.frequency), - quantity_format="dB10") +ffdata.plot_2d_cut(quantity='RealizedGain', primary_sweep='theta', secondary_sweep_value=[-180, -75, 75], + title='Azimuth at {}Hz'.format(ffdata.frequency), quantity_format="dB10") -ffdata.plot_2d_cut(primary_sweep="phi", secondary_sweep_value=30, - farfield_quantity='RealizedGain', - title='Elevation', +ffdata.plot_2d_cut(quantity='RealizedGain', primary_sweep="phi", secondary_sweep_value=30, title='Elevation', quantity_format="dB10") ########################################################## @@ -154,4 +148,4 @@ # Generate 3D polar plots in Matplotlib. You can define # the Theta scan and Phi scan. -ffdata.polar_plot_3d(farfield_quantity='RealizedGain') +ffdata.polar_plot_3d(quantity='RealizedGain') diff --git a/examples/02-HFSS/HFSS_Dipole.py b/examples/02-HFSS/HFSS_Dipole.py index 0010f3d64c2..c1cdc385a3d 100644 --- a/examples/02-HFSS/HFSS_Dipole.py +++ b/examples/02-HFSS/HFSS_Dipole.py @@ -198,7 +198,7 @@ # Generate a 2D plot using Matplotlib where you specify whether it is a polar # plot or a rectangular plot. -solutions.plot(math_formula="db20", is_polar=True) +solutions.plot(formula="db20", is_polar=True) ########################################################## # Get far field data @@ -216,11 +216,8 @@ # Generate 2D cutout plot. You can define the Theta scan # and Phi scan. -ffdata.plot_2d_cut(primary_sweep="theta", secondary_sweep_value=0, - farfield_quantity='RealizedGain', - title='FarField', - quantity_format="dB20", - is_polar=True) +ffdata.plot_2d_cut(quantity='RealizedGain', primary_sweep="theta", secondary_sweep_value=0, title='FarField', + quantity_format="dB20", is_polar=True) ############################################################################### # Close AEDT diff --git a/examples/02-HFSS/HFSS_Spiral.py b/examples/02-HFSS/HFSS_Spiral.py index f48d24978a3..c52b09fa4cf 100644 --- a/examples/02-HFSS/HFSS_Spiral.py +++ b/examples/02-HFSS/HFSS_Spiral.py @@ -193,7 +193,7 @@ def create_line(pts): # Plot the calculated values in Matplotlib. data = hfss.post.get_solution_data([L_formula, Q_formula]) -data.plot(curves=[L_formula, Q_formula], math_formula="re", xlabel="Freq", ylabel="L and Q") +data.plot(curves=[L_formula, Q_formula], formula="re", x_label="Freq", y_label="L and Q") ################################################################ # Export results to csv file diff --git a/examples/02-SBR+/SBR_Time_Plot.py b/examples/02-SBR+/SBR_Time_Plot.py index 6d1ed582ec6..6384ef137ff 100644 --- a/examples/02-SBR+/SBR_Time_Plot.py +++ b/examples/02-SBR+/SBR_Time_Plot.py @@ -64,7 +64,7 @@ # Export IFFT to a CSV file. frames_list_file = solution_data.ifft_to_file(coord_system_center=[-0.15, 0, 0], db_val=True, - csv_dir=os.path.join(hfss.working_directory, "csv")) + csv_path=os.path.join(hfss.working_directory, "csv")) ############################################################################### # Plot scene diff --git a/examples/05-Q3D/Q2D_Example_Stripline.py b/examples/05-Q3D/Q2D_Example_Stripline.py index ac56e9bd024..cba8e8a33ff 100644 --- a/examples/05-Q3D/Q2D_Example_Stripline.py +++ b/examples/05-Q3D/Q2D_Example_Stripline.py @@ -215,7 +215,7 @@ q.analyze() plot_sources = matrix.get_sources_for_plot(category="Z0") a = q.post.get_solution_data(expressions=plot_sources, context=matrix.name) -a.plot(snapshot_path=os.path.join(q.working_directory, "plot.jpg")) # Save plot as jpg +a.plot(snapshot_path=os.path.join(q.working_directory, "plot.jpg")) # Save plot as jpg # Add a parametric sweep and analyze. parametric = q.parametrics.add(sweep_var="sig_bot_w", start_point=75, end_point=100, step=5, diff --git a/examples/06-Multiphysics/Hfss_Icepak_Coupling.py b/examples/06-Multiphysics/Hfss_Icepak_Coupling.py index 6252d6f8281..07bc757222f 100644 --- a/examples/06-Multiphysics/Hfss_Icepak_Coupling.py +++ b/examples/06-Multiphysics/Hfss_Icepak_Coupling.py @@ -309,10 +309,7 @@ cxt = ["Domain:=", "Sweep"] families = ["Freq:=", ["All"]] my_data = aedtapp.post.get_solution_data(expressions=trace_names) -my_data.plot(trace_names, "db20", - xlabel="Frequency (Ghz)", - ylabel="SParameters(dB)", - title="Scattering Chart", +my_data.plot(trace_names, "db20", x_label="Frequency (Ghz)", y_label="SParameters(dB)", title="Scattering Chart", snapshot_path=os.path.join(results_folder, "Touchstone_from_matplotlib.jpg")) ################################################################################ diff --git a/examples/07-Circuit/Circuit_AMI.py b/examples/07-Circuit/Circuit_AMI.py index d9b2ee7e8b7..14c32da76ab 100644 --- a/examples/07-Circuit/Circuit_AMI.py +++ b/examples/07-Circuit/Circuit_AMI.py @@ -134,7 +134,7 @@ fig, ax = plt.subplots() ax.plot(sampled_time_zoom, sampled_data_zoom, "r*") -ax.plot(np.array(list(original_data_zoom.index.values)), original_data_zoom.values, color='blue') +ax.plot(np.array(list(original_data_zoom.index.values)), original_data_zoom.values) ax.set_title('WaveAfterProbe') ax.set_xlabel(original_data.units_sweeps["Time"]) ax.set_ylabel(original_data.units_data[plot_name]) @@ -242,7 +242,7 @@ fig, ax = plt.subplots() ax.plot(sampled_data_zoom_array[:, 0], sampled_data_zoom_array[:, 1], "r*") -ax.plot(original_sweep_zoom, original_data_zoom_array[:, 1], color='blue') +ax.plot(original_sweep_zoom, original_data_zoom_array[:, 1]) ax.set_title(plot_name) ax.set_xlabel(waveform_sweep_unit) ax.set_ylabel(waveform_unit) diff --git a/examples/07-TwinBuilder/01-RC_Circuit_Example.py b/examples/07-TwinBuilder/01-RC_Circuit_Example.py index b9ea8696501..0deec81cc46 100644 --- a/examples/07-TwinBuilder/01-RC_Circuit_Example.py +++ b/examples/07-TwinBuilder/01-RC_Circuit_Example.py @@ -99,7 +99,7 @@ C_Value = "C1.V" x = tb.post.get_solution_data([E_Value, C_Value], "TR", "Time") -x.plot([E_Value, C_Value], xlabel="Time", ylabel="Capacitor Voltage vs Input Pulse") +x.plot([E_Value, C_Value], x_label="Time", y_label="Capacitor Voltage vs Input Pulse") tb.save_project() diff --git a/pyaedt/application/Analysis3D.py b/pyaedt/application/Analysis3D.py index 0416ae6804b..f416560d359 100644 --- a/pyaedt/application/Analysis3D.py +++ b/pyaedt/application/Analysis3D.py @@ -1120,7 +1120,7 @@ def identify_touching_conductors(self, object_name=None): output = {"Net1": net_vals} return output return nets - plt_obj = self.plot(show=False, objects=self.get_all_conductors_names()) + plt_obj = self.plot() import pyvista as pv nets = {} diff --git a/pyaedt/generic/pdf.py b/pyaedt/generic/pdf.py index 9c067177a3b..6871215a0c1 100644 --- a/pyaedt/generic/pdf.py +++ b/pyaedt/generic/pdf.py @@ -258,9 +258,7 @@ def add_project_info(self, design): msg = f"Furthermore, the layout has {stats.num_nets} nets, {stats.num_traces} traces," msg += f" {stats.num_vias} vias. The stackup total thickness is {stats.stackup_thickness}." image_path = os.path.join(design.working_directory, "model.jpg") - design.modeler.edb.nets.plot( - save_plot=image_path, - ) + design.modeler.edb.nets.plot() self.add_image(image_path, "Model Image") elif design.design_type in ["Circuit Design"]: msg = f"The schematic has {len(design.modeler.components.components)} components." diff --git a/pyaedt/generic/plot.py b/pyaedt/generic/plot.py index 20556436c8d..1c11b0b3cb2 100644 --- a/pyaedt/generic/plot.py +++ b/pyaedt/generic/plot.py @@ -445,7 +445,7 @@ def plot_2d_chart(plot_data, size=(2000, 1000), show_legend=True, xlabel="", yla else: x = np.array([i for i, j in zip(plo_obj[0], plo_obj[1]) if j]) y = np.array([i for i in plo_obj[1] if i]) - ax.plot(x, y, label=label) + ax.plot(x, y) label_id += 1 ax.set(xlabel=xlabel, ylabel=ylabel, title=title) diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index d2ca4de0b7b..bb095e37582 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -2252,8 +2252,8 @@ def _get_fields_plot(self): if isinstance(setups_data[setup], (OrderedDict, dict)) and "PlotDefinition" in setup: plot_name = setups_data[setup]["PlotName"] plots[plot_name] = FieldPlot(self) - plots[plot_name].solutionName = self._get_base_name(setup) - plots[plot_name].quantityName = self.ofieldsreporter.GetFieldPlotQuantityName( + plots[plot_name].solution = self._get_base_name(setup) + plots[plot_name].quantity = self.ofieldsreporter.GetFieldPlotQuantityName( setups_data[setup]["PlotName"] ) plots[plot_name].intrinsics = self._get_intrinsic(setup) @@ -2262,20 +2262,18 @@ def _get_fields_plot(self): id = list_objs[0] num_objects = list_objs[2] if id == 64: - plots[plot_name].volume_indexes = self._get_volume_objects( - list_objs[3 : num_objects + 3] - ) + plots[plot_name].volumes = self._get_volume_objects(list_objs[3 : num_objects + 3]) elif id == 128: out, faces = self._get_surface_objects(list_objs[3 : num_objects + 3]) if out == "CutPlane": - plots[plot_name].cutplane_indexes = faces + plots[plot_name].cutplanes = faces else: - plots[plot_name].surfaces_indexes = faces + plots[plot_name].surfaces = faces elif id == 256: - plots[plot_name].line_indexes = self._get_volume_objects(list_objs[3 : num_objects + 3]) + plots[plot_name].lines = self._get_volume_objects(list_objs[3 : num_objects + 3]) list_objs = list_objs[num_objects + 3 :] plots[plot_name].name = setups_data[setup]["PlotName"] - plots[plot_name].plotFolder = setups_data[setup]["PlotFolder"] + plots[plot_name].plot_folder = setups_data[setup]["PlotFolder"] surf_setts = setups_data[setup]["PlotOnSurfaceSettings"] plots[plot_name].Filled = surf_setts["Filled"] plots[plot_name].IsoVal = surf_setts["IsoValType"] @@ -2981,34 +2979,26 @@ def _create_fieldplot( plot_name = quantity + "_" + "".join(random.sample(char_set, 6)) filter_boxes = [] if filter_boxes is None else filter_boxes if list_type == "CutPlane": - plot = FieldPlot( - self, cutplanelist=objects, solutionName=setup_name, quantityName=quantity, intrinsics=intrinsics - ) + plot = FieldPlot(self, cutplanes=objects, solution=setup_name, quantity=quantity, intrinsics=intrinsics) elif list_type == "FacesList": - plot = FieldPlot( - self, surfacelist=objects, solutionName=setup_name, quantityName=quantity, intrinsics=intrinsics - ) + plot = FieldPlot(self, surfaces=objects, solution=setup_name, quantity=quantity, intrinsics=intrinsics) elif list_type == "ObjList": - plot = FieldPlot( - self, objlist=objects, solutionName=setup_name, quantityName=quantity, intrinsics=intrinsics - ) + plot = FieldPlot(self, objects=objects, solution=setup_name, quantity=quantity, intrinsics=intrinsics) elif list_type == "Line": - plot = FieldPlot( - self, linelist=objects, solutionName=setup_name, quantityName=quantity, intrinsics=intrinsics - ) + plot = FieldPlot(self, lines=objects, solution=setup_name, quantity=quantity, intrinsics=intrinsics) elif list_type.startswith("Layer"): plot = FieldPlot( self, - solutionName=setup_name, - quantityName=quantity, + solution=setup_name, + quantity=quantity, intrinsics=intrinsics, - layers_nets=objects, - layers_plot_type=list_type, + layer_nets=objects, + layer_plot_type=list_type, ) if self._app.design_type == "Q3D Extractor": # pragma: no cover plot.field_type = field_type plot.name = plot_name - plot.plotFolder = plot_name + plot.plot_folder = plot_name plot.filter_boxes = filter_boxes plt = plot.create() if "Maxwell" in self._app.design_type and "Transient" in self.post_solution_type: @@ -3050,17 +3040,17 @@ def _create_fieldplot_line_traces( plot_name = quantity + "_" + "".join(random.sample(char_set, 6)) plot = FieldPlot( self, - objlist=in_volume_tracing_ids, - surfacelist=surface_tracing_ids, - solutionName=setup_name, - quantityName=quantity, + objects=in_volume_tracing_ids, + surfaces=surface_tracing_ids, + solution=setup_name, + quantity=quantity, intrinsics=intrinsics, - seedingFaces=seeding_faces_ids, + seeding_faces=seeding_faces_ids, ) if field_type: plot.field_type = field_type plot.name = plot_name - plot.plotFolder = plot_name + plot.plot_folder = plot_name plt = plot.create() if "Maxwell" in self._app.design_type and self.post_solution_type == "Transient": diff --git a/pyaedt/modules/solutions.py b/pyaedt/modules/solutions.py index cbde938ed40..cca16d28c76 100644 --- a/pyaedt/modules/solutions.py +++ b/pyaedt/modules/solutions.py @@ -128,26 +128,26 @@ def _get_variations(self): variations_lists.append(variations) return variations_lists - @pyaedt_function_handler() - def variation_values(self, variation_name): + @pyaedt_function_handler(variation_name="variation") + def variation_values(self, variation): """Get the list of the specific variation available values. Parameters ---------- - variation_name : str + variation : str Name of variation to return. Returns ------- list """ - if variation_name in self.intrinsics: - return self.intrinsics[variation_name] + if variation in self.intrinsics: + return self.intrinsics[variation] else: vars_vals = [] for el in self.variations: - if variation_name in el and el[variation_name] not in vars_vals: - vars_vals.append(el[variation_name]) + if variation in el and el[variation] not in vars_vals: + vars_vals.append(el[variation]) return vars_vals @property @@ -451,17 +451,18 @@ def data_magnitude(self, expression=None, convert_to_SI=False): return sol @staticmethod - @pyaedt_function_handler() - def _convert_list_to_SI(datalist, dataunits, units): + @pyaedt_function_handler(datalist="data", dataunits="data_units") + def _convert_list_to_SI(data, data_units, units): """Convert a data list to the SI unit system. Parameters ---------- - datalist : list + data : list List of data to convert. - dataunits : - - units : + data_units : str + Data units. + units : str + SI units to convert data into. Returns @@ -470,9 +471,9 @@ def _convert_list_to_SI(datalist, dataunits, units): List of the data converted to the SI unit system. """ - sol = datalist - if dataunits in AEDT_UNITS and units in AEDT_UNITS[dataunits]: - sol = [i * AEDT_UNITS[dataunits][units] for i in datalist] + sol = data + if data_units in AEDT_UNITS and units in AEDT_UNITS[data_units]: + sol = [i * AEDT_UNITS[data_units][units] for i in data] return sol @pyaedt_function_handler() @@ -664,13 +665,13 @@ def data_imag(self, expression=None, convert_to_SI=False): expression = self.active_expression temp = self._variation_tuple() - solution_Data = self._solutions_imag[expression] + solution_data = self._solutions_imag[expression] sol = [] position = list(self._sweeps_names).index(self.primary_sweep) for el in self.primary_sweep_values: temp[position] = el try: - sol.append(solution_Data[tuple(temp)]) + sol.append(solution_data[tuple(temp)]) except KeyError: sol.append(None) if convert_to_SI and self._quantity(self.units_data[expression]): @@ -744,15 +745,15 @@ def export_data_to_csv(self, output, delimiter=";"): return write_csv(output, list_full, delimiter=delimiter) - @pyaedt_function_handler() + @pyaedt_function_handler(math_formula="formula", xlabel="x_label", ylabel="y_label") def plot( self, curves=None, - math_formula=None, + formula=None, size=(2000, 1000), show_legend=True, - xlabel="", - ylabel="", + x_label="", + y_label="", title="", snapshot_path=None, is_polar=False, @@ -763,7 +764,7 @@ def plot( ---------- curves : list Curves to be plotted. If None, the first curve will be plotted. - math_formula : str , optional + formula : str , optional Mathematical formula to apply to the plot curve. Valid values are `"re"`, `"im"`, `"db20"`, `"db10"`, `"abs"`, `"mag"`, `"phasedeg"`, `"phaserad"`. `None` value will plot only real value of the data stored in solution data. @@ -771,9 +772,9 @@ def plot( Image size in pixel (width, height). show_legend : bool Either to show legend or not. Flag will be ignored if number of curves to plot is greater than 15. - xlabel : str + x_label : str Plot X label. - ylabel : str + y_label : str Plot Y label. title : str Plot Title label. @@ -800,45 +801,45 @@ def plot( else: sw = self.primary_sweep_values for curve in curves: - if not math_formula: + if not formula: data_plot.append([sw, self.data_real(curve), curve]) - elif math_formula == "re": - data_plot.append([sw, self.data_real(curve), "{}({})".format(math_formula, curve)]) - elif math_formula == "im": - data_plot.append([sw, self.data_imag(curve), "{}({})".format(math_formula, curve)]) - elif math_formula == "db20": - data_plot.append([sw, self.data_db20(curve), "{}({})".format(math_formula, curve)]) - elif math_formula == "db10": - data_plot.append([sw, self.data_db10(curve), "{}({})".format(math_formula, curve)]) - elif math_formula == "mag": - data_plot.append([sw, self.data_magnitude(curve), "{}({})".format(math_formula, curve)]) - elif math_formula == "phasedeg": - data_plot.append([sw, self.data_phase(curve, False), "{}({})".format(math_formula, curve)]) - elif math_formula == "phaserad": - data_plot.append([sw, self.data_phase(curve, True), "{}({})".format(math_formula, curve)]) - if not xlabel: - xlabel = sweep_name - if not ylabel: - ylabel = math_formula + elif formula == "re": + data_plot.append([sw, self.data_real(curve), "{}({})".format(formula, curve)]) + elif formula == "im": + data_plot.append([sw, self.data_imag(curve), "{}({})".format(formula, curve)]) + elif formula == "db20": + data_plot.append([sw, self.data_db20(curve), "{}({})".format(formula, curve)]) + elif formula == "db10": + data_plot.append([sw, self.data_db10(curve), "{}({})".format(formula, curve)]) + elif formula == "mag": + data_plot.append([sw, self.data_magnitude(curve), "{}({})".format(formula, curve)]) + elif formula == "phasedeg": + data_plot.append([sw, self.data_phase(curve, False), "{}({})".format(formula, curve)]) + elif formula == "phaserad": + data_plot.append([sw, self.data_phase(curve, True), "{}({})".format(formula, curve)]) + if not x_label: + x_label = sweep_name + if not y_label: + y_label = formula if not title: title = "Simulation Results Plot" if len(data_plot) > 15: show_legend = False if is_polar: - return plot_polar_chart(data_plot, size, show_legend, xlabel, ylabel, title, snapshot_path) + return plot_polar_chart(data_plot, size, show_legend, x_label, y_label, title, snapshot_path) else: - return plot_2d_chart(data_plot, size, show_legend, xlabel, ylabel, title, snapshot_path) + return plot_2d_chart(data_plot, size, show_legend, x_label, y_label, title, snapshot_path) - @pyaedt_function_handler() + @pyaedt_function_handler(xlabel="x_label", ylabel="y_label", math_formula="formula") def plot_3d( self, curve=None, x_axis="Theta", y_axis="Phi", - xlabel="", - ylabel="", + x_label="", + y_label="", title="", - math_formula=None, + formula=None, size=(2000, 1000), snapshot_path=None, ): @@ -852,15 +853,19 @@ def plot_3d( X Axis sweep. Default is `"Theta"`. y_axis : str, optional Y Axis sweep. Default is `"Phi"`. - math_formula : str , optional + x_label : str + Plot X label. + y_label : str + Plot Y label. + title : str + Plot title label. + formula : str , optional Mathematical formula to apply to the plot curve. Valid values are `"re"`, `"im"`, `"db20"`, `"db10"`, `"abs"`, `"mag"`, `"phasedeg"`, `"phaserad"`. size : tuple, optional Image size in pixel (width, height). snapshot_path : str Full path to image file if a snapshot is needed. - is_polar : bool, optional - Set to `True` if this is a polar plot. Returns ------- @@ -872,8 +877,8 @@ def plot_3d( if not curve: curve = self.active_expression - if not math_formula: - math_formula = "mag" + if not formula: + formula = "mag" theta = self.variation_values(x_axis) y_axis_val = self.variation_values(y_axis) @@ -883,19 +888,19 @@ def plot_3d( self.active_variation[y_axis] = el phi.append(el * math.pi / 180) - if math_formula == "re": + if formula == "re": r.append(self.data_real(curve)) - elif math_formula == "im": + elif formula == "im": r.append(self.data_imag(curve)) - elif math_formula == "db20": + elif formula == "db20": r.append(self.data_db20(curve)) - elif math_formula == "db10": + elif formula == "db10": r.append(self.data_db10(curve)) - elif math_formula == "mag": + elif formula == "mag": r.append(self.data_magnitude(curve)) - elif math_formula == "phasedeg": + elif formula == "phasedeg": r.append(self.data_phase(curve, False)) - elif math_formula == "phaserad": + elif formula == "phaserad": r.append(self.data_phase(curve, True)) active_sweep = self.active_intrinsic[self.primary_sweep] position = self.variation_values(self.primary_sweep).index(active_sweep) @@ -905,13 +910,13 @@ def plot_3d( new_r.append([el[position]]) r = new_r data_plot = [theta, phi, r] - if not xlabel: - xlabel = x_axis - if not ylabel: - ylabel = y_axis + if not x_label: + x_label = x_axis + if not y_label: + y_label = y_axis if not title: title = "Simulation Results Plot" - return plot_3d_chart(data_plot, size, xlabel, ylabel, title, snapshot_path) + return plot_3d_chart(data_plot, size, x_label, y_label, title, snapshot_path) @pyaedt_function_handler() def ifft(self, curve_header="NearE", u_axis="_u", v_axis="_v", window=False): @@ -939,60 +944,60 @@ def ifft(self, curve_header="NearE", u_axis="_u", v_axis="_v", window=False): freq = self.variation_values("Freq") if self.enable_pandas_output: - E_realx = np.reshape(self._solutions_real[curve_header + "X"].copy().values, (len(freq), len(v), len(u))) - E_imagx = np.reshape(self._solutions_imag[curve_header + "X"].copy().values, (len(freq), len(v), len(u))) - E_realy = np.reshape(self._solutions_real[curve_header + "Y"].copy().values, (len(freq), len(v), len(u))) - E_imagy = np.reshape(self._solutions_imag[curve_header + "Y"].copy().values, (len(freq), len(v), len(u))) - E_realz = np.reshape(self._solutions_real[curve_header + "Z"].copy().values, (len(freq), len(v), len(u))) - E_imagz = np.reshape(self._solutions_imag[curve_header + "Z"].copy().values, (len(freq), len(v), len(u))) + e_real_x = np.reshape(self._solutions_real[curve_header + "X"].copy().values, (len(freq), len(v), len(u))) + e_imag_x = np.reshape(self._solutions_imag[curve_header + "X"].copy().values, (len(freq), len(v), len(u))) + e_real_y = np.reshape(self._solutions_real[curve_header + "Y"].copy().values, (len(freq), len(v), len(u))) + e_imag_y = np.reshape(self._solutions_imag[curve_header + "Y"].copy().values, (len(freq), len(v), len(u))) + e_real_z = np.reshape(self._solutions_real[curve_header + "Z"].copy().values, (len(freq), len(v), len(u))) + e_imag_z = np.reshape(self._solutions_imag[curve_header + "Z"].copy().values, (len(freq), len(v), len(u))) else: - vals_real_Ex = [j for j in self._solutions_real[curve_header + "X"].values()] - vals_imag_Ex = [j for j in self._solutions_imag[curve_header + "X"].values()] - vals_real_Ey = [j for j in self._solutions_real[curve_header + "Y"].values()] - vals_imag_Ey = [j for j in self._solutions_imag[curve_header + "Y"].values()] - vals_real_Ez = [j for j in self._solutions_real[curve_header + "Z"].values()] - vals_imag_Ez = [j for j in self._solutions_imag[curve_header + "Z"].values()] - - E_realx = np.reshape(vals_real_Ex, (len(freq), len(v), len(u))) - E_imagx = np.reshape(vals_imag_Ex, (len(freq), len(v), len(u))) - E_realy = np.reshape(vals_real_Ey, (len(freq), len(v), len(u))) - E_imagy = np.reshape(vals_imag_Ey, (len(freq), len(v), len(u))) - E_realz = np.reshape(vals_real_Ez, (len(freq), len(v), len(u))) - E_imagz = np.reshape(vals_imag_Ez, (len(freq), len(v), len(u))) - - Temp_E_compx = E_realx + 1j * E_imagx # Here is the complex FD data matrix, ready for transforming - Temp_E_compy = E_realy + 1j * E_imagy - Temp_E_compz = E_realz + 1j * E_imagz - - E_compx = np.zeros((len(freq), len(v), len(u)), dtype="complex_") - E_compy = np.zeros((len(freq), len(v), len(u)), dtype="complex_") - E_compz = np.zeros((len(freq), len(v), len(u)), dtype="complex_") + vals_e_real_x = [j for j in self._solutions_real[curve_header + "X"].values()] + vals_e_imag_x = [j for j in self._solutions_imag[curve_header + "X"].values()] + vals_e_real_y = [j for j in self._solutions_real[curve_header + "Y"].values()] + vals_e_imag_y = [j for j in self._solutions_imag[curve_header + "Y"].values()] + vals_e_real_z = [j for j in self._solutions_real[curve_header + "Z"].values()] + vals_e_imag_z = [j for j in self._solutions_imag[curve_header + "Z"].values()] + + e_real_x = np.reshape(vals_e_real_x, (len(freq), len(v), len(u))) + e_imag_x = np.reshape(vals_e_imag_x, (len(freq), len(v), len(u))) + e_real_y = np.reshape(vals_e_real_y, (len(freq), len(v), len(u))) + e_imag_y = np.reshape(vals_e_imag_y, (len(freq), len(v), len(u))) + e_real_z = np.reshape(vals_e_real_z, (len(freq), len(v), len(u))) + e_imag_z = np.reshape(vals_e_imag_z, (len(freq), len(v), len(u))) + + temp_e_comp_x = e_real_x + 1j * e_imag_x # Here is the complex FD data matrix, ready for transforming + temp_e_comp_y = e_real_y + 1j * e_imag_y + temp_e_comp_z = e_real_z + 1j * e_imag_z + + e_comp_x = np.zeros((len(freq), len(v), len(u)), dtype="complex_") + e_comp_y = np.zeros((len(freq), len(v), len(u)), dtype="complex_") + e_comp_z = np.zeros((len(freq), len(v), len(u)), dtype="complex_") if window: timewin = np.hanning(len(freq)) for row in range(0, len(v)): for col in range(0, len(u)): - E_compx[:, row, col] = np.multiply(Temp_E_compx[:, row, col], timewin) - E_compy[:, row, col] = np.multiply(Temp_E_compy[:, row, col], timewin) - E_compz[:, row, col] = np.multiply(Temp_E_compz[:, row, col], timewin) + e_comp_x[:, row, col] = np.multiply(temp_e_comp_x[:, row, col], timewin) + e_comp_y[:, row, col] = np.multiply(temp_e_comp_y[:, row, col], timewin) + e_comp_z[:, row, col] = np.multiply(temp_e_comp_z[:, row, col], timewin) else: - E_compx = Temp_E_compx - E_compy = Temp_E_compy - E_compz = Temp_E_compz - - E_time_x = np.fft.ifft(np.fft.fftshift(E_compx, 0), len(freq), 0, None) - E_time_y = np.fft.ifft(np.fft.fftshift(E_compy, 0), len(freq), 0, None) - E_time_z = np.fft.ifft(np.fft.fftshift(E_compz, 0), len(freq), 0, None) - E_time = np.zeros((np.size(freq), np.size(v), np.size(u))) + e_comp_x = temp_e_comp_x + e_comp_y = temp_e_comp_y + e_comp_z = temp_e_comp_z + + e_time_x = np.fft.ifft(np.fft.fftshift(e_comp_x, 0), len(freq), 0, None) + e_time_y = np.fft.ifft(np.fft.fftshift(e_comp_y, 0), len(freq), 0, None) + e_time_z = np.fft.ifft(np.fft.fftshift(e_comp_z, 0), len(freq), 0, None) + e_time = np.zeros((np.size(freq), np.size(v), np.size(u))) for i in range(0, len(freq)): - E_time[i, :, :] = np.abs( - np.sqrt(np.square(E_time_x[i, :, :]) + np.square(E_time_y[i, :, :]) + np.square(E_time_z[i, :, :])) + e_time[i, :, :] = np.abs( + np.sqrt(np.square(e_time_x[i, :, :]) + np.square(e_time_y[i, :, :]) + np.square(e_time_z[i, :, :])) ) - self._ifft = E_time + self._ifft = e_time return self._ifft - @pyaedt_function_handler() + @pyaedt_function_handler(csv_dir="csv_path", name_str="csv_file_header") def ifft_to_file( self, u_axis="_u", @@ -1000,8 +1005,8 @@ def ifft_to_file( coord_system_center=None, db_val=False, num_frames=None, - csv_dir=None, - name_str="res_", + csv_path=None, + csv_file_header="res_", ): """Save IFFT Matrix to a list of csv files (one per time step). @@ -1017,9 +1022,9 @@ def ifft_to_file( Either if data has to be exported in db or not. num_frames : int, optional Number of frames to export. - csv_dir : str + csv_path : str Output path - name_str : str, optional + csv_file_header : str, optional csv file header. Returns @@ -1041,15 +1046,15 @@ def ifft_to_file( else: frames = t_matrix.shape[0] csv_list = [] - if os.path.exists(csv_dir): - files = [os.path.join(csv_dir, f) for f in os.listdir(csv_dir) if name_str in f and ".csv" in f] + if os.path.exists(csv_path): + files = [os.path.join(csv_path, f) for f in os.listdir(csv_path) if csv_file_header in f and ".csv" in f] for file in files: os.remove(file) else: - os.mkdir(csv_dir) + os.mkdir(csv_path) for frame in range(frames): - output = os.path.join(csv_dir, name_str + str(frame) + ".csv") + output = os.path.join(csv_path, csv_file_header + str(frame) + ".csv") list_full = [["x", "y", "z", "val"]] for i, y in enumerate(y_c_list): for j, x in enumerate(x_c_list): @@ -1065,7 +1070,7 @@ def ifft_to_file( write_csv(output, list_full, delimiter=",") csv_list.append(output) - txt_file_name = csv_dir + "fft_list.txt" + txt_file_name = csv_path + "fft_list.txt" textfile = open_file(txt_file_name, "w") for element in csv_list: @@ -1102,7 +1107,7 @@ class FfdSolutionData(object): >>> frequencies = data.frequencies >>> app.release_desktop() >>> farfield_data = FfdSolutionData(frequencies=frequencies, eep_files=eep_files) - >>> farfield_data.polar_plot_3d_pyvista(qty_str="rETotal", quantity_format="dB10") + >>> farfield_data.polar_plot_3d_pyvista(quantity_format="dB10",qty_str="rETotal") """ def __init__( @@ -1387,13 +1392,13 @@ def _phase_shift_steering(self, a, b, theta=0.0, phi=0.0): lattice_vector = self._lattice_vector[self._freq_index] - Ax, Ay, Bx, By = [lattice_vector[0], lattice_vector[1], lattice_vector[3], lattice_vector[4]] + a_x, a_y, b_x, b_y = [lattice_vector[0], lattice_vector[1], lattice_vector[3], lattice_vector[4]] - phase_shift_A = -((Ax * k * np.sin(theta) * np.cos(phi)) + (Ay * k * np.sin(theta) * np.sin(phi))) + phase_shift_a = -((a_x * k * np.sin(theta) * np.cos(phi)) + (a_y * k * np.sin(theta) * np.sin(phi))) - phase_shift_B = -((Bx * k * np.sin(theta) * np.cos(phi)) + (By * k * np.sin(theta) * np.sin(phi))) + phase_shift_b = -((b_x * k * np.sin(theta) * np.cos(phi)) + (b_y * k * np.sin(theta) * np.sin(phi))) - phase_shift = a * phase_shift_A + b * phase_shift_B + phase_shift = a * phase_shift_a + b * phase_shift_b return np.rad2deg(phase_shift) @@ -1504,15 +1509,18 @@ def combine_farfield(self, phi_scan=0, theta_scan=0): return farfield_data # fmt: off - @pyaedt_function_handler() + @pyaedt_function_handler(farfield_quantity="quantity", + phi_scan="phi", + theta_scan="theta", + export_image_path="image_path") def plot_farfield_contour( self, - farfield_quantity="RealizedGain", - phi_scan=0, - theta_scan=0, + quantity="RealizedGain", + phi=0, + theta=0, title="RectangularPlot", quantity_format="dB10", - export_image_path=None, + image_path=None, levels=64, show=True, **kwargs @@ -1522,13 +1530,13 @@ def plot_farfield_contour( Parameters ---------- - farfield_quantity : str, optional + quantity : str, optional Far field quantity to plot. The default is ``"RealizedGain"``. Available quantities are: ``"RealizedGain"``, ``"RealizedGain_Phi"``, ``"RealizedGain_Theta"``, ``"rEPhi"``, ``"rETheta"``, and ``"rETotal"``. - phi_scan : float, int, optional + phi : float, int, optional Phi scan angle in degrees. The default is ``0``. - theta_scan : float, int, optional + theta : float, int, optional Theta scan angle in degrees. The default is ``0``. title : str, optional Plot title. The default is ``"RectangularPlot"``. @@ -1536,7 +1544,7 @@ def plot_farfield_contour( Conversion data function. Available functions are: ``"abs"``, ``"ang"``, ``"dB10"``, ``"dB20"``, ``"deg"``, ``"imag"``, ``"norm"``, and ``"real"``. - export_image_path : str, optional + image_path : str, optional Full path for the image file. The default is ``None``, in which case the file is not exported. levels : int, optional Color map levels. The default is ``64``. @@ -1567,19 +1575,19 @@ def plot_farfield_contour( self.logger.warning("`convert_to_db` is deprecated since v0.7.8. Use `quantity_format` instead.") quantity_format = "dB10" if kwargs["convert_to_db"] else "abs" elif k == "qty_str": # pragma: no cover - self.logger.warning("`qty_str` is deprecated since v0.7.8. Use `farfield_quantity` instead.") - farfield_quantity = kwargs["qty_str"] + self.logger.warning("`qty_str` is deprecated since v0.7.8. Use `quantity` instead.") + quantity = kwargs["qty_str"] else: # pragma: no cover msg = "{} not valid.".format(k) self.logger.error(msg) raise TypeError(msg) - data = self.combine_farfield(phi_scan, theta_scan) - if farfield_quantity not in data: # pragma: no cover + data = self.combine_farfield(phi, theta) + if quantity not in data: # pragma: no cover self.logger.error("Far field quantity is not available.") return False - data_to_plot = data[farfield_quantity] + data_to_plot = data[quantity] data_to_plot = conversion_function(data_to_plot, quantity_format) if not isinstance(data_to_plot, np.ndarray): # pragma: no cover self.logger.error("Wrong format quantity") @@ -1595,23 +1603,26 @@ def plot_farfield_contour( ylabel="Phi (degree)", title=title, levels=levels, - snapshot_path=export_image_path, + snapshot_path=image_path, ) else: return data_to_plot # fmt: off - @pyaedt_function_handler() + @pyaedt_function_handler(farfield_quantity="quantity", + phi_scan="phi", + theta_scan="theta", + export_image_path="image_path") def plot_2d_cut( self, - farfield_quantity="RealizedGain", + quantity="RealizedGain", primary_sweep="phi", secondary_sweep_value=0, - phi_scan=0, - theta_scan=0, + phi=0, + theta=0, title="Far Field Cut", quantity_format="dB10", - export_image_path=None, + image_path=None, show=True, is_polar=False, **kwargs @@ -1621,7 +1632,7 @@ def plot_2d_cut( Parameters ---------- - farfield_quantity : str, optional + quantity : str, optional Quantity to plot. The default is ``"RealizedGain"``. Available quantities are: ``"RealizedGain"``, ``"RealizedGain_Theta"``, ``"RealizedGain_Phi"``, ``"rETotal"``, ``"rETheta"``, and ``"rEPhi"``. @@ -1630,9 +1641,9 @@ def plot_2d_cut( secondary_sweep_value : float, list, string, optional List of cuts on the secondary sweep to plot. The default is ``0``. Options are `"all"`, a single value float, or a list of float values. - phi_scan : float, int, optional + phi : float, int, optional Phi scan angle in degrees. The default is ``0``. - theta_scan : float, int, optional + theta : float, int, optional Theta scan angle in degrees. The default is ``0``. title : str, optional Plot title. The default is ``"RectangularPlot"``. @@ -1640,7 +1651,7 @@ def plot_2d_cut( Conversion data function. Available functions are: ``"abs"``, ``"ang"``, ``"dB10"``, ``"dB20"``, ``"deg"``, ``"imag"``, ``"norm"``, and ``"real"``. - export_image_path : str, optional + image_path : str, optional Full path for the image file. The default is ``None``, in which case an image in not exported. show : bool, optional Whether to show the plot. The default is ``True``. @@ -1664,7 +1675,7 @@ def plot_2d_cut( >>> frequencies = [77e9] >>> sphere = "3D" >>> data = app.get_antenna_ffd_solution_data(frequencies, setup_name, sphere) - >>> data.plot_2d_cut(theta_scan=20) + >>> data.plot_2d_cut(theta=20) """ @@ -1673,19 +1684,19 @@ def plot_2d_cut( self.logger.warning("`convert_to_db` is deprecated since v0.7.8. Use `quantity_format` instead.") quantity_format = "dB10" if kwargs["convert_to_db"] else "abs" elif k == "qty_str": # pragma: no cover - self.logger.warning("`qty_str` is deprecated since v0.7.8. Use `farfield_quantity` instead.") - farfield_quantity = kwargs["qty_str"] + self.logger.warning("`qty_str` is deprecated since v0.7.8. Use `quantity` instead.") + quantity = kwargs["qty_str"] else: # pragma: no cover msg = "{} not valid.".format(k) self.logger.error(msg) raise TypeError(msg) - data = self.combine_farfield(phi_scan, theta_scan) - if farfield_quantity not in data: # pragma: no cover + data = self.combine_farfield(phi, theta) + if quantity not in data: # pragma: no cover self.logger.error("Far field quantity not available") return False - data_to_plot = data[farfield_quantity] + data_to_plot = data[quantity] curves = [] if primary_sweep == "phi": @@ -1735,33 +1746,36 @@ def plot_2d_cut( return plot_polar_chart( curves, xlabel=x_key, - ylabel=farfield_quantity, + ylabel=quantity, title=title, - snapshot_path=export_image_path, + snapshot_path=image_path, show_legend=show_legend, ) else: return plot_2d_chart( curves, xlabel=x_key, - ylabel=farfield_quantity, + ylabel=quantity, title=title, - snapshot_path=export_image_path, + snapshot_path=image_path, show_legend=show_legend, ) else: return curves # fmt: off - @pyaedt_function_handler() + @pyaedt_function_handler(farfield_quantity="quantity", + phi_scan="phi", + theta_scan="theta", + export_image_path="image_path") def polar_plot_3d( self, - farfield_quantity="RealizedGain", - phi_scan=0, - theta_scan=0, + quantity="RealizedGain", + phi=0, + theta=0, title="3D Plot", quantity_format="dB10", - export_image_path=None, + image_path=None, show=True, **kwargs ): @@ -1770,13 +1784,13 @@ def polar_plot_3d( Parameters ---------- - farfield_quantity : str, optional + quantity : str, optional Far field quantity to plot. The default is ``"RealizedGain"``. Available quantities are: ``"RealizedGain"``, ``"RealizedGain_Phi"``, ``"RealizedGain_Theta"``, ``"rEPhi"``, ``"rETheta"``, and ``"rETotal"``. - phi_scan : float, int, optional + phi : float, int, optional Phi scan angle in degree. The default is ``0``. - theta_scan : float, int, optional + theta : float, int, optional Theta scan angle in degree. The default is ``0``. title : str, optional Plot title. The default is ``"3D Plot"``. @@ -1784,7 +1798,7 @@ def polar_plot_3d( Conversion data function. Available functions are: ``"abs"``, ``"ang"``, ``"dB10"``, ``"dB20"``, ``"deg"``, ``"imag"``, ``"norm"``, and ``"real"``. - export_image_path : str, optional + image_path : str, optional Full path for the image file. The default is ``None``, in which case a file is not exported. show : bool, optional Whether to show the plot. The default is ``True``. @@ -1805,7 +1819,7 @@ def polar_plot_3d( >>> frequencies = [77e9] >>> sphere = "3D" >>> data = app.get_antenna_ffd_solution_data(frequencies, setup_name, sphere) - >>> data.polar_plot_3d(theta_scan=10) + >>> data.polar_plot_3d(theta=10) """ for k in kwargs: @@ -1813,19 +1827,19 @@ def polar_plot_3d( self.logger.warning("`convert_to_db` is deprecated since v0.7.8. Use `quantity_format` instead.") quantity_format = "dB10" if kwargs["convert_to_db"] else "abs" elif k == "qty_str": # pragma: no cover - self.logger.warning("`qty_str` is deprecated since v0.7.8. Use `farfield_quantity` instead.") - farfield_quantity = kwargs["qty_str"] + self.logger.warning("`qty_str` is deprecated since v0.7.8. Use `quantity` instead.") + quantity = kwargs["qty_str"] else: # pragma: no cover msg = "{} not valid.".format(k) self.logger.error(msg) raise TypeError(msg) - data = self.combine_farfield(phi_scan, theta_scan) - if farfield_quantity not in data: # pragma: no cover + data = self.combine_farfield(phi, theta) + if quantity not in data: # pragma: no cover self.logger.error("Far field quantity is not available.") return False - ff_data = conversion_function(data[farfield_quantity], quantity_format) + ff_data = conversion_function(data[quantity], quantity_format) if not isinstance(ff_data, np.ndarray): # pragma: no cover self.logger.error("Format of the quantity is wrong.") return False @@ -1844,18 +1858,18 @@ def polar_plot_3d( y = r * np.sin(theta_grid) * np.sin(phi_grid) z = r * np.cos(theta_grid) if show: - plot_3d_chart([x, y, z], xlabel="Theta", ylabel="Phi", title=title, snapshot_path=export_image_path) + plot_3d_chart([x, y, z], xlabel="Theta", ylabel="Phi", title=title, snapshot_path=image_path) else: return x, y, z # fmt: off - @pyaedt_function_handler() + @pyaedt_function_handler(farfield_quantity="quantity", export_image_path="image_path") def polar_plot_3d_pyvista( self, - farfield_quantity="RealizedGain", + quantity="RealizedGain", quantity_format="dB10", rotation=None, - export_image_path=None, + image_path=None, show=True, show_as_standalone=False, pyvista_object=None, @@ -1870,7 +1884,7 @@ def polar_plot_3d_pyvista( Parameters ---------- - farfield_quantity : str, optional + quantity : str, optional Quantity to plot. The default is ``"RealizedGain"``. Available quantities are: ``"RealizedGain"``, ``"RealizedGain_Theta"``, ``"RealizedGain_Phi"``, ``"rETotal"``, ``"rETheta"``, and ``"rEPhi"``. @@ -1878,7 +1892,7 @@ def polar_plot_3d_pyvista( Conversion data function. Available functions are: ``"abs"``, ``"ang"``, ``"dB10"``, ``"dB20"``, ``"deg"``, ``"imag"``, ``"norm"``, and ``"real"``. - export_image_path : str, optional + image_path : str, optional Full path for the image file. The default is ``None``, in which case a file is not exported. rotation : list, optional Far field rotation matrix. The matrix contains three vectors, around x, y, and z axes. @@ -1914,7 +1928,7 @@ def polar_plot_3d_pyvista( >>> frequencies = [77e9] >>> sphere = "3D" >>> data = app.get_antenna_ffd_solution_data(frequencies, setup_name, sphere) - >>> data.polar_plot_3d_pyvista(qty_str="RealizedGain", quantity_format="dB10") + >>> data.polar_plot_3d_pyvista(quantity_format="dB10",qty_str="RealizedGain") """ for k in kwargs: @@ -1922,8 +1936,8 @@ def polar_plot_3d_pyvista( self.logger.warning("`convert_to_db` is deprecated since v0.7.8. Use `quantity_format` instead.") quantity_format = "dB10" if kwargs["convert_to_db"] else "abs" elif k == "qty_str": # pragma: no cover - self.logger.warning("`qty_str` is deprecated since v0.7.8. Use `farfield_quantity` instead.") - farfield_quantity = kwargs["qty_str"] + self.logger.warning("`qty_str` is deprecated since v0.7.8. Use `quantity` instead.") + quantity = kwargs["qty_str"] else: # pragma: no cover msg = "{} not valid.".format(k) self.logger.error(msg) @@ -1939,17 +1953,17 @@ def polar_plot_3d_pyvista( text_color = "black" farfield_data = self.combine_farfield(phi_scan=0, theta_scan=0) - if farfield_quantity not in farfield_data: # pragma: no cover + if quantity not in farfield_data: # pragma: no cover self.logger.error("Far field quantity is not available.") return False self.farfield_data = farfield_data - self.mesh = self.get_far_field_mesh(farfield_quantity=farfield_quantity, quantity_format=quantity_format) + self.mesh = self.get_far_field_mesh(quantity=quantity, quantity_format=quantity_format) rotation_euler = self._rotation_to_euler_angles(rotation) * 180 / np.pi - if not export_image_path and not show: + if not image_path and not show: off_screen = False else: off_screen = not show @@ -1962,7 +1976,7 @@ def polar_plot_3d_pyvista( else: # pragma: no cover p = pyvista_object - uf = UpdateBeamForm(self, farfield_quantity, quantity_format) + uf = UpdateBeamForm(self, quantity, quantity_format) default_background = [255, 255, 255] axes_color = [i / 255 for i in default_background] @@ -2019,7 +2033,7 @@ def polar_plot_3d_pyvista( ) cad_mesh = self._get_geometry() - data = conversion_function(self.farfield_data[farfield_quantity], function_str=quantity_format) + data = conversion_function(self.farfield_data[quantity], function_str=quantity_format) if not isinstance(data, np.ndarray): # pragma: no cover self.logger.error("Wrong format quantity") return False @@ -2081,8 +2095,8 @@ def scale(value=1): p.add_text("Show Geometry", position=(70, 75), color=text_color, font_size=10) - if export_image_path: - p.show(screenshot=export_image_path) + if image_path: + p.show(screenshot=image_path) return True elif show: # pragma: no cover p.show() @@ -2138,13 +2152,13 @@ def _init_ffd(self, eep_file_info): return True - @pyaedt_function_handler() - def get_far_field_mesh(self, farfield_quantity="RealizedGain", quantity_format="dB10", **kwargs): + @pyaedt_function_handler(farfield_quantity="quantity") + def get_far_field_mesh(self, quantity="RealizedGain", quantity_format="dB10", **kwargs): """Generate a PyVista ``UnstructuredGrid`` object that represents the far field mesh. Parameters ---------- - farfield_quantity : str, optional + quantity : str, optional Far field quantity to plot. The default is ``"RealizedGain"``. Available quantities are: ``"RealizedGain"``, ``"RealizedGain_Phi"``, ``"RealizedGain_Theta"``, ``"rEPhi"``, ``"rETheta"``, and ``"rETotal"``. @@ -2168,11 +2182,11 @@ def get_far_field_mesh(self, farfield_quantity="RealizedGain", quantity_format=" self.logger.error(msg) raise TypeError(msg) - if farfield_quantity not in self.farfield_data: + if quantity not in self.farfield_data: self.logger.error("Far field quantity is not available.") return False - data = self.farfield_data[farfield_quantity] + data = self.farfield_data[quantity] ff_data = conversion_function(data, quantity_format) @@ -2424,7 +2438,7 @@ class FfdSolutionDataExporter(FfdSolutionData): >>> frequencies = [77e9] >>> sphere = "3D" >>> data = app.get_antenna_ffd_solution_data(frequencies, setup_name, sphere) - >>> data.polar_plot_3d_pyvista(qty_str="rETotal", quantity_format="dB10") + >>> data.polar_plot_3d_pyvista(quantity_format="dB10",qty_str="rETotal") """ @@ -2582,13 +2596,14 @@ class UpdateBeamForm: and ``"real"``. """ + @pyaedt_function_handler(farfield_quantity="quantity") def __init__(self, ff, farfield_quantity="RealizedGain", quantity_format="abs"): self.output = ff.mesh self._phi = 0 self._theta = 0 # default parameters self.ff = ff - self.farfield_quantity = farfield_quantity + self.quantity = farfield_quantity self.quantity_format = quantity_format @pyaedt_function_handler() @@ -2596,7 +2611,7 @@ def _update_both(self): """Update far field.""" self.ff.farfield_data = self.ff.combine_farfield(phi_scan=self._phi, theta_scan=self._theta) - self.ff.mesh = self.ff.get_far_field_mesh(self.farfield_quantity, self.quantity_format) + self.ff.mesh = self.ff.get_far_field_mesh(self.quantity, self.quantity_format) self.output.overwrite(self.ff.mesh) return @@ -2620,46 +2635,57 @@ class FieldPlot: Parameters ---------- postprocessor : :class:`pyaedt.modules.PostProcessor.PostProcessor` - objlist : list + objects : list List of objects. - solutionName : str + solution : str Name of the solution. - quantityName : str + quantity : str Name of the plot or the name of the object. intrinsics : dict, optional Name of the intrinsic dictionary. The default is ``{}``. """ - @pyaedt_function_handler(IntrinsincList="intrinsics") + @pyaedt_function_handler( + objlist="objects", + surfacelist="surfaces", + linelist="lines", + cutplanelist="cutplanes", + solutionName="solution", + quantityName="quantity", + IntrinsincList="intrinsics", + seedingFaces="seeding_faces", + layers_nets="layer_nets", + layers_plot_type="layer_plot_type", + ) def __init__( self, postprocessor, - objlist=[], - surfacelist=[], - linelist=[], - cutplanelist=[], - solutionName="", - quantityName="", + objects=[], + surfaces=[], + lines=[], + cutplanes=[], + solution="", + quantity="", intrinsics={}, - seedingFaces=[], - layers_nets=[], - layers_plot_type="LayerNetsExtFace", + seeding_faces=[], + layer_nets=[], + layer_plot_type="LayerNetsExtFace", ): self._postprocessor = postprocessor self.oField = postprocessor.ofieldsreporter - self.volume_indexes = objlist - self.surfaces_indexes = surfacelist - self.line_indexes = linelist - self.cutplane_indexes = cutplanelist - self.layers_nets = layers_nets - self.layers_plot_type = layers_plot_type - self.seeding_faces = seedingFaces - self.solutionName = solutionName - self.quantityName = quantityName + self.volumes = objects + self.surfaces = surfaces + self.lines = lines + self.cutplanes = cutplanes + self.layer_nets = layer_nets + self.layer_plot_type = layer_plot_type + self.seeding_faces = seeding_faces + self.solution = solution + self.quantity = quantity self.intrinsics = intrinsics self.name = "Field_Plot" - self.plotFolder = "Field_Plot" + self.plot_folder = "Field_Plot" self.Filled = False self.IsoVal = "Fringe" self.SmoothShade = True @@ -2705,32 +2731,32 @@ def filter_boxes(self, val): def plotGeomInfo(self): """Plot geometry information.""" idx = 0 - if self.volume_indexes: + if self.volumes: idx += 1 - if self.surfaces_indexes: + if self.surfaces: idx += 1 - if self.cutplane_indexes: + if self.cutplanes: idx += 1 - if self.line_indexes: + if self.lines: idx += 1 - if self.layers_nets: + if self.layer_nets: idx += 1 info = [idx] - if self.volume_indexes: + if self.volumes: info.append("Volume") info.append("ObjList") - info.append(len(self.volume_indexes)) - for index in self.volume_indexes: + info.append(len(self.volumes)) + for index in self.volumes: info.append(str(index)) - if self.surfaces_indexes: + if self.surfaces: model_faces = [] nonmodel_faces = [] if self._postprocessor._app.design_type == "HFSS 3D Layout Design": - model_faces = [str(i) for i in self.surfaces_indexes] + model_faces = [str(i) for i in self.surfaces] else: models = self._postprocessor.modeler.model_objects - for index in self.surfaces_indexes: + for index in self.surfaces: try: if isinstance(index, FacePrimitive): index = index.id @@ -2752,26 +2778,26 @@ def plotGeomInfo(self): info.append(len(nonmodel_faces)) for index in nonmodel_faces: info.append(index) - if self.cutplane_indexes: + if self.cutplanes: info.append("Surface") info.append("CutPlane") - info.append(len(self.cutplane_indexes)) - for index in self.cutplane_indexes: + info.append(len(self.cutplanes)) + for index in self.cutplanes: info.append(str(index)) - if self.line_indexes: + if self.lines: info.append("Line") - info.append(len(self.line_indexes)) - for index in self.line_indexes: + info.append(len(self.lines)) + for index in self.lines: info.append(str(index)) - if self.layers_nets: - if self.layers_plot_type == "LayerNets": + if self.layer_nets: + if self.layer_plot_type == "LayerNets": info.append("Volume") info.append("LayerNets") else: info.append("Surface") info.append("LayerNetsExtFace") - info.append(len(self.layers_nets)) - for index in self.layers_nets: + info.append(len(self.layer_nets)) + for index in self.layer_nets: info.append(index[0]) info.append(len(index[1:])) info.extend(index[1:]) @@ -2810,11 +2836,7 @@ def plotsettings(self): list List of plot settings. """ - if ( - self.surfaces_indexes - or self.cutplane_indexes - or (self.layers_nets and self.layers_plot_type == "LayerNetsExtFace") - ): + if self.surfaces or self.cutplanes or (self.layer_nets and self.layer_plot_type == "LayerNetsExtFace"): arg = [ "NAME:PlotOnSurfaceSettings", "Filled:=", @@ -2847,7 +2869,7 @@ def plotsettings(self): "GridColor:=", self.GridColor, ] - elif self.line_indexes: + elif self.lines: arg = [ "NAME:PlotOnLineSettings", ["NAME:LineSettingsID", "Width:=", self.LineWidth, "Style:=", self.LineStyle], @@ -2902,11 +2924,11 @@ def surfacePlotInstruction(self): out = [ "NAME:" + self.name, "SolutionName:=", - self.solutionName, + self.solution, "QuantityName:=", - self.quantityName, + self.quantity, "PlotFolder:=", - self.plotFolder, + self.plot_folder, ] if self.field_type: out.extend(["FieldType:=", self.field_type]) @@ -2951,7 +2973,7 @@ def surfacePlotInstructionLineTraces(self): out = [ "NAME:" + self.name, "SolutionName:=", - self.solutionName, + self.solution, "UserSpecifyName:=", 0, "UserSpecifyFolder:=", @@ -2959,7 +2981,7 @@ def surfacePlotInstructionLineTraces(self): "QuantityName:=", "QuantityName_FieldLineTrace", "PlotFolder:=", - self.plotFolder, + self.plot_folder, ] if self.field_type: out.extend(["FieldType:=", self.field_type]) @@ -2976,9 +2998,9 @@ def surfacePlotInstructionLineTraces(self): "Seeding Markers:=", [0], "Surface Tracing Objects:=", - self.surfaces_indexes, + self.surfaces, "Volume Tracing Objects:=", - self.volume_indexes, + self.volumes, "Seeding Sampling Option:=", self.SeedingSamplingOption, "Seeding Points Number:=", @@ -3113,28 +3135,28 @@ def update(self): self.seeding_faces.remove(face) return False self.seeding_faces[0] = len(self.seeding_faces) - 1 - if self.volume_indexes[0] != len(self.volume_indexes) - 1: - for obj in self.volume_indexes[1:]: + if self.volumes[0] != len(self.volumes) - 1: + for obj in self.volumes[1:]: if not isinstance(obj, int): self._postprocessor.logger.error("Provide valid object id for in-volume object.") return False else: if obj not in list(self._postprocessor._app.modeler.objects.keys()): self._postprocessor.logger.error("Invalid object id.") - self.volume_indexes.remove(obj) + self.volumes.remove(obj) return False - self.volume_indexes[0] = len(self.volume_indexes) - 1 - if self.surfaces_indexes[0] != len(self.surfaces_indexes) - 1: - for obj in self.surfaces_indexes[1:]: + self.volumes[0] = len(self.volumes) - 1 + if self.surfaces[0] != len(self.surfaces) - 1: + for obj in self.surfaces[1:]: if not isinstance(obj, int): self._postprocessor.logger.error("Provide valid object id for surface object.") return False else: if obj not in list(self._postprocessor._app.modeler.objects.keys()): self._postprocessor.logger.error("Invalid object id.") - self.surfaces_indexes.remove(obj) + self.surfaces.remove(obj) return False - self.surfaces_indexes[0] = len(self.surfaces_indexes) - 1 + self.surfaces[0] = len(self.surfaces) - 1 self.oField.ModifyFieldPlot(self.name, self.surfacePlotInstructionLineTraces) else: self.oField.ModifyFieldPlot(self.name, self.surfacePlotInstruction) @@ -3217,7 +3239,7 @@ def change_plot_scale(self, minimum_value, maximum_value, is_log=False, is_db=Fa 1, ] ] - self.oField.SetPlotFolderSettings(self.plotFolder, args) + self.oField.SetPlotFolderSettings(self.plot_folder, args) return True @pyaedt_function_handler() @@ -3253,13 +3275,13 @@ def export_image(self, full_path=None, width=1920, height=1080, orientation="iso >>> oModule.ExportModelImageToFile >>> oModule.ExportPlotImageWithViewToFile """ - self.oField.UpdateQuantityFieldsPlots(self.plotFolder) + self.oField.UpdateQuantityFieldsPlots(self.plot_folder) if not full_path: full_path = os.path.join(self._postprocessor._app.working_directory, self.name + ".png") status = self._postprocessor.export_field_jpg( full_path, self.name, - self.plotFolder, + self.plot_folder, orientation=orientation, width=width, height=height, @@ -3314,7 +3336,7 @@ def export_image_from_aedtplt( meshplot=plot_mesh, imageformat="jpg", view=view, - plot_label=self.quantityName, + plot_label=self.quantity, show=False, scale_min=scale_min, scale_max=scale_max, @@ -3332,7 +3354,7 @@ class VRTFieldPlot: postprocessor : :class:`pyaedt.modules.PostProcessor.PostProcessor` is_creeping_wave : bool Whether it is a creeping wave model or not. - quantity_name : str, optional + quantity : str, optional Name of the plot or the name of the object. max_frequency : str, optional Maximum Frequency. The default is ``"1GHz"``. @@ -3345,11 +3367,12 @@ class VRTFieldPlot: """ + @pyaedt_function_handler(quantity_name="quantity") def __init__( self, postprocessor, is_creeping_wave=False, - quantity_name="QuantityName_SBR", + quantity="QuantityName_SBR", max_frequency="1GHz", ray_density=2, bounces=5, @@ -3358,7 +3381,7 @@ def __init__( self.is_creeping_wave = is_creeping_wave self._postprocessor = postprocessor self._ofield = postprocessor.ofieldsreporter - self.quantity_name = quantity_name + self.quantity = quantity self.intrinsics = intrinsics self.name = "Field_Plot" self.plot_folder = "Field_Plot" @@ -3418,7 +3441,7 @@ def _create_args(self): "UserSpecifyFolder:=", 0, "QuantityName:=", - self.quantity_name, + self.quantity, "PlotFolder:=", "Visual Ray Trace SBR", "IntrinsicVar:=", @@ -3488,7 +3511,7 @@ def _create_args_creeping(self): "UserSpecifyFolder:=", 0, "QuantityName:=", - self.quantity_name, + self.quantity, "PlotFolder:=", "Visual Ray Trace CW", "IntrinsicVar:=", @@ -3567,13 +3590,13 @@ def delete(self): self._ofield.DeleteFieldPlot([self.name]) return True - @pyaedt_function_handler() - def export(self, path_to_hdm_file=None): + @pyaedt_function_handler(path_to_hdm_file="path") + def export(self, path=None): """Export the Visual Ray Tracing to ``hdm`` file. Parameters ---------- - path_to_hdm_file : str, optional + path : str, optional Full path to output file. If ``None``, the file will be exported in working directory. Returns @@ -3581,7 +3604,7 @@ def export(self, path_to_hdm_file=None): str Path to the file. """ - if not path_to_hdm_file: - path_to_hdm_file = os.path.join(self._postprocessor._app.working_directory, self.name + ".hdm") - self._ofield.ExportFieldPlot(self.name, False, path_to_hdm_file) - return path_to_hdm_file + if not path: + path = os.path.join(self._postprocessor._app.working_directory, self.name + ".hdm") + self._ofield.ExportFieldPlot(self.name, False, path) + return path From cb5c69a0fe18619a092260802bcea462b33e5f33 Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Wed, 3 Apr 2024 14:41:12 +0200 Subject: [PATCH 15/22] back compatibility with ipy --- pyaedt/generic/general_methods.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pyaedt/generic/general_methods.py b/pyaedt/generic/general_methods.py index 6a0f59c9946..7a030731f1d 100644 --- a/pyaedt/generic/general_methods.py +++ b/pyaedt/generic/general_methods.py @@ -239,11 +239,12 @@ def rename_kwargs(func_name, kwargs, aliases): for alias, new in aliases.items(): if alias in kwargs: if new in kwargs: - raise TypeError( - f"{func_name} received both {alias} and {new} as arguments!" - f" {alias} is deprecated, use {new} instead." - ) - pyaedt_logger.warning(f"`{alias}` is deprecated as an argument to `{func_name}`; use" f" `{new}` instead.") + msg = "{} received both {} and {} as arguments!\n".format(func_name, alias, new) + msg += "{} is deprecated, use {} instead.".format(alias, new) + raise TypeError(msg) + pyaedt_logger.warning( + '`{}` is deprecated as an argument to `{}`; use" f" `{}` instead.'.format(alias, func_name, new) + ) kwargs[new] = kwargs.pop(alias) From 85902927590ef22de971b45db992cee0b5a56692 Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Wed, 3 Apr 2024 14:48:34 +0200 Subject: [PATCH 16/22] reverted unit test --- _unittest/test_02_2D_modeler.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/_unittest/test_02_2D_modeler.py b/_unittest/test_02_2D_modeler.py index 2304fb5e8d4..0837a6394f8 100644 --- a/_unittest/test_02_2D_modeler.py +++ b/_unittest/test_02_2D_modeler.py @@ -166,11 +166,16 @@ def test_09_plot(self): self.aedtapp.modeler.create_regular_polygon( position=[0, 0, 0], start_point=[0, 0, 2], num_sides=3, name="MyPolygon", matname="Copper" ) - obj = self.aedtapp.plot() + obj = self.aedtapp.plot( + show=False, + export_path=os.path.join(self.local_scratch.path, "image.jpg"), + show_bounding=True, + show_grid=True, + ) assert os.path.exists(obj.image_file) - obj2 = self.aedtapp.plot() + obj2 = self.aedtapp.plot(show=False, export_path=os.path.join(self.local_scratch.path, "image.jpg"), view="xy") assert os.path.exists(obj2.image_file) - obj3 = self.aedtapp.plot() + obj3 = self.aedtapp.plot(show=False, export_path=os.path.join(self.local_scratch.path, "image.jpg"), view="xy1") assert filecmp.cmp(obj.image_file, obj3.image_file) def test_10_edit_menu_commands(self): From caf6f3d4935826393a41b6fd87f38349f84f03a7 Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Wed, 3 Apr 2024 15:35:42 +0200 Subject: [PATCH 17/22] fixed UT --- pyaedt/application/Analysis3D.py | 2 +- pyaedt/icepak.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pyaedt/application/Analysis3D.py b/pyaedt/application/Analysis3D.py index f416560d359..0416ae6804b 100644 --- a/pyaedt/application/Analysis3D.py +++ b/pyaedt/application/Analysis3D.py @@ -1120,7 +1120,7 @@ def identify_touching_conductors(self, object_name=None): output = {"Net1": net_vals} return output return nets - plt_obj = self.plot() + plt_obj = self.plot(show=False, objects=self.get_all_conductors_names()) import pyvista as pv nets = {} diff --git a/pyaedt/icepak.py b/pyaedt/icepak.py index c1bcc0b4991..838597cef35 100644 --- a/pyaedt/icepak.py +++ b/pyaedt/icepak.py @@ -4594,8 +4594,8 @@ def assign_hollow_block( bound = BoundaryObject(self, boundary_name, props, "Block") return _create_boundary(bound) - @pyaedt_function_handler() - def get_fans_operating_point(self, export_file=None, setup_name=None, timestep=None, design_variation=None): + @pyaedt_function_handler(timestep="time_step") + def get_fans_operating_point(self, export_file=None, setup_name=None, time_step=None, design_variation=None): """ Get operating point of the fans in the design. @@ -4607,7 +4607,7 @@ def get_fans_operating_point(self, export_file=None, setup_name=None, timestep=N setup_name : str, optional Setup name from which to determine the fans' operating point. The default is ``None``, in which case the first available setup is used. - timestep : str, optional + time_step : str, optional Time, with units, at which to determine the fans' operating point. The default is ``None``, in which case the first available timestep is used. This argument is only relevant in transient simulations. @@ -4637,7 +4637,7 @@ def get_fans_operating_point(self, export_file=None, setup_name=None, timestep=N >>> filename, vol_flow_name, p_rise_name, op_dict= ipk.post.get_fans_operating_point() """ - return self.post.get_fans_operating_point(export_file, setup_name, timestep, design_variation) + return self.post.get_fans_operating_point(export_file, setup_name, time_step, design_variation) @pyaedt_function_handler() def assign_free_opening( From d053b96d58efd156d9e21a0b5e482c948b687b1c Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Wed, 3 Apr 2024 16:19:38 +0200 Subject: [PATCH 18/22] fixed UT --- pyaedt/generic/pdf.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyaedt/generic/pdf.py b/pyaedt/generic/pdf.py index 6871215a0c1..acc8373caa0 100644 --- a/pyaedt/generic/pdf.py +++ b/pyaedt/generic/pdf.py @@ -258,8 +258,9 @@ def add_project_info(self, design): msg = f"Furthermore, the layout has {stats.num_nets} nets, {stats.num_traces} traces," msg += f" {stats.num_vias} vias. The stackup total thickness is {stats.stackup_thickness}." image_path = os.path.join(design.working_directory, "model.jpg") - design.modeler.edb.nets.plot() - self.add_image(image_path, "Model Image") + design.modeler.edb.nets.plot(save_plot=image_path) + if os.path.exists(image_path): + self.add_image(image_path, "Model Image") elif design.design_type in ["Circuit Design"]: msg = f"The schematic has {len(design.modeler.components.components)} components." self.add_text(msg) From b6cc6a13cb93318bf3996782267cd8c521fe44cd Mon Sep 17 00:00:00 2001 From: Massimo Capodiferro <77293250+maxcapodi78@users.noreply.github.com> Date: Thu, 4 Apr 2024 14:06:57 +0200 Subject: [PATCH 19/22] Apply suggestions from code review Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/modules/AdvancedPostProcessing.py | 33 ++++++++-------- pyaedt/modules/PostProcessor.py | 45 +++++++++++++--------- pyaedt/modules/solutions.py | 48 ++++++++++++++---------- 3 files changed, 72 insertions(+), 54 deletions(-) diff --git a/pyaedt/modules/AdvancedPostProcessing.py b/pyaedt/modules/AdvancedPostProcessing.py index 5d8f0cb1f7f..9b7ee1147a0 100644 --- a/pyaedt/modules/AdvancedPostProcessing.py +++ b/pyaedt/modules/AdvancedPostProcessing.py @@ -470,11 +470,11 @@ def plot_field( Parameters ---------- quantity : str - Quantity to plot (e.g. ``"Mag_E"``). + Quantity to plot. For example, ``"Mag_E"``. objects : str, list - Objects or faces to which apply the Field Plot. + Objects or faces to apply the field plot to. plot_type : str, optional - Plot type. Options are ``"Surface"``, ``"Volume"``, ``"CutPlane"``. + Plot type. Options are ``"CutPlane"``, ``"Surface"``, and ``"Volume"``. setup_name : str, optional Setup and sweep name on which create the field plot. Default is None for nominal setup usage. intrinsics : dict, optional. @@ -603,9 +603,9 @@ def plot_animated_field( quantity : str Quantity to plot (e.g. ``"Mag_E"``). objects : list, str - List of objects or faces to which apply the Field Plot. + List of objects or faces to apply the field plot to. plot_type : str, optional - Plot type. Options are ``"Surface"``, ``"Volume"``, ``"CutPlane"``. + Plot type. Options are ``"CutPlane"``, ``"Surface"``, and ``"Volume"``. setup_name : str, optional Setup and sweep name on which create the field plot. Default is None for nominal setup usage. intrinsics : dict, optional. @@ -746,7 +746,8 @@ def animate_fields_from_aedtplt( List of variation values with units. The default is ``["0deg"]``. project_path : str, optional - Path for the export. The default is ``""`` which export file in working_directory. + Path for the export. The default is ``""``, in which case the file is exported + to the working directory. export_gif : bool, optional The default is ``False``. show=False, @@ -852,8 +853,8 @@ def animate_fields_from_aedtplt_2( objects : list, optional Name of the ``folderplot`` folder. plot_type : str - Type of the plot. Options are ``"Surface"``, ``"Volume"``, and - ``"CutPlane"``. + Type of the plot. Options are ``"CutPlane"``, ``"Surface"``, and + ``"Volume"``. setup_name : str, optional Name of the setup (sweep) to use for the export. The default is ``None``. @@ -877,11 +878,11 @@ def animate_fields_from_aedtplt_2( log_scale : bool, optional Whether to plot fields in log scale. The default is ``True``. dark_mode : bool, optional - Whether to plot with dark mode. The default is ``False``. + Whether to plot in dark mode. The default is ``False``. show_grid : bool, optional - Whether to show grid on plot. The default is ``False``. + Whether to show a grid on the plot. The default is ``False``. show_bounding : bool, optional - Whether to show bounding on plot. The default is ``False``. + Whether to show bounding on the plot. The default is ``False``. Returns ------- @@ -961,12 +962,12 @@ def plot_scene( Parameters ---------- frames : list or str - File list containing animation frames to plot in csv format or - path to a txt index file containing full path to csv files. + File list containing animation frames to plot in CSV format or + path to a text index file containing the full path to CSV files. gif_path : str - Full path to output gif file. + Full path for outputting the GIF file. norm_index : int, optional - Pick the frame to use to normalize your images. + Frame to use to normalize your images. Data is already saved as dB : 100 for usual traffic scenes. dy_rng : int, optional Specify how many dB below you would like to specify the range_min. @@ -1022,7 +1023,7 @@ def plot_scene( scene.zoom = zoom scene.bounding_box = False scene.color_bar = False - scene.gif_file = gif_path # This gif may be a bit slower so we can speed it up a bit + scene.gif_file = gif_path # This GIF file may be a bit slower so it can be speed it up a bit scene.convert_fields_in_db = convert_fields_in_db scene.log_multiplier = log_multiplier scene.animate() diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index bb095e37582..850b9f2346e 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -1615,7 +1615,7 @@ def create_report( polyline_points=1001, plot_name=None, ): - """Create a report in AEDT. It can be a 2D plot, 3D plot, polar plots or data tables. + """Create a report in AEDT. It can be a 2D plot, 3D plot, polar plot, or a data table. Parameters ---------- @@ -1647,7 +1647,7 @@ def create_report( plot_name : str, optional Name of the plot. The default is ``None``. polyline_points : int, optional, - Number of points on which create the report for plots on polylines. + Number of points to create the report for plots on polylines on. subdesign_id : int, optional Specify a subdesign ID to export a Touchstone file of this subdesign. Valid for Circuit Only. The default value is ``None``. @@ -2517,7 +2517,8 @@ def export_field_file_on_grid( The default is ``None``. filename : str, optional Full path and name to save the file to. - The default is ``None`` which export file in working_directory. + The default is ``None``, in which case the file is exported + to the working directory. grid_type : str, optional Type of the grid to export. The default is ``"Cartesian"``. grid_center : list, optional @@ -2711,8 +2712,9 @@ def export_field_file( objects : str, optional List of objects to export. The default is ``"AllObjects"``. objects_type : str, optional - Type of objects to export. Options are ``"Vol"`` for volume and - ``"Surf"`` for surface. The default is ``"Vol"``. + Type of objects to export. The default is ``"Vol"``. + Options are ``"Surf"`` for surface and ``"Vol"`` for + volume. intrinsics : str, optional This parameter is mandatory for a frequency or transient field calculation. The default is ``None``. @@ -2860,7 +2862,7 @@ def export_field_plot(self, plot_name, file_path, file_name="", file_format="aed Path for saving the file. file_name : str, optional - Name of the file. The default is ``""``. + Name of the file. The default is ``""``, in which case a name is automatically assigned. file_format : str, optional Name of the file extension. The default is ``"aedtplt"``. Options are ``"case"`` and ``"fldplt"``. @@ -3358,9 +3360,9 @@ def create_fieldplot_cutplane( Name of the fieldplot to create. filter_objects : list, optional Objects list on which filter the plot. - The default value is ``None`` in which case an empty list is passed. + The default value is ``None``, in which case an empty list is passed. field_type : str, optional - Field type to plot. Valid only for Q3D Field plots. + Field type to plot. This parameter is valid only for Q3D field plots. Returns ------- @@ -3731,18 +3733,20 @@ def export_model_obj(self, objects=None, export_path=None, export_as_single_obje Parameters ---------- objects : list, optional - List of objects to export. Export every model object except 3D ones, vacuum and air objects. + List of objects to export. Export every model object except 3D ones and + vacuum and air objects. export_path : str, optional - Full path of the exported obj file. + Full path of the exported OBJ file. export_as_single_objects : bool, optional - Define if the model will be exported as single object or list of objects for each object. + Whether to export the model as single object. The default is ``False``, in which + case is exported asa list of objects for each object. air_objects : bool, optional Define if air and vacuum objects will be exported. Returns ------- list - Files obj path. + List of paths for OBJ files. """ if objects and not isinstance(objects, (list, tuple)): objects = [objects] @@ -3803,7 +3807,9 @@ def export_mesh_obj(self, setup_name=None, intrinsics=None): where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. intrinsics : dict, optional. Intrinsic dictionary that is needed for the export. - The default is ``{}`` which assumes no variables are present in the dict or nominal values are used. + The default is ``{}``, which assumes that no variables are present in + the dictionary or nominal values are used. +```Here's your definition that should be used in other locations?! Returns ------- @@ -4497,7 +4503,8 @@ def create_ami_initial_response_plot( plot_final_response : bool, optional Set whether to plot the final input response. Default is ``False``. plot_name : str, optional - The plot name. Default is a unique name. + Plot name. The default is ``None``, in which case + a unique name is automatically assigned. Returns ------- @@ -4587,8 +4594,10 @@ def create_ami_statistical_eye_plot( variation_list_w_value : list Variations with relative values. ami_plot_type : str, optional - String containing the report AMI type. Default is ``"InitialEye"``. It can be ``"EyeAfterSource"``, - ``"EyeAfterChannel"`` or ``"EyeAfterProbe"``. + String containing the report AMI type. The default is ``"InitialEye"``. + Options are ``"EyeAfterChannel"``, ``"EyeAfterProbe"````"EyeAfterSource"``, + and ``"InitialEye"``. + . plot_name : str, optional The name of the plot. Defaults to a unique name starting with ``"Plot"``. @@ -4688,11 +4697,11 @@ def create_statistical_eye_plot(self, setup_name, probe_names, variation_list_w_ setup_name : str Name of the setup. probe_names : str or list - Name of the probe to plot in the EYE diagram. + One or more names of the probe to plot in the eye diagram. variation_list_w_value : list List of variations with relative values. plot_name : str, optional - The name of the plot. + Plot name. The default is ``None``, in which case a name is automatically assigned. Returns ------- diff --git a/pyaedt/modules/solutions.py b/pyaedt/modules/solutions.py index 72831f4299d..153fd358660 100644 --- a/pyaedt/modules/solutions.py +++ b/pyaedt/modules/solutions.py @@ -763,21 +763,26 @@ def plot( Parameters ---------- curves : list - Curves to be plotted. If None, the first curve will be plotted. + Curves to be plotted. The default is ``None``, in which case + the first curve is plotted. formula : str , optional - Mathematical formula to apply to the plot curve. - Valid values are `"re"`, `"im"`, `"db20"`, `"db10"`, `"abs"`, `"mag"`, `"phasedeg"`, `"phaserad"`. - `None` value will plot only real value of the data stored in solution data. + Mathematical formula to apply to the plot curve. The default is ``None``, + in which case only real value of the data stored in the solution data is plotted. + Options are ``"abs"``, ``"db10"``, ``"db20"``, ``"im"``, ``"mag"``, ``"phasedeg"``, + ``"phaserad"``, and ``"re"``. + size : tuple, optional - Image size in pixel (width, height). + Image size in pixels (width, height). show_legend : bool - Either to show legend or not. Flag will be ignored if number of curves to plot is greater than 15. + Whether to show the legend. The default is ``True``. + This parameter is ignored if the number of curves to plot is + greater than 15. x_label : str Plot X label. y_label : str Plot Y label. title : str - Plot Title label. + Plot title label. snapshot_path : str Full path to image file if a snapshot is needed. is_polar : bool, optional @@ -850,9 +855,9 @@ def plot_3d( curve : str Curve to be plotted. If None, the first curve will be plotted. x_axis : str, optional - X Axis sweep. Default is `"Theta"`. + X-axis sweep. The default is ``"Theta"``. y_axis : str, optional - Y Axis sweep. Default is `"Phi"`. + Y-axis sweep. The default is ``"Phi"``. x_label : str Plot X label. y_label : str @@ -860,12 +865,14 @@ def plot_3d( title : str Plot title label. formula : str , optional - Mathematical formula to apply to the plot curve. - Valid values are `"re"`, `"im"`, `"db20"`, `"db10"`, `"abs"`, `"mag"`, `"phasedeg"`, `"phaserad"`. + Mathematical formula to apply to the plot curve. The default is ``None``. + Options are `"abs"``, ``"db10"``, ``"db20"``, ``"im"``, ``"mag"``, ``"phasedeg"``, + ``"phaserad"``, and ``"re"``. size : tuple, optional - Image size in pixel (width, height). - snapshot_path : str + Image size in pixels (width, height). The default is ``(2000, 1000)``. + snapshot_path : str, optional Full path to image file if a snapshot is needed. + The default is ``None``. Returns ------- @@ -1008,7 +1015,7 @@ def ifft_to_file( csv_path=None, csv_file_header="res_", ): - """Save IFFT Matrix to a list of csv files (one per time step). + """Save IFFT matrix to a list of CSV files (one per time step). Parameters ---------- @@ -1019,13 +1026,13 @@ def ifft_to_file( coord_system_center : list, optional List of UV GlobalCS Center. db_val : bool, optional - Either if data has to be exported in db or not. + Whether data must be exported into a database. The default is ``False``. num_frames : int, optional - Number of frames to export. - csv_path : str - Output path + Number of frames to export. The default is ``None``. + csv_path : str, optional + Output path. The default is ``None``. csv_file_header : str, optional - csv file header. + CSV file header. The default is ``"res_"``. Returns ------- @@ -3597,7 +3604,8 @@ def export(self, path=None): Parameters ---------- path : str, optional - Full path to output file. If ``None``, the file will be exported in working directory. + Full path to the output file. The default is ``None``, in which case the file is + exported to the working directory. Returns ------- From 2acaac0875b46a105eb97cc1495452bfd051e9a8 Mon Sep 17 00:00:00 2001 From: Massimo Capodiferro <77293250+maxcapodi78@users.noreply.github.com> Date: Thu, 4 Apr 2024 14:07:42 +0200 Subject: [PATCH 20/22] Update pyaedt/modules/PostProcessor.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/modules/PostProcessor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index 850b9f2346e..b87f9ee1c39 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -3741,7 +3741,7 @@ def export_model_obj(self, objects=None, export_path=None, export_as_single_obje Whether to export the model as single object. The default is ``False``, in which case is exported asa list of objects for each object. air_objects : bool, optional - Define if air and vacuum objects will be exported. + Whether to export air and vacuum objects. The default is ``False``. Returns ------- From f65a6c612b24ccaf8666e58e183520e7436cf20e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 12:08:05 +0000 Subject: [PATCH 21/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyaedt/modules/PostProcessor.py | 64 ++++++++++++++++----------------- pyaedt/modules/solutions.py | 2 +- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index b87f9ee1c39..d73ef2a8b88 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -3793,38 +3793,38 @@ def export_model_obj(self, objects=None, export_path=None, export_as_single_obje @pyaedt_function_handler() def export_mesh_obj(self, setup_name=None, intrinsics=None): """Export the mesh in ``aedtplt`` format. - The mesh has to be available in the selected setup. - If a parametric model is provided user can choose the mesh to export providing a specific set of variations. - This method applies only to ``Hfss``, ``Q3d``, ``Q2D``, ``Maxwell3d``, ``Maxwell2d``, ``Icepak`` - and ``Mechanical`` objects. This method is calling ``create_fieldplot_surface`` to create a mesh plot and - ``export_field_plot`` to export it as ``aedtplt`` file. - - Parameters - ---------- - setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. - intrinsics : dict, optional. - Intrinsic dictionary that is needed for the export. - The default is ``{}``, which assumes that no variables are present in - the dictionary or nominal values are used. -```Here's your definition that should be used in other locations?! - - Returns - ------- - str - File Generated with full path. - - Examples - -------- - >>> from pyaedt import Hfss - >>> hfss = Hfss() - >>> hfss.analyze() - >>> # Export report using defaults. - >>> hfss.post.export_mesh_obj(setup_name=None, intrinsics=None) - >>> # Export report using arguments. - >>> hfss.post.export_mesh_obj(setup_name="MySetup : LastAdaptive", intrinsics={"w1":"5mm", "l1":"3mm"}) + The mesh has to be available in the selected setup. + If a parametric model is provided user can choose the mesh to export providing a specific set of variations. + This method applies only to ``Hfss``, ``Q3d``, ``Q2D``, ``Maxwell3d``, ``Maxwell2d``, ``Icepak`` + and ``Mechanical`` objects. This method is calling ``create_fieldplot_surface`` to create a mesh plot and + ``export_field_plot`` to export it as ``aedtplt`` file. + + Parameters + ---------- + setup_name : str, optional + Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. + Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` + where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + intrinsics : dict, optional. + Intrinsic dictionary that is needed for the export. + The default is ``{}``, which assumes that no variables are present in + the dictionary or nominal values are used. + ```Here's your definition that should be used in other locations?! + + Returns + ------- + str + File Generated with full path. + + Examples + -------- + >>> from pyaedt import Hfss + >>> hfss = Hfss() + >>> hfss.analyze() + >>> # Export report using defaults. + >>> hfss.post.export_mesh_obj(setup_name=None, intrinsics=None) + >>> # Export report using arguments. + >>> hfss.post.export_mesh_obj(setup_name="MySetup : LastAdaptive", intrinsics={"w1":"5mm", "l1":"3mm"}) """ if intrinsics is None: intrinsics = {} diff --git a/pyaedt/modules/solutions.py b/pyaedt/modules/solutions.py index 153fd358660..f8487ebc8ba 100644 --- a/pyaedt/modules/solutions.py +++ b/pyaedt/modules/solutions.py @@ -770,7 +770,7 @@ def plot( in which case only real value of the data stored in the solution data is plotted. Options are ``"abs"``, ``"db10"``, ``"db20"``, ``"im"``, ``"mag"``, ``"phasedeg"``, ``"phaserad"``, and ``"re"``. - + size : tuple, optional Image size in pixels (width, height). show_legend : bool From 6d59955a9d43c043e212260b69dd3c76a97c80f4 Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Thu, 4 Apr 2024 15:34:11 +0200 Subject: [PATCH 22/22] PR review --- _unittest/test_12_PostProcessing.py | 12 +- _unittest_solvers/test_00_analyze.py | 47 ++- pyaedt/generic/general_methods.py | 6 +- pyaedt/modules/AdvancedPostProcessing.py | 3 +- pyaedt/modules/PostProcessor.py | 395 ++++++++++++----------- 5 files changed, 247 insertions(+), 216 deletions(-) diff --git a/_unittest/test_12_PostProcessing.py b/_unittest/test_12_PostProcessing.py index 7ffd64db834..3c6dc6815ea 100644 --- a/_unittest/test_12_PostProcessing.py +++ b/_unittest/test_12_PostProcessing.py @@ -879,7 +879,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post): "Heat_Flow_Rate", scalar_function="Integrate", solution=None, - variation_dict={"power_block": "0.25W", "power_source": "0.075W"}, + variations={"power_block": "0.25W", "power_source": "0.075W"}, is_vector=False, intrinsics=None, phase=None, @@ -891,7 +891,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post): "Heat_Flow_Rate", scalar_function="Integrate", solution=None, - variation_dict={"power_block": "0.6W", "power_source": "0.15W"}, + variations={"power_block": "0.6W", "power_source": "0.15W"}, is_vector=False, intrinsics=None, phase=None, @@ -903,7 +903,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post): "Heat_Flow_Rate", scalar_function="Integrate", solution=None, - variation_dict={"power_block": "0.6W", "power_source": "0.15W"}, + variations={"power_block": "0.6W", "power_source": "0.15W"}, is_vector=False, intrinsics=None, phase=None, @@ -915,7 +915,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post): "Temperature", scalar_function="Maximum", solution=None, - variation_dict={"power_block": "0.6W", "power_source": "0.15W"}, + variations={"power_block": "0.6W", "power_source": "0.15W"}, is_vector=False, intrinsics=None, phase=None, @@ -927,7 +927,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post): "Temperature", scalar_function="Maximum", solution=None, - variation_dict={"power_block": "0.6W", "power_source": "0.15W"}, + variations={"power_block": "0.6W", "power_source": "0.15W"}, is_vector=False, intrinsics=None, phase=None, @@ -939,7 +939,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post): "Temperature", scalar_function="Value", solution=None, - variation_dict=None, + variations=None, is_vector=False, intrinsics=None, phase=None, diff --git a/_unittest_solvers/test_00_analyze.py b/_unittest_solvers/test_00_analyze.py index b7d03f4c058..ebd4c4f610b 100644 --- a/_unittest_solvers/test_00_analyze.py +++ b/_unittest_solvers/test_00_analyze.py @@ -185,12 +185,11 @@ def test_02_hfss_export_results(self, hfss_app): assert len(exported_files) > 0 fld_file1 = os.path.join(self.local_scratch.path, "test_fld_hfss1.fld") - assert hfss_app.post.export_field_file(quantity_name="Mag_E", filename=fld_file1, objects="Box1", - intrinsics="1GHz", phase="5deg") + assert hfss_app.post.export_field_file(quantity="Mag_E", file_name=fld_file1, objects="Box1", intrinsics="1GHz", + phase="5deg") assert os.path.exists(fld_file1) fld_file2 = os.path.join(self.local_scratch.path, "test_fld_hfss2.fld") - assert hfss_app.post.export_field_file(quantity_name="Mag_E", filename=fld_file2, objects="Box1", - intrinsics="1GHz") + assert hfss_app.post.export_field_file(quantity="Mag_E", file_name=fld_file2, objects="Box1", intrinsics="1GHz") assert os.path.exists(fld_file2) def test_03a_icepak_analyze_and_export_summary(self): @@ -291,28 +290,28 @@ def test_03d_icepak_eval_tempc(self): def test_03e_icepak_ExportFLDFil(self): fld_file = os.path.join(self.local_scratch.path, "test_fld.fld") - self.icepak_app.post.export_field_file(quantity_name="Temp", solution=self.icepak_app.nominal_sweep, - variation_dict={}, filename=fld_file, objects="box") + self.icepak_app.post.export_field_file(quantity="Temp", solution=self.icepak_app.nominal_sweep, variations={}, + file_name=fld_file, objects="box") assert os.path.exists(fld_file) fld_file_1 = os.path.join(self.local_scratch.path, "test_fld_1.fld") sample_points_file = os.path.join(local_path, "example_models", test_subfolder, "temp_points.pts") - self.icepak_app.post.export_field_file(quantity_name="Temp", solution=self.icepak_app.nominal_sweep, - variation_dict=self.icepak_app.available_variations.nominal_w_values_dict, - filename=fld_file_1, objects="box", + self.icepak_app.post.export_field_file(quantity="Temp", solution=self.icepak_app.nominal_sweep, + variations=self.icepak_app.available_variations.nominal_w_values_dict, + file_name=fld_file_1, objects="box", sample_points_file=sample_points_file) assert os.path.exists(fld_file_1) fld_file_2 = os.path.join(self.local_scratch.path, "test_fld_2.fld") - self.icepak_app.post.export_field_file(quantity_name="Temp", solution=self.icepak_app.nominal_sweep, - variation_dict=self.icepak_app.available_variations.nominal_w_values_dict, - filename=fld_file_2, objects="box", - sample_points_lists=[[0, 0, 0], [3, 6, 8], [4, 7, 9]]) + self.icepak_app.post.export_field_file(quantity="Temp", solution=self.icepak_app.nominal_sweep, + variations=self.icepak_app.available_variations.nominal_w_values_dict, + file_name=fld_file_2, objects="box", + sample_points=[[0, 0, 0], [3, 6, 8], [4, 7, 9]]) assert os.path.exists(fld_file_2) cs = self.icepak_app.modeler.create_coordinate_system() fld_file_3 = os.path.join(self.local_scratch.path, "test_fld_3.fld") - self.icepak_app.post.export_field_file(quantity_name="Temp", solution=self.icepak_app.nominal_sweep, - variation_dict=self.icepak_app.available_variations.nominal_w_values_dict, - filename=fld_file_3, objects="box", - sample_points_lists=[[0, 0, 0], [3, 6, 8], [4, 7, 9]], + self.icepak_app.post.export_field_file(quantity="Temp", solution=self.icepak_app.nominal_sweep, + variations=self.icepak_app.available_variations.nominal_w_values_dict, + file_name=fld_file_3, objects="box", + sample_points=[[0, 0, 0], [3, 6, 8], [4, 7, 9]], reference_coordinate_system=cs.name, export_in_si_system=False, export_field_in_reference=False) assert os.path.exists(fld_file_3) @@ -421,17 +420,17 @@ def test_06_m3d_harmonic_forces(self, m3dtransient): def test_07_export_maxwell_fields(self, m3dtransient): m3dtransient.analyze(m3dtransient.active_setup, num_cores=2) fld_file_3 = os.path.join(self.local_scratch.path, "test_fld_3.fld") - assert m3dtransient.post.export_field_file(quantity_name="Mag_B", solution=m3dtransient.nominal_sweep, - variation_dict={}, filename=fld_file_3, objects="Coil_A2", - objects_type="Surf", intrinsics="10ms") + assert m3dtransient.post.export_field_file(quantity="Mag_B", solution=m3dtransient.nominal_sweep, variations={}, + file_name=fld_file_3, objects="Coil_A2", objects_type="Surf", + intrinsics="10ms") assert os.path.exists(fld_file_3) fld_file_4 = os.path.join(self.local_scratch.path, "test_fld_4.fld") - assert not m3dtransient.post.export_field_file(quantity_name="Mag_B", solution=m3dtransient.nominal_sweep, - variation_dict=m3dtransient.available_variations.nominal_w_values_dict, - filename=fld_file_4, objects="Coil_A2", objects_type="invalid") + assert not m3dtransient.post.export_field_file(quantity="Mag_B", solution=m3dtransient.nominal_sweep, + variations=m3dtransient.available_variations.nominal_w_values_dict, + file_name=fld_file_4, objects="Coil_A2", objects_type="invalid") setup = m3dtransient.setups[0] m3dtransient.setups[0].delete() - assert not m3dtransient.post.export_field_file(quantity_name="Mag_B", variation_dict={}, filename=fld_file_4, + assert not m3dtransient.post.export_field_file(quantity="Mag_B", variations={}, file_name=fld_file_4, objects="Coil_A2") new_setup = m3dtransient.create_setup(setupname=setup.name, setuptype=setup.setuptype) diff --git a/pyaedt/generic/general_methods.py b/pyaedt/generic/general_methods.py index 7a030731f1d..bf3f69aefac 100644 --- a/pyaedt/generic/general_methods.py +++ b/pyaedt/generic/general_methods.py @@ -201,7 +201,7 @@ def _check_types(arg): def _function_handler_wrapper(user_function, **deprecated_kwargs): def wrapper(*args, **kwargs): if deprecated_kwargs and kwargs: - rename_kwargs(user_function.__name__, kwargs, deprecated_kwargs) + deprecate_kwargs(user_function.__name__, kwargs, deprecated_kwargs) if not settings.enable_error_handler: result = user_function(*args, **kwargs) return result @@ -234,8 +234,8 @@ def wrapper(*args, **kwargs): return wrapper -def rename_kwargs(func_name, kwargs, aliases): - """Helper function for deprecating function arguments.""" +def deprecate_kwargs(func_name, kwargs, aliases): + """Use helper function for deprecating function arguments.""" for alias, new in aliases.items(): if alias in kwargs: if new in kwargs: diff --git a/pyaedt/modules/AdvancedPostProcessing.py b/pyaedt/modules/AdvancedPostProcessing.py index 9b7ee1147a0..4fcb1dd4eb6 100644 --- a/pyaedt/modules/AdvancedPostProcessing.py +++ b/pyaedt/modules/AdvancedPostProcessing.py @@ -749,8 +749,7 @@ def animate_fields_from_aedtplt( Path for the export. The default is ``""``, in which case the file is exported to the working directory. export_gif : bool, optional - The default is ``False``. - show=False, + Whether to export the GIF file. The default is ``False``. show : bool, optional Generate the animation without showing an interactive plot. The default is ``True``. dark_mode : bool, optional diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index d73ef2a8b88..27bd5e300ed 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -135,9 +135,10 @@ def standard(self, expressions=None, setup_name=None): Expression List to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. Returns ------- @@ -175,9 +176,10 @@ def monitor(self, expressions=None, setup_name=None): Expression List to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. Returns ------- @@ -210,9 +212,10 @@ def fields(self, expressions=None, setup_name=None, polyline=None): Expression List to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. Returns ------- @@ -247,9 +250,10 @@ def cg_fields(self, expressions=None, setup_name=None, polyline=None): Expression List to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. Returns ------- @@ -284,9 +288,10 @@ def dc_fields(self, expressions=None, setup_name=None, polyline=None): Expression List to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. Returns ------- @@ -321,9 +326,10 @@ def rl_fields(self, expressions=None, setup_name=None, polyline=None): Expression List to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. Returns ------- @@ -361,9 +367,10 @@ def far_field(self, expressions=None, setup_name=None, sphere_name=None, source_ Expression List to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. sphere_name : str, optional Name of the sphere to create the far field on. source_context : str, optional @@ -404,9 +411,10 @@ def antenna_parameters(self, expressions=None, setup_name=None, sphere_name=None Expression List to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. sphere_name : str, optional Name of the sphere on which compute antenna parameters. @@ -442,9 +450,10 @@ def near_field(self, expressions=None, setup_name=None): Expression List to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. Returns ------- @@ -479,9 +488,10 @@ def modal_solution(self, expressions=None, setup_name=None): Expression List to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. Returns ------- @@ -515,9 +525,10 @@ def terminal_solution(self, expressions=None, setup_name=None): Expression List to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. Returns ------- @@ -551,9 +562,10 @@ def eigenmode(self, expressions=None, setup_name=None): Expression List to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. Returns ------- @@ -644,9 +656,10 @@ def eye_diagram( Expression to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. quantity_type : int, optional For AMI Analysis only, specify the quantity type. Options are: 0 for Initial Wave, 1 for Wave after Source, 2 for Wave after Channel and 3 for Wave after Probe. Default is 3. @@ -704,9 +717,10 @@ def spectral(self, expressions=None, setup_name=None): Expression List to add into the report. The expression can be any of the available formula you can enter into the Electronics Desktop Report Editor. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. Returns ------- @@ -1641,9 +1655,11 @@ def create_report( plot_type : str, optional The format of Data Visualization. Default is ``Rectangular Plot``. context : str, optional - The default is ``None``. It can be `None`, `"Differential Pairs"`,`"RL"`, - `"Sources"`, `"Vias"`,`"Bondwires"`, `"Probes"` for Hfss3dLayout or - Reduce Matrix Name for Q2d/Q3d solution or Infinite Sphere name for Far Fields Plot. + The default is ``None``. + - For HFSS 3D Layout, options are ``"Bondwires"``, ``"Differential Pairs"``, + ``None``, ``"Probes"``, ``"RL"``, ``"Sources"``, and ``"Vias"``. + - For Q2D or Q3D, specify the name of a reduced matrix. + - For a far fields plot, specify the name of an infinite sphere. plot_name : str, optional Name of the plot. The default is ``None``. polyline_points : int, optional, @@ -1813,9 +1829,10 @@ def get_solution_data( One or more formulas to add to the report. Example is value ``"dB(S(1,1))"`` or a list of values. Default is `None` which will return all traces. setup_sweep_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. domain : str, optional Plot Domain. Options are "Sweep" for frequency domain related results and "Time" for transient related data. variations : dict, optional @@ -2357,13 +2374,13 @@ def change_field_property(self, plot_name, property_name, property_value): ] ) - @pyaedt_function_handler(isvector="is_vector") + @pyaedt_function_handler(quantity_name="quantity", variation_dict="variations", isvector="is_vector") def get_scalar_field_value( self, - quantity_name, + quantity, scalar_function="Maximum", solution=None, - variation_dict=None, + variations=None, is_vector=False, intrinsics=None, phase=None, @@ -2375,22 +2392,22 @@ def get_scalar_field_value( Parameters ---------- - quantity_name : str + quantity : str Name of the quantity to export. For example, ``"Temp"``. scalar_function : str, optional The name of the scalar function. For example, ``"Maximum"``, ``"Integrate"``. The default is ``"Maximum"``. solution : str, optional Name of the solution in the format ``"solution : sweep"``. The default is ``None``. - variation_dict : dict, optional + variations : dict, optional Dictionary of all variation variables with their values. e.g. ``['power_block:=', ['0.6W'], 'power_source:=', ['0.15W']]`` The default is ``None``. is_vector : bool, optional Whether the quantity is a vector. The default is ``False``. intrinsics : str, optional - This parameter is mandatory for a frequency field - calculation. The default is ``None``. + This parameter is mandatory for a frequency field calculation. + The default is ``None``. phase : str, optional Field phase. The default is ``None``. object_name : str, optional @@ -2419,25 +2436,25 @@ def get_scalar_field_value( >>> oModule.ClcEval >>> GetTopEntryValue """ - self.logger.info("Exporting {} field. Be patient".format(quantity_name)) + self.logger.info("Exporting {} field. Be patient".format(quantity)) if not solution: solution = self._app.existing_analysis_sweeps[0] self.ofieldsreporter.CalcStack("clear") if is_vector: try: - self.ofieldsreporter.EnterQty(quantity_name) + self.ofieldsreporter.EnterQty(quantity) except Exception: - self.ofieldsreporter.CopyNamedExprToStack(quantity_name) + self.ofieldsreporter.CopyNamedExprToStack(quantity) self.ofieldsreporter.CalcOp("Smooth") self.ofieldsreporter.EnterScalar(0) self.ofieldsreporter.CalcOp("AtPhase") self.ofieldsreporter.CalcOp("Mag") else: try: - self.ofieldsreporter.EnterQty(quantity_name) + self.ofieldsreporter.EnterQty(quantity) except Exception: - self.logger.info("Quantity {} not present. Trying to get it from Stack".format(quantity_name)) - self.ofieldsreporter.CopyNamedExprToStack(quantity_name) + self.logger.info("Quantity {} not present. Trying to get it from Stack".format(quantity)) + self.ofieldsreporter.CopyNamedExprToStack(quantity) obj_list = object_name if scalar_function: if object_type == "volume": @@ -2451,11 +2468,11 @@ def get_scalar_field_value( self.ofieldsreporter.EnterPoint(obj_list) self.ofieldsreporter.CalcOp(scalar_function) - if not variation_dict: - variation_dict = self._app.available_variations.nominal_w_values_dict + if not variations: + variations = self._app.available_variations.nominal_w_values_dict variation = [] - for el, value in variation_dict.items(): + for el, value in variations.items(): variation.append(el + ":=") variation.append(value) @@ -2484,13 +2501,19 @@ def get_scalar_field_value( self.ofieldsreporter.CalcStack("clear") return float(value) - @pyaedt_function_handler(gridtype="grid_type", isvector="is_vector") + @pyaedt_function_handler( + quantity_name="quantity", + variation_dict="variations", + filename="file_name", + gridtype="grid_type", + isvector="is_vector", + ) def export_field_file_on_grid( self, - quantity_name, + quantity, solution=None, - variation_dict=None, - filename=None, + variations=None, + file_name=None, grid_type="Cartesian", grid_center=None, grid_start=None, @@ -2508,14 +2531,14 @@ def export_field_file_on_grid( Parameters ---------- - quantity_name : str + quantity : str Name of the quantity to export. For example, ``"Temp"``. solution : str, optional Name of the solution in the format ``"solution : sweep"``. The default is ``None``. - variation_dict : dict, optional + variations : dict, optional Dictionary of all variation variables with their values. The default is ``None``. - filename : str, optional + file_name : str, optional Full path and name to save the file to. The default is ``None``, in which case the file is exported to the working directory. @@ -2537,8 +2560,8 @@ def export_field_file_on_grid( is_vector : bool, optional Whether the quantity is a vector. The default is ``False``. intrinsics : str, optional - This parameter is mandatory for a frequency field - calculation. The default is ``None``. + This parameter is mandatory for a frequency field calculation. + The default is ``None``. phase : str, optional Field phase. The default is ``None``. export_with_sample_points : bool, optional @@ -2576,7 +2599,7 @@ def export_field_file_on_grid( >>> var = hfss.available_variations.nominal_w_values >>> setup = "Setup1 : LastAdaptive" >>> path = "Field.fld" - >>> hfss.post.export_field_file_on_grid("E", setup, var, path, 'Cartesian', [0, 0, 0], intrinsics="8GHz") + >>> hfss.post.export_field_file_on_grid("E",setup,var,path,'Cartesian',[0, 0, 0],intrinsics="8GHz") """ if grid_step is None: grid_step = [0, 0, 0] @@ -2586,20 +2609,20 @@ def export_field_file_on_grid( grid_stop = [0, 0, 0] if grid_center is None: grid_center = [0, 0, 0] - self.logger.info("Exporting %s field. Be patient", quantity_name) + self.logger.info("Exporting %s field. Be patient", quantity) if not solution: solution = self._app.existing_analysis_sweeps[0] - if not filename: - filename = os.path.join( - self._app.working_directory, "{}_{}.fld".format(quantity_name, solution.replace(" : ", "_")) + if not file_name: + file_name = os.path.join( + self._app.working_directory, "{}_{}.fld".format(quantity, solution.replace(" : ", "_")) ) - elif os.path.isdir(filename): - filename = os.path.join(filename, "{}_{}.fld".format(quantity_name, solution.replace(" : ", "_"))) + elif os.path.isdir(file_name): + file_name = os.path.join(file_name, "{}_{}.fld".format(quantity, solution.replace(" : ", "_"))) self.ofieldsreporter.CalcStack("clear") try: - self.ofieldsreporter.EnterQty(quantity_name) + self.ofieldsreporter.EnterQty(quantity) except Exception: - self.ofieldsreporter.CopyNamedExprToStack(quantity_name) + self.ofieldsreporter.CopyNamedExprToStack(quantity) if is_vector: self.ofieldsreporter.CalcOp("Smooth") if phase: @@ -2627,11 +2650,11 @@ def export_field_file_on_grid( self.logger.error("Error in the type of the grid.") return False - if not variation_dict: - variation_dict = self._app.available_variations.nominal_w_values_dict + if not variations: + variations = self._app.available_variations.nominal_w_values_dict variation = [] - for el, value in variation_dict.items(): + for el, value in variations.items(): variation.append(el + ":=") variation.append(value) @@ -2661,7 +2684,7 @@ def export_field_file_on_grid( ] self.ofieldsreporter.ExportOnGrid( - filename, + file_name, grid_start_wu, grid_stop_wu, grid_step_wu, @@ -2672,23 +2695,30 @@ def export_field_file_on_grid( grid_center, False, ) - if os.path.exists(filename): - return filename + if os.path.exists(file_name): + return file_name return False # pragma: no cover - @pyaedt_function_handler(obj_list="objects", obj_type="objects_type") + @pyaedt_function_handler( + quantity_name="quantity", + variation_dict="variations", + filename="file_name", + obj_list="objects", + obj_type="objects_type", + sample_points_lists="sample_points", + ) def export_field_file( self, - quantity_name, + quantity, solution=None, - variation_dict=None, - filename=None, + variations=None, + file_name=None, objects="AllObjects", objects_type="Vol", intrinsics=None, phase=None, sample_points_file=None, - sample_points_lists=None, + sample_points=None, export_with_sample_points=True, reference_coordinate_system="Global", export_in_si_system=True, @@ -2698,15 +2728,15 @@ def export_field_file( Parameters ---------- - quantity_name : + quantity : Name of the quantity to export. For example, ``"Temp"``. solution : str, optional Name of the solution in the format ``"solution: sweep"``. The default is ``None``. - variation_dict : dict, optional + variations : dict, optional Dictionary of all variation variables with their values. The default is ``None``. - filename : str, optional + file_name : str, optional Full path and name to save the file to. The default is ``None`` which export file in working_directory. objects : str, optional @@ -2716,13 +2746,13 @@ def export_field_file( Options are ``"Surf"`` for surface and ``"Vol"`` for volume. intrinsics : str, optional - This parameter is mandatory for a frequency or transient field - calculation. The default is ``None``. + This parameter is mandatory for a frequency or transient field calculation. + The default is ``None``. phase : str, optional Field phase. The default is ``None``. sample_points_file : str, optional Name of the file with sample points. The default is ``None``. - sample_points_lists : list, optional + sample_points : list, optional List of the sample points. The default is ``None``. export_with_sample_points : bool, optional Whether to include the sample points in the file to export. @@ -2753,29 +2783,29 @@ def export_field_file( >>> oModule.CalculatorWrite >>> oModule.ExportToFile """ - self.logger.info("Exporting %s field. Be patient", quantity_name) + self.logger.info("Exporting %s field. Be patient", quantity) if not solution: if not self._app.existing_analysis_sweeps: self.logger.error("There are no existing sweeps.") return False solution = self._app.existing_analysis_sweeps[0] - if not filename: + if not file_name: appendix = "" ext = ".fld" - filename = os.path.join(self._app.working_directory, solution.replace(" : ", "_") + appendix + ext) + file_name = os.path.join(self._app.working_directory, solution.replace(" : ", "_") + appendix + ext) else: - filename = filename.replace("//", "/").replace("\\", "/") + file_name = file_name.replace("//", "/").replace("\\", "/") self.ofieldsreporter.CalcStack("clear") try: - self.ofieldsreporter.EnterQty(quantity_name) + self.ofieldsreporter.EnterQty(quantity) except Exception: - self.ofieldsreporter.CopyNamedExprToStack(quantity_name) + self.ofieldsreporter.CopyNamedExprToStack(quantity) - if not variation_dict: - variation_dict = self._app.available_variations.nominal_w_values_dict + if not variations: + variations = self._app.available_variations.nominal_w_values_dict variation = [] - for el, value in variation_dict.items(): + for el, value in variations.items(): variation.append(el + ":=") variation.append(value) @@ -2791,7 +2821,7 @@ def export_field_file( variation.append(phase) else: variation.append("0deg") - if not sample_points_file and not sample_points_lists: + if not sample_points_file and not sample_points: if objects_type == "Vol": self.ofieldsreporter.EnterVol(objects) elif objects_type == "Surf": @@ -2800,7 +2830,7 @@ def export_field_file( self.logger.error("No correct choice.") return False self.ofieldsreporter.CalcOp("Value") - self.ofieldsreporter.CalculatorWrite(filename, ["Solution:=", solution], variation) + self.ofieldsreporter.CalculatorWrite(file_name, ["Solution:=", solution], variation) elif sample_points_file: export_options = [ "NAME:ExportOption", @@ -2814,7 +2844,7 @@ def export_field_file( export_field_in_reference, ] self.ofieldsreporter.ExportToFile( - filename, + file_name, sample_points_file, solution, variation, @@ -2824,7 +2854,7 @@ def export_field_file( sample_points_file = os.path.join(self._app.working_directory, "temp_points.pts") with open_file(sample_points_file, "w") as f: f.write("Unit={}\n".format(self.model_units)) - for point in sample_points_lists: + for point in sample_points: f.write(" ".join([str(i) for i in point]) + "\n") export_options = [ "NAME:ExportOption", @@ -2838,15 +2868,15 @@ def export_field_file( export_field_in_reference, ] self.ofieldsreporter.ExportToFile( - filename, + file_name, sample_points_file, solution, variation, export_options, ) - if os.path.exists(filename): - return filename + if os.path.exists(file_name): + return file_name return False # pragma: no cover @pyaedt_function_handler(plotname="plot_name", filepath="file_path", filename="file_name") @@ -3076,14 +3106,15 @@ def create_fieldplot_line( quantity : str Name of the quantity to plot. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. intrinsics : dict, optional - Dictionary containing all intrinsic variables. The default - is ``{}``. + Dictionary containing all intrinsic variables. + The default is ``None``. plot_name : str, optional - Name of the fieldplot to create. + Name of the field plot to create. field_type : str, optional Field type to plot. Valid only for Q3D Field plots. @@ -3132,8 +3163,8 @@ def create_fieldplot_line_traces( Name of the setup in the format ``"setupName : sweepName"``. The default is ``None``. intrinsics : dict, optional - Dictionary containing all intrinsic variables. The default - is ``{}``. + Dictionary containing all intrinsic variables. + The default is ``None``. plot_name : str, optional Name of the field plot to create. The default is ``None``. field_type : str, optional @@ -3214,9 +3245,9 @@ def create_fieldplot_line_traces( field_type=field_type, ) - @pyaedt_function_handler() + @pyaedt_function_handler(quantity_name="quantity") def create_fieldplot_layers_nets( - self, layers_nets, quantity_name, setup_name=None, intrinsics=None, plot_on_surface=True, plot_name=None + self, layers_nets, quantity, setup_name=None, intrinsics=None, plot_on_surface=True, plot_name=None ): # pragma: no cover # type: (list, str, str, dict, bool, str) -> FieldPlot """Create a field plot of stacked layer plot. @@ -3228,7 +3259,7 @@ def create_fieldplot_layers_nets( layers_nets : list List of layers and nets to plot. For example: ``[["Layer1", "GND", "PWR"], ["Layer2", "VCC"], ...]``. - quantity_name : str + quantity : str Name of the quantity to plot. setup_name : str, optional Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` @@ -3236,8 +3267,8 @@ def create_fieldplot_layers_nets( ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to use in the export or ``LastAdaptive``. intrinsics : dict, optional - Dictionary containing all intrinsic variables. The default - is ``{}``. + Dictionary containing all intrinsic variables. + The default is ``None``. plot_on_surface : bool, optional Whether the plot is to be on the surface or volume of traces. plot_name : str, optional @@ -3272,12 +3303,12 @@ def create_fieldplot_layers_nets( get_ids = self._odesign.GetGeometryIdsForNetLayerCombination(el, layer[0], setup_name) if isinstance(get_ids, (tuple, list)) and len(get_ids) > 2: lst.extend([int(i) for i in get_ids[2:]]) - return self._create_fieldplot(lst, quantity_name, setup_name, intrinsics, "FacesList", plot_name) + return self._create_fieldplot(lst, quantity, setup_name, intrinsics, "FacesList", plot_name) if plot_on_surface: plot_type = "LayerNetsExtFace" else: plot_type = "LayerNets" - return self._create_fieldplot(layers_nets, quantity_name, setup_name, intrinsics, plot_type, plot_name) + return self._create_fieldplot(layers_nets, quantity, setup_name, intrinsics, plot_type, plot_name) @pyaedt_function_handler(objlist="objects", quantityName="quantity", IntrinsincDict="intrinsics") def create_fieldplot_surface( @@ -3292,14 +3323,15 @@ def create_fieldplot_surface( quantity : str Name of the quantity to plot. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. intrinsics : dict, optional - Dictionary containing all intrinsic variables. The default - is ``{}``. + Dictionary containing all intrinsic variables. + The default is ``None``. plot_name : str, optional - Name of the fieldplot to create. + Name of the field plot to create. field_type : str, optional Field type to plot. Valid only for Q3D Field plots. @@ -3355,9 +3387,9 @@ def create_fieldplot_cutplane( where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. intrinsics : dict, optional Dictionary containing all intrinsic variables. - The default is ``{}``. + The default is ``None``. plot_name : str, optional - Name of the fieldplot to create. + Name of the field plot to create. filter_objects : list, optional Objects list on which filter the plot. The default value is ``None``, in which case an empty list is passed. @@ -3405,14 +3437,15 @@ def create_fieldplot_volume( quantity : Name of the quantity to plot. setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. intrinsics : dict, optional - Dictionary containing all intrinsic variables. The default - is ``{}``. + Dictionary containing all intrinsic variables. + The default is ``None``. plot_name : str, optional - Name of the fieldplot to create. + Name of the field plot to create. Returns ------- @@ -3793,38 +3826,38 @@ def export_model_obj(self, objects=None, export_path=None, export_as_single_obje @pyaedt_function_handler() def export_mesh_obj(self, setup_name=None, intrinsics=None): """Export the mesh in ``aedtplt`` format. - The mesh has to be available in the selected setup. - If a parametric model is provided user can choose the mesh to export providing a specific set of variations. - This method applies only to ``Hfss``, ``Q3d``, ``Q2D``, ``Maxwell3d``, ``Maxwell2d``, ``Icepak`` - and ``Mechanical`` objects. This method is calling ``create_fieldplot_surface`` to create a mesh plot and - ``export_field_plot`` to export it as ``aedtplt`` file. - - Parameters - ---------- - setup_name : str, optional - Name of the setup. The default is ``None`` which automatically take ``nominal_adaptive`` setup. - Please make sure to build a setup string in the form of ``"SetupName : SetupSweep"`` - where ``SetupSweep`` is the Sweep name to use in the export or ``LastAdaptive``. - intrinsics : dict, optional. - Intrinsic dictionary that is needed for the export. - The default is ``{}``, which assumes that no variables are present in - the dictionary or nominal values are used. - ```Here's your definition that should be used in other locations?! - - Returns - ------- - str - File Generated with full path. - - Examples - -------- - >>> from pyaedt import Hfss - >>> hfss = Hfss() - >>> hfss.analyze() - >>> # Export report using defaults. - >>> hfss.post.export_mesh_obj(setup_name=None, intrinsics=None) - >>> # Export report using arguments. - >>> hfss.post.export_mesh_obj(setup_name="MySetup : LastAdaptive", intrinsics={"w1":"5mm", "l1":"3mm"}) + The mesh has to be available in the selected setup. + If a parametric model is provided user can choose the mesh to export providing a specific set of variations. + This method applies only to ``Hfss``, ``Q3d``, ``Q2D``, ``Maxwell3d``, ``Maxwell2d``, ``Icepak`` + and ``Mechanical`` objects. This method is calling ``create_fieldplot_surface`` to create a mesh plot and + ``export_field_plot`` to export it as ``aedtplt`` file. + + Parameters + ---------- + setup_name : str, optional + Name of the setup. The default is ``None``, in which case the ``nominal_adaptive`` + setup is used. Be sure to build a setup string in the form of + ``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to + use in the export or ``LastAdaptive``. + intrinsics : dict, optional. + Intrinsic dictionary that is needed for the export. + The default is ``None``, which assumes that no variables are present in + the dictionary or nominal values are used. + + Returns + ------- + str + File Generated with full path. + + Examples + -------- + >>> from pyaedt import Hfss + >>> hfss = Hfss() + >>> hfss.analyze() + >>> # Export report using defaults. + >>> hfss.post.export_mesh_obj(setup_name=None, intrinsics=None) + >>> # Export report using arguments. + >>> hfss.post.export_mesh_obj(setup_name="MySetup : LastAdaptive", intrinsics={"w1":"5mm", "l1":"3mm"}) """ if intrinsics is None: intrinsics = {} @@ -4596,10 +4629,10 @@ def create_ami_statistical_eye_plot( ami_plot_type : str, optional String containing the report AMI type. The default is ``"InitialEye"``. Options are ``"EyeAfterChannel"``, ``"EyeAfterProbe"````"EyeAfterSource"``, - and ``"InitialEye"``. - . + and ``"InitialEye"``.. plot_name : str, optional - The name of the plot. Defaults to a unique name starting with ``"Plot"``. + Plot name. The default is ``None``, in which case + a unique name starting with ``"Plot"`` is automatically assigned. Returns ------- @@ -5121,7 +5154,7 @@ def get_field_summary_data(self, setup_name=None, design_variation={}, intrinsic The default is ``{}``, in which case nominal variation is used. intrinsics : str, optional Intrinsic values to use for the computation. The default is ``""``, - suitable when no frequency needs to be selected. + which is suitable when no frequency needs to be selected. pandas_output : bool, optional Whether to use pandas output. The default is ``False``, in which case the dictionary output is used. @@ -5167,7 +5200,7 @@ def export_csv(self, file_name, setup_name=None, variations={}, intrinsics=""): The default is ``{}``, in which case the nominal variation is used. intrinsics : str, optional Intrinsic values to use for the computation. The default is ``""``, - suitable when no frequency needs to be selected. + which is suitable when no frequency needs to be selected. Returns -------