Skip to content

Fix realisation plots#108

Open
lispandfound wants to merge 4 commits intomasterfrom
generate_velocity_model_parameters_refactor
Open

Fix realisation plots#108
lispandfound wants to merge 4 commits intomasterfrom
generate_velocity_model_parameters_refactor

Conversation

@lispandfound
Copy link
Contributor

@lispandfound lispandfound commented Feb 4, 2026

A few months ago we migrated to using rrup boundary polygons for domain determination (again). So this module needed an update. Also included: deleting the requirements.txt, adding a lock file, and refactoring the dependencies into pyproject.toml.

Copilot AI review requested due to automatic review settings February 4, 2026 03:39
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lispandfound, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request modernizes the project's dependency management by migrating from requirements.txt to pyproject.toml and updates the realisation plotting module. The plotting logic has been refactored to align with the current rrup boundary polygon approach for domain determination, enhancing the accuracy and relevance of the generated plots.

Highlights

  • Dependency Management Migration: The project's dependencies have been migrated from the requirements.txt file to pyproject.toml, centralizing dependency management and introducing optional dependency groups for testing, typing, and development tools.
  • Realisation Plotting Update: The visualisation/realisation.py module has been updated to align with the current rrup boundary polygon approach for domain determination, replacing the older PGV target methodology for plotting.
  • Refactored Plotting Function Signature: The plot_realisation function now directly accepts Magnitudes, DomainParameters, VelocityModelParameters, and SourceConfig objects, improving modularity and clarity by removing the reliance on a single realisation_ffp path parameter.
Changelog
  • pyproject.toml
    • Migrated project dependencies from requirements.txt to pyproject.toml's [project.dependencies] section.
    • Introduced [project.optional-dependencies] for test, types, and dev groups.
    • Added [tool.deptry] configuration for managing development dependencies.
    • Registered plot-realisation as a new project script.
    • Removed the [tool.setuptools.dynamic] section that previously linked to requirements.txt.
    • Applied minor formatting adjustments to ruff and numpydoc_validation configurations.
  • requirements.txt
    • Deleted the requirements.txt file, as all dependencies are now managed via pyproject.toml.
  • visualisation/realisation.py
    • Updated imports to reflect changes in workflow module, specifically replacing RupturePropagationConfig with Magnitudes and adding generate_domain.
    • Renamed the pgv_target parameter to rrup_target in plot_rrup_polygon and its associated documentation, and updated the label format to display in kilometers.
    • Refactored the plot_realisation function signature to accept Magnitudes, DomainParameters, VelocityModelParameters, and SourceConfig objects directly, removing the realisation_ffp path parameter.
    • Replaced show_pgv_targets and pgv_targets parameters with show_rrup_targets in plot_realisation and plot_realisation_to_file.
    • Modified the internal logic of plot_realisation to compute rrup_bounding_polygons using generate_domain.find_r_surfaces and shapely.buffer, aligning with the rrup boundary polygon methodology.
    • Adjusted the plot_realisation_to_file function to read the necessary configuration objects from the realisation_ffp before passing them to the updated plot_realisation function.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/deptry.yml
Activity
  • No specific activity has been recorded for this pull request yet, such as comments or reviews.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a good improvement, migrating dependency management from requirements.txt to pyproject.toml and refactoring the realisation plotting logic. The code changes for the plotting fix look correct and align with the goal of using rrup boundary polygons. I've left a few comments regarding the dependency migration, suggesting to add a missing test dependency and to sort the lists for better maintainability. I also found an issue in visualisation/realisation.py where a docstring example was not updated after a function signature refactoring, which would cause an error. Overall, great work on modernizing the project setup and fixing the plotting logic.

Comment on lines 207 to 221
def plot_realisation(
realisation_ffp: Path,
magnitudes: Magnitudes,
domain_parameters: DomainParameters,
velocity_model_parameters: VelocityModelParameters,
source_config: SourceConfig,
latitude_pad: float = 0,
longitude_pad: float = 0,
title: str | None = None,
subtitle: str | None = None,
width: float = 10,
show_geonet_stations: bool = False,
show_geometry: bool = True,
show_pgv_targets: bool = False,
pgv_targets: list[float] | None = None,
show_rrup_targets: bool = False,
stations: Path | None = None,
) -> pygmt.Figure:
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The function signature has been refactored, which is a great improvement. However, the corresponding docstring example (starting on line 261) has not been fully updated. It still shows a call with realisation_ffp, which is no longer a parameter, and will cause a TypeError. Please update the example to be consistent with the new function signature.

