Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #228 +/- ##
==========================================
+ Coverage 73.63% 73.78% +0.14%
==========================================
Files 51 55 +4
Lines 3050 3174 +124
==========================================
+ Hits 2246 2342 +96
- Misses 804 832 +28 ☔ View full report in Codecov by Sentry. |
| @overload | ||
| def plot_seismograms( | ||
| session: Session, plot_for: AimbatEvent | AimbatStation, return_fig: Literal[True] | ||
| ) -> tuple[plt.Figure, plt.Axes]: ... |
| @overload | ||
| def plot_seismograms( | ||
| session: Session, plot_for: AimbatEvent | AimbatStation, return_fig: Literal[False] | ||
| ) -> None: ... |
There was a problem hiding this comment.
Pull request overview
This PR refactors plotting-related functionality into a new aimbat.plot package, adds interactive seismogram plotting for both events and stations, and updates the CLI/TUI and documentation to use the new plotting entry points.
Changes:
- Introduce
src/aimbat/plot/with seismogram plotting utilities and ICCS plotting wrappers, and remove plotting fromcore/_seismogram.py/core/_iccs.py. - Add a new
snapshot previewCLI command and update existing CLI/TUI commands to useaimbat.plotfunctions and the renamedIccsPlotParameters.all_seismograms. - Add
mplcursorsdependency and update docs/tests accordingly.
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
zensical.toml |
Reorders/extends docs navigation to include the new plot API page and tidies formatting. |
uv.lock |
Adds mplcursors and bumps locked deps (e.g. cyclopts), updates pysmo git rev. |
pyproject.toml |
Adds mplcursors dependency and configures Ruff isort sections (incl. pysmo-group). |
src/aimbat/plot/__init__.py |
New plot package init exporting plotting helpers (currently has an __all__/noqa issue). |
src/aimbat/plot/_seismograms.py |
New unified plot_seismograms() for events/stations using mplcursors. |
src/aimbat/plot/_plot_utils.py |
New helpers for preparing/filtering/resampling seismograms for plotting. |
src/aimbat/plot/_iccs.py |
New wrappers around pysmo.tools.iccs plotting/update functions with DB write-back. |
src/aimbat/core/_seismogram.py |
Removes plot_all_seismograms() from core API. |
src/aimbat/core/_iccs.py |
Removes plotting/update helpers from core and refines ICCS/MCCC docstrings. |
src/aimbat/_cli/common.py |
Adds DebugParameter, renames IccsPlotParameters.all→all_seismograms, late-bound converters for --use-* IDs. |
src/aimbat/_cli/plot.py |
Updates plot subcommands (seismograms, stack, matrix) to use aimbat.plot. |
src/aimbat/_cli/pick.py |
Routes pick/timewindow/ccnorm interactive operations through aimbat.plot wrappers. |
src/aimbat/_cli/snapshot.py |
Renames delete function, adds snapshot preview command (currently has arg-parsing issue). |
src/aimbat/_cli/station.py |
Adds station plotseis command using plot_seismograms. |
src/aimbat/_cli/shell.py |
Makes --event auto-injection conditional on whether the command actually accepts it. |
src/aimbat/_cli/data.py |
Switches --use-event/--use-station parameter factories to late-bound converters; adjusts debug/global parameter usage. |
src/aimbat/_cli/event.py |
Replaces GlobalParameters usage in some commands with DebugParameter. |
src/aimbat/_cli/seismogram.py |
Replaces GlobalParameters usage in some commands with DebugParameter. |
src/aimbat/_cli/project.py |
Replaces GlobalParameters usage in commands with DebugParameter. |
src/aimbat/_cli/utils/sampledata.py |
Replaces GlobalParameters usage with DebugParameter. |
src/aimbat/_tui/app.py |
Updates ICCS interactive tools to call aimbat.plot update functions and renames args. |
src/aimbat/io/sac.py |
Import formatting-only change. |
tests/unit/_cli/test_common.py |
Updates tests for IccsPlotParameters.all_seismograms. |
tests/integration/core/test_seismogram.py |
Updates plotting integration tests to use plot_seismograms for event and station. |
tests/functional/test_cli_snapshots.py |
Adds CLI tests for snapshot delete failure, rollback restoring seismogram params, preview command calls, and improves list/details assertions. |
tests/unit/io/test_sac.py |
Formatting-only change. |
tests/integration/io/test_datasource_sac.py |
Import ordering tweak (for new isort grouping). |
tests/integration/core/test_data.py |
Import ordering tweak. |
tests/assets/make_events.py |
Formatting-only change. |
docs/api/aimbat/plot.md |
Adds mkdocstrings page for the new aimbat.plot module. |
docs/usage/api.md |
Documents IO-cache semantics for AimbatSeismogram.data and read-only arrays. |
docs/first-steps/data.md |
Clarifies snapshot behaviour, including what happens when adding data after a snapshot. |
| # flake8: noqa: E402, F403 | ||
| """Visualisation and interactive quality control for seismograms and alignment results. | ||
|
|
||
| This module provides tools for generating static plots of seismic data and alignment | ||
| stacks, as well as interactive interfaces for refining phase picks and time windows. | ||
| It integrates with matplotlib to support both automated reporting and manual | ||
| verification workflows. | ||
| """ | ||
|
|
||
| from ._iccs import * | ||
| from ._seismograms import * | ||
|
|
||
| _internal_names = set(dir()) | ||
|
|
||
| __all__ = [s for s in dir() if not s.startswith("_") and s not in _internal_names] | ||
|
|
There was a problem hiding this comment.
__all__ is computed after the import * statements, so _internal_names already contains all imported public symbols and __all__ ends up empty. This also means the leading # flake8: noqa will not suppress Ruff's F403 (and any related) lint errors for the star imports. Consider either (a) defining an explicit __all__ and importing explicit names, or (b) capturing _internal_names before the star imports and using a Ruff-compatible # ruff: noqa/per-line # noqa: F403 as needed.
| @app.command(name="preview") | ||
| @simple_exception | ||
| def cli_snapshot_preview( | ||
| snapshot_id: Annotated[uuid.UUID, id_parameter(AimbatSnapshot)], | ||
| iccs_plot_parameters: IccsPlotParameters = IccsPlotParameters(), | ||
| as_matrix: Annotated[bool, Parameter(name="matrix")] = False, | ||
| _: DebugParameter = DebugParameter(), | ||
| ) -> None: |
There was a problem hiding this comment.
cli_snapshot_preview declares iccs_plot_parameters, as_matrix, and the debug parameter as positional arguments. In Cyclopts this will typically make them required positionals (or at least change parsing), which is likely not intended for option-style flags like --context/--all and --matrix. Make these parameters keyword-only (add * after snapshot_id) so they behave as options consistently with the other CLI commands.
| global_parameters: GlobalParameters = GlobalParameters(), | ||
| _: DebugParameter = DebugParameter(), | ||
| ) -> None: | ||
| """Plot input seismograms for events recored at this station.""" |
There was a problem hiding this comment.
Typo in the command docstring: "recored" → "recorded".
| """Plot input seismograms for events recored at this station.""" | |
| """Plot input seismograms for events recorded at this station.""" |
📚 Documentation preview 📚: https://aimbat--228.org.readthedocs.build/en/228/