Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
28 changes: 28 additions & 0 deletions src/ansys/dpf/core/fields_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,34 @@ def get_time_scoping(self):
"""
return self.get_label_scoping("time")

def plot(self, label_space: dict = None, **kwargs):
"""Plots the fields in the FieldsContainer for the given LabelSpace.
Check the labels available for the FieldsContainer with
:func:`~fields_container.FieldsContainer.labels`.

Parameters
----------
label_space:
A dictionary (LabelSpace) of labels of the :class:`FieldsContainer` with associated
values to select for plotting.
This is used to filter the data to plot, for example:
- if ``label_space={'time': 10}``: a single time step (mandatory for transient)
- if ``label_space={'complex': 0, 'part': 12}``: real part of complex data for a part
See :func:`~fields_container.FieldsContainer.get_fields`.
If None is given, it renders all fields available, which may not make sense.
**kwargs:
For more information on accepted keyword arguments, see :func:`~field.Field.plot` and
:class:`~plotter.DpfPlotter`.
"""
from ansys.dpf.core import plotter
plt = plotter.DpfPlotter(**kwargs)
if label_space is None:
label_space = {}
fields = self.get_fields(label_space=label_space)
for f in fields:
plt.add_field(field=f, **kwargs)
plt.show_figure(**kwargs)

def animate(self, save_as=None, deform_by=None, scale_factor=1.0, **kwargs):
"""Creates an animation based on the Fields contained in the FieldsContainer.

Expand Down
4 changes: 2 additions & 2 deletions tests/test_fieldscontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,5 +529,5 @@ def test_fields_container_empty_tf_support(server_type):
assert fields_container.time_freq_support == None


if __name__ == "__main__":
test_add_field_by_time_id()
def test_fields_container_plot(server_type, disp_fc):
disp_fc.plot()