Skip to content

Implemented new method to get all available report quantities categories and all report quantities. #1323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion _unittest/test_12_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def teardown_class(self):
def test_01B_Field_Plot(self):
cutlist = ["Global:XY", "Global:XZ", "Global:YZ"]
setup_name = self.aedtapp.existing_analysis_sweeps[0]
assert self.aedtapp.setups[0].is_solved
quantity_name = "ComplexMag_E"
intrinsic = {"Freq": "5GHz", "Phase": "180deg"}
min_value = self.aedtapp.post.get_scalar_field_value(quantity_name, "Minimum", setup_name, intrinsics="5GHz")
Expand Down Expand Up @@ -254,6 +255,8 @@ def test_09_manipulate_report(self):
assert data.primary_sweep == "Freq"
assert data.expressions[0] == "S(1,1)"
assert len(self.aedtapp.post.all_report_names) > 0
assert self.field_test.setups[0].is_solved

variations = self.field_test.available_variations.nominal_w_values_dict
variations["Theta"] = ["All"]
variations["Phi"] = ["All"]
Expand Down Expand Up @@ -511,7 +514,7 @@ def test_09h_add_line_from_point(self): # pragma: no cover
config["desktopVersion"] < "2022.2", reason="Not working in non-graphical mode in version earlier than 2022.2."
)
def test_09l_add_note(self): # pragma: no cover
new_report = self.aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))")
new_report = self.aedtapp.post.reports_by_category.modal_solution()
new_report.create()

new_report.add_note("Test", 8000, 1500)
Expand Down Expand Up @@ -608,8 +611,11 @@ def test_16_create_field_plot(self):
assert plot

def test_17_circuit(self):
assert not self.circuit_test.setups[0].is_solved

