Skip to content

Commit 6b4a0e8

Browse files
authored
Post Processor Report Refactoring (#1017)
* New Report Objects added * New Report Objects added * New Report Objects added * improved UT and Examples * improved UT and Examples * added few more methods to Report * added few more methods to Report * added few more methods to Report * added few more methods to Report Co-authored-by: maxcapodi78 <Shark78>
1 parent 60f0e69 commit 6b4a0e8

File tree

11 files changed

+1585
-75
lines changed

11 files changed

+1585
-75
lines changed

_unittest/test_12_PostProcessing.py

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ def test_08_manipulate_report(self):
209209

210210
def test_09_manipulate_report(self):
211211
assert self.aedtapp.post.create_report("dB(S(1,1))")
212+
new_report = self.aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))")
213+
assert new_report.create()
214+
212215
data = self.aedtapp.post.get_solution_data("S(1,1)")
213216
assert data.primary_sweep == "Freq"
214217
assert data.expressions[0] == "S(1,1)"
@@ -227,6 +230,15 @@ def test_09_manipulate_report(self):
227230
context="3D",
228231
report_category="Far Fields",
229232
)
233+
new_report = self.field_test.post.reports_by_category.far_field(
234+
"db(RealizedGainTotal)", self.field_test.nominal_adaptive
235+
)
236+
new_report.variations = variations
237+
new_report.report_type = "3D Polar Plot"
238+
new_report.far_field_sphere = "3D"
239+
assert new_report.create()
240+
new_report.report_type = "Rectangular Contour Plot"
241+
assert new_report.create()
230242
data = self.field_test.post.get_solution_data(
231243
"GainTotal",
232244
self.field_test.nominal_adaptive,
@@ -252,6 +264,10 @@ def test_09_manipulate_report(self):
252264
context="Poly1",
253265
report_category="Fields",
254266
)
267+
new_report = self.field_test.post.reports_by_category.fields("Mag_H", self.field_test.nominal_adaptive)
268+
new_report.variations = variations2
269+
new_report.polyline = "Poly1"
270+
assert new_report.create()
255271
assert data.primary_sweep == "Theta"
256272
assert data.data_magnitude("GainTotal")
257273
assert not data.data_magnitude("GainTotal2")
@@ -261,11 +277,44 @@ def test_09_manipulate_report(self):
261277
variations=variations,
262278
plot_type="Smith Chart",
263279
)
280+
new_report = self.field_test.post.reports_by_category.modal_solution("S(1,1)")
281+
new_report.plot_type = "Smith Chart"
282+
assert new_report.create()
283+
pass
264284

265-
def test_09b_export_report(self):
285+
def test_09b_export_report(self): # pragma: no cover
266286
files = self.aedtapp.export_results()
267287
assert len(files) > 0
268288

289+
@pytest.mark.skipif(
290+
config["build_machine"], reason="Skipped because it cannot run on build machine in non-graphical mode"
291+
)
292+
def test_09c_create_monitor(self): # pragma: no cover
293+
assert self.aedtapp.post.create_report("dB(S(1,1))")
294+
new_report = self.aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))")
295+
assert new_report.create()
296+
297+
assert new_report.add_cartesian_x_marker("3GHz")
298+
assert new_report.add_cartesian_y_marker("-55")
299+
300+
@pytest.mark.skipif(
301+
config["build_machine"], reason="Skipped because it cannot run on build machine in non-graphical mode"
302+
)
303+
def test_09d_add_line_from_point(self): # pragma: no cover
304+
assert self.aedtapp.post.create_report("dB(S(1,1))")
305+
new_report = self.aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))")
306+
assert new_report.create()
307+
assert new_report.add_limit_line_from_points([3, 5, 5, 3], [-50, -50, -60, -60], "GHz")
308+
309+
@pytest.mark.skipif(
310+
config["build_machine"], reason="Skipped because it cannot run on build machine in non-graphical mode"
311+
)
312+
def test_09e_add_line_from_equation(self):
313+
assert self.aedtapp.post.create_report("dB(S(1,1))")
314+
new_report = self.aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))")
315+
assert new_report.create()
316+
assert new_report.add_limit_line_from_equation(1, 20, 0.5, "GHz")
317+
269318
def test_10_delete_report(self):
270319
assert self.aedtapp.post.delete_report("MyNewScattering")
271320

