API 參考
警特報
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 查詢指定地點生效中的警特報,也可查詢全臺。
參數
location縣市、鄉鎮、座標或地點序列。省略時查詢全部警特報。alert_type只查詢指定類別的警特報。
回傳值
單筆查詢回傳警特報集合;批次查詢時以地點為鍵回傳各地點的警特報集合。
例外
UnknownLocationError查無指定地名。
範例
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 取得鄉鎮層級的豪大雨、低溫、高溫、強風與濃霧特報。
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 警特報所列地區名稱及可確認的行政區。
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, ...] 警特報原文、生效時段及發布範圍。
Alert.contains
def contains(coordinates: Coordinates) -> Match 判斷警特報範圍是否包含指定座標,含邊界。
Alert.affects
def affects(location: AlertInput) -> Match 判斷警特報是否涵蓋指定行政區或座標。
AlertCollection
class AlertCollection 以地點為索引的警特報。
AlertSet
alerts: tuple[Alert, ...]
as_of: datetime
sources: tuple[Source, ...]
complete: bool 指定查詢時間有效的警特報,並附涵蓋狀態。
AlertSet.for_scope
def for_scope(scope: AlertScope | None, alert_type: AlertType | None = None) -> AlertSet 保留確定涵蓋或可能涵蓋指定範圍的警特報。
AlertType
class AlertType 氣象署發布的警特報類別。
Match
class Match 表示確定涵蓋、確定不涵蓋或無法確認。