pylindol
pylindol scrapes earthquake data from the Philippine Institute of Volcanology and Seismology (PHIVOLCS) website into clean, typed pandas DataFrames. It works as a Python library and as a command line tool, and covers every month PHIVOLCS has published since January 2017.
Made with examples/plot_map.py.
Installation
pip install pylindol
# or
uv add pylindol
For Parquet output, install the extra: pip install "pylindol[parquet]".
Requires Python 3.11 or later.
Command line usage
pylindol # current month, saved to data/
pylindol --month 8 --year 2025 # a past month
pylindol --start 2025-01 --end 2025-06 # a range of months, in one file
pylindol --month 8 --year 2025 --format json --output-path archive
pylindol --month 8 --year 2025 --stdout | head # print instead of saving
| Option | Description |
|---|---|
--month, --year |
Month to scrape. Defaults to the current month (Philippine time). |
--start, --end |
Range of months to scrape, as YYYY-MM. |
--format |
csv (default), json or parquet. |
--output-path |
Directory to save to. Default: data. |
--stdout |
Print CSV or JSON instead of saving a file. |
--delay |
Seconds between requests when scraping a range. Default: 1. |
-v / -q |
Debug logging / warnings and errors only. |
Run pylindol --help for details.
Library usage
from pylindol import PhivolcsEarthquakeInfoScraper, scrape_months
# One month. Returns a DataFrame and, by default, also writes a CSV.
df = PhivolcsEarthquakeInfoScraper(month=8, year=2025).run()
# Just the DataFrame, no file.
df = PhivolcsEarthquakeInfoScraper(month=8, year=2025, export=False).run()
# Write JSON to a custom directory instead.
PhivolcsEarthquakeInfoScraper(
month=8, year=2025, output_path="archive", output_format="json"
).run()
# Several months in one DataFrame (requests are spaced out by `delay`).
df = scrape_months((2025, 1), (2025, 6))
strong = df[df["magnitude"] >= 5]
Output
Every layout PHIVOLCS has used is normalized to the same columns:
| Column | Type | Example |
|---|---|---|
datetime |
datetime, Asia/Manila timezone | 2025-08-31 23:56:00+08:00 |
date |
string | 2025-08-31 |
time |
string | 23:56:00 |
latitude |
float, °N | 13.35 |
longitude |
float, °E | 120.66 |
depth_km |
float | 8.0 |
magnitude |
float | 1.9 |
location |
string | 012 km S 35° W of Abra De Ilog (Occidental Mindoro) |
Files are named phivolcs_earthquake_data_{month}_{year}.{format}, or
phivolcs_earthquake_data_{m1}_{y1}_to_{m2}_{y2}.{format} for a range. JSON
keeps the +08:00 offset in datetime.
Errors
ValueError: invalid input, such as a month outside 1-12, a month before January 2017, or a future month, or only one ofmonth/yeargiven.TypeError:monthoryearis not an integer.DataNotAvailableError: PHIVOLCS has no data for the month.requests.RequestException: network errors, after automatic retries.
Logging
pylindol uses loguru and is silent when imported as a library. To see its logs:
from loguru import logger
logger.enable("pylindol")
How it works
- Finding the data. PHIVOLCS pages are hand-edited HTML with several
layout tables, and the earthquake table's structure has changed over the
years: headers in the first row or in a separate table, extra empty
columns, mixed encodings and typos such as
11Jun 2017. pylindol picks the table whose rows look like PHIVOLCS timestamps and maps its columns by position, so all of these parse the same way. - The current month. The main page lists the current month and, until PHIVOLCS archives it, the previous one. pylindol filters the page to the month you asked for, and reads last month from the main page while its archive page doesn't exist yet.
- TLS. Some PHIVOLCS servers don't send the intermediate certificate
their certificate chain needs, so a standard
requestscall fails verification. pylindol ships that intermediate (GlobalSign RSA OV SSL CA 2018) and loads it, along with certifi's CAs, into an in-memory SSL context. Nothing is written to disk, and verification is never turned off. - Being polite. Requests send a
pylindolUser-Agent, time out, retry transient errors with backoff, and range scrapes wait between months. Please don't lower--delayfor large ranges; PHIVOLCS is a public service.
Development
git clone git@github.com:clnhrn/pylindol.git
cd pylindol
uv sync
uv run pre-commit install --hook-type pre-commit --hook-type commit-msg
uv run pytest # unit tests, using saved PHIVOLCS pages
uv run pytest -m live # tests against the real website
uv run ruff check . && uv run mypy
Commits follow Conventional Commits.
Merging to main opens a version bump PR, and merging that PR tags the
release and publishes it to PyPI.
License
Released under the MIT License.
Metadata
Release files for pylindol 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pylindol-0.6.0.tar.gz | 15.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pylindol-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.0 kB
Release files / pylindol-0.6.0.tar.gz
| Download URL | pylindol-0.6.0.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d6da027909295db64b06d3bc427e777e9ebc38b19689f16733e6bfa1b2397fa0
|
|
BLAKE2b-256 checksum How to use checksums |
49ec5224626a34d1477abdaf2825fc13471af6cb20909b646428d83b305b39cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pylindol-0.6.0-py3-none-any.whl
| Download URL | pylindol-0.6.0-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a4e7d39f66cc2e51cf9dee2a336b5b25ad18343c3913a74117143b2d215f633
|
|
BLAKE2b-256 checksum How to use checksums |
4f218606f333204cb9d0a1adcabc716383a7e84bfd485859e05cdce047362e59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|