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

PlotPowerMonitors: skip filtered modes #6206

Merged
merged 1 commit into from
Aug 13, 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
16 changes: 14 additions & 2 deletions src/Visualization/Python/PlotPowerMonitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def plot_power_monitors(
domain: Union[Domain[1], Domain[2], Domain[3]],
dimension_labels: Sequence[str] = [r"$\xi$", r"$\eta$", r"$\zeta$"],
element_patterns: Optional[Sequence[str]] = None,
skip_filtered_modes: int = 0,
figsize: Optional[Tuple[float, float]] = None,
):
plot_over_time = obs_id is None
Comment on lines 62 to 63
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, but we should move the doc string from the _command function to this function.

Expand Down Expand Up @@ -113,12 +114,14 @@ def plot_power_monitors(

# Compute power monitors and take L2 norm over tensor components
all_modes = [
np.zeros(element.mesh.extents(d)) for d in range(element.dim)
np.zeros(element.mesh.extents(d) - skip_filtered_modes)
for d in range(element.dim)
]
for component in tensor_data:
modes = power_monitors(DataVector(component), element.mesh)
for d, modes_dim in enumerate(modes):
all_modes[d] += modes_dim**2
num_modes = len(modes_dim) - skip_filtered_modes
all_modes[d] += np.array(modes_dim)[:num_modes] ** 2
for d in range(element.dim):
all_modes[d] = np.sqrt(all_modes[d])

Expand Down Expand Up @@ -313,6 +316,15 @@ def plot_power_monitors(
@click.option(
"--over-time", "-T", is_flag=True, help="Plot power monitors over time."
)
@click.option(
"--skip-filtered-modes",
type=int,
default=0,
help=(
"Skip this number of highest modes. Useful if the highest modes are"
" filtered, zeroing them out."
),
)
# Plotting options
@click.option("--figsize", nargs=2, type=float, help="Figure size in inches.")
@apply_stylesheet_command()
Expand Down
Loading