@@ -329,9 +378,16 @@ def test_17_circuit(self):
329378
self.circuit_test.analyze_setup("LNA")
330379
self.circuit_test.analyze_setup("Transient")
331380
assert self.circuit_test.post.create_report(["dB(S(Port1, Port1))", "dB(S(Port1, Port2))"], "LNA")
381+
new_report = self.circuit_test.post.reports_by_category.standard(
382+
["dB(S(Port1, Port1))", "dB(S(Port1, Port2))"], "LNA"
383+
)
384+
assert new_report.create()
332385
data1 = self.circuit_test.post.get_solution_data(["dB(S(Port1, Port1))", "dB(S(Port1, Port2))"], "LNA")
333386
assert data1.primary_sweep == "Freq"
334387
assert self.circuit_test.post.create_report(["V(net_11)"], "Transient", "Time")
388+
new_report = self.circuit_test.post.reports_by_category.standard(["V(net_11)"], "Transient")
389+
new_report.domain = "Time"
390+
assert new_report.create()
335391
data2 = self.circuit_test.post.get_solution_data(["V(net_11)"], "Transient", "Time")
336392
assert data2.primary_sweep == "Time"
337393
assert data2.data_magnitude()
@@ -349,6 +405,10 @@ def test_18_diff_plot(self):
349405
primary_sweep_variable="l1",
350406
context="Differential Pairs",
351407
)
408+
new_report = self.diff_test.post.reports_by_category.standard("dB(S(1,1))")
409+
new_report.differential_pairs = True
410+
assert new_report.create()
411+
assert new_report.get_solution_data()
352412
data1 = self.diff_test.post.get_solution_data(
353413
["S(Diff1, Diff1)"],
354414
"LinearFrequency",
@@ -436,8 +496,35 @@ def test_56_test_export_q3d_results(self):
436496
self.q3dtest.analyze_nominal()
437497
assert os.path.exists(self.q3dtest.export_convergence("Setup1"))
438498
assert os.path.exists(self.q3dtest.export_profile("Setup1"))
499+
new_report = self.q3dtest.post.reports_by_category.standard(self.q3dtest.get_traces_for_plot())
500+
assert new_report.create()
501+
self.q3dtest.modeler.create_polyline([[0, -5, 0.425], [0.5, 5, 0.5]], name="Poly1", non_model=True)
502+
new_report = self.q3dtest.post.reports_by_category.cg_fields("SmoothQ", polyline="Polyline1")
503+
assert new_report.create()
504+
new_report = self.q3dtest.post.reports_by_category.rl_fields("Mag_SurfaceJac", polyline="Polyline1")
505+
assert new_report.create()
506+
new_report = self.q3dtest.post.reports_by_category.dc_fields("Mag_VolumeJdc", polyline="Polyline1")
507+
assert new_report.create()
508+
assert len(self.q3dtest.post.plots) == 4
439509

440510
def test_57_test_export_q2d_results(self):
441511
self.q2dtest.analyze_nominal()
442512
assert os.path.exists(self.q2dtest.export_convergence("Setup1"))
443513
assert os.path.exists(self.q2dtest.export_profile("Setup1"))
514+
new_report = self.q2dtest.post.reports_by_category.standard(self.q2dtest.get_traces_for_plot())
515+
assert new_report.create()
516+
self.q2dtest.modeler.create_polyline([[-1.9, -0.1, 0], [-1.2, -0.2, 0]], name="Poly1", non_model=True)
517+
new_report = self.q2dtest.post.reports_by_category.cg_fields("Mag_E", polyline="Poly1")
518+
assert new_report.create()
519+
new_report = self.q2dtest.post.reports_by_category.rl_fields("Mag_H", polyline="Poly1")
520+
assert new_report.create()
521+
assert len(self.q2dtest.post.plots) == 3
522+
523+
def test_58_test_no_report(self):
524+
assert not self.aedtapp.post.reports_by_category.eye_diagram()
525+
assert not self.q3dtest.post.reports_by_category.modal_solution()
526+
assert not self.q3dtest.post.reports_by_category.terminal_solution()
527+
assert not self.q2dtest.post.reports_by_category.far_field()
528+
assert not self.q2dtest.post.reports_by_category.near_field()
529+
assert self.aedtapp.post.reports_by_category.eigenmode()
530+
assert not self.q2dtest.post.reports_by_category.eigenmode()

_unittest/test_21_Circuit.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ def test_06b_add_3dlayout_component(self):
100100
report_category="Standard",
101101
subdesign_id=myedb.id,
102102
)
103+
new_report = self.aedtapp.post.reports_by_category.standard(insertions)
104+
new_report.sub_design_id = myedb.id
105+
assert new_report.create()
103106