Comment on lines +12 to +29
dependencies = [
"cartopy",
"matplotlib",
"numpy",
"ffmpeg-python",
"pygmt",
"pygmt-helper>=2025.12.1",
"source-modelling>=2025.12.1",
"workflow @ git+https://github.com/ucgmsim/workflow.git@pegasus",
"qcore-utils>=2025.12.2",
"geopandas",
"pandas",
"shapely",
"scipy >= 1.15.0",
"pooch",
"typer",
"tqdm",
]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better maintainability and to avoid potential merge conflicts, it's a good practice to keep the main dependency list sorted alphabetically.

Suggested change
dependencies = [
"cartopy",
"matplotlib",
"numpy",
"ffmpeg-python",
"pygmt",
"pygmt-helper>=2025.12.1",
"source-modelling>=2025.12.1",
"workflow @ git+https://github.com/ucgmsim/workflow.git@pegasus",
"qcore-utils>=2025.12.2",
"geopandas",
"pandas",
"shapely",
"scipy >= 1.15.0",
"pooch",
"typer",
"tqdm",
]
dependencies = [
"cartopy",
"ffmpeg-python",
"geopandas",
"matplotlib",
"numpy",
"pandas",
"pooch",
"pygmt",
"pygmt-helper>=2025.12.1",
"qcore-utils>=2025.12.2",
"scipy >= 1.15.0",
"shapely",
"source-modelling>=2025.12.1",
"tqdm",
"typer",
"workflow @ git+https://github.com/ucgmsim/workflow.git@pegasus",
]

Comment on lines +33 to +39
test = [
"diffimg",
"pytest",
"pytest-cov",
"hypothesis[pandas, numpy]",
"hypothesis-networkx",
]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The pytest-xdist dependency, which was present in the old requirements.txt, seems to be missing from the new test optional dependencies. Was its removal intentional? If not, it should be added back to ensure tests can be run in parallel. For consistency and maintainability, it's also a good idea to keep this list sorted alphabetically.

Suggested change
test = [
"diffimg",
"pytest",
"pytest-cov",
"hypothesis[pandas, numpy]",
"hypothesis-networkx",
]
test = [
"diffimg",
"hypothesis[pandas, numpy]",
"hypothesis-networkx",
"pytest",
"pytest-cov",
"pytest-xdist",
]

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the realisation plotting module from using PGV (Peak Ground Velocity) targets to using rrup (rupture distance) boundary polygons for domain determination, aligning with a codebase-wide change made several months ago. Additionally, the PR consolidates dependency management by removing requirements.txt and moving all dependencies into pyproject.toml.

Changes:

  • Updated plot_realisation() to accept individual configuration objects instead of a realisation file path, and replaced PGV-based polygon generation with rrup-based polygon generation using generate_domain.find_r_surfaces()
  • Removed requirements.txt and migrated all dependencies to pyproject.toml with proper separation of main, test, types, and dev dependencies
  • Simplified the GitHub Actions deptry workflow to use uv instead of manual pip installations

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 1 comment.

File Description
visualisation/realisation.py Refactored plotting functions to use rrup boundaries instead of PGV targets; updated function signatures to accept configuration objects directly instead of file paths; renamed parameters from pgv_target to rrup_target
requirements.txt Deleted in favor of pyproject.toml
pyproject.toml Added dependencies section with all packages from requirements.txt; added optional-dependencies for test, types, and dev; added plot-realisation script entry point; minor formatting improvements
.github/workflows/deptry.yml Simplified workflow to use uv for dependency installation and checking

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The region of the plot.
pgv_target : float
rrup_target : float
The PGV target for the polygon (used as a label).
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

The docstring still references "The PGV target for the polygon" when describing the rrup_target parameter. This should be updated to say "The rrup target (distance in meters) for the polygon" to accurately reflect what this parameter represents.

Suggested change
The PGV target for the polygon (used as a label).
The rrup target (distance in meters) for the polygon (used as a label).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants