diff --git a/_unittest/test_12_1_PostProcessing.py b/_unittest/test_12_1_PostProcessing.py index d08731659e0..7116492618f 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, @@ -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.plot_folder ) 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() @@ -501,13 +499,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 +524,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 +555,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) @@ -580,11 +578,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 aced256c218..3c6dc6815ea 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,14 +232,14 @@ 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) + assert data_farfield2.plot(formula="db20", is_polar=True) def test_09b_export_report_A(self, circuit_test): files = circuit_test.export_results() @@ -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" @@ -361,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", @@ -405,15 +399,11 @@ 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( - 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( @@ -595,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 @@ -610,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 @@ -635,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 @@ -686,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")) @@ -863,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): @@ -897,8 +879,8 @@ 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"}, - isvector=False, + variations={"power_block": "0.25W", "power_source": "0.075W"}, + is_vector=False, intrinsics=None, phase=None, object_name="cube2", @@ -909,8 +891,8 @@ 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"}, - isvector=False, + variations={"power_block": "0.6W", "power_source": "0.15W"}, + is_vector=False, intrinsics=None, phase=None, object_name="cube2", @@ -921,8 +903,8 @@ 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"}, - isvector=False, + variations={"power_block": "0.6W", "power_source": "0.15W"}, + is_vector=False, intrinsics=None, phase=None, object_name="cube2", @@ -933,8 +915,8 @@ 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"}, - isvector=False, + variations={"power_block": "0.6W", "power_source": "0.15W"}, + is_vector=False, intrinsics=None, phase=None, object_name="cube1", @@ -945,8 +927,8 @@ 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"}, - isvector=False, + variations={"power_block": "0.6W", "power_source": "0.15W"}, + is_vector=False, intrinsics=None, phase=None, object_name="cube2", @@ -957,8 +939,8 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post): "Temperature", scalar_function="Value", solution=None, - variation_dict=None, - isvector=False, + variations=None, + is_vector=False, intrinsics=None, phase=None, object_name="Point1", diff --git a/_unittest/test_21_Circuit.py b/_unittest/test_21_Circuit.py index be0a6a5a264..660e2b78982 100644 --- a/_unittest/test_21_Circuit.py +++ b/_unittest/test_21_Circuit.py @@ -249,9 +249,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 ) @@ -261,7 +261,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" ) @@ -270,7 +270,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" ) @@ -282,7 +282,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/_unittest/test_98_Icepak.py b/_unittest/test_98_Icepak.py index 767323cb0c5..578cb3d87df 100644 --- a/_unittest/test_98_Icepak.py +++ b/_unittest/test_98_Icepak.py @@ -1247,7 +1247,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/_unittest_solvers/test_00_analyze.py b/_unittest_solvers/test_00_analyze.py index 4a5e93d7120..ebd4c4f610b 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): @@ -194,14 +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, obj_list="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, obj_list="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): @@ -302,48 +290,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="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, - obj_list="box", - sample_points_file=sample_points_file, - ) + 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, - obj_list="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, - 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="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) def test_04a_3dl_generate_mesh(self): @@ -406,14 +376,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 +420,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="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, - obj_list="Coil_A2", - obj_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, obj_list="Coil_A2" - ) + 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) new_setup.props = setup.props 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/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) diff --git a/doc/source/User_guide/postprocessing.rst b/doc/source/User_guide/postprocessing.rst index 401acf4b5a9..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, - intrinsincDict=intrinsic) + intrinsics=intrinsic) .. image:: ../Resources/field_plot.png 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 cf2a2313798..c1cdc385a3d 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 @@ -204,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 @@ -222,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_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-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-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_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/02-SBR+/SBR_Time_Plot.py b/examples/02-SBR+/SBR_Time_Plot.py index 5abf89a49ad..6384ef137ff 100644 --- a/examples/02-SBR+/SBR_Time_Plot.py +++ b/examples/02-SBR+/SBR_Time_Plot.py @@ -64,17 +64,14 @@ # 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 # ~~~~~~~~~~ # 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 6655291464d..9a5ee2c2377 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 @@ -183,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] @@ -197,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] @@ -227,7 +215,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/03-Maxwell/Maxwell2D_Electrostatic.py b/examples/03-Maxwell/Maxwell2D_Electrostatic.py index c25959d110c..dd37e9fafbc 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 @@ -197,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 b49e9ca4360..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,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(objects=faces_reg, quantity='Flux_Lines', intrinsics={ + "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/Maxwell2D_Transient.py b/examples/03-Maxwell/Maxwell2D_Transient.py index 7014226eae3..61f69994e25 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 @@ -128,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/03-Maxwell/Maxwell3DTeam7.py b/examples/03-Maxwell/Maxwell3DTeam7.py index 08c7ce89066..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) @@ -424,9 +418,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", 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 d4a1479bb86..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 @@ -237,7 +231,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", intrinsics=intrinsic_dict, plot_name="Mag_J") ############################################################################### # Release AEDT 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/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/05-Q3D/Q3D_DC_IR.py b/examples/05-Q3D/Q3D_DC_IR.py index f727bdb2559..c1cbbd280b7 100644 --- a/examples/05-Q3D/Q3D_DC_IR.py +++ b/examples/05-Q3D/Q3D_DC_IR.py @@ -214,19 +214,10 @@ # ~~~~~~~~ # 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"}) - -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, -) +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, 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/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_Icepak_Coupling.py b/examples/06-Multiphysics/Hfss_Icepak_Coupling.py index 6dac5618f11..07bc757222f 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] @@ -325,17 +309,14 @@ 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")) ################################################################################ # 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/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 c251debc3b1..0f8b7a8b40a 100644 --- a/examples/06-Multiphysics/MRI.py +++ b/examples/06-Multiphysics/MRI.py @@ -107,20 +107,13 @@ # 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") -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 @@ -214,23 +207,17 @@ # 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", filter_objects=["implant_box"]) mech.save_project() data = mech.post.get_solution_data("Temperature", primary_sweep_variable="Time", context="Point1", 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 @@ -305,8 +292,7 @@ # 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", 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..4f5e9b12bd6 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, quantity="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(objects=["Global:XZ"], quantity="Velocity Vectors", + plot_name="Velocity Vectors") surf_temperature.export_image() velocity_cutplane.export_image(orientation="right") diff --git a/examples/07-Circuit/Circuit_AMI.py b/examples/07-Circuit/Circuit_AMI.py index 2801fadb066..14c32da76ab 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) @@ -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/circuit.py b/pyaedt/circuit.py index 29c595b3336..0b560e22374 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/generic/general_methods.py b/pyaedt/generic/general_methods.py index 0d36228f1f5..bf3f69aefac 100644 --- a/pyaedt/generic/general_methods.py +++ b/pyaedt/generic/general_methods.py @@ -198,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: + deprecate_kwargs(user_function.__name__, kwargs, deprecated_kwargs) if not settings.enable_error_handler: result = user_function(*args, **kwargs) return result @@ -232,7 +234,21 @@ def wrapper(*args, **kwargs): return wrapper -def pyaedt_function_handler(direct_func=None): +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: + 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) + + +def pyaedt_function_handler(direct_func=None, **deprecated_kwargs): """Provides an exception handler, logging mechanism, and argument converter for client-server communications. @@ -242,13 +258,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 @@ -258,7 +274,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..acc8373caa0 100644 --- a/pyaedt/generic/pdf.py +++ b/pyaedt/generic/pdf.py @@ -258,10 +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( - save_plot=image_path, - ) - 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) diff --git a/pyaedt/generic/plot.py b/pyaedt/generic/plot.py index cba6ee2f221..ce95fcd9c6a 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/hfss.py b/pyaedt/hfss.py index fc113dc0e70..86c8b6f6c25 100644 --- a/pyaedt/hfss.py +++ b/pyaedt/hfss.py @@ -4473,7 +4473,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() @@ -6220,10 +6220,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/hfss3dlayout.py b/pyaedt/hfss3dlayout.py index bb77f56b87b..788168bb570 100644 --- a/pyaedt/hfss3dlayout.py +++ b/pyaedt/hfss3dlayout.py @@ -822,7 +822,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/icepak.py b/pyaedt/icepak.py index 1e53b66e877..838597cef35 100644 --- a/pyaedt/icepak.py +++ b/pyaedt/icepak.py @@ -223,7 +223,6 @@ def assign_grille( air_faces, free_loss_coeff=True, free_area_ratio=0.8, - resistance_type=0, external_temp="AmbientTemp", expternal_pressure="AmbientPressure", x_curve=["0", "1", "2"], @@ -241,14 +240,6 @@ 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"``. expternal_pressure : str, optional @@ -4603,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. @@ -4616,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. @@ -4646,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( 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 d8252955f08..dffc94f531b 100644 --- a/pyaedt/modeler/cad/Primitives.py +++ b/pyaedt/modeler/cad/Primitives.py @@ -4605,7 +4605,6 @@ def import_3d_cad( >>> oEditor.Import """ - if str(healing) in ["0", "1"]: warnings.warn( "Assigning `0` or `1` to `healing` option is deprecated. Assign `True` or `False` instead.", diff --git a/pyaedt/modeler/cad/object3d.py b/pyaedt/modeler/cad/object3d.py index ce8fd8a3cc4..058f7756ca6 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 0830c547e29..fb502158810 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 aae16b13c85..42965095a27 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 self._pins = {} @@ -806,11 +806,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 @@ -864,11 +864,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 @@ -1672,7 +1672,7 @@ def move(self, new_position): return True -class ComponentsSubCircuit3DLayout(Objec3DLayout, object): +class ComponentsSubCircuit3DLayout(Object3DLayout, object): """Contains 3d Components in HFSS 3D Layout. Parameters @@ -1685,7 +1685,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/AdvancedPostProcessing.py b/pyaedt/modules/AdvancedPostProcessing.py index 17c51454c4c..4fcb1dd4eb6 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 @@ -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() @@ -310,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, @@ -339,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"``. @@ -398,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, @@ -416,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: @@ -433,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, @@ -455,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, @@ -472,11 +470,11 @@ def plot_field( Parameters ---------- quantity : str - Quantity to plot (e.g. ``"Mag_E"``). - object_list : str, list - Objects or faces to which apply the Field Plot. + Quantity to plot. For example, ``"Mag_E"``. + objects : str, list + 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. @@ -501,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"``. @@ -536,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) @@ -550,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, @@ -569,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, @@ -604,10 +602,10 @@ def plot_animated_field( ---------- quantity : str Quantity to plot (e.g. ``"Mag_E"``). - object_list : list, str - List of objects or faces to which apply the Field Plot. + objects : list, str + 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. @@ -615,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 @@ -670,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)) @@ -716,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, @@ -738,23 +735,21 @@ 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. + 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 @@ -777,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].intrinsincList: - self.field_plots[plotname].intrinsincList[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" ) ) @@ -813,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, @@ -838,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. @@ -847,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 - Type of the plot. Options are ``"Surface"``, ``"Volume"``, and - ``"CutPlane"``. - meshplot : bool, optional - The default is ``False``. + plot_type : str + 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``. - 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 @@ -878,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 in dark mode. The default is ``False``. + show_grid : bool, optional + Whether to show a grid on the plot. The default is ``False``. + show_bounding : bool, optional + Whether to show bounding on the plot. The default is ``False``. Returns ------- @@ -890,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() @@ -937,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, @@ -956,13 +960,13 @@ def plot_scene( Parameters ---------- - frames_list : 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 - Full path to output gif file. + frames : list or str + 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 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. @@ -985,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=",") @@ -1018,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 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() @@ -1032,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. @@ -1045,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. @@ -1084,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: @@ -1132,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``. @@ -1156,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 ``""``. @@ -1175,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"``. @@ -1216,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 ``""``. @@ -1234,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"``. @@ -1271,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 ``""``. @@ -1290,24 +1292,22 @@ 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() + @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) diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index 2a4e22eda24..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 ------- @@ -1093,13 +1107,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 @@ -1113,7 +1127,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 @@ -1182,27 +1196,27 @@ def rename_report(self, plot_name, new_name): except Exception: 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 @@ -1217,16 +1231,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) @@ -1438,7 +1454,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, @@ -1452,7 +1468,7 @@ def _get_report_inputs( context=None, subdesign_id=None, polyline_points=0, - plotname=None, + plot_name=None, only_get_method=False, ): ctxt = [] @@ -1563,8 +1579,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"]: @@ -1595,9 +1611,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, @@ -1611,9 +1627,9 @@ 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. + """Create a report in AEDT. It can be a 2D plot, 3D plot, polar plot, or a data table. Parameters ---------- @@ -1639,13 +1655,15 @@ 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. - plotname : str, optional + 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, - 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``. @@ -1672,29 +1690,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 @@ -1787,7 +1799,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 @@ -1817,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 @@ -2193,21 +2206,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 = [] @@ -2256,30 +2269,28 @@ 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].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] 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"] @@ -2329,17 +2340,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 @@ -2357,20 +2368,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(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, - isvector=False, + variations=None, + is_vector=False, intrinsics=None, phase=None, object_name="AllObjects", @@ -2381,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``. - 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 - 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 @@ -2425,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 isvector: + 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": @@ -2457,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) @@ -2490,19 +2501,25 @@ def get_scalar_field_value( self.ofieldsreporter.CalcStack("clear") return float(value) - @pyaedt_function_handler() + @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, - gridtype="Cartesian", + variations=None, + file_name=None, + 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, @@ -2514,17 +2531,18 @@ 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`` which export file in working_directory. - gridtype : str, optional + 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 The ``[x, y, z]`` coordinates for the center of the grid. @@ -2539,11 +2557,11 @@ 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 - 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 @@ -2581,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] @@ -2591,21 +2609,21 @@ 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) - if isvector: + self.ofieldsreporter.CopyNamedExprToStack(quantity) + if is_vector: self.ofieldsreporter.CalcOp("Smooth") if phase: self.ofieldsreporter.EnterScalar(0) @@ -2613,17 +2631,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] @@ -2632,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) @@ -2666,34 +2684,41 @@ def export_field_file_on_grid( ] self.ofieldsreporter.ExportOnGrid( - filename, + file_name, grid_start_wu, grid_stop_wu, grid_step_wu, solution, variation, export_options, - gridtype, + grid_type, 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() + @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, - obj_list="AllObjects", - obj_type="Vol", + 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, @@ -2703,30 +2728,31 @@ 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. - obj_list : str, optional + objects : str, optional List of objects to export. The default is ``"AllObjects"``. - obj_type : str, optional - Type of objects to export. Options are ``"Vol"`` for volume and - ``"Surf"`` for surface. The default is ``"Vol"``. + objects_type : str, optional + 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``. + 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. @@ -2757,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) @@ -2795,16 +2821,16 @@ def export_field_file( variation.append(phase) 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 not sample_points_file and not sample_points: + 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 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", @@ -2818,7 +2844,7 @@ def export_field_file( export_field_in_reference, ] self.ofieldsreporter.ExportToFile( - filename, + file_name, sample_points_file, solution, variation, @@ -2828,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", @@ -2842,31 +2868,31 @@ 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() - 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 - Name of the file. The default is ``""``. + file_name : str, optional + 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"``. @@ -2880,15 +2906,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 Exception: # pragma: no cover self.logger.error("{} file format is not supported for this plot.".format(file_format)) return False @@ -2952,12 +2978,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, setup_name, intrinsics, listtype, plot_name=None, filter_boxes=[], field_type=None + self, + objects, + quantity, + setup_name, + intrinsics, + 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: @@ -2974,52 +3008,29 @@ def _create_fieldplot( char_set = string.ascii_uppercase + string.digits if not plot_name: - plot_name = quantityName + "_" + "".join(random.sample(char_set, 6)) - if listtype == "CutPlane": - plot = FieldPlot( - self, - cutplanelist=objlist, - solutionName=setup_name, - quantityName=quantityName, - intrinsincList=intrinsics, - ) - elif listtype == "FacesList": - plot = FieldPlot( - self, - surfacelist=objlist, - solutionName=setup_name, - quantityName=quantityName, - intrinsincList=intrinsics, - ) - elif listtype == "ObjList": - plot = FieldPlot( - self, - objlist=objlist, - solutionName=setup_name, - quantityName=quantityName, - intrinsincList=intrinsics, - ) - elif listtype == "Line": + 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, cutplanes=objects, solution=setup_name, quantity=quantity, intrinsics=intrinsics) + elif list_type == "FacesList": + plot = FieldPlot(self, surfaces=objects, solution=setup_name, quantity=quantity, intrinsics=intrinsics) + elif list_type == "ObjList": + plot = FieldPlot(self, objects=objects, solution=setup_name, quantity=quantity, intrinsics=intrinsics) + elif list_type == "Line": + plot = FieldPlot(self, lines=objects, solution=setup_name, quantity=quantity, intrinsics=intrinsics) + elif list_type.startswith("Layer"): plot = FieldPlot( self, - linelist=objlist, - solutionName=setup_name, - quantityName=quantityName, - intrinsincList=intrinsics, - ) - elif listtype.startswith("Layer"): - plot = FieldPlot( - self, - layers_nets=objlist, - solutionName=setup_name, - quantityName=quantityName, - intrinsincList=intrinsics, - layers_plot_type=listtype, + solution=setup_name, + quantity=quantity, + intrinsics=intrinsics, + 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: @@ -3030,13 +3041,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, @@ -3058,20 +3069,20 @@ 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, - intrinsincList=intrinsics, - seedingFaces=seeding_faces_ids, + objects=in_volume_tracing_ids, + surfaces=surface_tracing_ids, + solution=setup_name, + quantity=quantity, + intrinsics=intrinsics, + 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": @@ -3082,27 +3093,28 @@ def _create_fieldplot_line_traces( else: return False - @pyaedt_function_handler() + @pyaedt_function_handler(objlist="objects", quantityName="quantity") def create_fieldplot_line( - self, objlist, quantityName, setup_name=None, intrinsincDict=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. - 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 - Dictionary containing all intrinsic variables. The default - is ``{}``. + 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 ``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. @@ -3116,23 +3128,23 @@ def create_fieldplot_line( >>> oModule.CreateFieldPlot """ - if intrinsincDict is None: - 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 + objects, quantity, setup_name, intrinsics, "Line", plot_name, field_type=field_type ) - @pyaedt_function_handler() + @pyaedt_function_handler(IntrinsincDict="intrinsics") def create_fieldplot_line_traces( self, seeding_faces, 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", ): @@ -3150,9 +3162,9 @@ 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 - Dictionary containing all intrinsic variables. The default - is ``{}``. + intrinsics : dict, optional + 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 @@ -3171,8 +3183,8 @@ 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 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,14 +3240,14 @@ def create_fieldplot_line_traces( surface_tracing_ids, "FieldLineTrace", setup_name, - intrinsinc_dict, + intrinsics, plot_name, 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. @@ -3247,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`` @@ -3255,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 @@ -3291,34 +3303,35 @@ 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() + @pyaedt_function_handler(objlist="objects", quantityName="quantity", IntrinsincDict="intrinsics") def create_fieldplot_surface( - self, objlist, quantityName, setup_name=None, intrinsincDict=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. - 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 - Dictionary containing all intrinsic variables. The default - is ``{}``. + 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 ``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. @@ -3332,55 +3345,56 @@ def create_fieldplot_surface( >>> oModule.CreateFieldPlot """ - if intrinsincDict is None: - 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] - 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, intrinsincDict, "FacesList", plot_name, field_type=field_type + new_obj_list, quantity, setup_name, intrinsics, "FacesList", plot_name, field_type=field_type ) - @pyaedt_function_handler() + @pyaedt_function_handler(objlist="objects", quantityName="quantity", IntrinsincDict="intrinsics") def create_fieldplot_cutplane( self, - objlist, - quantityName, + objects, + quantity, setup_name=None, - intrinsincDict=None, + intrinsics=None, plot_name=None, - filter_objects=[], + filter_objects=None, field_type="DC R/L Fields", ): """Create a field plot of cut planes. 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. 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 ``{}``. + 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. 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 ------- @@ -3392,51 +3406,46 @@ def create_fieldplot_cutplane( >>> oModule.CreateFieldPlot """ - if intrinsincDict is None: - 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] if filter_objects: filter_objects = self._app.modeler.convert_to_selections(filter_objects, True) return self._create_fieldplot( - objlist, - quantityName, + objects, + quantity, setup_name, - intrinsincDict, + intrinsics, "CutPlane", plot_name, filter_boxes=filter_objects, field_type=field_type, ) - @pyaedt_function_handler() + @pyaedt_function_handler(objlist="objects", quantityName="quantity", IntrinsincDict="intrinsics") def create_fieldplot_volume( - self, - objlist, - quantityName, - setup_name=None, - intrinsincDict=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. - 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 - Dictionary containing all intrinsic variables. The default - is ``{}``. + 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 ``None``. plot_name : str, optional - Name of the fieldplot to create. + Name of the field plot to create. Returns ------- @@ -3448,21 +3457,21 @@ def create_fieldplot_volume( >>> oModule.CreateFieldPlot """ - if intrinsincDict is None: - 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 + 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, @@ -3477,11 +3486,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"``. @@ -3535,15 +3544,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, @@ -3555,7 +3564,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 @@ -3702,10 +3711,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``, @@ -3721,7 +3728,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 @@ -3737,54 +3744,56 @@ 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") 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 - List of objects to export. Export every model object except 3D ones, vacuum and air objects. + objects : list, optional + 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 obj or list of objs 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. + Whether to export air and vacuum objects. The default is ``False``. Returns ------- list - Files obj path. + List of paths for OBJ files. """ - 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" @@ -3793,7 +3802,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: @@ -3811,11 +3820,11 @@ 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() - 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. @@ -3826,12 +3835,14 @@ def export_mesh_obj(self, setup_name=None, intrinsic_dict=None): 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``. - intrinsic_dict : dict, 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 ``{}`` which assumes no variables are present in the dict or nominal values are used. + The default is ``None``, which assumes that no variables are present in + the dictionary or nominal values are used. Returns ------- @@ -3844,12 +3855,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 +3871,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() @@ -4236,6 +4247,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", @@ -4285,6 +4297,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", @@ -4317,10 +4330,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 @@ -4331,6 +4341,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", @@ -4404,6 +4415,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", @@ -4491,22 +4503,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. @@ -4522,16 +4535,17 @@ 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 - The plot name. Default is a unique name. + plot_name : str, optional + Plot name. The default is ``None``, in which case + a unique name is automatically assigned. Returns ------- 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: @@ -4554,10 +4568,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:=", @@ -4596,26 +4610,29 @@ 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. 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"``. - plotname : str, optional - The name of the plot. Defaults to a unique name starting with ``"Plot"``. + String containing the report AMI type. The default is ``"InitialEye"``. + Options are ``"EyeAfterChannel"``, ``"EyeAfterProbe"````"EyeAfterSource"``, + and ``"InitialEye"``.. + plot_name : str, optional + Plot name. The default is ``None``, in which case + a unique name starting with ``"Plot"`` is automatically assigned. Returns ------- @@ -4627,8 +4644,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"], @@ -4663,10 +4680,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:=", @@ -4702,21 +4719,22 @@ 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. + One or more names of the probe to plot in the eye diagram. variation_list_w_value : list List of variations with relative values. - plotname : str, optional - The name of the plot. + plot_name : str, optional + Plot name. The default is ``None``, in which case a name is automatically assigned. Returns ------- @@ -4728,8 +4746,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"], @@ -4755,10 +4773,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:=", @@ -4794,8 +4812,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, @@ -4834,7 +4853,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) """ @@ -4883,9 +4902,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, @@ -4898,7 +4918,7 @@ def sample_ami_waveform( Parameters ---------- - setupname : str + setup_name : str Name of the setup. probe_name : str Name of the AMI probe. @@ -4926,7 +4946,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 @@ -4949,7 +4969,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: @@ -4975,7 +4995,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, ) @@ -5026,7 +5046,7 @@ def sample_ami_waveform( "MassFlowRate", "VolumeFlowRate", "MassFlux", - "ViscocityRatio", + "ViscosityRatio", "WallYPlus", "TKE", "Epsilon", @@ -5119,8 +5139,8 @@ def add_calculation( ) # TODO : last argument not documented return True - @pyaedt_function_handler() - def get_field_summary_data(self, setup_name=None, design_variation={}, intrinsic_value="", pandas_output=False): + @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. @@ -5132,9 +5152,9 @@ 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. + 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. @@ -5147,7 +5167,7 @@ def get_field_summary_data(self, setup_name=None, design_variation={}, intrinsic """ 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) @@ -5163,24 +5183,24 @@ 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={}, intrinsic_value=""): + @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. - 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. + which is suitable when no frequency needs to be selected. Returns ------- @@ -5190,8 +5210,8 @@ def export_csv(self, filename, setup_name=None, design_variation={}, intrinsic_v 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( [ @@ -5200,9 +5220,9 @@ def export_csv(self, filename, setup_name=None, design_variation={}, intrinsic_v "DesignVariationKey:=", dv_string, "ExportFileName:=", - filename, + file_name, "IntrinsicValue:=", - intrinsic_value, + intrinsics, ] ) return True diff --git a/pyaedt/modules/SolveSetup.py b/pyaedt/modules/SolveSetup.py index b5e18865b83..07e8fc1fca0 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, ) diff --git a/pyaedt/modules/solutions.py b/pyaedt/modules/solutions.py index 866836f4be7..f8487ebc8ba 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, @@ -762,21 +763,26 @@ def plot( Parameters ---------- curves : list - Curves to be plotted. If None, the first curve will be plotted. - math_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. + 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. 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. - xlabel : str + 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. - ylabel : str + 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 @@ -800,45 +806,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, ): @@ -849,18 +855,24 @@ 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"`. - math_formula : str , optional - Mathematical formula to apply to the plot curve. - Valid values are `"re"`, `"im"`, `"db20"`, `"db10"`, `"abs"`, `"mag"`, `"phasedeg"`, `"phaserad"`. + Y-axis sweep. The default is ``"Phi"``. + 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. 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. - is_polar : bool, optional - Set to `True` if this is a polar plot. + The default is ``None``. Returns ------- @@ -872,8 +884,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 +895,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 +917,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 +951,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,10 +1012,10 @@ 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). + """Save IFFT matrix to a list of CSV files (one per time step). Parameters ---------- @@ -1014,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_dir : str - Output path - name_str : str, optional - csv file header. + 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. The default is ``"res_"``. Returns ------- @@ -1041,15 +1053,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 +1077,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 +1114,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 +1399,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 +1516,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 +1537,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 +1551,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 +1582,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 +1610,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 +1639,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 +1648,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 +1658,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 +1682,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 +1691,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 +1753,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 +1791,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 +1805,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 +1826,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 +1834,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 +1865,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 +1891,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 +1899,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 +1935,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 +1943,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 +1960,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 +1983,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 +2040,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 +2102,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 +2159,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 +2189,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 +2445,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 +2603,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 +2618,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.copy_from(self.ff.mesh) return @@ -2620,45 +2642,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. - intrinsincList : dict, optional + intrinsics : dict, optional Name of the intrinsic dictionary. The default is ``{}``. """ + @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="", - intrinsincList={}, - seedingFaces=[], - layers_nets=[], - layers_plot_type="LayerNetsExtFace", + objects=[], + surfaces=[], + lines=[], + cutplanes=[], + solution="", + quantity="", + intrinsics={}, + 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.intrinsincList = intrinsincList + 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 @@ -2704,32 +2738,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 @@ -2751,26 +2785,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:]) @@ -2786,18 +2820,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 @@ -2809,11 +2843,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:=", @@ -2846,7 +2876,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], @@ -2901,11 +2931,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]) @@ -2950,7 +2980,7 @@ def surfacePlotInstructionLineTraces(self): out = [ "NAME:" + self.name, "SolutionName:=", - self.solutionName, + self.solution, "UserSpecifyName:=", 0, "UserSpecifyFolder:=", @@ -2958,7 +2988,7 @@ def surfacePlotInstructionLineTraces(self): "QuantityName:=", "QuantityName_FieldLineTrace", "PlotFolder:=", - self.plotFolder, + self.plot_folder, ] if self.field_type: out.extend(["FieldType:=", self.field_type]) @@ -2975,9 +3005,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:=", @@ -3112,28 +3142,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) @@ -3216,7 +3246,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() @@ -3252,13 +3282,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, @@ -3313,7 +3343,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, @@ -3331,7 +3361,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"``. @@ -3339,26 +3369,27 @@ 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 ``{}``. """ + @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, - intrinsinc_list={}, + intrinsics={}, ): self.is_creeping_wave = is_creeping_wave self._postprocessor = postprocessor self._ofield = postprocessor.ofieldsreporter - self.quantity_name = quantity_name - self.intrinsics = intrinsinc_list + self.quantity = quantity + self.intrinsics = intrinsics self.name = "Field_Plot" self.plot_folder = "Field_Plot" self.max_frequency = max_frequency @@ -3417,7 +3448,7 @@ def _create_args(self): "UserSpecifyFolder:=", 0, "QuantityName:=", - self.quantity_name, + self.quantity, "PlotFolder:=", "Visual Ray Trace SBR", "IntrinsicVar:=", @@ -3487,7 +3518,7 @@ def _create_args_creeping(self): "UserSpecifyFolder:=", 0, "QuantityName:=", - self.quantity_name, + self.quantity, "PlotFolder:=", "Visual Ray Trace CW", "IntrinsicVar:=", @@ -3566,21 +3597,22 @@ 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 - Full path to output file. If ``None``, the file will be exported in working directory. + path : str, optional + Full path to the output file. The default is ``None``, in which case the file is + exported to the working directory. Returns ------- 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