-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add DataFrame.min and DataFrame.max over 'set_ids' axis or MeshIndex #333
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2d97cb4
DataFrame.min and DataFrame.max over time-Index and MeshIndex
PProfizi e9af80f
DataFrame.min and DataFrame.max over time-Index and MeshIndex
PProfizi 5bc0d0c
WIP mean
PProfizi 6372268
Revert "WIP mean"
PProfizi 450450c
Improve docstring
PProfizi 6a600e0
Merge branch 'master' into feat/dataframe_min_max_mean
PProfizi 4bcaec3
Fix step "Set licensing if necessary" in CI and CI_release for retro …
PProfizi 9764599
Fix ANSYS_VERSION for "upload test results" step of retro in ci.yml a…
PProfizi 341f4c8
Merge branch 'master' into feat/dataframe_min_max_mean
PProfizi 6a553cb
Update example to remove mention of mean
PProfizi 2478cf7
Update example
PProfizi 7ecde11
Add examples to docstrings
PProfizi 4d9615e
Fix docstring examples
PProfizi 702cc2f
Take comments into account
PProfizi d5fe0c7
Fix docstring example for min
PProfizi 5f8c145
Rename example 06-compute-min-max.py
PProfizi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
""" | ||
.. _ref_compute_statistics_example: | ||
|
||
Compute minimum and maximum of a DataFrame | ||
========================================== | ||
In this example, transient mechanical displacement data is used | ||
to show how to compute the min or max of a given DataFrame. | ||
""" | ||
|
||
############################################################################### | ||
# Perform required imports | ||
# ------------------------ | ||
# This example uses a supplied file that you can | ||
# get using the ``examples`` module. | ||
|
||
from ansys.dpf import post | ||
from ansys.dpf.post import examples | ||
|
||
############################################################################### | ||
# Get ``Simulation`` object | ||
# ------------------------- | ||
# Get the ``Simulation`` object that allows access to the result. The ``Simulation`` | ||
# object must be instantiated with the path for the result file. For example, | ||
# ``"C:/Users/user/my_result.rst"`` on Windows or ``"/home/user/my_result.rst"`` | ||
# on Linux. | ||
|
||
example_path = examples.download_crankshaft() | ||
simulation = post.StaticMechanicalSimulation(example_path) | ||
|
||
# print the simulation to get an overview of what's available | ||
print(simulation) | ||
|
||
############################################################################### | ||
# Extract displacement data | ||
# ------------------------- | ||
|
||
displacement = simulation.displacement(all_sets=True) | ||
print(displacement) | ||
|
||
############################################################################### | ||
# Compute the maximum displacement for each component at each time-step | ||
# --------------------------------------------------------------------- | ||
|
||
# The default axis is the MeshIndex | ||
maximum_over_mesh = displacement.max() | ||
print(maximum_over_mesh) | ||
# is equivalent to | ||
maximum_over_mesh = displacement.max(axis="node_ids") | ||
print(maximum_over_mesh) | ||
|
||
# Compute the maximum displacement for each node and component across time | ||
# ------------------------------------------------------------------------ | ||
maximum_over_time = displacement.max(axis="set_ids") | ||
print(maximum_over_time) | ||
|
||
# Compute the maximum displacement overall | ||
# ---------------------------------------- | ||
maximum_overall = maximum_over_time.max() | ||
print(maximum_overall) | ||
|
||
############################################################################### | ||
# Compute the minimum displacement for each component at each time-step | ||
# --------------------------------------------------------------------- | ||
|
||
# The default axis is the MeshIndex | ||
minimum_over_mesh = displacement.min() | ||
print(minimum_over_mesh) | ||
# is equivalent to | ||
minimum_over_mesh = displacement.min(axis="node_ids") | ||
print(minimum_over_mesh) | ||
|
||
# Compute the minimum displacement for each node and component across time | ||
# ------------------------------------------------------------------------ | ||
minimum_over_time = displacement.min(axis="set_ids") | ||
print(minimum_over_time) | ||
|
||
# Compute the minimum displacement overall | ||
# ---------------------------------------- | ||
minimum_overall = minimum_over_time.min() | ||
print(minimum_overall) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it expected to expose and use a protected attribute
_fc
for the field containers?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaxJPRey not to the user. We do have
._core_object
property though which we will implement for all classes wrapping a Core entity to give easy access in case it is needed.Here in the tests this allows me to compare the result of the max operation with doing the same thing directly on the data held by the underlying fields container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, got it. Thanks for the info.