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
420 changes: 322 additions & 98 deletions nzgmdb/calculation/distances.py

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions nzgmdb/data_retrieval/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,16 @@ def create_site_table_response() -> pd.DataFrame:
on="sta",
how="left",
)
# Fill Elevation NaN values from sta_df
merged_df["elev"] = merged_df["Elevation"].combine_first(merged_df["elev"])
# Specify the required files for fiona
NZGMDB_DATA.fetch("TectonicDomains_Feb2021_8_NZTM.shp")
NZGMDB_DATA.fetch("TectonicDomains_Feb2021_8_NZTM.dbf")
NZGMDB_DATA.fetch("TectonicDomains_Feb2021_8_NZTM.shx")
NZGMDB_DATA.fetch("nt_domains_kiran.shp")
NZGMDB_DATA.fetch("nt_domains_kiran.dbf")
NZGMDB_DATA.fetch("nt_domains_kiran.shx")

# Shape file for determining neotectonic domain
shapes = list(
fiona.open(Path(NZGMDB_DATA.abspath) / "TectonicDomains_Feb2021_8_NZTM.shp")
)
with fiona.open(Path(NZGMDB_DATA.abspath) / "nt_domains_kiran.shp") as collection:
shapes = list(collection)
tect_merged_df = tect_domain.find_domain_from_shapes(merged_df, shapes)

# Rename the domain column
Expand Down
21 changes: 10 additions & 11 deletions nzgmdb/data_retrieval/tect_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pandas as pd
from pyproj import Transformer

