# Weather warnings (https://nolantw.github.io/cwa/en/reference/alerts/)

## `alerts.active`

```python
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.

```python
from cwa import alerts

result = alerts.active("臺北市信義區")
```

```python
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`

```python
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.

```python
from cwa import alerts

result = alerts.hazards("臺東縣鹿野鄉")
```

```python
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`

```python
label: str
county: County | None
township: Township | None
```

Published area label and any verified administrative identity.

## `Alert`

```python
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`

```python
def contains(coordinates: Coordinates) -> Match
```

Check whether warnings cover a coordinate, including boundaries.

### `Alert.affects`

```python
def affects(location: AlertInput) -> Match
```

Match administrative scopes and coordinates against published coverage.

## `AlertCollection`

```python
class AlertCollection
```

Warnings indexed by location.

## `AlertSet`

```python
alerts: tuple[Alert, ...]
as_of: datetime
sources: tuple[Source, ...]
complete: bool
```

Warnings and coverage metadata at the captured reference time.

### `AlertSet.for_scope`

```python
def for_scope(scope: AlertScope | None, alert_type: AlertType | None = None) -> AlertSet
```

Retain definite matches and warnings with uncertain coverage.

## `AlertType`

```python
class AlertType
```

Weather hazard categories reported by CWA.

## `Match`

```python
class Match
```

Whether published coverage includes the requested location.