Nearest-Neighbor-Distance algorithm to decluster seismic catalog in Python based on the work of Baiesi & Paczuski 2004 and Zaliapin et al. 2008.
The code make_declustering.py
finds for each event of a given catalog its nearest neighbor. The utilisator is invited to select his own threshold to make the distinction between aftershocks and background events.
An example is provided with the Southern California Earthquake Data Center catalog from 2014 to 2019.
It requires the package mpi4py
which can be simply install with:
conda install -c anaconda mpi4py
or
pip install mpi4py
for more information have a look here.
The file needs to contain the following headers: - year - month - day - hour - minute - second - time: first event is 0, can be second, day, etc.. - latitude - longitude - depth: not taken account in the current version. However, easy to implement. - magnitude
The output will add the following columns: - Tij: the rescaled Time with the with the nearest neighbor - Rij: the rescaled Distance - Nij: the nearest neighbor distance metric - parent_magnitude - neighbor: the index of the nearest neighbor
The code is able to run in serial:
python make_declustering.py
or in parallel on a laptop or a node on a cluster (>= 1 node):
mpirun -np <number of cpu desired> python make_declustering.py