tr-deprem

Türkiye earthquake (deprem) data in Python: one client for AFAD, Kandilli (KOERI), USGS and EMSC with cross-source de-duplication, province lookup, Gutenberg-Richter b-value and a Turkish CLI.

Version 0.1.2 · Python >=3.9 · MIT licence
pip install tr-deprem
PyPISourceIssuesChangelogCite (DOI)

tr-deprem

PyPI version Python versions pipeline status License: MIT DOI Downloads

Türkiye deprem verisi için Python istemcisi: AFAD, Kandilli, USGS ve EMSC tek arayüzde. Turkish earthquake data in Python: AFAD, Kandilli, USGS and EMSC through one interface.

Türkçe | English

Uyarı / Disclaimer: tr-deprem resmi bir deprem uyarı veya erken uyarı sistemi değildir. Veriler kaynaklardan gecikmeli gelir ve sonradan revize edilebilir. Resmi bilgi ve afet durumunda talimatlar için AFAD ve Kandilli Rasathanesi duyurularını izleyin. This is not an official warning or early-warning system. Data arrive with a delay and may be revised. Follow AFAD and Kandilli Observatory for official information.


Türkçe

Neler yapar?

Kurulum

pip install tr-deprem

# pandas DataFrame çıktısı için
pip install "tr-deprem[pandas]"

Python 3.9 ve üzeri gerekir.

Hızlı başlangıç

import tr_deprem

# Son 24 saat, AFAD + Kandilli, tekrarlar birleştirilmiş, en yeni önce
for d in tr_deprem.son(min_magnitude=3):
    print(d.time_tr, d.magnitude, d.magnitude_type, d.location, d.source)

# Ayrıntılı arama: dört kaynak, Malatya, son 7 gün, M >= 2.5
istemci = tr_deprem.DepremClient("tumu")
depremler = istemci.ara("7g", il="Malatya", min_magnitude=2.5)
print(istemci.errors)          # erişilemeyen kaynak varsa burada görünür

# Bir noktanın çevresi (enlem, boylam) ve yarıçap (km)
yakin = istemci.ara("2026-11-01", center=(38.35, 38.31), radius_km=50)

# İstatistik
gr = tr_deprem.b_value(depremler)             # Mc otomatik; az veri varsa ValueError
print(gr)                                     # örn. "b = 1.02 ± 0.05, a = 4.31, Mc = 2.5, N = 61"
print(tr_deprem.magnitude_bins(depremler))    # örn. {2.0: 48, 3.0: 12, 4.0: 1}

# İl bulma
print(tr_deprem.nearest_il(39.52, 28.92))     # Balıkesir
print(depremler[0].konum())                   # örn. ('Malatya', 'Battalgazi', None)

# Çıktılar
geojson = tr_deprem.to_geojson(depremler)
with open("depremler.csv", "w", encoding="utf-8-sig", newline="") as f:   # Excel için BOM
    tr_deprem.to_csv(depremler, f)
df = tr_deprem.to_dataframe(depremler)        # pip install "tr-deprem[pandas]"

Komut satırı

$ tr-deprem son -n 6
Tarih / Saat (TSİ)   Büy.  Tip  Der.km    Enlem   Boylam  Yer                     Kaynak
-------------------  ----  ---  ------  -------  -------  ----------------------  --------
2026-11-08 22:42:04   1.7  ML      6.7  38.3320  38.8005  CANAKCI-KALE (MALATYA)  Kandilli
2026-11-08 22:23:02   3.3  ML      7.0  39.5192  28.9182  Dursunbey (Balıkesir)   AFAD +1
2026-11-08 22:14:46   1.2  ML      7.0  39.0905  33.1950  Kulu (Konya)            AFAD
2026-11-08 21:51:34   1.5  ML      7.0  37.2708  28.5025  Menteşe (Muğla)         AFAD +1
2026-11-08 21:29:26   1.0  ML      6.6  39.1462  28.2457  Sındırgı (Balıkesir)    AFAD
2026-11-08 21:15:06   2.0  ML     11.1  38.2143  38.5225  Battalgazi (Malatya)    AFAD +1

AFAD +1: aynı deprem bir başka kaynakta da var (birleştirildi). --ayri ile birleştirmeden gösterilir.

$ tr-deprem son -k tumu -m 3 --saat 72 -n 5
Tarih / Saat (TSİ)   Büy.  Tip  Der.km    Enlem   Boylam  Yer                    Kaynak
-------------------  ----  ---  ------  -------  -------  ---------------------  -------
2026-11-08 22:23:02   3.3  ML      7.0  39.5192  28.9182  Dursunbey (Balıkesir)  AFAD +2
2026-11-08 19:49:19   3.2  ML      7.8  37.8925  35.2612  Yahyalı (Kayseri)      AFAD +2
2026-11-08 14:01:20   3.2  ML      7.0  37.6422  35.3672  Aladağ (Adana)         AFAD +2
2026-11-07 13:42:52   3.3  ML     10.8  40.5937  42.0227  Oltu (Erzurum)         AFAD +2
2026-11-07 02:45:21   3.4  ML      6.9  34.5025  25.0347  Akdeniz                AFAD

$ tr-deprem ara -k afad -b 10g --il Balıkesir --istatistik
Deprem sayısı: 82
Kaynaklara göre: AFAD: 82
Büyüklük aralığı: 0.8 - 3.3
Derinlik aralığı: 5.3 - 15.6 km
Büyüklük dağılımı:
   0.0- 0.9       7  ###
   1.0- 1.9      73  ##############################
   2.0- 2.9       1  #
   3.0- 3.9       1  #
