Skip to content

refactor: Update plot seismograms.#228

Merged
smlloyd merged 1 commit intomasterfrom
plots
Mar 8, 2026
Merged

refactor: Update plot seismograms.#228
smlloyd merged 1 commit intomasterfrom
plots

Conversation

@smlloyd
Copy link
Copy Markdown
Member

@smlloyd smlloyd commented Mar 8, 2026


📚 Documentation preview 📚: https://aimbat--228.org.readthedocs.build/en/228/

Copilot AI review requested due to automatic review settings March 8, 2026 16:38
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 8, 2026

Codecov Report

❌ Patch coverage is 64.19214% with 82 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.78%. Comparing base (9c6c207) to head (cd55341).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/aimbat/plot/_iccs.py 39.13% 28 Missing ⚠️
src/aimbat/_cli/shell.py 17.64% 14 Missing ⚠️
src/aimbat/_cli/station.py 35.71% 9 Missing ⚠️
src/aimbat/_cli/plot.py 38.46% 8 Missing ⚠️
src/aimbat/_cli/pick.py 0.00% 6 Missing ⚠️
src/aimbat/plot/_plot_utils.py 82.14% 5 Missing ⚠️
src/aimbat/plot/_seismograms.py 91.93% 5 Missing ⚠️
src/aimbat/_cli/common.py 63.63% 4 Missing ⚠️
src/aimbat/_tui/app.py 40.00% 3 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@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: ...
Copy link
Copy Markdown
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 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 from core/_seismogram.py / core/_iccs.py.
  • Add a new snapshot preview CLI command and update existing CLI/TUI commands to use aimbat.plot functions and the renamed IccsPlotParameters.all_seismograms.
  • Add mplcursors dependency 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.allall_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.

Comment on lines +1 to +16
# 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]

Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

__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.

Copilot uses AI. Check for mistakes.
Comment on lines +206 to +213
@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:
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread src/aimbat/_cli/station.py Outdated
global_parameters: GlobalParameters = GlobalParameters(),
_: DebugParameter = DebugParameter(),
) -> None:
"""Plot input seismograms for events recored at this station."""
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

Typo in the command docstring: "recored" → "recorded".

Suggested change
"""Plot input seismograms for events recored at this station."""
"""Plot input seismograms for events recorded at this station."""

Copilot uses AI. Check for mistakes.
@smlloyd smlloyd merged commit 717e28d into master Mar 8, 2026
23 of 24 checks passed
@smlloyd smlloyd deleted the plots branch March 8, 2026 17:08
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