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

CLI for plotting trajectories of binaries #5976

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

vtommasini
Copy link
Contributor

Proposed CLI for plotting trajectories

Code review checklist

  • This CLI plots trajectories from an inspiral run, concatenating the partial trajectories from each segment, and plots the full trajectories.
  • The output can be a .pdf, .png, or graphic window if no output file type is sepcified.
  • Example of output file:
Screenshot 2024-05-09 at 8 17 13 AM

@nilsvu nilsvu self-requested a review May 9, 2024 15:59
@nilsvu nilsvu added the cli/pybindings Command line interface & Python bindings label May 9, 2024
Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

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

This looks great! Thanks for writing this script. Please squash all your commits including changes you make in response to my comments below into a single commit, then force-push to this branch.

src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
Comment on lines 41 to 43
@show_or_save_plot_command()
@apply_stylesheet_command()
def plot_trajectories_command(h5_files, subfile_name_aha, subfile_name_ahb):
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks great! The image that this produces is really cool!

trajectories

Could you also add some tests for this? Similar to the test in tests/Unit/Visualization/Python/Test_PlotSizeControl.py

src/Visualization/Python/PlotSizeControl.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
return None, None


def plot_trajectory(AhA, AhB, sample_rate=15):
Copy link
Member

Choose a reason for hiding this comment

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

Please add documentation to this function that describes what the function does and also describes each argument. You find examples in the other Python files in this directory.

src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is my revised version, with all the current comments/suggestions incorporated. I made the code more compact. The suggested as well as new options are documented in the help file. I'll keep working on the Test script while I wait for more feedback.

Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

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

Only a test is missing now as @knelli2 mentioned above. Maybe write some made-up data to a file in a setUp function, then run the CLI command to plot it (@knelli2 pointed to some examples). You can't really test that the plot looks correct, but at least this test makes sure that the code runs without error, and keeps working in the future.

You can squash everything into 1 commit.

src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
tests/Unit/Visualization/Python/Test_PlotTrajectories.py Outdated Show resolved Hide resolved
tests/Unit/Visualization/Python/Test_PlotTrajectories.py Outdated Show resolved Hide resolved
tests/Unit/Visualization/Python/Test_PlotTrajectories.py Outdated Show resolved Hide resolved
tests/Unit/Visualization/Python/Test_PlotTrajectories.py Outdated Show resolved Hide resolved
tests/Unit/Visualization/Python/Test_PlotTrajectories.py Outdated Show resolved Hide resolved
tests/Unit/Visualization/Python/Test_PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
src/Visualization/Python/PlotTrajectories.py Outdated Show resolved Hide resolved
Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

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

Looks great! Move this one thing, then squash everything into a single commit.

@@ -12,115 +14,110 @@
from spectre.Informer import unit_test_build_path, unit_test_src_path
from spectre.Visualization.PlotTrajectories import plot_trajectories_command

# Configure logging
logging.basicConfig(level=logging.INFO)
Copy link
Member

Choose a reason for hiding this comment

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

Move this to __main__ at the bottom, like this:

if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)
    unittest.main(verbosity=2)

fixup for PlotTrajectories CLI

fixup for Test of PlotTrajectories CLI

fixup 2 for PlotTrajectories CLI

fixup 3

fixup 4
@nilsvu
Copy link
Member

nilsvu commented Jun 6, 2024

Yay nice job 👍

@nilsvu nilsvu merged commit 9d029b7 into sxs-collaboration:develop Jun 6, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli/pybindings Command line interface & Python bindings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants