Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
python-version:
- "3.12"
- "3.13"
- "3.14"

steps:
- uses: actions/checkout@v4
Expand All @@ -35,7 +36,7 @@ jobs:
run: |
uv build
- name: Upload build artifacts
if: ${{ matrix.python-version == '3.13' && github.event.workflow_run.conclusion == 'success'}}
if: ${{ matrix.python-version == '3.14' && github.event.workflow_run.conclusion == 'success'}}
uses: actions/upload-artifact@v4
with:
name: packages
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.12", "3.13"]
python-version: ["3.12", "3.13", "3.14"]

steps:
- uses: awalsh128/cache-apt-pkgs-action@latest
Expand All @@ -30,7 +30,7 @@ jobs:
uv sync --locked --all-extras --no-group docs
uv run black . --check --diff --color
uv run ruff check
uv run py.test --mpl --mypy --cov=aimbat --cov-append --cov-report=term-missing --junitxml=junit.xml
uv run py.test --mpl --mypy --cov src --cov-append --cov-report=term-missing --junitxml=junit.xml

- name: Store coverage results as artifacts
uses: actions/upload-artifact@v4
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ test-tutorial: check-uv ## Check if the tutorial notebook runs error-free.
uv run py.test --nbmake docs/examples/tutorial.ipynb

tests: check-uv mypy test-tutorial ## Run all tests with pytest.
uv run pytest --cov=aimbat --cov-report=term-missing --cov-report=html --mpl
uv run pytest --cov-report=term-missing --cov-report=html --mpl

mypy: check-uv ## Run typing tests with pytest.
uv run pytest --mypy -m mypy aimbat tests
uv run pytest --mypy -m mypy src tests

docs: check-uv install ## Build html docs.
uv run mkdocs build
Expand All @@ -52,7 +52,7 @@ docs-export: check-uv install ## Export installed package information to docs/re
uv export --only=docs -o docs/requirements.txt

live-docs: check-uv install ## Live build html docs. They are served on http://localhost:8000
uv run mkdocs serve -w README.md -w aimbat
uv run mkdocs serve -w README.md -w src

notebook: check-uv install ## Run a jupyter notebook in the uv environment
uv run jupyter-lab
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
nativeBuildInputs = with pkgs; [
uv
ruff
python312
(python314.withPackages (ps: with ps; [tox]))
python313
python313Packages.tox
python312
gnumake
sqlitebrowser
];
Expand All @@ -39,7 +39,7 @@
stdenv.cc.cc.lib
zlib
zstd
xorg.libX11
libX11
libGL
glib
libxkbcommon
Expand All @@ -48,6 +48,9 @@
dbus
wayland
]}:$LD_LIBRARY_PATH
export UV_PYTHON=$(which python3.14)
export UV_NO_MANAGED_PYTHON=true
[ ! -d .venv ] && uv venv --system-site-packages
uv sync --locked --all-extras
VENV=.venv
export MPLBACKEND=QtAgg
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
site_name: AIMBAT
copyright: Copyright © 2024-2025 Simon Lloyd
copyright: Copyright © 2024-2026 Simon Lloyd

