T-rate is a Python/PyMC tool for inferring transient stress evolution from changes in seismicity rate. It was developed for seismicity rate observations governed by rate-and-state friction and is demonstrated here using synthetic experiments.
The code was developed for:
Jiang, Y., Trugman, D. T., & González, P. J. (2026).
Bayesian inference of complex stress evolution in rate-and-state governed faults constrained by seismicity rate observations.
Journal of Geophysical Research: Solid Earth.
T-rate estimates the timing and amplitude of transient stress-rate histories from observed changes in seismicity rate. The goal of the inversion is to find the stress-rate history that best explains the observed seismicity rate changes.
In the default implementation, each transient source is represented by a trapezoidal stress-rate function. For each ramp function, the source parameters are:
Here,
The global constitutive/loading parameters are:
Here,
The characteristic time is calculated internally as:
For a model with
where the two global parameters are
Figure 1. Stress and seismicity rate ratio under a trapezoidal ramp function stress rate history. (a) Stress rate (blue) and stress history (red), with the characteristic time epochs (t1-t4) highlighted in green. (b) The seismicity rate ratio is derived from the stress history shown in panel (a).
The physical meaning of the key parameters is summarized below.
| Group | Symbol | Parameter name | Physical definition |
|---|---|---|---|
| Source | Number of ramp functions | Number of transient stress-rate source functions | |
| Source | Stress-rate amplitude | Peak amplitude of the transient Coulomb stress rate |
|
| Source | Onset time | Start time of transient stress loading |
|
| Source | Ramp duration | Duration of stress-rate ramp-up | |
| Source | Plateau duration | Duration of constant stress-rate plateau | |
| Source | Ramp duration | Duration of stress-rate ramp-down | |
| Constitutive | Background stress rate | Steady-state tectonic shear stressing rate | |
| Constitutive | Frictional stress scale | Controls seismicity sensitivity to stress changes |
|
| Constitutive | Decay time | Characteristic aftershock decay time, calculated as |
|
| Constitutive | Seismicity rate | Non-earthquake-triggered seismicity rate | |
| Constitutive | Seismicity rate | Background seismicity rate |
T-rate/
├── Trate.py
├── run_T_rate_inversion_example.py
├── example_input/
│ └── .gitkeep
├── example_output/example/
├── figures/
│ ├── T_rate_logo.png
│ ├── Figure_parameter_schematic.png
│ └── Figure_control_experiment_results.png
├── README.md
├── requirements.txt
└── LICENSE
Trate.py contains the reusable T-rate core functions, including the forward model, posterior extraction, and plotting utilities. The Bayesian model setup, including the likelihood choice, is defined in run_T_rate_inversion_example.py.
The run_T_rate_inversion_example.py file is the user-facing driver script. New experiments can be created by copying and editing this script.
Create a separate environment:
conda create -n Trate_env python=3.11
conda activate Trate_env
pip install -r requirements.txtThe requirements.txt file should include:
numpy
pandas
matplotlib
seaborn
pymc
pytensor
arviz
scipy
tqdm
Run the control example:
python run_T_rate_inversion_example.pyThe example inversion takes approximately 5–15 minutes on a 4-core machine (10,000 draws + 10,000 tuning steps × 4 chains). The progress bar will appear shortly after the script starts.
The example inversion uses a synthetic input file included in example_input/:
example_input/example_input.txt
New users do not need to prepare their own catalog before running this example. The example inversion should run without modification if the repository is downloaded completely.
After a successful run, output files should be created in example_output/example/. It should contain files such as:
parameters.txt
posterior_summary.txt
R_obs_vs_mod.png
S_modeled.png
trace_plot.png
For a first test, users should:
- Create and activate the
Trate_envenvironment. - Run
python run_T_rate_inversion_example.pywithout changing anything. The script will take approximately 5–15 minutes to complete. The terminal will show a live progress bar during MCMC sampling — this is normal. - Confirm that output files are created in
example_output/example/. - Open
R_obs_vs_mod.png,S_modeled.png,joint_posterior_probability_kde.png, andtrace_plot.png.
For a new application, users should copy one existing driver script and modify the copy.
For example:
run_T_rate_inversion_example.py
There are two main places to modify.
This function controls the Bayesian inversion setup, including:
- prior distributions and prior bounds
- number of MCMC draws and tuning steps
- sampler choice
- likelihood choice
- number of chains and CPU cores
Typical parameters to modify include
In the README and manuscript notation, the Python variable Asigma_0 corresponds to tau_rate_bg corresponds to
For a first trial, choose prior bounds that are broad enough to include the expected transient timing and amplitude.
The example uses 10,000 draws and 10,000 tuning steps in pm.sample() to balance runtime and inversion stability. Users may increase the number of draws and tuning steps to obtain more stable posterior estimates and smoother uncertainty ranges, although this will increase the computational time.
The main execution block is:
if __name__ == "__main__":This part controls experiment-level settings, including:
- input data file
- time-bin width
time_bin - background seismicity rate
$r$ - number of ramp functions
$N$ , commonly defined in the code asn_ramps - experiment ID
- likelihood option
- output folder
The example driver script reads:
example_input/example_input.txt
This file is a plain text file with two columns:
time R/r
where:
timeis the middle time of each time binR/ris the seismicity rate ratio in that time bin
Example:
0.5 0.0
20.5 0.0
40.5 800.0
50.5 2050.0
80.5 100.0
The reusable forward model is unit-flexible, but the provided example script uses days as the time unit and Pa/day as the stress-rate unit. If users choose a different time unit, they should also update the prior values and plot labels in the driver/helper scripts. However, the same time unit must be used consistently for:
- time
- time-bin width
time_bin - source timing parameters
$t_1$ ,$\Delta t_{12}$ ,$\Delta t_{23}$ , and$\Delta t_{34}$ - background seismicity rate
$r$ - background stressing rate
$\dot{\tau}_r$
The background seismicity rate
Start with:
n_ramps = 1The reusable functions in Trate.py support multiple ramp functions, but the current example driver script is configured for n_ramps = 1. To use n_ramps > 1, users need to define prior bounds for each additional ramp in run_inversion().
The timing parameters are
Asigma_0. As a practical starting value, users can try:
This value is motivated by Sirorattanakul and Avouac (2026, Science Advances).
tau_rate_bg.
A practical first-order estimate is:
For crustal applications, users may start with a shear modulus of 30 GPa. The strain rate can be obtained from reliable sources such as GPS-based strain rate models (such as Global Strain Rate Model, Kreemer et al., 2014, G3), InSAR-based strain rate models, or other geodetic/experimental constraints.
Each run produces output files in example_output/example/. The exact output folder name can be modified in the driver script.
The current example script produces the following files:
Inversion_t_obsRr_modRr.txt
R_obs_vs_mod.png
R_r_optimal.txt
R_r_results.txt
S_modeled.png
S_optimal.txt
S_results.txt
dS_optimal.txt
dS_results.txt
joint_posterior_probability_kde.png
parameters.txt
posterior_summary.txt
prior_predictive_check_log.png
trace_plot.png
A few key outputs are:
-
R_obs_vs_mod.png: observed and modeled seismicity rate ratio$R/r$ . -
S_modeled.png: inferred stressing-rate and cumulative stress histories. -
joint_posterior_probability_kde.png: joint posterior probability distribution of the model parameters. -
trace_plot.png: MCMC trace plot for checking sampling behavior. -
posterior_summary.txt: posterior summary statistics for the key parameters. -
parameters.txt: posterior parameter samples. -
Inversion_t_obsRr_modRr.txt: time, observed$R/r$ , and modeled$R/r$ used in the inversion figure.
Figure 2. Input data and inversion results for the synthetic example experiment. (a) Observed and modeled seismicity rate ratio, R/r. (b) Modeled stressing rate history and cumulative stress history. (c) Joint posterior probability distribution of the model parameters.
The synthetic values and informative prior distributions used in the example inversion are summarized below.
| Parameter | Synthetic value | Informative prior distribution |
|---|---|---|
| 7500 | ||
| 4.1 | ||
| 7500 | ||
| 20 | ||
| 30 | ||
| 20 | ||
| 10 |
The posterior parameter file is organized as:
[t1..., delta_t1_t2..., delta_t2_t3..., delta_t3_t4..., L..., Asigma_0, tau_rate_bg]
For one ramp:
t1 delta_t1_t2 delta_t2_t3 delta_t3_t4 L Asigma_0 tau_rate_bg
For two ramps:
t1_1 t1_2 delta_t1_t2_1 delta_t1_t2_2 delta_t2_t3_1 delta_t2_t3_2 delta_t3_t4_1 delta_t3_t4_2 L_1 L_2 Asigma_0 tau_rate_bg
This repository is primarily designed to demonstrate T-rate using synthetic experiments. In the current implementation, the stress source is represented by a trapezoidal stress-rate function, but this function is flexible and can approximate several simpler source types. For example, it can approximate an impulse-like function using very short but non-zero ramp durations to represent an instantaneous stress jump, such as a coseismic Coulomb stress change, or as a boxcar function to represent a period of approximately constant stressing rate, such as a simplified slow-slip event. The same framework may therefore be useful for seismicity rate data from laboratory acoustic emission experiments, earthquake swarms, induced seismicity, and slow-slip-related seismicity or tremor. For these applications, users should carefully define the background seismicity rate
If you use T-rate in your research, please cite:
Jiang, Y., Trugman, D. T., & González, P. J. (2026).
Bayesian inference of complex stress evolution in rate-and-state governed faults constrained by seismicity rate observations.
Journal of Geophysical Research: Solid Earth.
This repository is released under the MIT License. See the LICENSE file for details.


