Skip to content
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

【PPSCI Doc No.108-109】update doc for ppsci.visualize.save_plot_from_1d_dict and ppsci.visualize.save_plot_from_3d_dict #764

Merged
merged 1 commit into from
Jan 22, 2024
Merged
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 ppsci/visualize/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ def save_plot_from_1d_dict(
coord_keys (Tuple[str, ...]): Tuple of coord key. such as ("x", "y").
value_keys (Tuple[str, ...]): Tuple of value key. such as ("u", "v").
num_timestamps (int, optional): Number of timestamp in data_dict. Defaults to 1.

Examples:
>>> import ppsci
>>> import numpy as np
>>> filename = "path/to/file"
>>> data_dict = {
... "x": np.array([[1], [2], [3],[4]]),
... "u": np.array([[4], [5], [6],[4]]),
... }
>>> coord_keys = ("x",)
>>> value_keys = ("u",)
>>> ppsci.visualize.save_plot_from_1d_dict(filename, data_dict, coord_keys, value_keys) # doctest: +SKIP
"""
space_ndim = len(coord_keys) - int("t" in coord_keys)
if space_ndim not in [1, 2, 3]:
Expand Down Expand Up @@ -375,6 +387,22 @@ def save_plot_from_3d_dict(
data_dict (Dict[str, Union[np.ndarray, paddle.Tensor]]): Data in dict.
visu_keys (Tuple[str, ...]): Keys for visualizing data. such as ("u", "v").
num_timestamps (int, optional): Number of timestamp in data_dict. Defaults to 1.

Examples:
>>> import numpy as np
>>> import ppsci

>>> data_dict = {
... "u": np.array([[[10], [20], [30], [40], [50]]]),
... "v": np.array([[[5], [15], [25], [35], [45]]]),
... }

>>> ppsci.visualize.save_plot_from_3d_dict(
... "path/to/file",
... data_dict,
... ("u", "v"),
... 1,
... ) # doctest: +SKIP
"""

visu_data = [data_dict[k] for k in visu_keys]
Expand Down