from cmt_solutions import cmt_data
from nzgmdb.management import config as cfg
from nzgmdb.management.data_registry import NZGMDB_DATA
from qcore import geo, point_in_polygon
Expand Down Expand Up @@ -473,18 +474,16 @@ def add_tect_domain(
The number of processes to use
"""
# Specify the required files for fiona
NZGMDB_DATA.fetch("TectonicDomains_Feb2021_8_NZTM.shp")
NZGMDB_DATA.fetch("TectonicDomains_Feb2021_8_NZTM.dbf")
NZGMDB_DATA.fetch("TectonicDomains_Feb2021_8_NZTM.shx")
NZGMDB_DATA.fetch("nt_domains_kiran.shp")
NZGMDB_DATA.fetch("nt_domains_kiran.dbf")
NZGMDB_DATA.fetch("nt_domains_kiran.shx")

# Shape file for determining neotectonic domain
shapes = list(
fiona.open(Path(NZGMDB_DATA.abspath) / "TectonicDomains_Feb2021_8_NZTM.shp")
)
with fiona.open(Path(NZGMDB_DATA.abspath) / "nt_domains_kiran.shp") as collection:
shapes = list(collection)

# Read the geonet CMT and event data
config = cfg.Config()
geonet_cmt_df = pd.read_csv(config.get_value("cmt_url"), dtype={"evid": str})
# Read the CMT and event data
cmt_df = cmt_data.get_cmt_data()
event_df = pd.read_csv(event_csv_ffp, dtype={"evid": str})

# Merge in the Reyners Catalogue data for relocations
Expand All @@ -493,8 +492,8 @@ def add_tect_domain(
)
event_df = merge_reyners_catalogue_on_events(event_df, reyners_catalogue_df)

# Replace the geonet CMT data on the event data (override the reyners relocations)
event_df = replace_cmt_data_on_event(event_df, geonet_cmt_df)
# Replace the CMT data on the event data (override the reyners relocations)
event_df = replace_cmt_data_on_event(event_df, cmt_df)

# Merge the NZSMDB data
event_df = merge_NZSMDB_flatfile_on_events(event_df)
Expand Down
14 changes: 14 additions & 0 deletions nzgmdb/management/data_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
"TectonicDomains_Feb2021_8_NZTM.shx": "sha256:9ca42e270e5604f4740b3d99ea6a72daa75eaae0e6c6bda3c4e5c86a72369403",
"TectonicDomains_Feb2021_8_NZTM.dbf": "sha256:534c644c5d4d6a08106752e2fe33894bc820645efa017e0137ef5b8d44e8200c",
"tectonic_domain_polygon_points.csv": "sha256:a54c30a4e68bb078c6ce9d99bd30f902a9627d57fd39392b403064de61b1f1a4",
"nt_domains_kiran.dbf": "sha256:97e86ca9b8ea50ea0d8eec32025513a1ec0026a602a7bae2777999f6ba9f7ac4",
"nt_domains_kiran.shp": "sha256:edfa412b9395258a1ca0e9de61070108567b427ca59d309e09c531b462ccd490",
"nt_domains_kiran.shx": "sha256:721a99e549961dcc22a342750f8bd9d62946a73dfbf6a1dc4e9ba8a11d578ac0",
"hik_focmec.npy": "sha256:3a13e4c31b99b80da9976e2cb38b5f0f69cccf860140bea0598f32f9ed075767",
"puy_focmec.npy": "sha256:6493cba83722cdbea24ceafadd192d8b7a9e5160423e0b5fef3357748cf3e66f",
"nzfocmecmod.json": "sha256:1612c364b0ddf6251bb4044c3cde1a36b36e672525465e71cf0e4007bc97b446",
"slab-faulting2.json": "sha256:debe5e1a082716dd9d3deaad79fc859de7aeaaf4a41e40632f26a6593b020c83",
"brendon_set.csv": "sha256:a62d8c69f7f7bc6ccf0318a113a152befb35cfb21c56ab4806c58f24f221ce2e",
"lee_large.csv": "sha256:e4077746552937cd0a48be723b0188d33d4a73c2364716f085c0cd55ab78ec58",
"lee_small.csv": "sha256:b274bc99fcacb2747623f754b92d594c3b6729cfcfd0d046365ad3c6fba706c1",
Expand All @@ -42,6 +49,13 @@
"TectonicDomains_Feb2021_8_NZTM.dbf": "https://www.dropbox.com/scl/fi/o2z83zbg3yvxq8yqiwkqk/TectonicDomains_Feb2021_8_NZTM.dbf?rlkey=o4imoxtoj8psa3ndvryqrx2qk&st=qvcwp7hj&dl=1",
"TectonicDomains_Feb2021_8_NZTM.shp": "https://www.dropbox.com/scl/fi/69qwsa48gvtzx056vqirs/TectonicDomains_Feb2021_8_NZTM.shp?rlkey=qjkzra3xu0z9xjkb3dcji4max&st=kfsh8gaw&dl=1",
"TectonicDomains_Feb2021_8_NZTM.shx": "https://www.dropbox.com/scl/fi/3qyw5v3cw0dzi41d6wnp8/TectonicDomains_Feb2021_8_NZTM.shx?rlkey=ducg84xqhi2ua6ku2qhbiutrg&st=flmk11e0&dl=1",
"nt_domains_kiran.dbf": "https://www.dropbox.com/scl/fi/eexo36xpy8zw4m4kqua5i/nt_domains_kiran.dbf?rlkey=79buc3tge8glyerhcv1mvhur0&st=rjozdfq5&dl=1",
"nt_domains_kiran.shp": "https://www.dropbox.com/scl/fi/szdddwmefe19wcpgjpmcr/nt_domains_kiran.shp?rlkey=4vfrmtvbh17xezu9bovw94y7m&st=ohbz9bcw&dl=1",
"nt_domains_kiran.shx": "https://www.dropbox.com/scl/fi/17vh8bzrr0ahbxx3p49d4/nt_domains_kiran.shx?rlkey=mf5f5ibq0tiju0826anx7i18o&st=8obiawck&dl=1",
"hik_focmec.npy": "https://www.dropbox.com/scl/fi/1fn9yy68kacot6zsrhhan/hik_focmec.npy?rlkey=sgr1p2jlr4r4fbxegszzjfbep&st=12uqjyid&dl=1",
"puy_focmec.npy": "https://www.dropbox.com/scl/fi/9d0ycs5387lmdw3izkobv/puy_focmec.npy?rlkey=ognpq4lxr3bxxhw5iify8r9lt&st=zbrd62da&dl=1",
"nzfocmecmod.json": "https://www.dropbox.com/scl/fi/5zhftxo8uyfzzr6fj5kiz/nzfocmecmod.json?rlkey=a6hs5kgcqeagk4mosrg7akz13&st=o8xxr9v0&dl=1",
"slab-faulting2.json": "https://www.dropbox.com/scl/fi/u6o5jiuz9dwh1bl666nxj/slab-faulting2.json?rlkey=q7gzx6j8hmo61ic13co28vftj&st=hjnu7akb&dl=1",
"2013p543824.srf": "https://www.dropbox.com/scl/fi/013i860bt3os1k80leai5/2013p543824.srf?rlkey=ww3clc60gud4sycwfzmgopvix&st=jpu99tse&dl=1",
"2013p613797.srf": "https://www.dropbox.com/scl/fi/7wx7glahf8cufo1g7umzc/2013p613797.srf?rlkey=1x9e5yb2nkf5468rs0bogm8ev&st=dut8d2uw&dl=1",
"2016p661332.srf": "https://www.dropbox.com/scl/fi/pp7s6iqilrdgbrs00wi55/2016p661332.srf?rlkey=bhgcddk3bcdpxoycorlhp2in6&st=b8o2bk4w&dl=1",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ignore = [
convention = "numpy"

[tool.ruff.lint.isort]
known-first-party = ["qcore", "oq_wrapper", "IM", "velocity_modelling", "source_modelling"]
known-first-party = ["qcore", "oq_wrapper", "IM", "velocity_modelling", "source_modelling", "cmt_solutions"]

[tool.ruff.lint.per-file-ignores]
# Ignore no docstring in __init__.py
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ source_modelling>=2025.12.1,
openquake.engine==3.23.2,
im-calculation>=2025.12.3,
velocity-modelling>=2025.12.1
cmt-solutions @ git+https://github.com/ucgmsim/cmt_solutions.git
8 changes: 4 additions & 4 deletions wiki/Add-Tectonic-Domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ Relocations are applied from the Reyners Catalogue to improve location accuracy:
- Sets `reloc` field to "reyners" for successfully relocated events

### 🔹 2. Centroid Moment Tensor (CMT) Solutions
GeoNet CMT location solutions are applied, which override Reyners relocations when overlapping:
GeoNet and John Townend CMT location solutions are applied, which override Reyners relocations when overlapping:

**GeoNet CMT Solutions**
**CMT Solutions**

- Applies Centroid Moment Tensor (CMT) solutions from GeoNet
- Applies Centroid Moment Tensor (CMT) solutions from GeoNet and John Townend study
- Overrides previous relocations (including Reyners) when CMT solutions are available
- Updates source parameters: mag (Mw), lat, lon, depth
- Sets metadata fields: mag_type="Mw", mag_method="CMT", loc_type="CMT", loc_grid="CMT", reloc="no"

Expand Down Expand Up @@ -128,7 +129,6 @@ The enhanced earthquake source table contains all original fields plus:
The step uses several configuration parameters from `config.yaml`:

- **nzsmdb_url**: URL for NZ Strong Motion Database flatfile
- **cmt_url**: URL for GeoNet CMT solutions
- **ll_num**: WGS84 coordinate system identifier
- **nztm_num**: NZTM coordinate system identifier

Expand Down
7 changes: 2 additions & 5 deletions wiki/Calculate-Distances.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ The system determines the correct nodal plane through the following hierarchy:
- Extract nodal plane parameters and SRF points
- Calculate weighted average of strike, dip, rake based on plane areas

2. **Check Modified CMT Solutions** (Custom review for most likely nodal plane):
2. **Check Reviewed CMT Solutions** (Custom review for most likely nodal plane):
- Use predetermined preferred nodal plane
- Extract strike, dip, rake values
- Apply CCLD Method A

3. **Check Standard CMT Solutions**: Search GeoNet CMT catalogue:
3. **Check Standard CMT Solutions**: Search CMT catalogue:
- Apply CCLD Method C with both nodal planes

4. **Use Domain Default**: For events without CMT solutions:
Expand Down Expand Up @@ -244,9 +244,6 @@ Key parameters from `config.yaml` that control distance calculations:
### 🔹 Fault Discretisation
- `points_per_km`: Resolution for SRF point generation (default: typically 2-4 points/km)

### 🔹 External Data Sources
- `cmt_url`: URL for GeoNet CMT solutions catalogue

---

## 📦 Output
Expand Down
Loading