cmt-solutions 0.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. cmt_solutions-0.0.0/.github/workflows/claude-review.yml +11 -0
  2. cmt_solutions-0.0.0/.github/workflows/deptry.yml +20 -0
  3. cmt_solutions-0.0.0/.github/workflows/publish-PyPi.yml +62 -0
  4. cmt_solutions-0.0.0/.github/workflows/ruff.yml +8 -0
  5. cmt_solutions-0.0.0/.github/workflows/wiki.yml +16 -0
  6. cmt_solutions-0.0.0/.gitignore +176 -0
  7. cmt_solutions-0.0.0/PKG-INFO +102 -0
  8. cmt_solutions-0.0.0/README.md +83 -0
  9. cmt_solutions-0.0.0/auto_cmt/__init__.py +0 -0
  10. cmt_solutions-0.0.0/auto_cmt/nz3dvm_2p3.csv +112001 -0
  11. cmt_solutions-0.0.0/auto_cmt/run_cmt.py +216 -0
  12. cmt_solutions-0.0.0/cmt_solutions/__init__.py +0 -0
  13. cmt_solutions-0.0.0/cmt_solutions/cmt_data.py +30 -0
  14. cmt_solutions-0.0.0/cmt_solutions/nodal_plane.py +83 -0
  15. cmt_solutions-0.0.0/cmt_solutions.egg-info/PKG-INFO +102 -0
  16. cmt_solutions-0.0.0/cmt_solutions.egg-info/SOURCES.txt +30 -0
  17. cmt_solutions-0.0.0/cmt_solutions.egg-info/dependency_links.txt +1 -0
  18. cmt_solutions-0.0.0/cmt_solutions.egg-info/requires.txt +11 -0
  19. cmt_solutions-0.0.0/cmt_solutions.egg-info/top_level.txt +2 -0
  20. cmt_solutions-0.0.0/data/CMT_solutions.csv +4189 -0
  21. cmt_solutions-0.0.0/data/john_townend_np2.csv +3425 -0
  22. cmt_solutions-0.0.0/interfaces/cmt_reviewer.py +543 -0
  23. cmt_solutions-0.0.0/pyproject.toml +69 -0
  24. cmt_solutions-0.0.0/requirements.txt +11 -0
  25. cmt_solutions-0.0.0/scripts/merge_john_townend_cmt_solutions.py +181 -0
  26. cmt_solutions-0.0.0/scripts/update_cmt_solutions.py +38 -0
  27. cmt_solutions-0.0.0/setup.cfg +4 -0
  28. cmt_solutions-0.0.0/wiki/Auto CMT.md +54 -0
  29. cmt_solutions-0.0.0/wiki/CMT Review.md +59 -0
  30. cmt_solutions-0.0.0/wiki/Home.md +40 -0
  31. cmt_solutions-0.0.0/wiki/John Townend CMT Study.md +100 -0
  32. cmt_solutions-0.0.0/wiki/images/cmt_review_interface.png +0 -0
