Logo: Gamma Phase Associator

Gamma Phase Associator

OrganisatiounBeléift
benchflow-ai
gamma-phase-associator

An overview of the python package for running the GaMMA earthquake phase association algorithm. The algorithm expects phase picks data and station data as input and produces (through unsupervised clustering) earthquake events with source information like earthquake location, origin time and magnitude. The skill explains commonly used functions and the expected input/output format.

Iwwersiicht

Editeurbenchflow-ai
Repositoryskillsbench
Skill-Nummgamma-phase-associator
Stären
1.8K
Forks
371
Matgeliwwert Dateien
Nëmmen Instruktiounen
LizenzApache-2.0
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    benchflow-ai huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Gamma Phase Associator an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/benchflow-ai/skillsbench/tree/main/tasks/earthquake-phase-association/environment/skills/gamma-phase-associator
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/benchflow-ai/skillsbench.git /tmp/skillsbench
mkdir -p .claude/skills
cp -r /tmp/skillsbench/tasks/earthquake-phase-association/environment/skills/gamma-phase-associator .claude/skills/gamma-phase-associator
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Gamma Phase Associator an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Gamma Phase Associator automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Gamma Phase Associator net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

GaMMA Associator Library

What is GaMMA?

GaMMA is an earthquake phase association algorithm that treats association as an unsupervised clustering problem. It uses multivariate Gaussian distribution to model the collection of phase picks of an event, and uses Expectation-Maximization to carry out pick assignment and estimate source parameters i.e., earthquake location, origin time, and magnitude.

GaMMA is a python library implementing the algorithm. For the input earthquake traces, this library assumes P/S wave picks have already been extracted. We provide documentation of its core API.

Zhu, W., McBrearty, I. W., Mousavi, S. M., Ellsworth, W. L., & Beroza, G. C. (2022). Earthquake phase association using a Bayesian Gaussian mixture model. Journal of Geophysical Research: Solid Earth, 127(5).

The skill is a derivative of the repo https://github.com/AI4EPS/GaMMA

Installing GaMMA

pip install git+https://github.com/wayneweiqiang/GaMMA.git

GaMMA core API

association

Function Signature
python
def association(picks, stations, config, event_idx0=0, method="BGMM", **kwargs)
Purpose

Associates seismic phase picks (P and S waves) to earthquake events using Bayesian or standard Gaussian Mixture Models. It clusters picks based on arrival time and amplitude information, then fits GMMs to estimate earthquake locations, times, and magnitudes.

1. Input Parameters
ParameterTypeDefaultDescription
picksDataFramerequiredSeismic phase pick data
stationsDataFramerequiredStation metadata with locations
configdictrequiredConfiguration parameters
event_idx0int0Starting event index for numbering
methodstr"BGMM""BGMM" (Bayesian) or "GMM" (standard)
2. Required DataFrame Columns
picks DataFrame
ColumnTypeDescriptionExample
idstrStation identifier (must match stations)network.station. or network.station.location.channel
timestampdatetime/strPick arrival time (ISO format or datetime)"2019-07-04T22:00:06.084"
typestrPhase type: "p" or "s" (lowercase)"p"
probfloatPick probability/weight (0-1)0.94
ampfloatAmplitude in m/s (required if use_amplitude=True)0.000017

Notes:

  • Timestamps must be in UTC or converted to UTC
  • Phase types are forced to lowercase internally
  • Picks with amp == 0 or amp == -1 are filtered when use_amplitude=True
  • The DataFrame index is used to track pick identities in the output
stations DataFrame
ColumnTypeDescriptionExample
idstrStation identifier"CI.CCC..BH"
x(km)floatX coordinate in km (projected)-35.6
y(km)floatY coordinate in km (projected)45.2
z(km)floatZ coordinate (elevation, typically negative)-0.67

Notes:

  • Coordinates should be in a projected local coordinate system (e.g., you can use the pyproj package)
  • The id column must match the id values in the picks DataFrame (e.g., network.station. or network.station.location.channel)
  • Group stations by unique id, identical attribute are collapsed to a single value and conflicting metadata are preseved as a sorted list.
3. Config Dictionary Keys
Required Keys
KeyTypeDescriptionExample
dimslist[str]Location dimensions to solve for["x(km)", "y(km)", "z(km)"]
min_picks_per_eqintMinimum picks required per earthquake5
max_sigma11floatMaximum allowed time residual in seconds2.0
use_amplitudeboolWhether to use amplitude in clusteringTrue
bfgs_boundstupleBounds for BFGS optimization((-35, 92), (-128, 78), (0, 21), (None, None))
oversample_factorfloatFactor for oversampling initial GMM components5.0 for BGMM, 1.0 for GMM

Notes on dims:

  • Options: ["x(km)", "y(km)", "z(km)"], ["x(km)", "y(km)"], or ["x(km)"]

Notes on bfgs_bounds:

  • Format: ((x_min, x_max), (y_min, y_max), (z_min, z_max), (None, None))
  • The last tuple is for time (unbounded)
