# Observations (https://nolantw.github.io/cwa/en/reference/observations/)

## `observations.latest`

```python
def latest(station: StationInput) -> Observation | None
def latest(station: Sequence[StationInput]) -> Mapping[str, Observation | None]
```

Get the latest observation for one or more stations.

```python
client.observations.latest(station: StationInput) -> Observation | None
client.observations.latest(station: Sequence[StationInput]) -> Mapping[str, Observation | None]
await async_client.observations.latest(station: StationInput) -> Observation | None
await async_client.observations.latest(station: Sequence[StationInput]) -> Mapping[str, Observation | None]
```

## `observations.nearest`

```python
def nearest(location: PointInput, *, max_distance_km: float | None = DEFAULT_DISTANCE_KM, max_age: timedelta | None = DEFAULT_AGE) -> LocatedObservation | None
def nearest(location: Sequence[PointInput], *, max_distance_km: float | None = DEFAULT_DISTANCE_KM, max_age: timedelta | None = DEFAULT_AGE) -> Mapping[Point, LocatedObservation | None]
```

Get observations from the nearest eligible stations.

**Parameters**

- `location` — Township name, township, coordinates, or a sequence.
- `max_distance_km` — Maximum distance in kilometres. None removes the distance limit.
- `max_age` — Maximum age of a reading. None removes the age limit.

**Returns**

A station reading with distance, or None if no station qualifies. A batch maps locations to readings.

**Raises**

- `ValueError` — A distance or age limit is invalid.

```python
from cwa import observations

result = observations.nearest("臺北市信義區")
```

```python
client.observations.nearest(location: PointInput, *, max_distance_km: float | None = DEFAULT_DISTANCE_KM, max_age: timedelta | None = DEFAULT_AGE) -> LocatedObservation | None
client.observations.nearest(location: Sequence[PointInput], *, max_distance_km: float | None = DEFAULT_DISTANCE_KM, max_age: timedelta | None = DEFAULT_AGE) -> Mapping[Point, LocatedObservation | None]
await async_client.observations.nearest(location: PointInput, *, max_distance_km: float | None = DEFAULT_DISTANCE_KM, max_age: timedelta | None = DEFAULT_AGE) -> LocatedObservation | None
await async_client.observations.nearest(location: Sequence[PointInput], *, max_distance_km: float | None = DEFAULT_DISTANCE_KM, max_age: timedelta | None = DEFAULT_AGE) -> Mapping[Point, LocatedObservation | None]
```

## `observations.rainfall`

```python
def rainfall(station: None = None) -> tuple[RainfallObservation, ...]
def rainfall(station: str) -> RainfallObservation
def rainfall(station: Sequence[str]) -> Mapping[str, RainfallObservation]
```

Return the latest rain gauge accumulations.

```python
from cwa import observations

result = observations.rainfall("C0A9C0")
```

```python
client.observations.rainfall(station: None = None) -> tuple[RainfallObservation, ...]
client.observations.rainfall(station: str) -> RainfallObservation
client.observations.rainfall(station: Sequence[str]) -> Mapping[str, RainfallObservation]
await async_client.observations.rainfall(station: None = None) -> tuple[RainfallObservation, ...]
await async_client.observations.rainfall(station: str) -> RainfallObservation
await async_client.observations.rainfall(station: Sequence[str]) -> Mapping[str, RainfallObservation]
```

## `observations.staffed`

```python
def staffed(station: None = None) -> tuple[Observation, ...]
def staffed(station: str) -> Observation
def staffed(station: Sequence[str]) -> Mapping[str, Observation]
```

Return the latest observations from staffed stations.

```python
from cwa import observations

result = observations.staffed("466920")
```

```python
client.observations.staffed(station: None = None) -> tuple[Observation, ...]
client.observations.staffed(station: str) -> Observation
client.observations.staffed(station: Sequence[str]) -> Mapping[str, Observation]
await async_client.observations.staffed(station: None = None) -> tuple[Observation, ...]
await async_client.observations.staffed(station: str) -> Observation
await async_client.observations.staffed(station: Sequence[str]) -> Mapping[str, Observation]
```

## `observations.uv`

```python
def uv(station: None = None) -> tuple[DailyUV, ...]
def uv(station: str) -> DailyUV
def uv(station: Sequence[str]) -> Mapping[str, DailyUV]
```

Return today's maximum UV index at each station.

```python
from cwa import observations

result = observations.uv("466920")
```

```python
client.observations.uv(station: None = None) -> tuple[DailyUV, ...]
client.observations.uv(station: str) -> DailyUV
client.observations.uv(station: Sequence[str]) -> Mapping[str, DailyUV]
await async_client.observations.uv(station: None = None) -> tuple[DailyUV, ...]
await async_client.observations.uv(station: str) -> DailyUV
await async_client.observations.uv(station: Sequence[str]) -> Mapping[str, DailyUV]
```

## `observations.DailyUV`

```python
station_id: str
uv_index: Number
date: OptionalDay
```

A station's maximum UV index for the day.

## `DirectionKind`

```python
class DirectionKind
```

The semantics of a reported wind direction.

## `LocatedObservation`

```python
observation: Observation
distance_km: float
station: Station
observed_at: datetime
temperature: float | None
```

The selected observation, its station and its distance from the query.

## `Observation`

```python
station: Station
observed_at: datetime
source: Source
temperature: float | None
humidity: float | None
pressure: float | None
wind: ObservedWind
precipitation: ObservedPrecipitation
condition: str | None
```

Station weather at the published observation time.

## `ObservedPrecipitation`

```python
millimetres: float | None
trace: bool
start: datetime
end: datetime
```

Accumulation since Taiwan midnight, in millimetres.

## `ObservedWind`

```python
speed: float | None
direction: WindDirection
```

Observed mean wind speed in metres per second and direction.

## `observations.RainfallObservation`

```python
id: str
name: str
maintainer: Text
observed_at: OptionalTime
coordinates: Coordinates | None
elevation_m: Number
township: TownshipCode
today: Number
past_10_minutes: Number
past_hour: Number
past_3_hours: Number
past_6_hours: Number
past_12_hours: Number
past_24_hours: Number
past_2_days: Number
past_3_days: Number
```

Accumulated rainfall in mm over the periods ending at observed_at.

today is the accumulation since Taiwan midnight. coordinates are WGS84.

## `WindDirection`

```python
kind: DirectionKind
degrees: float | None
```

Meteorological direction in degrees clockwise from north, when known.