|
4 | 4 | Extract and explore results metadata |
5 | 5 | ==================================== |
6 | 6 |
|
7 | | -.. |Field| replace:: :class:`Field<ansys.dpf.core.field.Field>` |
8 | | -.. |Examples| replace:: :mod:`Examples<ansys.dpf.core.examples>` |
| 7 | +.. include:: ../../../links_and_refs.rst |
9 | 8 | .. |ResultInfo| replace:: :class:`ResultInfo<ansys.dpf.core.result_info.ResultInfo>` |
10 | 9 |
|
11 | | -You can explore the general results metadata before extracting them by using |
12 | | -the |ResultInfo| object. This metadata includes: |
13 | | - |
14 | | -- Analysis type; |
15 | | -- Physics type; |
16 | | -- Number of results; |
17 | | -- Unit system; |
18 | | -- Solver version, date and time; |
19 | | -- Job name; |
20 | | - |
21 | | -When you extract a result from a result file DPF stores it in a |Field|. |
22 | | -This |Field| will then contain the metadata for the result associated with it. |
23 | | -This metadata includes: |
24 | | - |
25 | | -- Location; |
26 | | -- Scoping; |
27 | | -- Shape of the data stored; |
28 | | -- Number of components; |
29 | | -- Units of the data. |
30 | | - |
31 | 10 | This tutorial shows how to extract and explore results metadata from a result file. |
32 | 11 |
|
| 12 | +:jupyter-download-script:`Download tutorial as Python script<extract_and_explore_results_metadata>` |
| 13 | +:jupyter-download-notebook:`Download tutorial as Jupyter notebook<extract_and_explore_results_metadata>` |
| 14 | + |
33 | 15 | Get the result file |
34 | 16 | ------------------- |
35 | 17 |
|
36 | | -Here we will download a result file available in our |Examples| package. |
37 | | -For more information about how to import your result file in DPF check |
38 | | -the :ref:`ref_tutorials_import_result_file` tutorial. |
| 18 | +First, import a result file. For this tutorial, you can use one available in the |Examples| module. |
| 19 | +For more information about how to import your own result file in DPF, see the :ref:`ref_tutorials_import_result_file` |
| 20 | +tutorial. |
39 | 21 |
|
40 | 22 | .. jupyter-execute:: |
41 | 23 |
|
42 | | - # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage |
| 24 | + # Import the ``ansys.dpf.core`` module |
43 | 25 | from ansys.dpf import core as dpf |
| 26 | + # Import the examples module |
44 | 27 | from ansys.dpf.core import examples |
| 28 | + # Import the operators module |
45 | 29 | from ansys.dpf.core import operators as ops |
46 | 30 |
|
47 | | - # Define the result file |
| 31 | + # Define the result file path |
48 | 32 | result_file_path_1 = examples.download_transient_result() |
49 | 33 | # Create the model |
50 | | - my_model_1 = dpf.Model(data_sources=result_file_path_1) |
| 34 | + model_1 = dpf.Model(data_sources=result_file_path_1) |
51 | 35 |
|
52 | | -Explore the general results metadata |
| 36 | +Explore the results general metadata |
53 | 37 | ------------------------------------ |
54 | 38 |
|
55 | | -Get the |ResultInfo| object from the model and then explore it using this class methods. |
| 39 | +You can explore the general results metadata, before extracting the results, by using |
| 40 | +the |ResultInfo| object and its methods. This metadata includes: |
| 41 | + |
| 42 | +- Analysis type; |
| 43 | +- Physics type; |
| 44 | +- Number of results; |
| 45 | +- Unit system; |
| 46 | +- Solver version, date and time; |
| 47 | +- Job name; |
56 | 48 |
|
57 | 49 | .. jupyter-execute:: |
58 | 50 |
|
59 | 51 | # Define the ResultInfo object |
60 | | - my_result_info_1 = my_model_1.metadata.result_info |
| 52 | + result_info_1 = model_1.metadata.result_info |
61 | 53 |
|
62 | 54 | # Get the analysis type |
63 | | - my_analysis_type = my_result_info_1.analysis_type |
64 | | - print("Analysis type: ",my_analysis_type, "\n") |
| 55 | + analysis_type = result_info_1.analysis_type |
| 56 | + # Print the analysis type |
| 57 | + print("Analysis type: ",analysis_type, "\n") |
65 | 58 |
|
66 | 59 | # Get the physics type |
67 | | - my_physics_type = my_result_info_1.physics_type |
68 | | - print("Physics type: ",my_physics_type, "\n") |
| 60 | + physics_type = result_info_1.physics_type |
| 61 | + # Print the physics type |
| 62 | + print("Physics type: ",physics_type, "\n") |
69 | 63 |
|
70 | 64 | # Get the number of available results |
71 | | - number_of_results = my_result_info_1.n_results |
| 65 | + number_of_results = result_info_1.n_results |
| 66 | + # Print the number of available results |
72 | 67 | print("Number of available results: ",number_of_results, "\n") |
73 | 68 |
|
74 | 69 | # Get the unit system |
75 | | - my_unit_system = my_result_info_1.unit_system |
76 | | - print("Unit system: ",my_unit_system, "\n") |
| 70 | + unit_system = result_info_1.unit_system |
| 71 | + # Print the unit system |
| 72 | + print("Unit system: ",unit_system, "\n") |
77 | 73 |
|
78 | 74 | # Get the solver version, data and time |
79 | | - my_solver_version = my_result_info_1.solver_version |
80 | | - print("Solver version: ",my_solver_version, "\n") |
81 | | - |
82 | | - my_solver_date = my_result_info_1.solver_date |
83 | | - print("Solver date: ", my_solver_date, "\n") |
| 75 | + solver_version = result_info_1.solver_version |
| 76 | + solver_date = result_info_1.solver_date |
| 77 | + solver_time = result_info_1.solver_time |
84 | 78 |
|
85 | | - my_solver_time = my_result_info_1.solver_time |
86 | | - print("Solver time: ",my_solver_time, "\n") |
| 79 | + # Print the solver version, data and time |
| 80 | + print("Solver version: ",solver_version, "\n") |
| 81 | + print("Solver date: ", solver_date, "\n") |
| 82 | + print("Solver time: ",solver_time, "\n") |
87 | 83 |
|
88 | 84 | # Get the job name |
89 | | - my_job_name = my_result_info_1.job_name |
90 | | - print("Job name: ",my_job_name, "\n") |
| 85 | + job_name = result_info_1.job_name |
| 86 | + # Print the job name |
| 87 | + print("Job name: ",job_name, "\n") |
91 | 88 |
|
92 | | -Explore a given result metadata |
93 | | -------------------------------- |
| 89 | +Explore a result metadata |
| 90 | +------------------------- |
| 91 | +When you extract a result from a result file DPF stores it in a |Field|. |
| 92 | +Thus, this |Field| contains the metadata for the result associated with it. |
| 93 | +This metadata includes: |
| 94 | + |
| 95 | +- Location; |
| 96 | +- Scoping (type and quantity of entities); |
| 97 | +- Elementary data count (number of entities, how many data vectors we have); |
| 98 | +- Components count (vectors dimension, here we have a displacement so we expect to have 3 components (X, Y and Z)); |
| 99 | +- Shape of the data stored (tuple with the elementary data count and the components count); |
| 100 | +- Fields size (length of the data entire vector (equal to the number of elementary data times the number of components)); |
| 101 | +- Units of the data. |
94 | 102 |
|
95 | 103 | Here we will explore the metadata of the displacement results. |
96 | 104 |
|
97 | | -Start by extracting the displacement results: |
| 105 | +Start by extracting the displacement results. |
98 | 106 |
|
99 | 107 | .. jupyter-execute:: |
100 | 108 |
|
101 | 109 | # Extract the displacement results |
102 | | - disp_results = my_model_1.results.displacement.eval() |
| 110 | + disp_results = model_1.results.displacement.eval() |
103 | 111 |
|
104 | 112 | # Get the displacement field |
105 | | - my_disp_field = disp_results[0] |
| 113 | + disp_field = disp_results[0] |
106 | 114 |
|
107 | 115 | Explore the displacement results metadata: |
108 | 116 |
|
109 | 117 | .. jupyter-execute:: |
110 | 118 |
|
111 | | - # Location of the displacement data |
112 | | - my_location = my_disp_field.location |
113 | | - print("Location: ", my_location,'\n') |
114 | | - |
115 | | - # Displacement field scoping |
116 | | - my_scoping = my_disp_field.scoping # type and quantity of entities |
117 | | - print("Scoping: ", '\n',my_scoping, '\n') |
118 | | - |
119 | | - my_scoping_ids = my_disp_field.scoping.ids # Available entities ids |
120 | | - print("Scoping ids: ", my_scoping_ids, '\n') |
121 | | - |
122 | | - # Elementary data count |
123 | | - # Number of entities (how many data vectors we have) |
124 | | - my_elementary_data_count = my_disp_field.elementary_data_count |
125 | | - print("Elementary data count: ", my_elementary_data_count, '\n') |
126 | | - |
127 | | - # Components count |
128 | | - # Vectors dimension, here we have a displacement so we expect to have 3 components (X, Y and Z) |
129 | | - my_components_count = my_disp_field.component_count |
130 | | - print("Components count: ", my_components_count, '\n') |
131 | | - |
132 | | - # Size |
133 | | - # Length of the data entire vector (equal to the number of elementary data times the number of components) |
134 | | - my_field_size = my_disp_field.size |
135 | | - print("Size: ", my_field_size, '\n') |
136 | | - |
137 | | - # Fields shape |
138 | | - # Gives a tuple with the elementary data count and the components count |
139 | | - my_shape = my_disp_field.shape |
140 | | - print("Shape: ", my_shape, '\n') |
141 | | - |
142 | | - # Units |
143 | | - my_unit = my_disp_field.unit |
144 | | - print("Unit: ", my_unit, '\n') |
| 119 | + # Get the location of the displacement data |
| 120 | + location = disp_field.location |
| 121 | + # Print the location |
| 122 | + print("Location: ", location,'\n') |
| 123 | + |
| 124 | + # Get the displacement Field scoping |
| 125 | + scoping = disp_field.scoping |
| 126 | + # Print the Field scoping |
| 127 | + print("Scoping: ", '\n',scoping, '\n') |
| 128 | + |
| 129 | + # Get the displacement Field scoping ids |
| 130 | + scoping_ids = disp_field.scoping.ids # Available entities ids |
| 131 | + # Print the Field scoping ids |
| 132 | + print("Scoping ids: ", scoping_ids, '\n') |
| 133 | + |
| 134 | + # Get the displacement Field elementary data count |
| 135 | + elementary_data_count = disp_field.elementary_data_count |
| 136 | + # Print the elementary data count |
| 137 | + print("Elementary data count: ", elementary_data_count, '\n') |
| 138 | + |
| 139 | + # Get the displacement Field components count |
| 140 | + components_count = disp_field.component_count |
| 141 | + # Print the components count |
| 142 | + print("Components count: ", components_count, '\n') |
| 143 | + |
| 144 | + # Get the displacement Field size |
| 145 | + field_size = disp_field.size |
| 146 | + # Print the Field size |
| 147 | + print("Size: ", field_size, '\n') |
| 148 | + |
| 149 | + # Get the displacement Field shape |
| 150 | + shape = disp_field.shape |
| 151 | + # Print the Field shape |
| 152 | + print("Shape: ", shape, '\n') |
| 153 | + |
| 154 | + # Get the displacement Field unit |
| 155 | + unit = disp_field.unit |
| 156 | + # Print the displacement Field unit |
| 157 | + print("Unit: ", unit, '\n') |
0 commit comments