@@ -0,0 +1,11 @@
1
+ name: Claude PR Review
2
+
3
+ on:
4
+ issue_comment:
5
+ types: [created]
6
+
7
+ jobs:
8
+ review:
9
+ uses: ucgmsim/meta-ci-action/.github/workflows/claude-review.yml@main
10
+ secrets:
11
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
@@ -0,0 +1,20 @@
1
+ name: Deptry Dependency Check
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v4
10
+ # Setup the minimum required python distribution
11
+ - uses: actions/setup-python@v5
12
+ with:
13
+ python-version: '3.11'
14
+ - run: pip install -r requirements.txt
15
+ # Install deptry
16
+ - run: pip install deptry
17
+ # Remove pyproject.toml so that deptry doesn't get confused
18
+ - run: rm pyproject.toml
19
+ # Run deptry to check that all dependencies are present.
20
+ - run: deptry .
@@ -0,0 +1,62 @@
1
+ name: Publish to PyPI
2
+ run-name: Publish Python Package to PyPI for release ${{ github.event.release.tag_name }}
3
+
4
+ on:
5
+ release:
6
+ types: [published]
7
+ workflow_dispatch:
8
+ inputs:
9
+ tag_name:
10
+ description: 'Git tag to checkout and publish'
11
+ required: false
12
+ type: string
13
+
14
+ jobs:
15
+ build:
16
+ name: Build distribution 📦
17
+ runs-on: ubuntu-latest
18
+
19
+ steps:
20
+ - name: Checkout code
21
+ uses: actions/checkout@v4
22
+ with:
23
+ ref: ${{ inputs.tag_name || github.ref }}
24
+
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v5
27
+ with:
28
+ python-version: "3.10"
29
+ - name: Install pypa/build
30
+ run: >-
31
+ python3 -m
32
+ pip install
33
+ build
34
+ --user
35
+ - name: Build a binary wheel and a source tarball
36
+ run: python3 -m build
37
+ - name: Store the distribution packages
38
+ uses: actions/upload-artifact@v4
39
+ with:
40
+ name: python-package-distributions
41
+ path: dist/
42
+ publish-to-pypi:
43
+ name: Publish to PyPI
44
+ needs:
45
+ - build
46
+ runs-on: ubuntu-latest
47
+
48
+ environment:
49
+ name: pypi
50
+ url: https://pypi.org/p/cmt_solutions
51
+
52
+ permissions:
53
+ id-token: write
54
+
55
+ steps:
56
+ - name: Download all the dists
57
+ uses: actions/download-artifact@v4
58
+ with:
59
+ name: python-package-distributions
60
+ path: dist/
61
+ - name: Publish distribution to PyPI
62
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,8 @@
1
+ name: Ruff
2
+ on: [pull_request]
3
+ jobs:
4
+ ruff:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v4
8
+ - uses: chartboost/ruff-action@v1
@@ -0,0 +1,16 @@
1
+ # .github/workflows/deploy-wiki.yml
2
+ name: deploy-wiki
3
+ on:
4
+ push:
5
+ branches: "main"
6
+ paths: wiki/**
7
+ workflow_dispatch:
8
+ jobs:
9
+ deploy-wiki:
10
+ permissions:
11
+ contents: write
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - run: perl -i -pe 's;(\[.*?\])\((?!https:\/\/)(.*?)\.md\);\1(\2);g' wiki/*.md
16
+ - uses: actions4gh/deploy-wiki@v1
@@ -0,0 +1,176 @@
1
+ # Created by https://www.toptal.com/developers/gitignore/api/python
2
+ # Edit at https://www.toptal.com/developers/gitignore?templates=python
3
+
4
+ ### Python ###
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .hypothesis/
55
+ .pytest_cache/
56
+ cover/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+ db.sqlite3-journal
67
+
68
+ # Flask stuff:
69
+ instance/
70
+ .webassets-cache
71
+
72
+ # Scrapy stuff:
73
+ .scrapy
74
+
75
+ # Sphinx documentation
76
+ docs/_build/
77
+
78
+ # PyBuilder
79
+ .pybuilder/
80
+ target/
81
+
82
+ # Jupyter Notebook
83
+ .ipynb_checkpoints
84
+
85
+ # IPython
86
+ profile_default/
87
+ ipython_config.py
88
+
89
+ # pyenv
90
+ # For a library or package, you might want to ignore these files since the code is
91
+ # intended to run in multiple environments; otherwise, check them in:
92
+ # .python-version
93
+
94
+ # pipenv
95
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
97
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
98
+ # install all needed dependencies.
99
+ #Pipfile.lock
100
+
101
+ # poetry
102
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
103
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
104
+ # commonly ignored for libraries.
105
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
106
+ #poetry.lock
107
+
108
+ # pdm
109
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
110
+ #pdm.lock
111
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
112
+ # in version control.
113
+ # https://pdm.fming.dev/#use-with-ide
114
+ .pdm.toml
115
+
116
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
117
+ __pypackages__/
118
+
119
+ # Celery stuff
120
+ celerybeat-schedule
121
+ celerybeat.pid
122
+
123
+ # SageMath parsed files
124
+ *.sage.py
125
+
126
+ # Environments
127
+ .env
128
+ .venv
129
+ env/
130
+ venv/
131
+ ENV/
132
+ env.bak/
133
+ venv.bak/
134
+
135
+ # Spyder project settings
136
+ .spyderproject
137
+ .spyproject
138
+
139
+ # Rope project settings
140
+ .ropeproject
141
+
142
+ # mkdocs documentation
143
+ /site
144
+
145
+ # mypy
146
+ .mypy_cache/
147
+ .dmypy.json
148
+ dmypy.json
149
+
150
+ # Pyre type checker
151
+ .pyre/
152
+
153
+ # pytype static type analyzer
154
+ .pytype/
155
+
156
+ # Cython debug symbols
157
+ cython_debug/
158
+
159
+ # PyCharm
160
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
161
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
162
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
163
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
164
+ #.idea/
165
+
166
+ ### Python Patch ###
167
+ # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
168
+ poetry.toml
169
+
170
+ # ruff
171
+ .ruff_cache/
172
+
173
+ # LSP config files
174
+ pyrightconfig.json
175
+
176
+ # End of https://www.toptal.com/developers/gitignore/api/python
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: cmt_solutions
3
+ Version: 0.0.0
4
+ Summary: Provides access to a range of CMT solutions for seismic events in New Zealand.
5
+ Author: QuakeCoRE
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: pandas
9
+ Requires-Dist: typer
10
+ Requires-Dist: numpy
11
+ Requires-Dist: streamlit
12
+ Requires-Dist: pydeck
13
+ Requires-Dist: obspy
14
+ Requires-Dist: shapely
15
+ Requires-Dist: requests
16
+ Requires-Dist: qcore-utils>=2025.12.1
17
+ Requires-Dist: source_modelling>=2025.12.1
18
+ Requires-Dist: BayesISOLA==0.2.0
19
+
20
+ # CMT Solutions
21
+
22
+ This repository contains the Centroid Moment Tensor (CMT) solutions and supporting tools used for the John Townend relocation / CMT study.
23
+
24
+ Contents
25
+ - `cmt_solutions/` — Python package with helpers for reading and working with CMT solution data (includes `cmt_data.py`, `nodal_plane.py`, etc.).
26
+ - `auto_cmt/` — runs BayesISOLA's automated 1-D CMT inversion for a single GeoNet event (`run_cmt.py`), for any event already in GeoNet's archive or, with `--real-time`, for one that has only just happened. Installed as the `auto_cmt` package so callers can launch it as a subprocess (`python -m auto_cmt.run_cmt ...`); see NZGMDB's `nzgmdb.management.background` for an example launcher.
27
+ - `data/` — CSV datasets (e.g. `CMT_solutions.csv`) used by the code and reviewer app.
28
+ - `interfaces/` — Streamlit UI for reviewing nodal planes (`cmt_reviewer.py`).
29
+ - `scripts/` — utility scripts used to build or update datasets.
30
+ - `wiki/` — documentation pages including the CMT review guide, the auto CMT guide, and the John Townend study notes.
31
+
32
+ Quick links (wiki)
33
+ - CMT Review guide: `wiki/CMT Review.md`
34
+ - Auto CMT guide: `wiki/Auto CMT.md`
35
+ - John Townend CMT study notes: `wiki/John Townend CMT Study.md`
36
+ - Home (scripts summary): open `wiki/Home.md` for descriptions of the scripts in `scripts/`.
37
+
38
+ ---
39
+
40
+ ## Install
41
+
42
+ We recommend using a new Python virtual environment. From the repository root (the directory containing `pyproject.toml` / `setup.py`) install editable mode so the package is importable during development and by the Streamlit app:
43
+
44
+ ```bash
45
+ python -m venv .venv
46
+ source .venv/bin/activate
47
+ python -m pip install --upgrade pip
48
+ python -m pip install -e .
49
+ python -m pip install -r requirements.txt
50
+ ```
51
+
52
+ ---
53
+
54
+ ### Running the Streamlit reviewer
55
+
56
+ From the repo root:
57
+
58
+ ```bash
59
+ cd interfaces
60
+ streamlit run cmt_reviewer.py
61
+ ```
62
+
63
+ Open the URL printed by Streamlit (usually `http://localhost:8501`). The `wiki/CMT Review.md` file contains a user guide for the reviewer UI and describes the steps to perform and save reviews.
64
+
65
+ ---
66
+
67
+ ### Using the Python API
68
+
69
+ This repository exposes a small API for loading and working with the CMT data. The main helper for loading the data is `get_cmt_data()` in `cmt_solutions/cmt_data.py`.
70
+
71
+ Example: load all CMT solutions
72
+
73
+ ```python
74
+ from cmt_solutions.cmt_data import get_cmt_data
75
+
76
+ df_all = get_cmt_data() # returns a pandas.DataFrame with the full contents of data/CMT_solutions.csv
77
+ print(len(df_all), "rows loaded")
78
+ ```
79
+
80
+ Example: load a single event by `PublicID`
81
+
82
+ ```python
83
+ from cmt_solutions.cmt_data import get_cmt_data
84
+
85
+ df_event = get_cmt_data(event_id="2016p858000")
86
+ ```
87
+
88
+ ### Reviewed-plane convention
89
+
90
+ When reviewing a CMT solution using the Streamlit app, the selected (preferred) plane is stored in the first plane columns and the other (alternative) plane in the second plane columns. Concretely:
91
+
92
+ - Preferred (chosen) plane -> `strike1`, `dip1`, `rake1`
93
+ - Other (non-preferred) plane -> `strike2`, `dip2`, `rake2`
94
+ - The `PreferredPlane` column is set to the chosen value (`"1"` or `"2"`), and the reviewer name and `reviewed` flag are recorded.
95
+
96
+ This means consumers of `CMT_solutions.csv` can always treat the first plane as the preferred plane when `reviewed == True`.
97
+
98
+ Working with reviewed results
99
+
100
+ The Streamlit reviewer writes the full working table (including `reviewed`, `reviewer`) to the output CSV you specify in the UI. You can use this file directly or replace `data/CMT_solutions.csv` with your reviewed file to share results.
101
+
102
+ To contribute reviewed results back to the repository follow the steps in the `wiki/CMT Review.md` guide.
@@ -0,0 +1,83 @@
1
+ # CMT Solutions
2
+
3
+ This repository contains the Centroid Moment Tensor (CMT) solutions and supporting tools used for the John Townend relocation / CMT study.
4
+
5
+ Contents
6
+ - `cmt_solutions/` — Python package with helpers for reading and working with CMT solution data (includes `cmt_data.py`, `nodal_plane.py`, etc.).
7
+ - `auto_cmt/` — runs BayesISOLA's automated 1-D CMT inversion for a single GeoNet event (`run_cmt.py`), for any event already in GeoNet's archive or, with `--real-time`, for one that has only just happened. Installed as the `auto_cmt` package so callers can launch it as a subprocess (`python -m auto_cmt.run_cmt ...`); see NZGMDB's `nzgmdb.management.background` for an example launcher.
8
+ - `data/` — CSV datasets (e.g. `CMT_solutions.csv`) used by the code and reviewer app.
9
+ - `interfaces/` — Streamlit UI for reviewing nodal planes (`cmt_reviewer.py`).
10
+ - `scripts/` — utility scripts used to build or update datasets.
11
+ - `wiki/` — documentation pages including the CMT review guide, the auto CMT guide, and the John Townend study notes.
12
+
13
+ Quick links (wiki)
14
+ - CMT Review guide: `wiki/CMT Review.md`
15
+ - Auto CMT guide: `wiki/Auto CMT.md`
16
+ - John Townend CMT study notes: `wiki/John Townend CMT Study.md`
17
+ - Home (scripts summary): open `wiki/Home.md` for descriptions of the scripts in `scripts/`.
18
+
19
+ ---
20
+
21
+ ## Install
22
+
23
+ We recommend using a new Python virtual environment. From the repository root (the directory containing `pyproject.toml` / `setup.py`) install editable mode so the package is importable during development and by the Streamlit app:
24
+
25
+ ```bash
26
+ python -m venv .venv
27
+ source .venv/bin/activate
28
+ python -m pip install --upgrade pip
29
+ python -m pip install -e .
30
+ python -m pip install -r requirements.txt
31
+ ```
32
+
33
+ ---
34
+
35
+ ### Running the Streamlit reviewer
36
+
37
+ From the repo root:
38
+
39
+ ```bash
40
+ cd interfaces
41
+ streamlit run cmt_reviewer.py
42
+ ```
43
+
44
+ Open the URL printed by Streamlit (usually `http://localhost:8501`). The `wiki/CMT Review.md` file contains a user guide for the reviewer UI and describes the steps to perform and save reviews.
45
+
46
+ ---
47
+
48
+ ### Using the Python API
49
+
50
+ This repository exposes a small API for loading and working with the CMT data. The main helper for loading the data is `get_cmt_data()` in `cmt_solutions/cmt_data.py`.
51
+
52
+ Example: load all CMT solutions
53
+
54
+ ```python
55
+ from cmt_solutions.cmt_data import get_cmt_data
56
+
57
+ df_all = get_cmt_data() # returns a pandas.DataFrame with the full contents of data/CMT_solutions.csv
58
+ print(len(df_all), "rows loaded")
59
+ ```
60
+
61
+ Example: load a single event by `PublicID`
62
+
63
+ ```python
64
+ from cmt_solutions.cmt_data import get_cmt_data
65
+
66
+ df_event = get_cmt_data(event_id="2016p858000")
67
+ ```
68
+
69
+ ### Reviewed-plane convention
70
+
71
+ When reviewing a CMT solution using the Streamlit app, the selected (preferred) plane is stored in the first plane columns and the other (alternative) plane in the second plane columns. Concretely:
72
+
73
+ - Preferred (chosen) plane -> `strike1`, `dip1`, `rake1`
74
+ - Other (non-preferred) plane -> `strike2`, `dip2`, `rake2`
75
+ - The `PreferredPlane` column is set to the chosen value (`"1"` or `"2"`), and the reviewer name and `reviewed` flag are recorded.
76
+
77
+ This means consumers of `CMT_solutions.csv` can always treat the first plane as the preferred plane when `reviewed == True`.
78
+
79
+ Working with reviewed results
80
+
81
+ The Streamlit reviewer writes the full working table (including `reviewed`, `reviewer`) to the output CSV you specify in the UI. You can use this file directly or replace `data/CMT_solutions.csv` with your reviewed file to share results.
82
+
83
+ To contribute reviewed results back to the repository follow the steps in the `wiki/CMT Review.md` guide.
File without changes