/
PostProcessor.py
5469 lines (4956 loc) · 209 KB
/
PostProcessor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
This module contains these classes: `FieldPlot`, `PostProcessor`, and `SolutionData`.
This module provides all functionalities for creating and editing plots in the 3D tools.
"""
from __future__ import absolute_import # noreorder
import ast
from collections import OrderedDict
from collections import defaultdict
import csv
import os
import random
import re
import string
import tempfile
from pyaedt import is_ironpython
from pyaedt.application.Variables import decompose_variable_value
from pyaedt.generic.DataHandlers import _dict_items_to_list_items
from pyaedt.generic.constants import unit_converter
from pyaedt.generic.general_methods import check_and_download_file
from pyaedt.generic.general_methods import generate_unique_name
from pyaedt.generic.general_methods import open_file
from pyaedt.generic.general_methods import pyaedt_function_handler
from pyaedt.generic.general_methods import read_configuration_file
from pyaedt.generic.settings import settings
from pyaedt.modeler.cad.elements3d import FacePrimitive
import pyaedt.modules.report_templates as rt
from pyaedt.modules.solutions import FieldPlot
from pyaedt.modules.solutions import SolutionData
from pyaedt.modules.solutions import VRTFieldPlot
if not is_ironpython:
try:
from enum import Enum
import pandas as pd
except ImportError: # pragma: no cover
pd = None
Enum = None
else: # pragma: no cover
Enum = object
TEMPLATES_BY_DESIGN = {
"HFSS": [
"Modal Solution Data",
"Terminal Solution Data",
"Eigenmode Parameters",
"Fields",
"Far Fields",
"Emissions",
"Near Fields",
"Antenna Parameters",
],
"Maxwell 3D": [
"Transient",
"EddyCurrent",
"Magnetostatic",
"Electrostatic",
"DCConduction",
"ElectroDCConduction",
"ElectricTransient",
"Fields",
"Spectrum",
],
"Maxwell 2D": [
"Transient",
"EddyCurrent",
"Magnetostatic",
"Electrostatic",
"ElectricTransient",
"ElectroDCConduction",
"Fields",
"Spectrum",
],
"Icepak": ["Monitor", "Fields"],
"Circuit Design": ["Standard", "Eye Diagram", "Statistical Eye", "Spectrum", "EMIReceiver"],
"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"],
"Twin Builder": ["Standard", "Spectrum"],
}
TEMPLATES_BY_NAME = {
"Standard": rt.Standard,
"Modal Solution Data": rt.Standard,
"Terminal Solution Data": rt.Standard,
"Fields": rt.Fields,
"CG Fields": rt.Fields,
"DC R/L Fields": rt.Fields,
"AC R/L Fields": rt.Fields,
"Matrix": rt.Standard,
"Monitor": rt.Standard,
"Far Fields": rt.FarField,
"Near Fields": rt.NearField,
"Eye Diagram": rt.EyeDiagram,
"Statistical Eye": rt.AMIEyeDiagram,
"AMI Contour": rt.AMIConturEyeDiagram,
"Eigenmode Parameters": rt.Standard,
"Spectrum": rt.Spectral,
"EMIReceiver": rt.EMIReceiver,
}
class Reports(object):
"""Provides the names of default solution types."""
def __init__(self, post_app, design_type):
self._post_app = post_app
self._design_type = design_type
self._templates = TEMPLATES_BY_DESIGN.get(self._design_type, None)
@pyaedt_function_handler()
def _retrieve_default_expressions(self, expressions, report, setup_sweep_name):
if expressions:
return expressions
setup_only_name = setup_sweep_name.split(":")[0].strip()
get_setup = self._post_app._app.get_setup(setup_only_name)
is_siwave_dc = False
if (
"SolveSetupType" in get_setup.props and get_setup.props["SolveSetupType"] == "SiwaveDCIR"
): # pragma: no cover
is_siwave_dc = True
return self._post_app.available_report_quantities(
solution=setup_sweep_name, context=report._context, is_siwave_dc=is_siwave_dc
)
@pyaedt_function_handler(setup_name="setup")
def standard(self, expressions=None, setup=None):
"""Create a standard or default report object.
Parameters
----------
expressions : str or list
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 : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
Returns
-------
:class:`pyaedt.modules.report_templates.Standard`
Examples
--------
>>> from pyaedt import Circuit
>>> cir = Circuit(my_project)
>>> report = cir.post.reports_by_category.standard("dB(S(1,1))","LNA")
>>> report.create()
>>> solutions = report.get_solution_data()
>>> report2 = cir.post.reports_by_category.standard(["dB(S(2,1))", "dB(S(2,2))"],"LNA")
"""
if not setup:
setup = self._post_app._app.nominal_sweep
rep = None
if "Standard" in self._templates:
rep = rt.Standard(self._post_app, "Standard", setup)
elif self._post_app._app.design_solutions.report_type:
rep = rt.Standard(self._post_app, self._post_app._app.design_solutions.report_type, setup)
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
@pyaedt_function_handler(setup_name="setup")
def monitor(self, expressions=None, setup=None):
"""Create an Icepak Monitor Report object.
Parameters
----------
expressions : str or list
One or more expressions to add to the report. The expression can be any of the available formula
you can enter into the Electronics Desktop Report Editor.
setup : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
Returns
-------
:class:`pyaedt.modules.report_templates.Standard`
Examples
--------
>>> from pyaedt import Icepak
>>> ipk = Icepak(my_project)
>>> report = ipk.post.reports_by_category.monitor(["monitor_surf.Temperature","monitor_point.Temperature"])
>>> report = report.create()
"""
if not setup:
setup = self._post_app._app.nominal_sweep
rep = None
if "Monitor" in self._templates:
rep = rt.Standard(self._post_app, "Monitor", setup)
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
@pyaedt_function_handler(setup_name="setup")
def fields(self, expressions=None, setup=None, polyline=None):
"""Create a Field Report object.
Parameters
----------
expressions : str or list
One or more expressions to add to the report. The expression can be any of the available formula
you can enter into the Electronics Desktop Report Editor.
setup : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
polyline : str, optional
Name of the polyline to plot the field on.
If a name is not provided, the report might be incorrect.
The default value is ``None``.
Returns
-------
:class:`pyaedt.modules.report_templates.Fields`
Examples
--------
>>> from pyaedt import Hfss
>>> hfss = Hfss(my_project)
>>> report = hfss.post.reports_by_category.fields("Mag_E", "Setup : LastAdaptive", "Polyline1")
>>> report.create()
>>> solutions = report.get_solution_data()
"""
if not setup:
setup = self._post_app._app.nominal_sweep
rep = None
if "Fields" in self._templates:
rep = rt.Fields(self._post_app, "Fields", setup)
rep.polyline = polyline
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
@pyaedt_function_handler(setup_name="setup")
def cg_fields(self, expressions=None, setup=None, polyline=None):
"""Create a CG Field Report object in Q3D and Q2D.
Parameters
----------
expressions : str or list
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 : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
polyline : str, optional
Name of the polyline to plot the field on.
If a name is not provided, the report might be incorrect.
The default value is ``None``.
Returns
-------
:class:`pyaedt.modules.report_templates.Fields`
Examples
--------
>>> from pyaedt import Q3d
>>> q3d = Q3d(my_project)
>>> report = q3d.post.reports_by_category.cg_fields("SmoothQ", "Setup : LastAdaptive", "Polyline1")
>>> report.create()
>>> solutions = report.get_solution_data()
"""
if not setup:
setup = self._post_app._app.nominal_sweep
rep = None
if "CG Fields" in self._templates:
rep = rt.Fields(self._post_app, "CG Fields", setup)
rep.polyline = polyline
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
@pyaedt_function_handler(setup_name="setup")
def dc_fields(self, expressions=None, setup=None, polyline=None):
"""Create a DC Field Report object in Q3D.
Parameters
----------
expressions : str or list
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 : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
polyline : str, optional
Name of the polyline to plot the field on.
If a name is not provided, the report might be incorrect.
The default value is ``None``.
Returns
-------
:class:`pyaedt.modules.report_templates.Fields`
Examples
--------
>>> from pyaedt import Q3d
>>> q3d = Q3d(my_project)
>>> report = q3d.post.reports_by_category.dc_fields("Mag_VolumeJdc", "Setup : LastAdaptive", "Polyline1")
>>> report.create()
>>> solutions = report.get_solution_data()
"""
if not setup:
setup = self._post_app._app.nominal_sweep
rep = None
if "DC R/L Fields" in self._templates:
rep = rt.Fields(self._post_app, "DC R/L Fields", setup)
rep.polyline = polyline
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
@pyaedt_function_handler(setup_name="setup")
def rl_fields(self, expressions=None, setup=None, polyline=None):
"""Create an AC RL Field Report object in Q3D and Q2D.
Parameters
----------
expressions : str or list
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 : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
polyline : str, optional
Name of the polyline to plot the field on.
If a name is not provided, the report might be incorrect.
The default value is ``None``.
Returns
-------
:class:`pyaedt.modules.report_templates.Fields`
Examples
--------
>>> from pyaedt import Q3d
>>> q3d = Q3d(my_project)
>>> report = q3d.post.reports_by_category.rl_fields("Mag_SurfaceJac", "Setup : LastAdaptive", "Polyline1")
>>> report.create()
>>> solutions = report.get_solution_data()
"""
if not setup:
setup = self._post_app._app.nominal_sweep
rep = None
if "AC R/L Fields" in self._templates or "RL Fields" in self._templates:
if self._post_app._app.design_type == "Q3D Extractor":
rep = rt.Fields(self._post_app, "AC R/L Fields", setup)
else:
rep = rt.Fields(self._post_app, "RL Fields", setup)
rep.polyline = polyline
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
@pyaedt_function_handler(setup_name="setup")
def far_field(self, expressions=None, setup=None, sphere_name=None, source_context=None):
"""Create a Far Field Report object.
Parameters
----------
expressions : str or list
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 : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
sphere_name : str, optional
Name of the sphere to create the far field on.
source_context : str, optional
Name of the active source to create the far field on.
Returns
-------
:class:`pyaedt.modules.report_templates.FarField`
Examples
--------
>>> from pyaedt import Hfss
>>> hfss = Hfss(my_project)
>>> report = hfss.post.reports_by_category.far_field("GainTotal", "Setup : LastAdaptive", "3D_Sphere")
>>> report.primary_sweep = "Phi"
>>> report.create()
>>> solutions = report.get_solution_data()
"""
if not setup:
setup = self._post_app._app.nominal_sweep
rep = None
if "Far Fields" in self._templates:
rep = rt.FarField(self._post_app, "Far Fields", setup)
rep.far_field_sphere = sphere_name
rep.source_context = source_context
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
@pyaedt_function_handler(setup_name="setup", sphere_name="infinite_sphere")
def antenna_parameters(self, expressions=None, setup=None, infinite_sphere=None):
"""Create an Antenna Parameters Report object.
Parameters
----------
expressions : str or list
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 : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
infinite_sphere : str, optional
Name of the sphere to compute antenna parameters on.
Returns
-------
:class:`pyaedt.modules.report_templates.AntennaParameters`
Examples
--------
>>> from pyaedt import Hfss
>>> hfss = Hfss(my_project)
>>> report = hfss.post.reports_by_category.antenna_parameters("GainTotal", "Setup : LastAdaptive", "3D_Sphere")
>>> report.create()
>>> solutions = report.get_solution_data()
"""
if not setup:
setup = self._post_app._app.nominal_sweep
rep = None
if "Antenna Parameters" in self._templates:
rep = rt.AntennaParameters(self._post_app, "Antenna Parameters", setup, infinite_sphere)
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
@pyaedt_function_handler(setup_name="setup")
def near_field(self, expressions=None, setup=None):
"""Create a Field Report object.
Parameters
----------
expressions : str or list
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 : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
Returns
-------
:class:`pyaedt.modules.report_templates.NearField`
Examples
--------
>>> from pyaedt import Hfss
>>> hfss = Hfss(my_project)
>>> report = hfss.post.reports_by_category.near_field("GainTotal", "Setup : LastAdaptive", "NF_1")
>>> report.primary_sweep = "Phi"
>>> report.create()
>>> solutions = report.get_solution_data()
"""
if not setup:
setup = self._post_app._app.nominal_sweep
rep = None
if "Near Fields" in self._templates:
rep = rt.NearField(self._post_app, "Near Fields", setup)
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
@pyaedt_function_handler(setup_name="setup")
def modal_solution(self, expressions=None, setup=None):
"""Create a Standard or Default Report object.
Parameters
----------
expressions : str or list
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 : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
Returns
-------
:class:`pyaedt.modules.report_templates.Standard`
Examples
--------
>>> from pyaedt import Hfss
>>> hfss = Hfss(my_project)
>>> report = hfss.post.reports_by_category.modal_solution("dB(S(1,1))")
>>> report.create()
>>> solutions = report.get_solution_data()
"""
if not setup:
setup = self._post_app._app.nominal_sweep
rep = None
if "Modal Solution Data" in self._templates:
rep = rt.Standard(self._post_app, "Modal Solution Data", setup)
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
@pyaedt_function_handler(setup_name="setup")
def terminal_solution(self, expressions=None, setup=None):
"""Create a Standard or Default Report object.
Parameters
----------
expressions : str or list
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 : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
Returns
-------
:class:`pyaedt.modules.report_templates.Standard`
Examples
--------
>>> from pyaedt import Hfss
>>> hfss = Hfss(my_project)
>>> report = hfss.post.reports_by_category.terminal_solution("dB(S(1,1))")
>>> report.create()
>>> solutions = report.get_solution_data()
"""
if not setup:
setup = self._post_app._app.nominal_sweep
rep = None
if "Terminal Solution Data" in self._templates:
rep = rt.Standard(self._post_app, "Terminal Solution Data", setup)
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
@pyaedt_function_handler(setup_name="setup")
def eigenmode(self, expressions=None, setup=None):
"""Create a Standard or Default Report object.
Parameters
----------
expressions : str or list
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 : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
Returns
-------
:class:`pyaedt.modules.report_templates.Standard`
Examples
--------
>>> from pyaedt import Hfss
>>> hfss = Hfss(my_project)
>>> report = hfss.post.reports_by_category.eigenmode("dB(S(1,1))")
>>> report.create()
>>> solutions = report.get_solution_data()
"""
if not setup:
setup = self._post_app._app.nominal_sweep
rep = None
if "Eigenmode Parameters" in self._templates:
rep = rt.Standard(self._post_app, "Eigenmode Parameters", setup)
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
@pyaedt_function_handler(setup_name="setup")
def statistical_eye_contour(self, expressions=None, setup=None, quantity_type=3):
"""Create a standard statistical AMI contour plot.
Parameters
----------
expressions : str
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 : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is either the sweep
name to use in the export or ``LastAdaptive``.
quantity_type : int, optional
For AMI analysis only, the quantity type. The default is ``3``. Options are:
- ``0`` for Initial Wave
- ``1`` for Wave after Source
- ``2`` for Wave after Channel
- ``3`` for Wave after Probe.
Returns
-------
:class:`pyaedt.modules.report_templates.AMIConturEyeDiagram`
Examples
--------
>>> from pyaedt import Circuit
>>> cir= Circuit()
>>> new_eye = cir.post.reports_by_category.statistical_eye_contour("V(Vout)")
>>> new_eye.unit_interval = "1e-9s"
>>> new_eye.time_stop = "100ns"
>>> new_eye.create()
"""
if not setup:
for setup in self._post_app._app.setups:
if "AMIAnalysis" in setup.props:
setup = setup.name
if not setup:
self._post_app._app.logger.error("AMI analysis is needed to create this report.")
return False
if isinstance(expressions, list):
expressions = expressions[0]
report_cat = "Standard"
rep = rt.AMIConturEyeDiagram(self._post_app, report_cat, setup)
rep.quantity_type = quantity_type
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
return
@pyaedt_function_handler(setup_name="setup")
def eye_diagram(
self, expressions=None, setup=None, quantity_type=3, statistical_analysis=True, unit_interval="1ns"
):
"""Create a Standard or Default Report object.
Parameters
----------
expressions : str
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 : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
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.
statistical_analysis : bool, optional
For AMI Analysis only, whether to plot the statistical eye plot or transient eye plot.
The default is ``True``.
unit_interval : str, optional
Unit interval for the eye diagram.
Returns
-------
:class:`pyaedt.modules.report_templates.Standard`
Examples
--------
>>> from pyaedt import Circuit
>>> cir= Circuit()
>>> new_eye = cir.post.reports_by_category.eye_diagram("V(Vout)")
>>> new_eye.unit_interval = "1e-9s"
>>> new_eye.time_stop = "100ns"
>>> new_eye.create()
"""
if not setup:
setup = self._post_app._app.nominal_sweep
if "Eye Diagram" in self._templates:
if "AMIAnalysis" in self._post_app._app.get_setup(setup).props:
report_cat = "Eye Diagram"
if statistical_analysis:
report_cat = "Statistical Eye"
rep = rt.AMIEyeDiagram(self._post_app, report_cat, setup)
rep.quantity_type = quantity_type
expressions = self._retrieve_default_expressions(expressions, rep, setup)
if isinstance(expressions, list):
rep.expressions = expressions[0]
return rep
else:
rep = rt.EyeDiagram(self._post_app, "Eye Diagram", setup)
rep.unit_interval = unit_interval
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
return
@pyaedt_function_handler(setup_name="setup")
def spectral(self, expressions=None, setup=None):
"""Create a Spectral Report object.
Parameters
----------
expressions : str or list, optional
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 : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is the sweep name to
use in the export or ``LastAdaptive``.
Returns
-------
:class:`pyaedt.modules.report_templates.Spectrum`
Examples
--------
>>> from pyaedt import Circuit
>>> cir= Circuit()
>>> new_eye = cir.post.reports_by_category.spectral("V(Vout)")
>>> new_eye.create()
"""
if not setup:
setup = self._post_app._app.nominal_sweep
rep = None
if "Spectrum" in self._templates:
rep = rt.Spectral(self._post_app, "Spectrum", setup)
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup)
return rep
@pyaedt_function_handler()
def emi_receiver(self, expressions=None, setup_name=None):
"""Create an EMI receiver report.
Parameters
----------
expressions : str or list, optional
One or more expressions to add into the report. An expression can be any of the formulas that
can be entered into the Electronics Desktop Report Editor.
setup_name : str, optional
Name of the setup. The default is ``None``, in which case the ``nominal_adaptive``
setup is used. Be sure to build a setup string in the form of
``"SetupName : SetupSweep"``, where ``SetupSweep`` is either the sweep name
to use in the export or ``LastAdaptive``.
Returns
-------
:class:`pyaedt.modules.report_templates.EMIReceiver`
Examples
--------
>>> from pyaedt import Circuit
>>> cir= Circuit()
>>> new_eye = cir.post.emi_receiver()
>>> new_eye.create()
"""
if not setup_name:
setup_name = self._post_app._app.nominal_sweep
rep = None
if "EMIReceiver" in self._templates and self._post_app._app.desktop_class.aedt_version_id > "2023.2":
rep = rt.EMIReceiver(self._post_app, setup_name)
if not expressions:
expressions = "Average[{}]".format(rep.net)
else:
if not isinstance(expressions, list):
expressions = [expressions]
pattern = r"\w+\[(.*?)\]"
for expression in expressions:
match = re.search(pattern, expression)
if match:
net_name = match.group(1)
rep.net = net_name
rep.expressions = self._retrieve_default_expressions(expressions, rep, setup_name)
return rep
orientation_to_view = {
"isometric": "iso",
"top": "XY",
"bottom": "XY",
"right": "XZ",
"left": "XZ",
"front": "YZ",
"back": "YZ",
}
@pyaedt_function_handler()
def _convert_dict_to_report_sel(sweeps):
if isinstance(sweeps, list):
return sweeps
sweep_list = []
for el in sweeps:
sweep_list.append(el + ":=")
if isinstance(sweeps[el], list):
sweep_list.append(sweeps[el])
else:
sweep_list.append([sweeps[el]])
return sweep_list
class PostProcessorCommon(object):
"""Manages the main AEDT postprocessing functions.
This class is inherited in the caller application and is accessible through the post variable( eg. ``hfss.post`` or
``q3d.post``).
.. note::
Some functionalities are available only when AEDT is running in
the graphical mode.
Parameters
----------
app : :class:`pyaedt.application.Analsis3D.FieldAnalysis3D`
Inherited parent object. The parent object must provide the members
``_modeler``, ``_desktop``, ``_odesign``, and ``logger``.
Examples
--------
>>> from pyaedt import Q3d
>>> q3d = Q3d()
>>> q3d = q.post.get_solution_data(domain="Original")
"""
def __init__(self, app):
self._app = app
self.oeditor = self.modeler.oeditor
self._scratch = self._app.working_directory
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())
@property
def update_report_dynamically(self):
"""Get/Set the boolean to automatically update reports on edits.
Returns
-------
bool
"""
return (
True
if self._app.odesktop.GetRegistryInt(
"Desktop/Settings/ProjectOptions/{}/UpdateReportsDynamicallyOnEdits".format(self._app.design_type)
)
== 1
else False
)
@update_report_dynamically.setter
def update_report_dynamically(self, value):
if value:
self._app.odesktop.SetRegistryInt(
"Desktop/Settings/ProjectOptions/{}/UpdateReportsDynamicallyOnEdits".format(self._app.design_type), 1
)
else: # pragma: no cover
self._app.odesktop.SetRegistryInt(
"Desktop/Settings/ProjectOptions/{}/UpdateReportsDynamicallyOnEdits".format(self._app.design_type), 0
)
@pyaedt_function_handler()
def available_display_types(self, report_category=None):
"""Retrieve display types for a report categories.
Parameters
----------
report_category : str, optional
Type of the report. The default value is ``None``.
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 [] # pragma: no cover
@pyaedt_function_handler()
def available_quantities_categories(
self, report_category=None, display_type=None, solution=None, context="", is_siwave_dc=False
):
"""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_adaptive solution.
context : str, optional
Report Category. Default is `""` which will take first default context.
is_siwave_dc : bool, optional
Whether if the setup is Siwave DCIR or not. Default is ``False``.
Returns
-------
list
References
----------
>>> oModule.GetAllCategories
"""
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 is_siwave_dc: # pragma: no cover
id_ = "0"
if context:
id_ = str(
[
"RL",
"Sources",
"Vias",
"Bondwires",
"Probes",
].index(context)
)
context = [
"NAME:Context",
"SimValueContext:=",
[37010, 0, 2, 0, False, False, -1, 1, 0, 1, 1, "", 0, 0, "DCIRID", False, id_, "IDIID", False, "1"],
]
elif not context: # pragma: no cover
context = ""
if solution and report_category and display_type:
return list(self.oreportsetup.GetAllCategories(report_category, display_type, solution, context))
return [] # pragma: no cover
@pyaedt_function_handler()
def available_report_quantities(
self,
report_category=None,
display_type=None,
solution=None,
quantities_category=None,
context="",
is_siwave_dc=False,
):
"""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