104107
def test_07_add_hfss_component(self):
105108
my_model, myname = self.aedtapp.modeler.schematic.create_field_model(

_unittest/test_98_Icepak.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,21 @@ def test_16_create_output_variable(self):
224224
assert self.aedtapp.create_output_variable("OutputVariable1", "abs(Variable1)") # test creation
225225
assert self.aedtapp.create_output_variable("OutputVariable1", "asin(Variable1)") # test update
226226

227+
def test_16_surface_monitor(self):
228+
self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.XY, [0, 0, 0], [10, 20], name="surf1")
229+
assert self.aedtapp.assign_surface_monitor("surf1", monitor_name="monitor_surf")
230+
231+
def test_16_point_monitor(self):
232+
assert self.aedtapp.assign_point_monitor([0, 0, 0], monitor_name="monitor_point")
233+
227234
def test_17_analyze(self):
228235
self.aedtapp.analyze_nominal()
229236

237+
def test_17_post_processing(self):
238+
rep = self.aedtapp.post.reports_by_category.monitor(["monitor_surf.Temperature", "monitor_point.Temperature"])
239+
assert rep.create()
240+
assert len(self.aedtapp.post.plots) == 1
241+
230242
def test_17_get_output_variable(self):
231243
value = self.aedtapp.get_output_variable("OutputVariable1")
232244
tol = 1e-9
@@ -324,13 +336,6 @@ def test_36_create_source(self):
324336
temperature="28cel",
325337
)
326338

327-
def test_37_surface_monitor(self):
328-
self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.XY, [0, 0, 0], [10, 20], name="surf1")
329-
assert self.aedtapp.assign_surface_monitor("surf1")
330-
331-
def test_38_point_monitor(self):
332-
assert self.aedtapp.assign_point_monitor([0, 0, 0])
333-
334339
def test_39_import_idf(self):
335340
self.aedtapp.insert_design("IDF")
336341
assert self.aedtapp.import_idf(os.path.join(local_path, "example_models", "brd_board.emn"))
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
from conf_unittest import test_generator, PytestMockup
3+
import os
4+
5+
test_filter = "test_"
6+
7+
test_name = os.path.basename(__file__).replace(".py", "")
8+
mymodule = __import__('_unittest.' + test_name, fromlist=['TestClass'])
9+
test_obj = mymodule.TestClass()
10+
11+
class TestSequenceFunctionsGenerate(PytestMockup):
12+
@classmethod
13+
def setUpClass(cls):
14+
test_obj.setup_class()
15+
16+
@classmethod
17+
def tearDownClass(cls):
18+
test_obj.teardown_class()
19+
20+
test_names = [name for name in dir(test_obj) if name.startswith(test_filter)]
21+
for test_name in test_names:
22+
test_fn = test_generator(test_obj, test_name)
23+
setattr(TestSequenceFunctionsGenerate, test_name, test_fn)

doc/source/API/Post.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ They are accessible through the ``post`` property:
1919
2020
# this call return a SolutionData Object
2121
my_data = post.get_report_data(expression=trace_names)
22+
23+
# this call return a new Standard Report Object and creates one or multiple report from it.
24+
standard_report = post.report_by_category.standard("db(S(1,1))")
25+
standard_report.create()
26+
sols = standard_report.get_solution_data()
2227
...
2328
2429
.. note::
@@ -40,4 +45,10 @@ They are accessible through the ``post`` property:
4045
PostProcessor.SolutionData
4146
PostProcessor.FieldPlot
4247
AdvancedPostProcessing.ModelPlotter
48+
report_templates.Standard
49+
report_templates.Fields
50+
report_templates.NearField
51+
report_templates.FarField
52+
report_templates.EyeDiagram
53+
report_templates.Emission
4354