Gutenberg-Richter (Aki MLE): b = 1.51 ± 0.23, Mc = 1.2 (maks. eğrilik), N(M≥Mc) = 54

Diğer örnekler:

tr-deprem ara -b 2026-11-01 -e "2026-11-05 12:00" -m 4 --json      # saatler TSİ
tr-deprem ara -k tumu -b 7g --merkez Malatya --yaricap 100 --csv > malatya.csv
tr-deprem ara -k usgs,emsc -b 30g --bbox 26,36,30,40 --geojson > ege.geojson
tr-deprem izle -m 3 --aralik 60          # her 60 sn'de yeni M≥3 depremleri yazar; Ctrl-C ile durur
tr-deprem izle -k tumu --il İzmir --json # satır başına bir JSON kaydı
Komut Açıklama Önemli seçenekler
son Son depremler (tablo) --saat 24, -n 20, -m, --il, -k
ara Arama -b/-e (TSİ), -m/--max-mag, --bbox, --merkez + --yaricap, --il, --min/max-derinlik, --istatistik
izle Yeni depremleri yazdır --aralik 60, -m, --il, --ilk, --en-fazla

Ortak seçenekler: -k/--kaynak afad,kandilli,usgs,emsc|tumu (varsayılan afad,kandilli), --json | --csv | --geojson, --ayri, --zaman-asimi 15.


English

What it does

tr-deprem is a dependency-free Python client for earthquakes in and around Türkiye.

Install

pip install tr-deprem
pip install "tr-deprem[pandas]"   # DataFrame output

Quickstart

from tr_deprem import DepremClient, b_value, to_geojson

client = DepremClient(["afad", "kandilli", "usgs", "emsc"], timeout=10, retries=2)

latest = client.latest(hours=6, min_magnitude=2)             # newest first
week = client.search("7d", il="Malatya")                       # province filter
box = client.search("2026-11-01", "2026-11-08", bbox=(26, 36, 30, 40), min_magnitude=3)
near = client.search("30d", center=(38.35, 38.31), radius_km=50)

for eq in latest:
    print(eq.time.isoformat(), eq.time_tr.strftime("%H:%M"), eq.magnitude,
          eq.location_tr, eq.source, eq.also_reported_by)

print(client.errors)        # {"kandilli": "..."} if a source was unreachable
print(b_value(week))        # b = ..., a = ..., Mc = ..., N = ...
geojson = to_geojson(week)

for eq in client.watch(interval=60, min_magnitude=3):          # generator; Ctrl-C to stop
    print("new:", eq.magnitude, eq.location_tr)

Times you pass in Python may be datetime, date, ISO strings or durations such as "24h", "7d", "30min"; naive values are UTC in the Python API and Türkiye time in the CLI.

Command line

tr-deprem latest -n 10                       # same as "son"
tr-deprem search --start 7d --province Izmir --min-mag 2 --json
tr-deprem search --source all --center 38.35,38.31 --radius 50 --stats
tr-deprem watch --min-mag 4 --interval 30

Data sources / Veri kaynakları

Source Endpoint Format Time zone Notes
AFAD https://deprem.afad.gov.tr/apiv2/event/filter JSON (numbers as strings) UTC Supports time, magnitude, depth, bbox, radius filters. In November 2026 the public API returned only about the last 10-11 days of events (older ranges come back empty); use USGS/EMSC for history.
Kandilli (KOERI RETMC) http://www.koeri.boun.edu.tr/scripts/lst0.asp fixed-width text in HTML, windows-1254 Türkiye local time Only the latest 500 events; no query API, all filters local. Preferred magnitude Mw > ML > MD.
USGS https://earthquake.usgs.gov/fdsnws/event/1/query GeoJSON UTC (epoch ms) Global; Türkiye box used when no spatial filter is given.
EMSC https://www.seismicportal.eu/fdsnws/event/1/query GeoJSON UTC Global; same default box.

All four endpoints and their formats were checked against the live services on 2026-11-08. The parsers match fields by name (with fallbacks) and Kandilli lines by pattern rather than column offsets, accept UTF-8 or windows-1254, and skip malformed records instead of failing. The FDSN parser also understands the pipe-separated format=text reply.

Attribution / Atıf. When you publish data obtained with this package, credit the original source:

The library identifies itself with the generic User-Agent tr-deprem/<version>, uses timeouts and limited retries with backoff, and does not poll faster than you ask. Please keep polling intervals reasonable (the CLI default is 60 s).

Accuracy notes

Development / Geliştirme

git clone https://gitlab.com/geophilo1/tr_deprem_sdk.git
cd tr_deprem_sdk
pip install -e ".[dev,pandas]"
python -m pytest --cov=tr_deprem       # tests use saved fixtures, no network
python -m ruff check . && python -m ruff format --check src tests tools
python -m mypy src

Citation

@software{eminoglu_tr_deprem,
  author  = {Eminoğlu, Yusuf},
  title   = {tr-deprem},
  year    = {2026},
  version = {0.1.2},
  doi     = {10.5281/zenodo.24063332},
  url     = {https://doi.org/10.5281/zenodo.24063332}
}

See CITATION.cff.

Related Geophilo SDKs

License

MIT © Yusuf Eminoğlu. See LICENSE. Data remain subject to their providers' terms (see above).

Other Geophilo SDKs