self.circuit_test.analyze_setup("LNA")
self.circuit_test.analyze_setup("Transient")
assert self.circuit_test.setups[0].is_solved
assert self.circuit_test.post.create_report(["dB(S(Port1, Port1))", "dB(S(Port1, Port2))"], "LNA")
new_report = self.circuit_test.post.reports_by_category.standard(
["dB(S(Port1, Port1))", "dB(S(Port1, Port2))"], "LNA"
Expand Down Expand Up @@ -648,10 +654,18 @@ def test_17_circuit(self):
assert self.circuit_test.post.create_report(
["dB(V(net_11))", "dB(V(Port1))"], domain="Spectrum", setup_sweep_name="Transient"
)
new_report = self.circuit_test.post.reports_by_category.spectral(None, "Transient")
new_report.window = "Hanning"
new_report.max_freq = "1GHz"
new_report.time_start = "1ns"
new_report.time_stop = "190ns"
new_report.plot_continous_spectrum = True
assert new_report.create()
pass

def test_18_diff_plot(self):
self.diff_test.analyze_setup("LinearFrequency")
assert self.diff_test.setups[0].is_solved
variations = self.diff_test.available_variations.nominal_w_values_dict
variations["Freq"] = ["All"]
variations["l1"] = ["All"]
Expand Down Expand Up @@ -725,6 +739,7 @@ def test_54_reload(self):
@pytest.mark.skipif(is_ironpython, reason="plot_scene method is not supported in ironpython")
def test_55_time_plot(self):
self.sbr_test.analyze_nominal(use_auto_settings=False)
assert self.sbr_test.setups[0].is_solved
solution_data = self.sbr_test.post.get_solution_data(
expressions=["NearEX", "NearEY", "NearEZ"],
variations={"_u": ["All"], "_v": ["All"], "Freq": ["All"]},
Expand Down Expand Up @@ -778,6 +793,8 @@ def test_57_test_export_q2d_results(self):
new_report = self.q2dtest.post.reports_by_category.rl_fields("Mag_H", polyline="Poly1")
assert new_report.create()
assert len(self.q2dtest.post.plots) == 3
new_report = self.q2dtest.post.reports_by_category.standard()
assert new_report.get_solution_data()

def test_58_test_no_report(self):
assert not self.aedtapp.post.reports_by_category.eye_diagram()
Expand Down
4 changes: 2 additions & 2 deletions pyaedt/application/design_solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,14 @@
"options": "TemperatureAndFlow",
"report_type": "Monitor",
"default_setup": 11,
"default_adaptive": None,
"default_adaptive": "SteadyState",
},
"Transient": {
"name": "Transient",
"options": "TemperatureAndFlow",
"report_type": "Monitor",
"default_setup": 36,
"default_adaptive": None,
"default_adaptive": "Transient",
},
},
"RMxprtSolution": {
Expand Down
168 changes: 126 additions & 42 deletions pyaedt/modules/PostProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"HFSS": [
"Modal Solution Data",
"Terminal Solution Data",
"EigenMode Parameters",
"Eigenmode Parameters",
"Fields",
"Far Fields",
"Emissions",
Expand Down Expand Up @@ -55,6 +55,7 @@
"Icepak": ["Monitor", "Fields"],
"Circuit Design": ["Standard", "Eye Diagram", "Spectrum"],
"HFSS 3D Layout": ["Standard", "Fields", "Spectrum"],
"HFSS 3D Layout Design": ["Standard", "Fields", "Spectrum"],
"Mechanical": ["Standard", "Fields"],
"Q3D Extractor": ["Matrix", "CG Fields", "DC R/L Fields", "AC R/L Fields"],
"2D Extractor": ["Matrix", "CG Fields", "RL Fields"],
Expand All @@ -73,7 +74,7 @@
"Far Fields": rt.FarField,
"Near Fields": rt.NearField,
"Eye Diagram": rt.EyeDiagram,
"EigenMode Parameters": rt.Standard,
"Eigenmode Parameters": rt.Standard,
"Spectrum": rt.Spectral,
}

Expand Down Expand Up @@ -481,8 +482,8 @@ def eigenmode(self, expressions=None, setup_name=None):
"""
if not setup_name:
setup_name = self._post_app._app.nominal_sweep
if "EigenMode Parameters" in self._templates:
rep = rt.Standard(self._post_app, "EigenMode Parameters", setup_name)
if "Eigenmode Parameters" in self._templates:
rep = rt.Standard(self._post_app, "Eigenmode Parameters", setup_name)
rep.expressions = expressions
return rep
return
Expand Down Expand Up @@ -609,6 +610,113 @@ def __init__(self, app):
self.plots = self._get_plot_inputs()
self.reports_by_category = Reports(self, self._app.design_type)

@property
def available_report_types(self):
"""Report types.

References
----------

>>> oModule.GetAvailableReportTypes
"""
return list(self.oreportsetup.GetAvailableReportTypes())

@pyaedt_function_handler()
def available_display_types(self, report_category=None):
"""Retrieve display types for a report categories.

Parameters
----------
report_category : str
Type of the report.

Returns
-------
list
List of available report categories.

References
----------
>>> oModule.GetAvailableDisplayTypes
"""
if not report_category:
report_category = self.available_report_types[0]
if report_category:
return list(self.oreportsetup.GetAvailableDisplayTypes(report_category))
return []

@pyaedt_function_handler()
def available_quantities_categories(self, report_category=None, display_type=None, solution=None, context=""):
"""Compute the list of all available report categories.

Parameters
----------
report_category : str, optional
Report Category. Default is `None` which will take first default category.
display_type : str, optional
Report Display Type.
Default is `None` which will take first default type which is in most of the case "Rectangular Plot".
solution : str, optional
Report Setup. Default is `None` which will take first nominal_adpative solution.
context : str, optional
Report Category. Default is `""` which will take first default context.

Returns
-------
list
"""
if not report_category:
report_category = self.available_report_types[0]
if not display_type:
display_type = self.available_display_types(report_category)[0]
if not solution:
solution = self._app.nominal_adaptive
if solution and report_category and display_type:
return list(self.oreportsetup.GetAllCategories(report_category, display_type, solution, context))
return []

@pyaedt_function_handler()
def available_report_quantities(
self, report_category=None, display_type=None, solution=None, quantities_category=None, context=""
):
"""Compute the list of all available report quantities of a given report quantity category.

Parameters
----------
report_category : str, optional
Report Category. Default is `None` which will take first default category.
display_type : str, optional
Report Display Type.
Default is `None` which will take first default type which is in most of the case "Rectangular Plot".
solution : str, optional
Report Setup. Default is `None` which will take first nominal_adpative solution.
quantities_category : str, optional
The category to which quantities belong. It has to be one of `available_quantities_categories` method.
Default is `None` which will take first default quantity.".
context : str, optional
Report Category. Default is `""` which will take first default context.

Returns
-------
list
"""
if not report_category:
report_category = self.available_report_types[0]
if not display_type:
display_type = self.available_display_types(report_category)[0]
if not solution:
solution = self._app.nominal_adaptive
if not quantities_category:
categories = self.available_quantities_categories(report_category, display_type, solution, context)
quantities_category = categories[0] if categories else None
if quantities_category and display_type and report_category and solution:
return list(
self.oreportsetup.GetAllQuantities(
report_category, display_type, solution, context, quantities_category
)
)
return None

@pyaedt_function_handler()
def _get_plot_inputs(self):
names = self._app.get_oo_name(self.oreportsetup)
Expand Down Expand Up @@ -1013,12 +1121,15 @@ def get_solution_data_per_variation(
if not setup_sweep_name:
setup_sweep_name = self._app.nominal_adaptive
sweep_list = _convert_dict_to_report_sel(sweeps)

data = list(
self.oreportsetup.GetSolutionDataPerVariation(soltype, setup_sweep_name, ctxt, sweep_list, expression)
)
self.logger.info("Solution Data Correctly Loaded.")
return SolutionData(data)
try:
data = list(
self.oreportsetup.GetSolutionDataPerVariation(soltype, setup_sweep_name, ctxt, sweep_list, expression)
)
self.logger.info("Solution Data Correctly Loaded.")
return SolutionData(data)
except:
self.logger.warning("Solution Data failed to load. Check solution, context or expression.")
return None

@pyaedt_function_handler()
def steal_focus_oneditor(self):
Expand Down Expand Up @@ -1762,37 +1873,6 @@ def ofieldsreporter(self):
"""
return self._app.ofieldsreporter

@property
def report_types(self):
"""Report types.

References
----------

>>> oModule.GetAvailableReportTypes
"""
return list(self.oreportsetup.GetAvailableReportTypes())

@pyaedt_function_handler()
def display_types(self, report_type):
"""Retrieve display types for a report type.

Parameters
----------
report_type : str
Type of the report.

Returns
-------
:attr:`pyaedt.modules.PostProcessor.PostProcessor.report_types`

References
----------

>>> oModule.GetAvailableDisplayTypes
"""
return self.oreportsetup.GetAvailableDisplayTypes(report_type)

@pyaedt_function_handler()
def _get_base_name(self, setup):
setups_data = self._app.design_properties["FieldsReporter"]["FieldsPlotManagerID"]
Expand All @@ -1805,7 +1885,11 @@ def _get_base_name(self, setup):
if isinstance(sim_data["SimSetup"], list):
for solution in sim_data["SimSetup"]:
base_name = solution["Name"]
for sol in solution["Solution"]:
if isinstance(solution["Solution"], (dict, OrderedDict)):
sols = [solution["Solution"]]
else:
sols = solution["Solution"]
for sol in sols:
if sol["ID"] == setups_data[setup]["SolutionId"]:
base_name += " : " + sol["Name"]
return base_name
Expand Down
Loading