Skip to Content
cwa
API reference

Observations

observations.latest

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

Get the latest observation for one or more stations.

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

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.
from cwa import observations

result = observations.nearest("臺北市信義區")
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

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.

from cwa import observations

result = observations.rainfall("C0A9C0")
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

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.

from cwa import observations

result = observations.staffed("466920")
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

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.

from cwa import observations

result = observations.uv("466920")
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

station_id: str
uv_index: Number
date: OptionalDay

A station’s maximum UV index for the day.

DirectionKind

class DirectionKind

The semantics of a reported wind direction.

LocatedObservation

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

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

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

Accumulation since Taiwan midnight, in millimetres.

ObservedWind

speed: float | None
direction: WindDirection

Observed mean wind speed in metres per second and direction.

observations.RainfallObservation

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

kind: DirectionKind
degrees: float | None

Meteorological direction in degrees clockwise from north, when known.