Earthquakes
Felt earthquake reports, local intensities and epicentral distances.
cwa.earthquakes returns the CWA’s felt earthquake reports, with magnitude, epicenter, depth and local intensities.
import cwa
quake = cwa.earthquakes.latest()
if quake:
print(quake.occurred_at, quake.epicenter_description)
print(f"M{quake.magnitude}, {quake.depth_km} km deep, max intensity {quake.maximum_intensity}") | Method | Returns |
|---|---|
latest() | The newest report, or None if there is none |
recent(limit=20) | Recent reports, newest first, at most limit |
Results include both kinds of report:
| Report | Meaning | number |
|---|---|---|
| Significant felt earthquake | Larger or more widely felt, with an official number | Report number |
| Local felt earthquake | Smaller, felt only locally | None |
Earthquake fields
| Field | Meaning |
|---|---|
occurred_at | When it happened |
magnitude, magnitude_scale | Magnitude and its scale as the CWA writes it, such as 芮氏規模 (local magnitude) |
depth_km | Focal depth (km) |
epicenter | Epicenter coordinates |
epicenter_description | Where the epicenter is, in the CWA’s Chinese wording |
maximum_intensity | The highest intensity anywhere in Taiwan |
intensities | Every intensity listed in the report |
report_url | The CWA report page, or None |
Intensity at a place
level = quake.intensity_at("臺北市") intensity_at() accepts a county, township or name and returns only an intensity the report explicitly lists for that place. If the report does not list it, the result is None; the SDK never substitutes the county’s intensity for a township.
Intensities are IntensityLevel values. They compare by size, and str() gives the CWA label:
from cwa import IntensityLevel
if level is not None and level >= IntensityLevel.FIVE_WEAK:
print(f"Intensity {level}, take care") # Intensity 5弱, take care Epicentral distance
distance_to() returns the horizontal distance from a place to the epicenter in km, not counting depth. The place can be a name, township or coordinates:
print(quake.distance_to("臺北市信義區")) English reports
Pass language="en" to latest() or recent() to read the English reports. Place names map to the same County members:
report = cwa.earthquakes.latest(language="en")