# Repository
repo_name: pysmo/aimbat
Expand Down
13 changes: 8 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = [
{ name = "Xiaoting Lou", email = "xlou@u.northwestern.edu" },
{ name = "Simon M. Lloyd", email = "simon@slloyd.net" },
]
requires-python = ">=3.12,<3.14"
requires-python = ">=3.12,<3.15"
readme = "README.md"
license = "GPL-3.0-or-later"
classifiers = [
Expand Down Expand Up @@ -80,11 +80,9 @@ exclude = [
"docs",
]


[tool.hatch.build.targets.wheel]
exclude = [
"tests",
"docs",
]
packages = ["src/aimbat"]

[build-system]
requires = ["hatchling"]
Expand All @@ -95,16 +93,20 @@ build-backend = "hatchling.build"
# xvfb_height = 1080
testpaths = [
"tests",
"src",
]
mpl-generate-summary = "html"
mpl-use-full-test-name = true

[tool.mypy]
mypy_path = "src"
namespace_packages = true
disallow_untyped_defs = true
warn_unused_ignores = true
warn_redundant_casts = true

[tool.coverage.run]
source = ["src"]
[tool.coverage.report]
exclude_also = [
"def __repr__",
Expand All @@ -126,6 +128,7 @@ exclude_also = [
target-version = [
"py312",
"py313",
"py314",
]

[tool.ruff]
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion aimbat/app.py → src/aimbat/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from rich.console import Console
import sys


try:
__version__ = str(metadata.version("aimbat"))
except Exception:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 17 additions & 17 deletions aimbat/cli/iccs.py → src/aimbat/cli/iccs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
@Parameter(name="*")
@dataclass
class IccsPlotParameters:
pad: bool = True
"Add extra padding to the time window for plotting."
context: bool = True
"Plot seismograms with extra context instead of the short tapered ones used for cross-correlation."
all: bool = False
"Include all seismograms in the plot, even if not used in stack."

Expand All @@ -30,58 +30,58 @@ def _run_iccs(autoflip: bool = False, autoselect: bool = False) -> None:


@simple_exception
def _plot_stack(padded: bool, all: bool) -> None:
def _plot_stack(context: bool, all: bool) -> None:
from aimbat.lib.db import engine
from aimbat.lib.iccs import create_iccs_instance, plot_stack
from sqlmodel import Session

with Session(engine) as session:
iccs = create_iccs_instance(session)
plot_stack(iccs, padded, all)
plot_stack(iccs, context, all)


@simple_exception
def _plot_seismograms(padded: bool, all: bool) -> None:
def _plot_seismograms(context: bool, all: bool) -> None:
from aimbat.lib.db import engine
from aimbat.lib.iccs import create_iccs_instance, plot_seismograms
from sqlmodel import Session

with Session(engine) as session:
iccs = create_iccs_instance(session)
plot_seismograms(iccs, padded, all)
plot_seismograms(iccs, context, all)


@simple_exception
def _update_pick(padded: bool, all: bool, use_seismogram_image: bool) -> None:
def _update_pick(context: bool, all: bool, use_seismogram_image: bool) -> None:
from aimbat.lib.db import engine
from aimbat.lib.iccs import create_iccs_instance, update_pick
from sqlmodel import Session

with Session(engine) as session:
iccs = create_iccs_instance(session)
update_pick(session, iccs, padded, all, use_seismogram_image)
update_pick(session, iccs, context, all, use_seismogram_image)


@simple_exception
def _update_timewindow(padded: bool, all: bool, use_seismogram_image: bool) -> None:
def _update_timewindow(context: bool, all: bool, use_seismogram_image: bool) -> None:
from aimbat.lib.db import engine
from aimbat.lib.iccs import create_iccs_instance, update_timewindow
from sqlmodel import Session

with Session(engine) as session:
iccs = create_iccs_instance(session)
update_timewindow(session, iccs, padded, all, use_seismogram_image)
update_timewindow(session, iccs, context, all, use_seismogram_image)


@simple_exception
def _update_min_ccnorm(padded: bool, all: bool) -> None:
def _update_min_ccnorm(context: bool, all: bool) -> None:
from aimbat.lib.db import engine
from aimbat.lib.iccs import create_iccs_instance, update_min_ccnorm
from sqlmodel import Session

with Session(engine) as session:
iccs = create_iccs_instance(session)
update_min_ccnorm(session, iccs, padded, all)
update_min_ccnorm(session, iccs, context, all)


app = App(name="iccs", help=__doc__, help_format="markdown")
Expand Down Expand Up @@ -125,7 +125,7 @@ def cli_iccs_plot_stack(
iccs_parameters = iccs_parameters or IccsPlotParameters()
global_parameters = global_parameters or GlobalParameters()

_plot_stack(iccs_parameters.pad, iccs_parameters.all)
_plot_stack(iccs_parameters.context, iccs_parameters.all)


@plot.command(name="image")
Expand All @@ -143,7 +143,7 @@ def cli_iccs_plot_seismograms(
iccs_parameters = iccs_parameters or IccsPlotParameters()
global_parameters = global_parameters or GlobalParameters()

_plot_seismograms(iccs_parameters.pad, iccs_parameters.all)
_plot_seismograms(iccs_parameters.context, iccs_parameters.all)


@update.command(name="pick")
Expand All @@ -163,7 +163,7 @@ def cli_iccs_update_pick(
global_parameters = global_parameters or GlobalParameters()

_update_pick(
iccs_parameters.pad,
iccs_parameters.context,
iccs_parameters.all,
use_seismogram_image,
)
Expand All @@ -186,7 +186,7 @@ def cli_iccs_update_timewindow(
global_parameters = global_parameters or GlobalParameters()

_update_timewindow(
iccs_parameters.pad,
iccs_parameters.context,
iccs_parameters.all,
use_seismogram_image,
)
Expand All @@ -203,7 +203,7 @@ def cli_iccs_update_min_ccnorm(
iccs_parameters = iccs_parameters or IccsPlotParameters()
global_parameters = global_parameters or GlobalParameters()

_update_min_ccnorm(iccs_parameters.pad, iccs_parameters.all)
_update_min_ccnorm(iccs_parameters.context, iccs_parameters.all)


if __name__ == "__main__":
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

from .app import app


__all__ = ["app"]
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions aimbat/config.py → src/aimbat/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@ class Settings(BaseSettings):
"""Enable debug logging."""

window_pre: timedelta = Field(
default=ICCS_DEFAULTS.WINDOW_PRE,
default=ICCS_DEFAULTS.window_pre,
lt=0,
description="Initial relative begin time of window.",
)
"""Initial relative begin time of window."""

window_post: timedelta = Field(
default=ICCS_DEFAULTS.WINDOW_POST,
default=ICCS_DEFAULTS.window_post,
ge=0,
description="Initial relative end time of window.",
)
"""Initial relative end time of window."""

window_padding: timedelta = Field(
default=ICCS_DEFAULTS.PLOT_PADDING,
context_width: timedelta = Field(
default=ICCS_DEFAULTS.context_width,
gt=0,
description="Padding around time window.",
description="Context padding to apply before and after the time window.",
)
"""Padding around time window."""
"""Context padding to apply before and after the time window."""

min_ccnorm: float | np.floating = Field(
default=ICCS_DEFAULTS.MIN_CCNORM,
default=ICCS_DEFAULTS.min_ccnorm,
ge=0,
le=1,
description="Initial minimum cross correlation coefficient.",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion aimbat/lib/db.py → src/aimbat/lib/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
from sqlmodel import create_engine
from aimbat.config import settings


engine = create_engine(url=settings.db_url, echo=False)
"""AIMBAT database engine."""
File renamed without changes.
Loading
Loading