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

Add script to plot power monitors #4663

Merged
merged 5 commits into from
Feb 7, 2023

Conversation

nilsvu
Copy link
Member

@nilsvu nilsvu commented Jan 30, 2023

Proposed changes

Creates plots like this:

plot

Invoke the script like this:

$ spectre plot-power-monitors ElasticityVolume0.h5  -d VolumeData \
    -b InnerCube -b Wedges -y 'Displacement_*' -o plot.pdf

Upgrade instructions

Code review checklist

  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.
  • The PR lists upgrade instructions and is labeled bugfix or
    new feature if appropriate.

Further comments

@nilsvu nilsvu added the new feature Adds a new feature that's worth highlighting in release notes label Jan 30, 2023
Comment on lines +44 to +46
fig, axes = plt.subplots(nrows=1,
ncols=num_plots,
figsize=(num_plots * 4, 4),
Copy link
Contributor

Choose a reason for hiding this comment

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

If you have more than two plots, this seems like it'll just create a super wide image/pdf. Is that intended? What about rows of 2 plots?

Copy link
Member Author

Choose a reason for hiding this comment

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

You choose the block groups on the command line, so you probably won't make plots with more than 3 or 4 block groups. Also, the single row helps comparing the truncation errors side-by-side. So I'd keep the single row for now. If this becomes an issue we can think of ways to organize the plot layout better.

Comment on lines +95 to +96
for d, modes_dim in enumerate(all_modes):
ax.semilogy(modes_dim, **props_dim[d], zorder=30 + d)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 30? Just a large number?

Copy link
Member Author

Choose a reason for hiding this comment

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

yea for the zorder only relative numbers matter

Comment on lines 148 to 158
help=("Observation step number. "
"Specify '-1' for the last step in the file. "
"Mutually exclusive with '--time'."))
Copy link
Contributor

Choose a reason for hiding this comment

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

How hard would it be to use last or Last to specify the last step rather than -1. When I was looking at the command, the -1 looked like its own option unrelated to --step (because of the hyphen/negative).

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Comment on lines 160 to 164
@click.option("--block",
"-b",
"block_or_group_names",
multiple=True,
help=("Names of blocks or block groups to analyze."))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the multiple=True propagate to the help text? If not, could you add that to the help text?

Copy link
Contributor

@knelli2 knelli2 left a comment

Choose a reason for hiding this comment

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

Looks good. You can squash

@nilsvu
Copy link
Member Author

nilsvu commented Jan 31, 2023

@nikwit or @guilara could one of you have a quick look over this, since you've been working on power monitors?

@guilara
Copy link
Contributor

guilara commented Feb 1, 2023

Nice! Looks good to me @nilsvu

@nilsvu
Copy link
Member Author

nilsvu commented Feb 2, 2023

@sxs-collaboration/spectre-core-devs could one of you sign off on this? The CylindricalBBH domain test timed out so I restarted the one build.



if __name__ == "__main__":
plot_power_monitors_command(help_option_names=["-h", "--help"])
Copy link
Member

Choose a reason for hiding this comment

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

When I run this with -h what general info do I get? I find it useful to have a description of what the code does in addition to the options.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching this, I forgot to add a docstring here. See fixup.

@click.option("--output",
"-o",
type=click.Path(writable=True),
help=("Output text file"))
Copy link
Member

Choose a reason for hiding this comment

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

what is saved into this text file? And where are is the image with the PM plots saved?

Copy link
Member Author

Choose a reason for hiding this comment

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

The help text was just wrong, thanks for catching this as well.

@nilsvu nilsvu linked an issue Feb 6, 2023 that may be closed by this pull request
5 tasks
@nilsvu nilsvu requested a review from nilsdeppe February 6, 2023 16:09
nilsdeppe
nilsdeppe previously approved these changes Feb 6, 2023
@nilsvu
Copy link
Member Author

nilsvu commented Feb 7, 2023

Merging because all that happened was a squash & rebase

@nilsvu nilsvu enabled auto-merge February 7, 2023 00:01
@nilsvu nilsvu disabled auto-merge February 7, 2023 00:01
@nilsvu nilsvu merged commit df9446a into sxs-collaboration:develop Feb 7, 2023
@nilsvu nilsvu deleted the py_plot_power_monitors branch February 7, 2023 00:02
@guilara guilara mentioned this pull request Feb 13, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Adds a new feature that's worth highlighting in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Visualize domain diagnostics
4 participants