examples/02-HFSS/HFSS_Dipole.py

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,36 @@
118118
)
119119

120120
###############################################################################
121-
# Postprocessing
121+
# Postprocessing using report objects
122+
# -----------------------------------
123+
# Another way to create a plot is using report_by_category.
124+
# This gives more freedom to the user in report creation.
125+
126+
new_report = hfss.post.reports_by_category.far_field("db(RealizedGainTotal)", hfss.nominal_adaptive, "3D")
127+
new_report.variations = variations
128+
new_report.primary_sweep = "Theta"
129+
new_report.create("Realized2D")
130+
131+
###############################################################################
132+
# Multiple Reports
133+
# ----------------
134+
# The same object new_report can be used to create multiple reports.
135+
# In this example a 2d and a 3d polar plot is created.
136+
137+
new_report.report_type = "3D Polar Plot"
138+
new_report.secondary_sweep = "Phi"
139+
new_report.create("Realized3D")
140+
141+
###############################################################################
142+
# Solution Data
143+
# -------------
144+
# The same object new_report can be used to get solution data and post process or plot outside AEDT.
145+
146+
solution_data = new_report.get_solution_data()
147+
solution_data.plot()
148+
149+
###############################################################################
150+
# Far Field Plot
122151
# --------------
123152
# Create post processing variable and assign to new coordinate system.
124153
# A post processing variable can be created directly from setter
@@ -128,42 +157,48 @@
128157
hfss.variable_manager.set_variable("y_post", 1, postprocessing=True)
129158
hfss.modeler.create_coordinate_system(["post_x", "y_post", 0], name="CS_Post")
130159
hfss.insert_infinite_sphere(custom_coordinate_system="CS_Post", name="Sphere_Custom")
160+
131161
###############################################################################
132-
# Postprocessing
133-
# --------------
162+
# Get Solution Data
163+
# -----------------
134164
# The same report can be obtained outside electronic desktop with the
135165
# following commands.
136166

137-
solutions = hfss.post.get_solution_data(
138-
"GainTotal",
139-
hfss.nominal_adaptive,
140-
variations,
141-
primary_sweep_variable="Theta",
142-
context="3D",
143-
report_category="Far Fields",
144-
)
145-
146-
solutions_custom = hfss.post.get_solution_data(
147-
"GainTotal",
148-
hfss.nominal_adaptive,
149-
variations,
150-
primary_sweep_variable="Theta",
151-
context="Sphere_Custom",
152-
report_category="Far Fields",
153-
)
167+
new_report = hfss.post.reports_by_category.far_field("GainTotal", hfss.nominal_adaptive, "3D")
168+
new_report.primary_sweep = "Theta"
169+
new_report.far_field_sphere = "3D"
170+
solutions = new_report.get_solution_data()
171+
# solutions = hfss.post.get_solution_data(
172+
# "GainTotal",
173+
# hfss.nominal_adaptive,
174+
# variations,
175+
# primary_sweep_variable="Theta",
176+
# context="3D",
177+
# report_category="Far Fields",
178+
# )
179+
#
180+
# solutions_custom = hfss.post.get_solution_data(
181+
# "GainTotal",
182+
# hfss.nominal_adaptive,
183+
# variations,
184+
# primary_sweep_variable="Theta",
185+
# context="Sphere_Custom",
186+
# report_category="Far Fields",
187+
# )
154188

155189
###############################################################################
156190
# 3D Plot
157191
# -------
158192
# plot_3d method created a 3d plot using matplotlib.
159-
160193
solutions.plot_3d()
161194

162195
###############################################################################
163196
# 3D Plot
164197
# -------
165198
# plot_3d method created a 3d plot using matplotlib.
166199

200+
new_report.far_field_sphere = "Sphere_Custom"
201+
solutions_custom = new_report.get_solution_data()
167202
solutions_custom.plot_3d()
168203

169204
###############################################################################

0 commit comments

Comments
 (0)