{"id":18818999,"url":"https://github.com/geoscienceaustralia/ga-wphase","last_synced_at":"2026-03-06T23:32:26.248Z","repository":{"id":42166951,"uuid":"322442790","full_name":"GeoscienceAustralia/ga-wphase","owner":"GeoscienceAustralia","description":"W-Phase inversion software used at the National Earthquake Alerts Centre","archived":false,"fork":false,"pushed_at":"2026-01-22T02:55:37.000Z","size":1715,"stargazers_count":11,"open_issues_count":0,"forks_count":6,"subscribers_count":8,"default_branch":"main","last_synced_at":"2026-01-22T14:12:30.176Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GeoscienceAustralia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-12-18T00:05:55.000Z","updated_at":"2025-12-04T02:59:50.000Z","dependencies_parsed_at":"2023-01-30T00:15:42.222Z","dependency_job_id":"6dbbc845-72c8-4cb4-a729-2730c72b12f1","html_url":"https://github.com/GeoscienceAustralia/ga-wphase","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/GeoscienceAustralia/ga-wphase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeoscienceAustralia%2Fga-wphase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeoscienceAustralia%2Fga-wphase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeoscienceAustralia%2Fga-wphase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeoscienceAustralia%2Fga-wphase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GeoscienceAustralia","download_url":"https://codeload.github.com/GeoscienceAustralia/ga-wphase/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeoscienceAustralia%2Fga-wphase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30203349,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"ssl_error","status_checked_at":"2026-03-06T18:57:34.882Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T00:19:46.737Z","updated_at":"2026-03-06T23:32:26.231Z","avatar_url":"https://github.com/GeoscienceAustralia.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GA W-Phase\n\nSoftware used for running wphase moment tensor + centroid inversions in the\nNational Earthquake Alert Centre at Geoscience Australia.\n\nOriginally implemented by Roberto Benavente.\n\nBased on the paper [*Source inversion of W phase: speeding up seismic tsunami\nwarning* by Kanamori and Rivera, 2008](https://doi.org/10.1111/j.1365-246X.2008.03887.x)\n\n\n## Requirements\n\n- Python 2.7+ or 3.6+ (with various PyPI dependencies)\n- Green's functions (see the section below)\n- Optional:\n  - SeisComP with python libraries (to use the CLI script to push results into\n    a SeisComP system/convert results to SCML)\n\n\n## Green's Functions\n\nThe Green's Function database used for W-Phase at GA is the same as those used\nby Kanamori and Rivera in their original implementation - see\n[here](http://wphase.unistra.fr/wiki/doku.php/wphase#green_s_function_databases)\nfor their information regarding these. You can contact them to attempt to\nobtain a copy of their original database; or attempt to generate a new one\nyourself using the PREM model. The database is stored as a directory structure\ncontaining SAC files, following this template:\n\n    H{DEPTH}/{MT_COMPONENT}/GF.{DISTANCE}.SY.LH{C}.SAC\n\nWhere:\n\n- `DEPTH` is the depth in km, which must end in `.5`\n- `MT_COMPONENT` is the moment tensor component, one of `PP`, `RP`, `RR`, `RT`,\n  `TP`, `TT` where `P` is \u0026phi;, `T` is \u0026theta;, `R` is r.\n- `DISTANCE` is the distance in 10ths of a degree, padded to 4 characters.\n  (In the current implementation, your database *must* include every 10th of a\n  degree from 0 to 90 degrees.)\n- `C` is the waveform component\n\nFor example, the vertical (`Z`) Green's function for M\u003csub\u003e\u0026phi;\u0026phi;\u003c/sub\u003e=1\n(`PP`) at a depth of 500.5km and distance of 90 degrees is stored at\n`H500.5/PP/GF.0900.SY.LHZ.SAC`.\n\nAs alternative to this very large file structure, an equivalent structure can be\nstored inside a HDF5 file.\n\n\n## Direct Installation\n\nFrom the same directory this README lives in:\n\n```sh\npip install .\n```\n\nIf you want to use it 'in place', use develop mode:\n\n```sh\npip install -e .\n```\n\nIf obspy has issues installing, you might need to install some dependencies first:\n\n```sh\npip install wheel Cython numpy\npip install .\n```\n\n## Running wphase\n\nRequired environment variables:\n\n- `WPHASE_OUTPUT_DIR`: absolute path to a directory in which W-Phase will write\n  its outputs.\n- `WPHASE_GREENS_FUNCTIONS`: absolute path to greens functions (either a\n  directory or a hdf5 file, as described above)\n\nYou can then run W-Phase in a couple of ways:\n\n- Directly from python, with basic results returned in a nested dict and\n  visualizations written to a provided output directory. See e.g.\n  [`test_runwphase`](tests/test_runwphase.py) for a minimal example.\n\n- Using the command-line script [`wphase`](scripts/wphase), which takes its\n  input as (a lot of!) command-line arguments and can send the basic results\n  directly to a SeisComP messaging system, and the visualizations to an Amazon\n  S3 bucket.\n\n  For example, if you have an FDSN server at http://localhost:8081 and a\n  SeisComP4+ messaging system at localhost:18180, the following script\n  would attempt to solve for the centroid moment tensor of an event at the\n  given location and time, and if successful, send the results to seiscomp\n  under the given event ID.\n\n```sh\nwphase \\\n    --evid ga2020yskxhe \\\n    --lat 5.2 \\\n    --lon 125.47 \\\n    --depth 42 \\\n    --time '2020-12-15T23:22:01Z' \\\n    --outputs /tmp/wphase-outputs \\\n    --server http://localhost:8081 \\\n    --host localhost:18180 \\\n    --debug\n```\n\nAll the usual seiscomp configuration flags are available:\n\n- `--console=1` to see errors on the command line (otherwise they are only\n  written to the logfile!)\n- `--debug` to see all log messages on the command line\n- `--user` to set the messaging username (default is `gawphase`)\n- `-g` to set the primary messaging group on which results are sent (default is\n  `FOCMECH`)\n\nYou can get a full list of options by invoking `run-wphase` with `--help`.\n\n\n\n## Using Docker\n\nIf you're running Linux with Docker and curl installed, you should be able to\nbuild a docker container simply by running (as root)\n`./run-or-build-container.sh build`.\n\nBy default, the image is configured to run as a non-root user with uid 1000;\nhopefully this maps on to your host user for easy development. To change this\nuid (or gid), provide the build-args `DOCKER_USER_UID` and/or\n`DOCKER_USER_GID`.\n\n### Developing on Docker\n\nWhile the container image includes the complete W-Phase application, it can\neasily be used for development by mounting in your working copy of the W-Phase\nsource.\n\nWhen you launch an interactive bash session on the container (e.g. using the\n`run-or-build-container.sh` script), if wphase is mounted at `/wphase` then it\nwill be automatically built and installed in development mode.\n\nThis is done for you if you use `./run-or-build-container.sh run`.\n\nTo use this script as-is, you'll need your greens functions to be stored at\n`~/wphase/greens`; but you should be able to modify the script to suit your\nneeds.\n\nTo start some process inside the container:\n\n```sh\n./run-or-build-container.sh run \u003ccommand\u003e\n\n# for example, to start a bash shell:\n./run-or-build-container.sh run bash\n\n# to run the test suite:\n./run-or-build-container.sh run pytest\n\n# to run the same example as above:\n./run-or-build-container.sh run wphase \\\n    --evid ga2020yskxhe \\\n    --lat 5.2 \\\n    --lon 125.47 \\\n    --depth 42 \\\n    --time '2020-12-15T23:22:01Z' \\\n    --outputs /tmp/wphase-outputs \\\n    --server http://localhost:8081 \\\n    --host localhost:18180 \\\n    --debug\n```\n\nSince the `./run-or-build-container.sh` script uses [host\nnetworking](https://docs.docker.com/network/host/), this last example would\nstill be able to contact the FDSN and Spread servers running on your host.\nAlternatively, you could of course use some other Docker networking scheme and\nswap out localhost for an appropriate hostname or IP.\n\n### Using Docker in production\n\nThe container image is also ready for production use: it includes a fully-built\nversion of wphase and directly invokes the wphase script as its default\nentrypoint default. It does *not* include the greens functions database (since\nthese are typically huge), so you'll still need to mount these; and you'll also\nneed to mount a directory to `/outputs`, where the output files will be stored.\n\nYou can use the `run-wphase` directive to invoke the production container,\nautomatically handling the directory mounting:\n\n```\n# to run the same example as above:\n./run-or-build-container.sh run-wphase \\\n    --evid ga2020yskxhe \\\n    --lat 5.2 \\\n    --lon 125.47 \\\n    --depth 42 \\\n    --time '2020-12-15T23:22:01Z' \\\n    --server http://localhost:8081 \\\n    --host localhost:18180\n```\n\nIn this example, the output files would then be available at\n`./outputs/ga2020ykxhe/`.\n\n## TODO\n\nI extracted this code from our private repository and ran a quick clean-up\npass, but many more improvements are possible:\n\n- Improve the Python API to return the results (focal mech,\n  derived origin, etc) in ObsPy or SeisComP data structures instead of the\n  current nested dictionaries?\n- Look into replacing the libtau fortran code with obspy's travel time model.\n    - When this code was first developed, apparently the latter was too slow; but\n      things might have improved or there might be optimizations we can make.\n    - I think this would allows us to relicense\n      under the more permissive Apache license (GA's preference).\n- General refactoring and code cleanup. I've done some, but there is a lot left\n  to do (particularly in the `psi/` directory).\n- Create a fully-integrated SeisComP plugin/daemon that watches the messaging\n  bus for events matching certain criteria and runs automatically (like\n  `scautomt` does).\n\n\n## License\n\nCopyright (C) 2021 Geoscience Australia\n\nThis program is free software; you can redistribute it and/or\nmodify it under the terms of the GNU General Public License\nas published by the Free Software Foundation; either version 2\nof the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeoscienceaustralia%2Fga-wphase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeoscienceaustralia%2Fga-wphase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeoscienceaustralia%2Fga-wphase/lists"}