Velocity Model Keys
KeyTypeDefaultDescription
veldict{"p": 6.0, "s": 3.47}Uniform velocity model (km/s)
eikonaldict/NoneNone1D velocity model for travel times
DBSCAN Pre-clustering Keys (Optional)
KeyTypeDefaultDescription
use_dbscanboolTrueEnable DBSCAN pre-clustering
dbscan_epsfloat25Max time between picks (seconds)
dbscan_min_samplesint3Min samples in DBSCAN neighborhood
dbscan_min_cluster_sizeint500Min cluster size for hierarchical splitting
dbscan_max_time_space_ratiofloat10Max time/space ratio for splitting
  • dbscan_eps is obtained from estimate_eps Function
Filtering Keys (Optional)

| Key | Type | Default | Description | |-----|------|-------------| | max_sigma22 | float | 1.0 | Max phase amplitude residual in log scale (required if use_amplitude=True) | | max_sigma12 | float | 1.0 | Max covariance | | max_sigma11 | float | 2.0 | Max phase time residual (s) | | min_p_picks_per_eq | int | 0 | Min P-phase picks per event | | min_s_picks_per_eq | int | 0 |Min S-phase picks per event | | min_stations | int | 5 |Min unique stations per event |

Other Optional Keys
KeyTypeDefaultDescription
covariance_priorlist[float]autoPrior for covariance [time, amp]
ncpuintautoNumber of CPUs for parallel processing
4. Return Values

Returns a tuple (events, assignments):

events (list[dict])

List of dictionaries, each representing an associated earthquake:

KeyTypeDescription
timestrOrigin time (ISO 8601 with milliseconds)
magnitudefloatEstimated magnitude (999 if use_amplitude=False)
sigma_timefloatTime uncertainty (seconds)
sigma_ampfloatAmplitude uncertainty (log10 scale)
cov_time_ampfloatTime-amplitude covariance
gamma_scorefloatAssociation quality score
num_picksintTotal picks assigned
num_p_picksintP-phase picks assigned
num_s_picksintS-phase picks assigned
event_indexintUnique event index
x(km)floatX coordinate of hypocenter
y(km)floatY coordinate of hypocenter
z(km)floatZ coordinate (depth)
assignments (list[tuple])

List of tuples (pick_index, event_index, gamma_score):

  • pick_index: Index in the original picks DataFrame
  • event_index: Associated event index
  • gamma_score: Probability/confidence of assignment

estimate_eps Function Documentation

Function Signature
python
def estimate_eps(stations, vp, sigma=2.0)
Purpose

Estimates an appropriate DBSCAN epsilon (eps) parameter for clustering seismic phase picks based on station spacing. The eps parameter controls the maximum time distance between picks that should be considered neighbors in the DBSCAN clustering algorithm.

1. Input Parameters
ParameterTypeDefaultDescription
stationsDataFramerequiredStation metadata with 3D coordinates
vpfloatrequiredP-wave velocity in km/s
sigmafloat2.0Number of standard deviations above the mean
2. Required DataFrame Columns
stations DataFrame
ColumnTypeDescriptionExample
x(km)floatX coordinate in km-35.6
y(km)floatY coordinate in km45.2
z(km)floatZ coordinate in km-0.67
3. Return Value
TypeDescription
floatEpsilon value in seconds for use with DBSCAN clustering
4. Example Usage
python
from gamma.utils import estimate_eps

# Assuming stations DataFrame is already prepared with x(km), y(km), z(km) columns
vp = 6.0  # P-wave velocity in km/s

# Estimate eps automatically based on station spacing
eps = estimate_eps(stations, vp, sigma=2.0)

# Use in config
config = {
    "use_dbscan": True,
    "dbscan_eps": eps,  # or use estimate_eps(stations, config["vel"]["p"])
    "dbscan_min_samples": 3,
    # ... other config options
}
Typical Usage Pattern
python
from gamma.utils import association, estimate_eps

# Automatic eps estimation
config["dbscan_eps"] = estimate_eps(stations, config["vel"]["p"])

# Or manual override (common in practice)
config["dbscan_eps"] = 15  # seconds
5. Practical Notes
  • In example notebooks, the function is often commented out in favor of hardcoded values (10-15 seconds)
  • Practitioners may prefer manual tuning for specific networks/regions
  • Typical output values range from 10-20 seconds depending on station density
  • Useful when optimal eps is unknown or when working with new networks
6. Related Configuration

The output is typically used with these config parameters:

python
config["dbscan_eps"] = estimate_eps(stations, config["vel"]["p"])
config["dbscan_min_samples"] = 3
config["dbscan_min_cluster_size"] = 500
config["dbscan_max_time_space_ratio"] = 10

Heefeg gestallte Froen

Wat mécht de KI-Skill Gamma Phase Associator?

An overview of the python package for running the GaMMA earthquake phase association algorithm. The algorithm expects phase picks data and station data as input and produces (through unsupervised clustering) earthquake events with source information like earthquake location, origin time and magnitude. The skill explains commonly used functions and the expected input/output format.

Firwat Gamma Phase Associator op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Gamma Phase Associator besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Gamma Phase Associator an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/benchflow-ai/skillsbench/tree/main/tasks/earthquake-phase-association/environment/skills/gamma-phase-associator an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Gamma Phase Associator benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Gamma Phase Associator benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Gamma Phase Associator domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Gamma Phase Associator gratis?

Jo. benchflow-ai huet de Skill ënner der Lizenz Apache-2.0 op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