Skip to content

Commit b81a7e4

Browse files
update the extract_and_explore_results_metadata.rst to the tutorials guidelines
1 parent e8ba0d4 commit b81a7e4

File tree

1 file changed

+99
-86
lines changed

1 file changed

+99
-86
lines changed

doc/source/user_guide/tutorials/import_data/extract_and_explore_results_metadata.rst

Lines changed: 99 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -4,141 +4,154 @@
44
Extract and explore results metadata
55
====================================
66

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
98
.. |ResultInfo| replace:: :class:`ResultInfo<ansys.dpf.core.result_info.ResultInfo>`
109

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-
3110
This tutorial shows how to extract and explore results metadata from a result file.
3211

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+
3315
Get the result file
3416
-------------------
3517

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.
3921

4022
.. jupyter-execute::
4123

42-
# Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage
24+
# Import the ``ansys.dpf.core`` module
4325
from ansys.dpf import core as dpf
26+
# Import the examples module
4427
from ansys.dpf.core import examples
28+
# Import the operators module
4529
from ansys.dpf.core import operators as ops
4630

47-
# Define the result file
31+
# Define the result file path
4832
result_file_path_1 = examples.download_transient_result()
4933
# 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)
5135

52-
Explore the general results metadata
36+
Explore the results general metadata
5337
------------------------------------
5438

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;
5648

5749
.. jupyter-execute::
5850

5951
# Define the ResultInfo object
60-
my_result_info_1 = my_model_1.metadata.result_info
52+
result_info_1 = model_1.metadata.result_info
6153

6254
# 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")
6558

6659
# 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")
6963

7064
# 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
7267
print("Number of available results: ",number_of_results, "\n")
7368

7469
# 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")
7773

7874
# 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
8478

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")
8783

8884
# 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")
9188

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.
94102

95103
Here we will explore the metadata of the displacement results.
96104

97-
Start by extracting the displacement results:
105+
Start by extracting the displacement results.
98106

99107
.. jupyter-execute::
100108

101109
# Extract the displacement results
102-
disp_results = my_model_1.results.displacement.eval()
110+
disp_results = model_1.results.displacement.eval()
103111

104112
# Get the displacement field
105-
my_disp_field = disp_results[0]
113+
disp_field = disp_results[0]
106114

107115
Explore the displacement results metadata:
108116

109117
.. jupyter-execute::
110118

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

Comments
 (0)