Weather warnings
alerts.active
def active(location: AlertInput | None = None, *, alert_type: AlertType | None = None) -> AlertSet
def active(location: Sequence[AlertInput], *, alert_type: AlertType | None = None) -> AlertCollection Get active weather warnings for the requested locations.
Parameters
location— County, township, coordinates, or a sequence. Omit it for all warnings.alert_type— Limit the results to one warning category.
Returns
A warning set, or a mapping of locations to warning sets for a batch.
Raises
UnknownLocationError— The supplied place name did not match a known location.
from cwa import alerts
result = alerts.active("臺北市信義區") client.alerts.active(location: AlertInput | None = None, *, alert_type: AlertType | None = None) -> AlertSet
client.alerts.active(location: Sequence[AlertInput], *, alert_type: AlertType | None = None) -> AlertCollection
await async_client.alerts.active(location: AlertInput | None = None, *, alert_type: AlertType | None = None) -> AlertSet
await async_client.alerts.active(location: Sequence[AlertInput], *, alert_type: AlertType | None = None) -> AlertCollection alerts.hazards
def hazards(location: AlertInput | None = None, *, alert_type: AlertType | None = None) -> AlertSet
def hazards(location: Sequence[AlertInput], *, alert_type: AlertType | None = None) -> AlertCollection Get township-level rain, cold, heat, wind and fog warnings.
These come from CWA’s CAP hazard products (W-C0033-003 to W-C0033-010), which list affected townships and polygons.
from cwa import alerts
result = alerts.hazards("臺東縣鹿野鄉") client.alerts.hazards(location: AlertInput | None = None, *, alert_type: AlertType | None = None) -> AlertSet
client.alerts.hazards(location: Sequence[AlertInput], *, alert_type: AlertType | None = None) -> AlertCollection
await async_client.alerts.hazards(location: AlertInput | None = None, *, alert_type: AlertType | None = None) -> AlertSet
await async_client.alerts.hazards(location: Sequence[AlertInput], *, alert_type: AlertType | None = None) -> AlertCollection AffectedArea
label: str
county: County | None
township: Township | None Published area label and any verified administrative identity.
Alert
identifier: str | None
type: AlertType
phenomena: str
title: str
text: str | None
status: str | None
severity: str | None
issued_at: datetime | None
effective_at: datetime
expires_at: datetime
areas: tuple[AffectedArea, ...]
source: Source
polygons: tuple[tuple[Coordinates, ...], ...]
geometry_complete: bool
geometry: tuple[Polygon, ...] Original warning text, validity and published spatial coverage.
Alert.contains
def contains(coordinates: Coordinates) -> Match Check whether warnings cover a coordinate, including boundaries.
Alert.affects
def affects(location: AlertInput) -> Match Match administrative scopes and coordinates against published coverage.
AlertCollection
class AlertCollection Warnings indexed by location.
AlertSet
alerts: tuple[Alert, ...]
as_of: datetime
sources: tuple[Source, ...]
complete: bool Warnings and coverage metadata at the captured reference time.
AlertSet.for_scope
def for_scope(scope: AlertScope | None, alert_type: AlertType | None = None) -> AlertSet Retain definite matches and warnings with uncertain coverage.
AlertType
class AlertType Weather hazard categories reported by CWA.
Match
class Match Whether published coverage includes the requested location.