From 8c57a0c85497ae384fa8851fcc0ca70176e51d75 Mon Sep 17 00:00:00 2001 From: Andrew Ridden-Harper Date: Wed, 3 Jun 2026 12:56:42 +1200 Subject: [PATCH 1/8] Use BoldM type for fault magnitudes in Magnitudes config source_modelling 2026.6.1 introduces the BoldM magnitude NewType. Update the Magnitudes config to use BoldM instead of float, and make call sites across the codebase consistent (bump dependency, cast floats to BoldM, pass bold_m=True to magnitude_to_moment). Co-Authored-By: Claude Opus 4.8 (1M context) --- pyproject.toml | 2 +- tests/test_generate_domain.py | 4 +- tests/test_realisation.py | 8 +- uv.lock | 88 ++++++++++++--------- workflow/realisations.py | 7 +- workflow/scripts/gcmt_to_realisation.py | 4 +- workflow/scripts/generate_domain.py | 10 +-- workflow/scripts/nshm2022_to_realisation.py | 4 +- workflow/scripts/realisation_to_srf.py | 2 +- 9 files changed, 74 insertions(+), 55 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dc18770f..77bf8c4e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ dependencies = [ "nshmdb>=2025.12.1", "oq_wrapper>=2025.12.3", "qcore-utils>=2025.12.2", - "source_modelling>=2025.12.1", + "source_modelling>=2026.6.1", # Data Formats "geopandas", "pandas[parquet, hdf5]", diff --git a/tests/test_generate_domain.py b/tests/test_generate_domain.py index 54c29677..f4efe9a7 100644 --- a/tests/test_generate_domain.py +++ b/tests/test_generate_domain.py @@ -6,7 +6,7 @@ from hypothesis import given from hypothesis import strategies as st -from source_modelling import sources +from source_modelling import magnitude_scaling, sources from workflow.realisations import ( Magnitudes, Rakes, @@ -90,7 +90,7 @@ def test_generate_domain() -> None: dip_dir=180.0, ) source_config = SourceConfig(dict(source=source)) - magnitudes = Magnitudes(dict(source=6.0)) + magnitudes = Magnitudes(dict(source=magnitude_scaling.BoldM(6.0))) rakes = Rakes(dict(source=180.0)) velocity_model_parameters = VelocityModelParameters( diff --git a/tests/test_realisation.py b/tests/test_realisation.py index 57b9ea0c..c0f539f8 100644 --- a/tests/test_realisation.py +++ b/tests/test_realisation.py @@ -13,7 +13,7 @@ import schema from IM import im_calculation -from source_modelling import rupture_propagation +from source_modelling import magnitude_scaling, rupture_propagation from velocity_modelling import bounding_box from workflow import defaults, realisations, schemas from workflow.realisations import SourceConfig @@ -493,7 +493,11 @@ def test_rupture_prop_config(tmp_path: Path) -> None: def test_magnitudes(tmp_path: Path) -> None: magnitudes = realisations.Magnitudes( - magnitudes={"A": 6.5, "B": 6.7, "C": 6.9}, + magnitudes={ + "A": magnitude_scaling.BoldM(6.5), + "B": magnitude_scaling.BoldM(6.7), + "C": magnitude_scaling.BoldM(6.9), + }, ) realisation_ffp = tmp_path / "realisation.json" diff --git a/uv.lock b/uv.lock index 62cd965f..84c754be 100644 --- a/uv.lock +++ b/uv.lock @@ -1073,22 +1073,26 @@ wheels = [ [[package]] name = "llvmlite" -version = "0.46.0" +version = "0.47.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/74/cd/08ae687ba099c7e3d21fe2ea536500563ef1943c5105bf6ab4ee3829f68e/llvmlite-0.46.0.tar.gz", hash = "sha256:227c9fd6d09dce2783c18b754b7cd9d9b3b3515210c46acc2d3c5badd9870ceb", size = 193456, upload-time = "2025-12-08T18:15:36.295Z" } +sdist = { url = "https://files.pythonhosted.org/packages/01/88/a8952b6d5c21e74cbf158515b779666f692846502623e9e3c39d8e8ba25f/llvmlite-0.47.0.tar.gz", hash = "sha256:62031ce968ec74e95092184d4b0e857e444f8fdff0b8f9213707699570c33ccc", size = 193614, upload-time = "2026-03-31T18:29:53.497Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/2b/f8/4db016a5e547d4e054ff2f3b99203d63a497465f81ab78ec8eb2ff7b2304/llvmlite-0.46.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:6b9588ad4c63b4f0175a3984b85494f0c927c6b001e3a246a3a7fb3920d9a137", size = 37232767, upload-time = "2025-12-08T18:15:00.737Z" }, - { url = "https://files.pythonhosted.org/packages/aa/85/4890a7c14b4fa54400945cb52ac3cd88545bbdb973c440f98ca41591cdc5/llvmlite-0.46.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:3535bd2bb6a2d7ae4012681ac228e5132cdb75fefb1bcb24e33f2f3e0c865ed4", size = 56275176, upload-time = "2025-12-08T18:15:03.936Z" }, - { url = "https://files.pythonhosted.org/packages/6a/07/3d31d39c1a1a08cd5337e78299fca77e6aebc07c059fbd0033e3edfab45c/llvmlite-0.46.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4cbfd366e60ff87ea6cc62f50bc4cd800ebb13ed4c149466f50cf2163a473d1e", size = 55128630, upload-time = "2025-12-08T18:15:07.196Z" }, - { url = "https://files.pythonhosted.org/packages/2a/6b/d139535d7590a1bba1ceb68751bef22fadaa5b815bbdf0e858e3875726b2/llvmlite-0.46.0-cp312-cp312-win_amd64.whl", hash = "sha256:398b39db462c39563a97b912d4f2866cd37cba60537975a09679b28fbbc0fb38", size = 38138940, upload-time = "2025-12-08T18:15:10.162Z" }, - { url = "https://files.pythonhosted.org/packages/e6/ff/3eba7eb0aed4b6fca37125387cd417e8c458e750621fce56d2c541f67fa8/llvmlite-0.46.0-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:30b60892d034bc560e0ec6654737aaa74e5ca327bd8114d82136aa071d611172", size = 37232767, upload-time = "2025-12-08T18:15:13.22Z" }, - { url = "https://files.pythonhosted.org/packages/0e/54/737755c0a91558364b9200702c3c9c15d70ed63f9b98a2c32f1c2aa1f3ba/llvmlite-0.46.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:6cc19b051753368a9c9f31dc041299059ee91aceec81bd57b0e385e5d5bf1a54", size = 56275176, upload-time = "2025-12-08T18:15:16.339Z" }, - { url = "https://files.pythonhosted.org/packages/e6/91/14f32e1d70905c1c0aa4e6609ab5d705c3183116ca02ac6df2091868413a/llvmlite-0.46.0-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:bca185892908f9ede48c0acd547fe4dc1bafefb8a4967d47db6cf664f9332d12", size = 55128629, upload-time = "2025-12-08T18:15:19.493Z" }, - { url = "https://files.pythonhosted.org/packages/4a/a7/d526ae86708cea531935ae777b6dbcabe7db52718e6401e0fb9c5edea80e/llvmlite-0.46.0-cp313-cp313-win_amd64.whl", hash = "sha256:67438fd30e12349ebb054d86a5a1a57fd5e87d264d2451bcfafbbbaa25b82a35", size = 38138941, upload-time = "2025-12-08T18:15:22.536Z" }, - { url = "https://files.pythonhosted.org/packages/95/ae/af0ffb724814cc2ea64445acad05f71cff5f799bb7efb22e47ee99340dbc/llvmlite-0.46.0-cp314-cp314-macosx_12_0_arm64.whl", hash = "sha256:d252edfb9f4ac1fcf20652258e3f102b26b03eef738dc8a6ffdab7d7d341d547", size = 37232768, upload-time = "2025-12-08T18:15:25.055Z" }, - { url = "https://files.pythonhosted.org/packages/c9/19/5018e5352019be753b7b07f7759cdabb69ca5779fea2494be8839270df4c/llvmlite-0.46.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:379fdd1c59badeff8982cb47e4694a6143bec3bb49aa10a466e095410522064d", size = 56275173, upload-time = "2025-12-08T18:15:28.109Z" }, - { url = "https://files.pythonhosted.org/packages/9f/c9/d57877759d707e84c082163c543853245f91b70c804115a5010532890f18/llvmlite-0.46.0-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2e8cbfff7f6db0fa2c771ad24154e2a7e457c2444d7673e6de06b8b698c3b269", size = 55128628, upload-time = "2025-12-08T18:15:31.098Z" }, - { url = "https://files.pythonhosted.org/packages/30/a8/e61a8c2b3cc7a597073d9cde1fcbb567e9d827f1db30c93cf80422eac70d/llvmlite-0.46.0-cp314-cp314-win_amd64.whl", hash = "sha256:7821eda3ec1f18050f981819756631d60b6d7ab1a6cf806d9efefbe3f4082d61", size = 39153056, upload-time = "2025-12-08T18:15:33.938Z" }, + { url = "https://files.pythonhosted.org/packages/fa/48/4b7fe0e34c169fa2f12532916133e0b219d2823b540733651b34fdac509a/llvmlite-0.47.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:306a265f408c259067257a732c8e159284334018b4083a9e35f67d19792b164f", size = 37232769, upload-time = "2026-03-31T18:28:43.735Z" }, + { url = "https://files.pythonhosted.org/packages/e6/4b/e3f2cd17822cf772a4a51a0a8080b0032e6d37b2dbe8cfb724eac4e31c52/llvmlite-0.47.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5853bf26160857c0c2573415ff4efe01c4c651e59e2c55c2a088740acfee51cd", size = 56275178, upload-time = "2026-03-31T18:28:48.342Z" }, + { url = "https://files.pythonhosted.org/packages/b6/55/a3b4a543185305a9bdf3d9759d53646ed96e55e7dfd43f53e7a421b8fbae/llvmlite-0.47.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:003bcf7fa579e14db59c1a1e113f93ab8a06b56a4be31c7f08264d1d4072d077", size = 55128632, upload-time = "2026-03-31T18:28:52.901Z" }, + { url = "https://files.pythonhosted.org/packages/2f/f5/d281ae0f79378a5a91f308ea9fdb9f9cc068fddd09629edc0725a5a8fde1/llvmlite-0.47.0-cp312-cp312-win_amd64.whl", hash = "sha256:f3079f25bdc24cd9d27c4b2b5e68f5f60c4fdb7e8ad5ee2b9b006007558f9df7", size = 38138692, upload-time = "2026-03-31T18:28:57.147Z" }, + { url = "https://files.pythonhosted.org/packages/77/6f/4615353e016799f80fa52ccb270a843c413b22361fadda2589b2922fb9b0/llvmlite-0.47.0-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:a3c6a735d4e1041808434f9d440faa3d78d9b4af2ee64d05a66f351883b6ceec", size = 37232771, upload-time = "2026-03-31T18:29:01.324Z" }, + { url = "https://files.pythonhosted.org/packages/31/b8/69f5565f1a280d032525878a86511eebed0645818492feeb169dfb20ae8e/llvmlite-0.47.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:2699a74321189e812d476a43d6d7f652f51811e7b5aad9d9bba842a1c7927acb", size = 56275178, upload-time = "2026-03-31T18:29:05.748Z" }, + { url = "https://files.pythonhosted.org/packages/d6/da/b32cafcb926fb0ce2aa25553bf32cb8764af31438f40e2481df08884c947/llvmlite-0.47.0-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6c6951e2b29930227963e53ee152441f0e14be92e9d4231852102d986c761e40", size = 55128632, upload-time = "2026-03-31T18:29:11.235Z" }, + { url = "https://files.pythonhosted.org/packages/46/9f/4898b44e4042c60fafcb1162dfb7014f6f15b1ec19bf29cfea6bf26df90d/llvmlite-0.47.0-cp313-cp313-win_amd64.whl", hash = "sha256:c2e9adf8698d813a9a5efb2d4370caf344dbc1e145019851fee6a6f319ba760e", size = 38138695, upload-time = "2026-03-31T18:29:15.43Z" }, + { url = "https://files.pythonhosted.org/packages/1c/d4/33c8af00f0bf6f552d74f3a054f648af2c5bc6bece97972f3bfadce4f5ec/llvmlite-0.47.0-cp314-cp314-macosx_12_0_arm64.whl", hash = "sha256:de966c626c35c9dff5ae7bf12db25637738d0df83fc370cf793bc94d43d92d14", size = 37232773, upload-time = "2026-03-31T18:29:19.453Z" }, + { url = "https://files.pythonhosted.org/packages/64/1d/a760e993e0c0ba6db38d46b9f48f6c7dceb8ac838824997fb9e25f97bc04/llvmlite-0.47.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ddbccff2aeaff8670368340a158abefc032fe9b3ccf7d9c496639263d00151aa", size = 56275176, upload-time = "2026-03-31T18:29:24.149Z" }, + { url = "https://files.pythonhosted.org/packages/84/3b/e679bc3b29127182a7f4aa2d2e9e5bea42adb93fb840484147d59c236299/llvmlite-0.47.0-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d4a7b778a2e144fc64468fb9bf509ac1226c9813a00b4d7afea5d988c4e22fca", size = 55128631, upload-time = "2026-03-31T18:29:29.536Z" }, + { url = "https://files.pythonhosted.org/packages/be/f7/19e2a09c62809c9e63bbd14ce71fb92c6ff7b7b3045741bb00c781efc3c9/llvmlite-0.47.0-cp314-cp314-win_amd64.whl", hash = "sha256:694e3c2cdc472ed2bd8bd4555ca002eec4310961dd58ef791d508f57b5cc4c94", size = 39153826, upload-time = "2026-03-31T18:29:33.681Z" }, + { url = "https://files.pythonhosted.org/packages/40/a1/581a8c707b5e80efdbbe1dd94527404d33fe50bceb71f39d5a7e11bd57b7/llvmlite-0.47.0-cp314-cp314t-macosx_12_0_arm64.whl", hash = "sha256:92ec8a169a20b473c1c54d4695e371bde36489fc1efa3688e11e99beba0abf9c", size = 37232772, upload-time = "2026-03-31T18:29:37.952Z" }, + { url = "https://files.pythonhosted.org/packages/11/03/16090dd6f74ba2b8b922276047f15962fbeea0a75d5601607edb301ba945/llvmlite-0.47.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:fa1cbd800edd3b20bc141521f7fd45a6185a5b84109aa6855134e81397ffe72b", size = 56275178, upload-time = "2026-03-31T18:29:42.58Z" }, + { url = "https://files.pythonhosted.org/packages/f5/cb/0abf1dd4c5286a95ffe0c1d8c67aec06b515894a0dd2ac97f5e27b82ab0b/llvmlite-0.47.0-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f6725179b89f03b17dabe236ff3422cb8291b4c1bf40af152826dfd34e350ae8", size = 55128632, upload-time = "2026-03-31T18:29:46.939Z" }, + { url = "https://files.pythonhosted.org/packages/4f/79/d3bbab197e86e0ff4f9c07122895b66a3e0d024247fcff7f12c473cb36d9/llvmlite-0.47.0-cp314-cp314t-win_amd64.whl", hash = "sha256:6842cf6f707ec4be3d985a385ad03f72b2d724439e118fcbe99b2929964f0453", size = 39153839, upload-time = "2026-03-31T18:29:51.004Z" }, ] [[package]] @@ -1469,26 +1473,30 @@ wheels = [ [[package]] name = "numba" -version = "0.63.1" +version = "0.65.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "llvmlite" }, { name = "numpy" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/dc/60/0145d479b2209bd8fdae5f44201eceb8ce5a23e0ed54c71f57db24618665/numba-0.63.1.tar.gz", hash = "sha256:b320aa675d0e3b17b40364935ea52a7b1c670c9037c39cf92c49502a75902f4b", size = 2761666, upload-time = "2025-12-10T02:57:39.002Z" } +sdist = { url = "https://files.pythonhosted.org/packages/f6/c5/db2ac3685833d626c0dcae6bd2330cd68433e1fd248d15f70998160d3ad7/numba-0.65.1.tar.gz", hash = "sha256:19357146c32fe9ed25059ab915e8465fb13951cf6b0aace3826b76886373ab23", size = 2765600, upload-time = "2026-04-24T02:02:56.551Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/14/9c/c0974cd3d00ff70d30e8ff90522ba5fbb2bcee168a867d2321d8d0457676/numba-0.63.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2819cd52afa5d8d04e057bdfd54367575105f8829350d8fb5e4066fb7591cc71", size = 2680981, upload-time = "2025-12-10T02:57:17.579Z" }, - { url = "https://files.pythonhosted.org/packages/cb/70/ea2bc45205f206b7a24ee68a159f5097c9ca7e6466806e7c213587e0c2b1/numba-0.63.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5cfd45dbd3d409e713b1ccfdc2ee72ca82006860254429f4ef01867fdba5845f", size = 3801656, upload-time = "2025-12-10T02:57:19.106Z" }, - { url = "https://files.pythonhosted.org/packages/0d/82/4f4ba4fd0f99825cbf3cdefd682ca3678be1702b63362011de6e5f71f831/numba-0.63.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:69a599df6976c03b7ecf15d05302696f79f7e6d10d620367407517943355bcb0", size = 3501857, upload-time = "2025-12-10T02:57:20.721Z" }, - { url = "https://files.pythonhosted.org/packages/af/fd/6540456efa90b5f6604a86ff50dabefb187e43557e9081adcad3be44f048/numba-0.63.1-cp312-cp312-win_amd64.whl", hash = "sha256:bbad8c63e4fc7eb3cdb2c2da52178e180419f7969f9a685f283b313a70b92af3", size = 2750282, upload-time = "2025-12-10T02:57:22.474Z" }, - { url = "https://files.pythonhosted.org/packages/57/f7/e19e6eff445bec52dde5bed1ebb162925a8e6f988164f1ae4b3475a73680/numba-0.63.1-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:0bd4fd820ef7442dcc07da184c3f54bb41d2bdb7b35bacf3448e73d081f730dc", size = 2680954, upload-time = "2025-12-10T02:57:24.145Z" }, - { url = "https://files.pythonhosted.org/packages/e9/6c/1e222edba1e20e6b113912caa9b1665b5809433cbcb042dfd133c6f1fd38/numba-0.63.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:53de693abe4be3bd4dee38e1c55f01c55ff644a6a3696a3670589e6e4c39cde2", size = 3809736, upload-time = "2025-12-10T02:57:25.836Z" }, - { url = "https://files.pythonhosted.org/packages/76/0a/590bad11a8b3feeac30a24d01198d46bdb76ad15c70d3a530691ce3cae58/numba-0.63.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:81227821a72a763c3d4ac290abbb4371d855b59fdf85d5af22a47c0e86bf8c7e", size = 3508854, upload-time = "2025-12-10T02:57:27.438Z" }, - { url = "https://files.pythonhosted.org/packages/4e/f5/3800384a24eed1e4d524669cdbc0b9b8a628800bb1e90d7bd676e5f22581/numba-0.63.1-cp313-cp313-win_amd64.whl", hash = "sha256:eb227b07c2ac37b09432a9bda5142047a2d1055646e089d4a240a2643e508102", size = 2750228, upload-time = "2025-12-10T02:57:30.36Z" }, - { url = "https://files.pythonhosted.org/packages/36/2f/53be2aa8a55ee2608ebe1231789cbb217f6ece7f5e1c685d2f0752e95a5b/numba-0.63.1-cp314-cp314-macosx_12_0_arm64.whl", hash = "sha256:f180883e5508940cc83de8a8bea37fc6dd20fbe4e5558d4659b8b9bef5ff4731", size = 2681153, upload-time = "2025-12-10T02:57:32.016Z" }, - { url = "https://files.pythonhosted.org/packages/13/91/53e59c86759a0648282368d42ba732c29524a745fd555ed1fb1df83febbe/numba-0.63.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f0938764afa82a47c0e895637a6c55547a42c9e1d35cac42285b1fa60a8b02bb", size = 3778718, upload-time = "2025-12-10T02:57:33.764Z" }, - { url = "https://files.pythonhosted.org/packages/6c/0c/2be19eba50b0b7636f6d1f69dfb2825530537708a234ba1ff34afc640138/numba-0.63.1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f90a929fa5094e062d4e0368ede1f4497d5e40f800e80aa5222c4734236a2894", size = 3478712, upload-time = "2025-12-10T02:57:35.518Z" }, - { url = "https://files.pythonhosted.org/packages/0d/5f/4d0c9e756732577a52211f31da13a3d943d185f7fb90723f56d79c696caa/numba-0.63.1-cp314-cp314-win_amd64.whl", hash = "sha256:8d6d5ce85f572ed4e1a135dbb8c0114538f9dd0e3657eeb0bb64ab204cbe2a8f", size = 2752161, upload-time = "2025-12-10T02:57:37.12Z" }, + { url = "https://files.pythonhosted.org/packages/57/bc/76f8f8c5cf9adee47fdb7bbb03be8900f76f902d451d7477cf12b845e1de/numba-0.65.1-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:ac3f1e77c352dd0ea9712732c2d8f9ca507717435eec5b5013bf138ac33c4a08", size = 2681371, upload-time = "2026-04-24T02:02:26.105Z" }, + { url = "https://files.pythonhosted.org/packages/69/47/a415af0283e4db0398104c6d1c11c9861a98dc67a7aa442a7769ed5d6196/numba-0.65.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:52bc6f3ceb8fcaff9b2ae26b4c6b1e9fee39db8d355534c0fe4f39a901246b84", size = 3802467, upload-time = "2026-04-24T02:02:27.712Z" }, + { url = "https://files.pythonhosted.org/packages/46/36/246f73ec99cfeab2f2cb2ce7d4218766cc36a2da418901223f4f4da9c813/numba-0.65.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:90ca10b3463bae0bd70589726fe3c77d01d6b5fc86bee54bcdf9fb6b47c28977", size = 3502628, upload-time = "2026-04-24T02:02:29.763Z" }, + { url = "https://files.pythonhosted.org/packages/db/9e/3c679b2ee078425b9e99a91e44f8d132a6830d8ccce5227bc5e9181aeed8/numba-0.65.1-cp312-cp312-win_amd64.whl", hash = "sha256:5971c632be2a2351500431f46213821dba8d02b18a9f7d02fd36bd2743e41a6a", size = 2750611, upload-time = "2026-04-24T02:02:31.477Z" }, + { url = "https://files.pythonhosted.org/packages/79/37/14a4579049c1eb673afd0de0cb4842982acd55b9ce2643e763db858bcea0/numba-0.65.1-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:1735c15c1134a5108b4d6a5c77fc0947924ea066a738dc09a52008c13df9cad3", size = 2681344, upload-time = "2026-04-24T02:02:33.65Z" }, + { url = "https://files.pythonhosted.org/packages/a0/22/b8d873f6466b20aa563fc9b33acd48dec89a07803ddaa2f1c8ca1cd33126/numba-0.65.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c09f49117ef255e1f1c6dad0c7a1ed39868243862a73be5706793241a3755f1b", size = 3810619, upload-time = "2026-04-24T02:02:36.041Z" }, + { url = "https://files.pythonhosted.org/packages/62/08/e16a8b5d9a018962ebb5c66be662317cde32b9f5dab08441f90bed5522fb/numba-0.65.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:594a8680b3fadac99e97e489b1fd89007177e5336713745c3b769528c635a464", size = 3509783, upload-time = "2026-04-24T02:02:38.245Z" }, + { url = "https://files.pythonhosted.org/packages/fd/a5/03c970d57f4c1741354837353ce39fb5206952ae1dba8922d29c86f64805/numba-0.65.1-cp313-cp313-win_amd64.whl", hash = "sha256:85be74c0d036842699a30058f82fb88fc5ffdc59f7615cab5792ea92914c9b62", size = 2750534, upload-time = "2026-04-24T02:02:39.903Z" }, + { url = "https://files.pythonhosted.org/packages/4f/2e/8aed9b726d9ba5f11ad287645fd479e88278db3060a25cb1225d730eb2b7/numba-0.65.1-cp314-cp314-macosx_12_0_arm64.whl", hash = "sha256:33f5eb68eb1c843511615d14663ce60258525d6a4c65ab040e2c2b0c4cf17450", size = 2681554, upload-time = "2026-04-24T02:02:41.812Z" }, + { url = "https://files.pythonhosted.org/packages/87/96/f3eb235fafa82a34e2ab5dd7dc9ffff998ebf5f0bbc23fa56a96aeb44da6/numba-0.65.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:71e73029bf53a62cc6afcf96be4bd942290d8b4c55f0a454fb536158115790f7", size = 3779602, upload-time = "2026-04-24T02:02:43.726Z" }, + { url = "https://files.pythonhosted.org/packages/09/90/b0f09b48752d23640b8284f22aa597737e8adaddc7fbfacc4708b7f73a4c/numba-0.65.1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3a07635e0be926b9bdbffb09137c230fb13f6ec0e564914ba937cee12ce3eb35", size = 3479532, upload-time = "2026-04-24T02:02:45.427Z" }, + { url = "https://files.pythonhosted.org/packages/56/46/3f7fc04fb853559e74b210e0b62c19974ec844cefec611f9e535f4da3761/numba-0.65.1-cp314-cp314-win_amd64.whl", hash = "sha256:2a20fcdabdefbdacf88d85caf70c3b18c4bcb7ebb8f82e6a19486383dd26ab63", size = 2752637, upload-time = "2026-04-24T02:02:47.664Z" }, + { url = "https://files.pythonhosted.org/packages/81/7b/c1a341a9067367778f4152a5f01061cf281fb09582c92c510ec4918cabf6/numba-0.65.1-cp314-cp314t-macosx_12_0_arm64.whl", hash = "sha256:548dd4b3a4508d5062768d1514b2cd7b015f9a25ec7af651c50dee243965e652", size = 2684600, upload-time = "2026-04-24T02:02:49.653Z" }, + { url = "https://files.pythonhosted.org/packages/03/36/98ddbcf3e4f04a6dd07e1c67249955920579ba4af6bb6868e3088f4ed282/numba-0.65.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:78abc28feff2c2ff8307fff3975b6438352759c9acb797ecd6b1fb6e7e39e31d", size = 3817198, upload-time = "2026-04-24T02:02:51.266Z" }, + { url = "https://files.pythonhosted.org/packages/a3/83/0dad21057ece5a835599f5d24099b091703995e23dbbf894f259e91c010b/numba-0.65.1-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ee7676cb389555805f9b9a1840cbcd1ea6c8bd5376ab6918e3a29c5ea1dbda20", size = 3533862, upload-time = "2026-04-24T02:02:52.987Z" }, + { url = "https://files.pythonhosted.org/packages/32/36/8be7118ffd4c8440881046eac3d0982cc5ab42909508cf5d67024d62a2e4/numba-0.65.1-cp314-cp314t-win_amd64.whl", hash = "sha256:20609346e3bd75204950dcbbfe383a8d7dbf4902f442aedbf00f97fef4aa8f38", size = 2758237, upload-time = "2026-04-24T02:02:54.612Z" }, ] [[package]] @@ -2757,12 +2765,14 @@ wheels = [ [[package]] name = "source-modelling" -version = "2025.12.1" +version = "2026.6.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "fiona" }, { name = "geopandas" }, + { name = "h5py" }, { name = "networkx" }, + { name = "numba" }, { name = "numpy" }, { name = "pandas" }, { name = "parse" }, @@ -2771,16 +2781,16 @@ dependencies = [ { name = "shapely" }, { name = "xarray", extra = ["io"] }, ] -sdist = { url = "https://files.pythonhosted.org/packages/7d/bb/46e27b37854874c8d05400b16572ae2ddce02c7bdde9aaa56be779686532/source_modelling-2025.12.1.tar.gz", hash = "sha256:01f0ec2f215000c8048ba55ca2903e516bab8971da167d4f4c75c381a0f28b2d", size = 41609091, upload-time = "2025-12-10T01:58:24.072Z" } +sdist = { url = "https://files.pythonhosted.org/packages/48/c7/ee71e74a2791549f91048d5feb2c7d3677f24a6e592670c93cb2a791993c/source_modelling-2026.6.1.tar.gz", hash = "sha256:e22b3526267a15ebb625f105018b9d7fe8c5299a7f1ae1c72f9b360d5a6a31cd", size = 406369, upload-time = "2026-06-03T00:03:06.129Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/7c/05/c09147d9a9e146f78d3117e2326e1fbae70f3cd693d22b4ba8785ec4c0a3/source_modelling-2025.12.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:58e2839897a43d7167005fdc45c58432c42fbab58ef9028d589b8968859bab97", size = 514997, upload-time = "2025-12-10T01:58:11.748Z" }, - { url = "https://files.pythonhosted.org/packages/f7/da/342824c2b39e5980ac8224a2ff58443d274b0f58009f19e57bd6dac77ca5/source_modelling-2025.12.1-cp312-cp312-macosx_11_0_x86_64.whl", hash = "sha256:fe9089c4a271f4717483baffefa3cdfeed2e503c8b771ce06b998e50b3b094f3", size = 524851, upload-time = "2025-12-10T01:58:13.244Z" }, - { url = "https://files.pythonhosted.org/packages/1e/79/c97aa38aad6fd18984c6df586b172565bbbdb837d7f6a9bd43b7fe3f414b/source_modelling-2025.12.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:541578569f5d2e5a900349047bdad2fbabbedbbd0028ff746f2965bc1bf57fe6", size = 560996, upload-time = "2025-12-10T01:58:14.771Z" }, - { url = "https://files.pythonhosted.org/packages/14/34/b8f3c7eab4b521f90ad2c53c5b714c57be676b692d350f109de4d0631991/source_modelling-2025.12.1-cp312-cp312-win_amd64.whl", hash = "sha256:077fa7aa6843962d951bc3db92e3a76fa4578f3ec3037d49a1ea8c4b5718dd51", size = 412848, upload-time = "2025-12-10T01:58:15.902Z" }, - { url = "https://files.pythonhosted.org/packages/8b/b4/0599eeaf12fc454917d0569ff922636351e6e524b119b5fe70c3c68a72b3/source_modelling-2025.12.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:12789f9e1417bd28eaa29deef0ced591c9b1a78306558f9d38dc248bba454e70", size = 514968, upload-time = "2025-12-10T01:58:17.07Z" }, - { url = "https://files.pythonhosted.org/packages/77/f4/5ff354ee68c9614dc680f24be3cddbe1b211c0ba6b532be5cf6a3d18dcfb/source_modelling-2025.12.1-cp313-cp313-macosx_11_0_x86_64.whl", hash = "sha256:03b3e0aa78f59ba88451fa989dccb5fba019f39adbebf65a0d8592a267502124", size = 524770, upload-time = "2025-12-10T01:58:18.37Z" }, - { url = "https://files.pythonhosted.org/packages/dd/ab/8cea95ab7e6ef9f0a791ef12fd8115de5483a5caef38aa94e92fdbcc1fa2/source_modelling-2025.12.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:63e074babe3f6a87af946e31fd29f9d8deaecdcaaaa2ee4fef3b6ddfa7a54eec", size = 560957, upload-time = "2025-12-10T01:58:19.481Z" }, - { url = "https://files.pythonhosted.org/packages/bb/43/57fd8b83a8eb80ea34620885061243991755bd71b29e68d7ec32ce440261/source_modelling-2025.12.1-cp313-cp313-win_amd64.whl", hash = "sha256:7667d02ad5d906d16b8862b98901b850aa10fa961e0a3097498df8e3b8171ce4", size = 412903, upload-time = "2025-12-10T01:58:20.819Z" }, + { url = "https://files.pythonhosted.org/packages/ca/ba/9410f0ddbe17c5b300af16bf3dcac08eb852fcb96f77b75b70e8a9cf164b/source_modelling-2026.6.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:31332ec31c174a332330759d6c4436f52badf50b3d1aabf42558b73ac0b0445b", size = 516101, upload-time = "2026-06-03T00:02:55.484Z" }, + { url = "https://files.pythonhosted.org/packages/b2/1b/00d80edf1d047e7215795d45dc4d69ef4ce35d2da158a1a4b95fcb3e4e3a/source_modelling-2026.6.1-cp312-cp312-macosx_11_0_x86_64.whl", hash = "sha256:3951083761d878b88c418b90c8816b11b339a2a9ff5e16efee4eda4bc4598b8b", size = 520151, upload-time = "2026-06-03T00:02:56.874Z" }, + { url = "https://files.pythonhosted.org/packages/0a/89/2ff236170486a5434b78786f1b4fdadb1261c2f644e58cafde532afc5cba/source_modelling-2026.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ed919543293e0570e55089c4de977807ce812039474cb97623f8b20146b4ce61", size = 558348, upload-time = "2026-06-03T00:02:58.383Z" }, + { url = "https://files.pythonhosted.org/packages/37/75/91418381d747f746d46f6c6fe99b47de25f627aa02a0b1ef249e0ba80fdd/source_modelling-2026.6.1-cp312-cp312-win_amd64.whl", hash = "sha256:cd4587c61b8ab342347238b256d98f0d05cbba1ef593d6254880903eb1670daf", size = 414571, upload-time = "2026-06-03T00:02:59.863Z" }, + { url = "https://files.pythonhosted.org/packages/60/7d/b538b88d385ed1ebdc1bb7edaeb87fe796826a8b0d2edbdc12869cdca1b5/source_modelling-2026.6.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:61666ca0d52240e8c8927362f68c962e0bbefdcbab77d6700c18fb3b2077996a", size = 516331, upload-time = "2026-06-03T00:03:01.128Z" }, + { url = "https://files.pythonhosted.org/packages/bf/83/e464ae2b02510988959082c0fa88a456f322692389742dc59eb6e0bbb00b/source_modelling-2026.6.1-cp313-cp313-macosx_11_0_x86_64.whl", hash = "sha256:4fa45005e848a1fc216e51c6fbec914fd794d3e2e0837ef741b2a27c2039ee80", size = 520245, upload-time = "2026-06-03T00:03:02.314Z" }, + { url = "https://files.pythonhosted.org/packages/55/0f/2c77e98e383161ebc72831d1bffbbbc967463596fa605bf7c1c8016adad5/source_modelling-2026.6.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:174e208627be44fe14e1d2966c3f21306985843b43d608b1cb7831793e11dd2c", size = 558527, upload-time = "2026-06-03T00:03:03.586Z" }, + { url = "https://files.pythonhosted.org/packages/7e/b5/e28234179eb747e4512dd6f1d1086443e554dfb09856c6140e6a5d8e8fab/source_modelling-2026.6.1-cp313-cp313-win_amd64.whl", hash = "sha256:3c5d9a1821eb2ca57d26d82027565ede27b96a3715be02a5546f4ce66a5062b1", size = 414507, upload-time = "2026-06-03T00:03:04.815Z" }, ] [[package]] @@ -3173,7 +3183,7 @@ requires-dist = [ { name = "scipy" }, { name = "scipy-stubs", marker = "extra == 'types'" }, { name = "shapely" }, - { name = "source-modelling", specifier = ">=2025.12.1" }, + { name = "source-modelling", specifier = ">=2026.6.1" }, { name = "structlog" }, { name = "tqdm" }, { name = "ty", marker = "extra == 'dev'" }, diff --git a/workflow/realisations.py b/workflow/realisations.py index 0ac98f0f..37f7c9de 100644 --- a/workflow/realisations.py +++ b/workflow/realisations.py @@ -26,6 +26,7 @@ from IM import im_calculation from source_modelling import sources +from source_modelling.magnitude_scaling import BoldM from source_modelling.rupture_propagation import JumpPair from source_modelling.sources import IsSource from velocity_modelling.bounding_box import BoundingBox @@ -649,10 +650,10 @@ class Magnitudes(RealisationConfiguration): _config_key: ClassVar[str] = "magnitudes" _schema: ClassVar[Schema] = schemas.MAGNITUDE_SCHEMA - magnitudes: dict[str, float] + magnitudes: dict[str, BoldM] """A map from faults to their magnitudes.""" - def __getitem__(self, key: str) -> float: + def __getitem__(self, key: str) -> BoldM: """Get the magnitude for a fault name. Parameters @@ -662,7 +663,7 @@ def __getitem__(self, key: str) -> float: Returns ------- - float + BoldM The magnitude. """ return self.magnitudes[key] diff --git a/workflow/scripts/gcmt_to_realisation.py b/workflow/scripts/gcmt_to_realisation.py index ff395a96..8bb75634 100644 --- a/workflow/scripts/gcmt_to_realisation.py +++ b/workflow/scripts/gcmt_to_realisation.py @@ -284,7 +284,9 @@ def gcmt_to_realisation( hypocentre = np.array([1 / 2, 1 / 2]) source_config = SourceConfig(source_geometries={gcmt_event_id: source_geometry}) - magnitudes = Magnitudes(magnitudes={gcmt_event_id: float(magnitude)}) + magnitudes = Magnitudes( + magnitudes={gcmt_event_id: magnitude_scaling.BoldM(float(magnitude))} + ) rakes = Rakes(rakes={gcmt_event_id: float(rake)}) rupture_config = RupturePropagationConfig( rupture_causality_tree={gcmt_event_id: None}, diff --git a/workflow/scripts/generate_domain.py b/workflow/scripts/generate_domain.py index e52dc1b6..8263b9db 100644 --- a/workflow/scripts/generate_domain.py +++ b/workflow/scripts/generate_domain.py @@ -38,7 +38,7 @@ import typer from qcore import cli, geo -from source_modelling import moment, sources +from source_modelling import magnitude_scaling, moment, sources from velocity_modelling import bounding_box from velocity_modelling.bounding_box import BoundingBox from workflow import log_utils, realisations, utils @@ -129,13 +129,13 @@ def boundary_distance( return float(shapely.hausdorff_distance(source_geometry, bounding_box_geometry)) -def total_magnitude(magnitudes: Iterable[float]) -> float: +def total_magnitude(magnitudes: Iterable[magnitude_scaling.BoldM]) -> float: """ Compute the total magnitude from an array of individual magnitudes. Parameters ---------- - magnitudes : Iterable[float] + magnitudes : Iterable[magnitude_scaling.BoldM] An array of magnitudes. Returns @@ -144,7 +144,7 @@ def total_magnitude(magnitudes: Iterable[float]) -> float: The total magnitude, computed from the summed moment of the input magnitudes. """ total_moment = sum( - moment.magnitude_to_moment(magnitude) for magnitude in magnitudes + moment.magnitude_to_moment(magnitude, bold_m=True) for magnitude in magnitudes ) return moment.moment_to_magnitude(total_moment) @@ -228,7 +228,7 @@ def average_rake(rakes: Rakes, magnitudes: Magnitudes) -> float: The moment-weighted average rake. """ moments = { - k: moment.magnitude_to_moment(magnitude) + k: moment.magnitude_to_moment(magnitude, bold_m=True) for k, magnitude in magnitudes.magnitudes.items() } max_moment = max(moments.values()) diff --git a/workflow/scripts/nshm2022_to_realisation.py b/workflow/scripts/nshm2022_to_realisation.py index ab9d5339..a599978e 100755 --- a/workflow/scripts/nshm2022_to_realisation.py +++ b/workflow/scripts/nshm2022_to_realisation.py @@ -376,7 +376,9 @@ def generate_realisation( strategy=str(strategy), # type: ignore jump_impossibility_limit_distance=round(jump_cutoff * 1000), ) - magnitudes = Magnitudes(magnitudes) + # ty flags this because dict is invariant (dict[str, float] != dict[str, BoldM]), + # but BoldM is a float NewType, so this is a safe no-op at runtime. + magnitudes = Magnitudes(magnitudes) # ty: ignore[invalid-argument-type] rakes = Rakes(rakes) rupture_propagation_config = RupturePropagationConfig( rupture_causality_tree=rupture_causality_tree, diff --git a/workflow/scripts/realisation_to_srf.py b/workflow/scripts/realisation_to_srf.py index 6ff3a100..eef98847 100644 --- a/workflow/scripts/realisation_to_srf.py +++ b/workflow/scripts/realisation_to_srf.py @@ -657,7 +657,7 @@ def generate_point_source_srf( # Get magnitude and convert to seismic moment magnitude = params.magnitudes.magnitudes[name] - moment_newton_metre = moment.magnitude_to_moment(magnitude) + moment_newton_metre = moment.magnitude_to_moment(magnitude, bold_m=True) velocity_model_df = params.velocity_model_1d.model.copy() velocity_model_df["depth_km"] = ( From e4aac3dc7ad53008eb3b31932df50304da59129d Mon Sep 17 00:00:00 2001 From: Andrew Ridden-Harper Date: Thu, 4 Jun 2026 10:12:39 +1200 Subject: [PATCH 2/8] enable SRF V2 in genslip --- workflow/scripts/realisation_to_srf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/scripts/realisation_to_srf.py b/workflow/scripts/realisation_to_srf.py index eef98847..a2d50982 100644 --- a/workflow/scripts/realisation_to_srf.py +++ b/workflow/scripts/realisation_to_srf.py @@ -456,7 +456,7 @@ def _build_genslip_command( cmd = [ str(genslip_path), "plane_header=1", - "srf_version=1.0", + "srf_version=2.0", "read_erf=0", "write_srf=1", "read_gsf=1", From 33bc6348d14548bb888c45a7a27db2c516b24b9e Mon Sep 17 00:00:00 2001 From: Andrew Ridden-Harper <52001209+AndrewRidden-Harper@users.noreply.github.com> Date: Fri, 5 Jun 2026 16:35:37 +1200 Subject: [PATCH 3/8] make it explicit that moment_to_magnitude uses BoldM Co-authored-by: Jake Faulkner --- workflow/scripts/gcmt_to_realisation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/scripts/gcmt_to_realisation.py b/workflow/scripts/gcmt_to_realisation.py index 8bb75634..3ddd8e5f 100644 --- a/workflow/scripts/gcmt_to_realisation.py +++ b/workflow/scripts/gcmt_to_realisation.py @@ -192,7 +192,7 @@ def gcmt_to_realisation( param_hint="GCMT_EVENT_ID", ) - magnitude = moment.moment_to_magnitude(solution_moment) + magnitude = moment.moment_to_magnitude(solution_moment, bold_m=True) model = community_fault_model.get_community_fault_model() From e73516796d830fcf656aa32684158c80266c911a Mon Sep 17 00:00:00 2001 From: Andrew Ridden-Harper <52001209+AndrewRidden-Harper@users.noreply.github.com> Date: Fri, 5 Jun 2026 16:36:51 +1200 Subject: [PATCH 4/8] fix: don't cast to BoldM as it should already be BoldM Co-authored-by: Jake Faulkner --- workflow/scripts/gcmt_to_realisation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/scripts/gcmt_to_realisation.py b/workflow/scripts/gcmt_to_realisation.py index 3ddd8e5f..af1d2f1e 100644 --- a/workflow/scripts/gcmt_to_realisation.py +++ b/workflow/scripts/gcmt_to_realisation.py @@ -285,7 +285,7 @@ def gcmt_to_realisation( source_config = SourceConfig(source_geometries={gcmt_event_id: source_geometry}) magnitudes = Magnitudes( - magnitudes={gcmt_event_id: magnitude_scaling.BoldM(float(magnitude))} + magnitudes={gcmt_event_id: magnitude} ) rakes = Rakes(rakes={gcmt_event_id: float(rake)}) rupture_config = RupturePropagationConfig( From 508189796be1b4e0dffbadf3ed71b5427e07a5d8 Mon Sep 17 00:00:00 2001 From: Andrew Ridden-Harper Date: Fri, 5 Jun 2026 16:47:25 +1200 Subject: [PATCH 5/8] fix: update genslip test for SRF V2 version string Commit e4aac3d switched genslip to srf_version=2.0, but test_build_genslip_command_static_args still expected 1.0. Update the test's expected arg set to match. Co-Authored-By: Claude Opus 4.8 --- tests/test_realisation_to_srf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_realisation_to_srf.py b/tests/test_realisation_to_srf.py index c6525ffc..407ed1cf 100644 --- a/tests/test_realisation_to_srf.py +++ b/tests/test_realisation_to_srf.py @@ -158,7 +158,7 @@ def test_build_genslip_command_static_args() -> None: "nh=1", "read_erf=0", "plane_header=1", - "srf_version=1.0", + "srf_version=2.0", "read_gsf=1", "nstk=50", "ndip=25", From c892ccd478b267288af70a53a6dcad54b5ccccb0 Mon Sep 17 00:00:00 2001 From: Andrew Ridden-Harper Date: Tue, 9 Jun 2026 13:48:55 +1200 Subject: [PATCH 6/8] del unnecessary code --- workflow/scripts/gcmt_to_realisation.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/workflow/scripts/gcmt_to_realisation.py b/workflow/scripts/gcmt_to_realisation.py index af1d2f1e..43e92f07 100644 --- a/workflow/scripts/gcmt_to_realisation.py +++ b/workflow/scripts/gcmt_to_realisation.py @@ -193,7 +193,6 @@ def gcmt_to_realisation( ) magnitude = moment.moment_to_magnitude(solution_moment, bold_m=True) - model = community_fault_model.get_community_fault_model() match nodal_plane: @@ -206,43 +205,34 @@ def gcmt_to_realisation( model, np.array([latitude, longitude]), nodal_plane_1, nodal_plane_2 ) - rake = selected_nodal_plane.rake - # Calculate dip direction from strike (strike + 90 degrees for right-hand rule) dip_direction = (selected_nodal_plane.strike + 90) % 360 length, width = magnitude_scaling.magnitude_to_length_width( - scaling_relation, magnitude, rake + scaling_relation, magnitude, selected_nodal_plane.rake ) centroid = np.array([latitude, longitude, centroid_depth]) # Create source based on source_type parameter if source_type == SourceType.POINT_SOURCE: - length_km, width_km = magnitude_scaling.magnitude_to_length_width( - scaling_relation, magnitude, rake - ) - length_m = length_km * 1000 # Convert km to meters - width_m = width_km * 1000 # Convert km to meters - source_geometry = sources.Point.from_lat_lon_depth( point_coordinates=np.array( [latitude, longitude, centroid_depth * 1000] ), # Convert km to meters - length_m=length_m, # Use calculated length from area - width_m=width_m, # Use calculated width from area + length_m=length*1000, # convert km to metres + width_m=width*1000, # convert km to metres strike=selected_nodal_plane.strike, dip=selected_nodal_plane.dip, dip_dir=dip_direction, ) else: - # Create plane source (default behavior) plane = sources.Plane.from_centroid_strike_dip( centroid, selected_nodal_plane.dip, - length, - width, + length*1000, # convert km to metres + width*1000, # convert km to metres strike=selected_nodal_plane.strike, ) @@ -287,7 +277,7 @@ def gcmt_to_realisation( magnitudes = Magnitudes( magnitudes={gcmt_event_id: magnitude} ) - rakes = Rakes(rakes={gcmt_event_id: float(rake)}) + rakes = Rakes(rakes={gcmt_event_id: float(selected_nodal_plane.rake)}) rupture_config = RupturePropagationConfig( rupture_causality_tree={gcmt_event_id: None}, jump_points={}, From dc9ab1d4794696f7f70b0ff6d85ffafc31e4b208 Mon Sep 17 00:00:00 2001 From: Andrew Ridden-Harper Date: Wed, 10 Jun 2026 14:32:56 +1200 Subject: [PATCH 7/8] Use convention-aware magnitude from source-modelling Co-Authored-By: Claude Fable 5 --- pyproject.toml | 2 +- uv.lock | 22 ++++----- workflow/scripts/nshm2022_to_realisation.py | 51 ++++++--------------- 3 files changed, 26 insertions(+), 49 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 77bf8c4e..f15d20f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ dependencies = [ "nshmdb>=2025.12.1", "oq_wrapper>=2025.12.3", "qcore-utils>=2025.12.2", - "source_modelling>=2026.6.1", + "source_modelling>=2026.6.2", # Data Formats "geopandas", "pandas[parquet, hdf5]", diff --git a/uv.lock b/uv.lock index 84c754be..be199ed9 100644 --- a/uv.lock +++ b/uv.lock @@ -2765,7 +2765,7 @@ wheels = [ [[package]] name = "source-modelling" -version = "2026.6.1" +version = "2026.6.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "fiona" }, @@ -2781,16 +2781,16 @@ dependencies = [ { name = "shapely" }, { name = "xarray", extra = ["io"] }, ] -sdist = { url = "https://files.pythonhosted.org/packages/48/c7/ee71e74a2791549f91048d5feb2c7d3677f24a6e592670c93cb2a791993c/source_modelling-2026.6.1.tar.gz", hash = "sha256:e22b3526267a15ebb625f105018b9d7fe8c5299a7f1ae1c72f9b360d5a6a31cd", size = 406369, upload-time = "2026-06-03T00:03:06.129Z" } +sdist = { url = "https://files.pythonhosted.org/packages/51/7f/47613841dab65a763bc4aa13ddb5a259814136d21fc3eeb226e7f1e17b19/source_modelling-2026.6.2.tar.gz", hash = "sha256:63d846f81af81fe41609402ab1c0696d41f3356599e338866940e43911022e5d", size = 406486, upload-time = "2026-06-09T04:08:03.284Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/ca/ba/9410f0ddbe17c5b300af16bf3dcac08eb852fcb96f77b75b70e8a9cf164b/source_modelling-2026.6.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:31332ec31c174a332330759d6c4436f52badf50b3d1aabf42558b73ac0b0445b", size = 516101, upload-time = "2026-06-03T00:02:55.484Z" }, - { url = "https://files.pythonhosted.org/packages/b2/1b/00d80edf1d047e7215795d45dc4d69ef4ce35d2da158a1a4b95fcb3e4e3a/source_modelling-2026.6.1-cp312-cp312-macosx_11_0_x86_64.whl", hash = "sha256:3951083761d878b88c418b90c8816b11b339a2a9ff5e16efee4eda4bc4598b8b", size = 520151, upload-time = "2026-06-03T00:02:56.874Z" }, - { url = "https://files.pythonhosted.org/packages/0a/89/2ff236170486a5434b78786f1b4fdadb1261c2f644e58cafde532afc5cba/source_modelling-2026.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ed919543293e0570e55089c4de977807ce812039474cb97623f8b20146b4ce61", size = 558348, upload-time = "2026-06-03T00:02:58.383Z" }, - { url = "https://files.pythonhosted.org/packages/37/75/91418381d747f746d46f6c6fe99b47de25f627aa02a0b1ef249e0ba80fdd/source_modelling-2026.6.1-cp312-cp312-win_amd64.whl", hash = "sha256:cd4587c61b8ab342347238b256d98f0d05cbba1ef593d6254880903eb1670daf", size = 414571, upload-time = "2026-06-03T00:02:59.863Z" }, - { url = "https://files.pythonhosted.org/packages/60/7d/b538b88d385ed1ebdc1bb7edaeb87fe796826a8b0d2edbdc12869cdca1b5/source_modelling-2026.6.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:61666ca0d52240e8c8927362f68c962e0bbefdcbab77d6700c18fb3b2077996a", size = 516331, upload-time = "2026-06-03T00:03:01.128Z" }, - { url = "https://files.pythonhosted.org/packages/bf/83/e464ae2b02510988959082c0fa88a456f322692389742dc59eb6e0bbb00b/source_modelling-2026.6.1-cp313-cp313-macosx_11_0_x86_64.whl", hash = "sha256:4fa45005e848a1fc216e51c6fbec914fd794d3e2e0837ef741b2a27c2039ee80", size = 520245, upload-time = "2026-06-03T00:03:02.314Z" }, - { url = "https://files.pythonhosted.org/packages/55/0f/2c77e98e383161ebc72831d1bffbbbc967463596fa605bf7c1c8016adad5/source_modelling-2026.6.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:174e208627be44fe14e1d2966c3f21306985843b43d608b1cb7831793e11dd2c", size = 558527, upload-time = "2026-06-03T00:03:03.586Z" }, - { url = "https://files.pythonhosted.org/packages/7e/b5/e28234179eb747e4512dd6f1d1086443e554dfb09856c6140e6a5d8e8fab/source_modelling-2026.6.1-cp313-cp313-win_amd64.whl", hash = "sha256:3c5d9a1821eb2ca57d26d82027565ede27b96a3715be02a5546f4ce66a5062b1", size = 414507, upload-time = "2026-06-03T00:03:04.815Z" }, + { url = "https://files.pythonhosted.org/packages/0c/79/61f7f506ef1dfa253c5af7b50765867f2d687c4f35d8fc2c93851ee5fdcc/source_modelling-2026.6.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:87e943362b889da5b9a1c2a2176aaa34e296a615ed9cdc7fd1037bcf32eb9cf1", size = 516223, upload-time = "2026-06-09T04:07:52.138Z" }, + { url = "https://files.pythonhosted.org/packages/e6/73/24e8527c874875ab9ed6823eac7f05b885e2ad5798a9f450ba0f0956fc56/source_modelling-2026.6.2-cp312-cp312-macosx_11_0_x86_64.whl", hash = "sha256:512eadbc4e49709c47060d4db51e09c383360489a8a3d9fdf11bef1dde5f2038", size = 520274, upload-time = "2026-06-09T04:07:53.507Z" }, + { url = "https://files.pythonhosted.org/packages/76/04/a208806f79755ed49e45bfa77f51b647ca7f76a1fc6ff7f15e03585e0469/source_modelling-2026.6.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c44e4e866c6bf383ca64ebc23ea43f5b4ee9a2810a2601397f3835e0d56c4d00", size = 558469, upload-time = "2026-06-09T04:07:54.715Z" }, + { url = "https://files.pythonhosted.org/packages/eb/05/40c6663cbf719d0fb6ba60fa6d53fa9a0cc7dc25448c4a2585def220ea25/source_modelling-2026.6.2-cp312-cp312-win_amd64.whl", hash = "sha256:fc54f17fb982cd0f5b20a1f165b8660cc5ebc07748c17c4ae0ce2d25fd762a4d", size = 414687, upload-time = "2026-06-09T04:07:56.787Z" }, + { url = "https://files.pythonhosted.org/packages/e0/a1/89f44f4993fe8edfe84fd405a0833950c5ea108d1eeceb2c977d48a7da46/source_modelling-2026.6.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:ff55bb9650cdd7175e8554423d8105cc78ed01c03eb9476a092e6f248df5a1ac", size = 516451, upload-time = "2026-06-09T04:07:58.102Z" }, + { url = "https://files.pythonhosted.org/packages/62/e1/6f7fafb3cf9bca6a9b7c97595b8cb820c3a822f9d63e34807ca60c6bd6c1/source_modelling-2026.6.2-cp313-cp313-macosx_11_0_x86_64.whl", hash = "sha256:5c3a78c57ebe44c7ad314824509f2fbea5a4da8b3032329ae16319939c2199f0", size = 520366, upload-time = "2026-06-09T04:07:59.606Z" }, + { url = "https://files.pythonhosted.org/packages/f1/bd/a44b7364ef9b78975caf1d3fa2ebe18b059dd75357040e5280487c501b54/source_modelling-2026.6.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1c77abc4a13321bd2421ab50cd3aeea14219608fd4bae5ae9522b68b0eaa0d5a", size = 558647, upload-time = "2026-06-09T04:08:00.777Z" }, + { url = "https://files.pythonhosted.org/packages/51/ea/e8194142b2e7a8b8c141485bcaa2ae6c74fff3cd82703310f5238fb9bff4/source_modelling-2026.6.2-cp313-cp313-win_amd64.whl", hash = "sha256:990d1441e70e3514c63ec9b5c9809b21900be948edec336c52aa4fa38b8b3a62", size = 414625, upload-time = "2026-06-09T04:08:01.891Z" }, ] [[package]] @@ -3183,7 +3183,7 @@ requires-dist = [ { name = "scipy" }, { name = "scipy-stubs", marker = "extra == 'types'" }, { name = "shapely" }, - { name = "source-modelling", specifier = ">=2026.6.1" }, + { name = "source-modelling", specifier = ">=2026.6.2" }, { name = "structlog" }, { name = "tqdm" }, { name = "ty", marker = "extra == 'dev'" }, diff --git a/workflow/scripts/nshm2022_to_realisation.py b/workflow/scripts/nshm2022_to_realisation.py index a599978e..e2ffdd11 100755 --- a/workflow/scripts/nshm2022_to_realisation.py +++ b/workflow/scripts/nshm2022_to_realisation.py @@ -45,8 +45,8 @@ from nshmdb import nshmdb from qcore import cli -from qcore.uncertainties import distributions, mag_scaling -from source_modelling import moment, rupture_propagation, sources +from qcore.uncertainties import distributions +from source_modelling import magnitude_scaling, moment, rupture_propagation, sources from source_modelling.sources import Fault from workflow import realisations from workflow.defaults import DefaultsVersion @@ -64,39 +64,13 @@ app = typer.Typer() -def a_to_mw_leonard(area: float, rake: float) -> float: - """ - Convert fault area and rake to moment magnitude using the Leonard scaling relation. - - Parameters - ---------- - area : float - The area of the fault in square kilometres. - rake : float - The rake angle of the fault in degrees. - - Returns - ------- - float - The estimated moment magnitude of the fault. - - References - ---------- - Leonard, M. (2010). Earthquake fault scaling: Self-consistent - relating of rupture length, width, average displacement, and - moment release. Bulletin of the Seismological Society of America, - 100(5A), 1971-1988. - """ - return mag_scaling.a_to_mw_leonard(area, 4, 3.99, rake) - - def default_magnitude_estimation( faults: dict[str, Fault], # NOTE: this must be in quotes because the runtime class DisjointSet is # not generic, just the stub implementation. components: "DisjointSet[str]", avg_rake: float, -) -> dict[str, float]: +) -> dict[str, magnitude_scaling.BoldM]: """Estimate the magnitudes for a set of faults based on their areas and average rake. Parameters @@ -113,11 +87,14 @@ def default_magnitude_estimation( Returns ------- dict - A dictionary where the keys are fault names and the values are the estimated magnitudes for each fault. + A dictionary where the keys are fault names and the values are the + estimated magnitudes (in the `BoldM` convention) for each fault. """ total_area = sum(fault.area() for fault in faults.values()) - estimated_mw = a_to_mw_leonard(total_area, avg_rake) - estimated_moment = mag_scaling.mag2mom(estimated_mw) + estimated_magnitude = magnitude_scaling.area_to_magnitude( + magnitude_scaling.ScalingRelation.LEONARD2014, total_area, avg_rake + ) + estimated_moment = moment.magnitude_to_moment(estimated_magnitude, bold_m=True) roots = {components[fault_name] for fault_name in faults} component_areas = { root: sum(faults[name].area() for name in components.subset(root)) @@ -139,7 +116,7 @@ def default_magnitude_estimation( segment_moments[fault_name] = (fault.area() / component_area) * component_moment return { - fault_name: mag_scaling.mom2mag(fault_moment) + fault_name: moment.moment_to_magnitude(fault_moment, bold_m=True) for fault_name, fault_moment in segment_moments.items() } @@ -355,7 +332,9 @@ def generate_realisation( ] ) else: - mfds_rates = db.most_likely_fault(rupture_id, magnitudes) + # The ty ignore below can be removed once NSHM2022DB merges the change to + # accept dict[str, BoldM] in most_likely_fault (branch support-BoldM-in-workflow). + mfds_rates = db.most_likely_fault(rupture_id, magnitudes) # ty: ignore[invalid-argument-type] mfds_probabilities = np.array(list(mfds_rates.values())) if np.allclose(mfds_probabilities, 0): mfds_probabilities = np.ones_like(mfds_probabilities) @@ -376,9 +355,7 @@ def generate_realisation( strategy=str(strategy), # type: ignore jump_impossibility_limit_distance=round(jump_cutoff * 1000), ) - # ty flags this because dict is invariant (dict[str, float] != dict[str, BoldM]), - # but BoldM is a float NewType, so this is a safe no-op at runtime. - magnitudes = Magnitudes(magnitudes) # ty: ignore[invalid-argument-type] + magnitudes = Magnitudes(magnitudes) rakes = Rakes(rakes) rupture_propagation_config = RupturePropagationConfig( rupture_causality_tree=rupture_causality_tree, From 2ac757266e1303949d5b5a1c0d4fb04347864063 Mon Sep 17 00:00:00 2001 From: Jake Faulkner Date: Thu, 11 Jun 2026 10:32:56 +1200 Subject: [PATCH 8/8] ruff formatting + dyne-cm conversion --- workflow/schemas.py | 28 +++++++++---------- workflow/scripts/convert_vm_hdf5_to_emod3d.py | 1 - workflow/scripts/gcmt_to_realisation.py | 16 +++++------ workflow/scripts/generate_velocity_model.py | 1 + workflow/utils.py | 1 + 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/workflow/schemas.py b/workflow/schemas.py index 6a56a86a..204aec56 100644 --- a/workflow/schemas.py +++ b/workflow/schemas.py @@ -31,8 +31,10 @@ class Stype(StrEnum): cos = "cos" seki = "seki" + class KModel(IntEnum): """Correlation length models for genslip.""" + SOMERVILLE = 1 MAI = 2 FRANKEL = 3 @@ -400,9 +402,8 @@ def _corners_to_array(corners_spec: list[dict[str, float]]) -> np.ndarray: ), Literal( "rvfrac_slip_sig", - description="Rupture velocity fraction slip sigma (null = disabled)."): Or( - And(NUMBER, _is_non_negative), None - ), + description="Rupture velocity fraction slip sigma (null = disabled).", + ): Or(And(NUMBER, _is_non_negative), None), Literal( "shallow_depth", description="Shallow transition depth.", @@ -489,12 +490,12 @@ def _corners_to_array(corners_spec: list[dict[str, float]]) -> np.ndarray: Literal("beta_asp", description="Asperity beta parameter."): And( NUMBER, _is_positive ), - Literal( - "beta_deep", description="Deep beta parameter for rise time." - ): And(NUMBER, _is_positive), - Literal( - "beta_mid", description="Mid-depth beta parameter for rise time." - ): And(NUMBER, _is_positive), + Literal("beta_deep", description="Deep beta parameter for rise time."): And( + NUMBER, _is_positive + ), + Literal("beta_mid", description="Mid-depth beta parameter for rise time."): And( + NUMBER, _is_positive + ), Literal( "beta_mid_depth", description="Mid-depth level for beta depth scaling.", @@ -503,9 +504,9 @@ def _corners_to_array(corners_spec: list[dict[str, float]]) -> np.ndarray: "beta_mid_depth_range", description="Mid-depth range for beta depth scaling.", ): And(NUMBER, _is_positive), - Literal( - "beta_shal", description="Shallow beta parameter for rise time." - ): And(NUMBER, _is_positive), + Literal("beta_shal", description="Shallow beta parameter for rise time."): And( + NUMBER, _is_positive + ), Literal( "beta_shal_depth", description="Shallow depth level for beta depth scaling.", @@ -552,7 +553,7 @@ def _corners_to_array(corners_spec: list[dict[str, float]]) -> np.ndarray: Literal( "stype", description="Slip time function type for genslip (null = use genslip default).", - ): Or(Use(Stype),None), + ): Or(Use(Stype), None), # Hybrid Correlation Length (hyb_corlen) Parameters Literal( "hyb_corlen_deep_wt_end", @@ -615,7 +616,6 @@ def _corners_to_array(corners_spec: list[dict[str, float]]) -> np.ndarray: "rvfmin", description="Minimum rupture velocity fraction.", ): And(NUMBER, _is_positive), - # Tapering & Slip Level Adjustments Literal( "truncate_zero_slip", diff --git a/workflow/scripts/convert_vm_hdf5_to_emod3d.py b/workflow/scripts/convert_vm_hdf5_to_emod3d.py index ee6a5465..5343d51c 100644 --- a/workflow/scripts/convert_vm_hdf5_to_emod3d.py +++ b/workflow/scripts/convert_vm_hdf5_to_emod3d.py @@ -72,4 +72,3 @@ def convert_vm_hdf5_to_emod3d( convert_hdf5_to_emod3d.convert_hdf5_to_emod3d( hdf5_output_file, velocity_model_output ) - diff --git a/workflow/scripts/gcmt_to_realisation.py b/workflow/scripts/gcmt_to_realisation.py index 43e92f07..77fe826f 100644 --- a/workflow/scripts/gcmt_to_realisation.py +++ b/workflow/scripts/gcmt_to_realisation.py @@ -192,7 +192,9 @@ def gcmt_to_realisation( param_hint="GCMT_EVENT_ID", ) - magnitude = moment.moment_to_magnitude(solution_moment, bold_m=True) + magnitude = moment.moment_to_magnitude( + moment.dyne_cm_to_newton_metre(solution_moment), bold_m=True + ) model = community_fault_model.get_community_fault_model() match nodal_plane: @@ -220,8 +222,8 @@ def gcmt_to_realisation( point_coordinates=np.array( [latitude, longitude, centroid_depth * 1000] ), # Convert km to meters - length_m=length*1000, # convert km to metres - width_m=width*1000, # convert km to metres + length_m=length * 1000, # convert km to metres + width_m=width * 1000, # convert km to metres strike=selected_nodal_plane.strike, dip=selected_nodal_plane.dip, dip_dir=dip_direction, @@ -231,8 +233,8 @@ def gcmt_to_realisation( plane = sources.Plane.from_centroid_strike_dip( centroid, selected_nodal_plane.dip, - length*1000, # convert km to metres - width*1000, # convert km to metres + length * 1000, # convert km to metres + width * 1000, # convert km to metres strike=selected_nodal_plane.strike, ) @@ -274,9 +276,7 @@ def gcmt_to_realisation( hypocentre = np.array([1 / 2, 1 / 2]) source_config = SourceConfig(source_geometries={gcmt_event_id: source_geometry}) - magnitudes = Magnitudes( - magnitudes={gcmt_event_id: magnitude} - ) + magnitudes = Magnitudes(magnitudes={gcmt_event_id: magnitude}) rakes = Rakes(rakes={gcmt_event_id: float(selected_nodal_plane.rake)}) rupture_config = RupturePropagationConfig( rupture_causality_tree={gcmt_event_id: None}, diff --git a/workflow/scripts/generate_velocity_model.py b/workflow/scripts/generate_velocity_model.py index f2611f12..9aa2f5c7 100644 --- a/workflow/scripts/generate_velocity_model.py +++ b/workflow/scripts/generate_velocity_model.py @@ -54,6 +54,7 @@ app = typer.Typer() + def write_nzvm_config( resolution: Resolution, domain_parameters: DomainParameters, diff --git a/workflow/utils.py b/workflow/utils.py index 2c30ccb6..69ecbd1c 100644 --- a/workflow/utils.py +++ b/workflow/utils.py @@ -196,6 +196,7 @@ def merge_dictionaries(dict_a: dict[str, Any], dict_b: dict[str, Any]) -> None: else: dict_a[key] = value + def stable_hash(value: str, size: int = 4) -> int: """Compute stable hashes for strings.