Forecasts
forecast.county
def county(county: None = None) -> tuple[CountyForecast, ...]
def county(county: CountyInput) -> CountyForecast
def county(county: Sequence[CountyInput]) -> Mapping[County, CountyForecast] Return the 36-hour county forecast in 12-hour periods.
from cwa import forecast
result = forecast.county("臺北市") client.forecast.county(county: None = None) -> tuple[CountyForecast, ...]
client.forecast.county(county: CountyInput) -> CountyForecast
client.forecast.county(county: Sequence[CountyInput]) -> Mapping[County, CountyForecast]
await async_client.forecast.county(county: None = None) -> tuple[CountyForecast, ...]
await async_client.forecast.county(county: CountyInput) -> CountyForecast
await async_client.forecast.county(county: Sequence[CountyInput]) -> Mapping[County, CountyForecast] forecast.get
def get(location: TownshipInput, *, days: int = 7) -> Forecast
def get(location: BatchScope, *, days: int = 7, errors: Literal['raise'] = 'raise') -> ForecastCollection
def get(location: BatchScope, *, days: int = 7, errors: Literal['collect']) -> BatchResult[Township, Forecast] Get forecasts for a township, county, or sequence of locations.
Parameters
location— Township name or object, county, or sequence of locations.days— Number of Taiwan calendar dates, from 1 to 7.errors— Pass collect for a batch to keep its successes and failures.
Returns
One forecast or a collection. With errors=collect, returns a BatchResult.
Raises
ValueError— The number of days is outside the supported range.BatchError— At least one batch item failed and errors is raise.
from cwa import forecast
result = forecast.get("臺北市信義區", days=3) client.forecast.get(location: TownshipInput, *, days: int = 7) -> Forecast
client.forecast.get(location: BatchScope, *, days: int = 7, errors: Literal['raise'] = 'raise') -> ForecastCollection
client.forecast.get(location: BatchScope, *, days: int = 7, errors: Literal['collect']) -> BatchResult[Township, Forecast]
await async_client.forecast.get(location: TownshipInput, *, days: int = 7) -> Forecast
await async_client.forecast.get(location: BatchScope, *, days: int = 7, errors: Literal['raise'] = 'raise') -> ForecastCollection
await async_client.forecast.get(location: BatchScope, *, days: int = 7, errors: Literal['collect']) -> BatchResult[Township, Forecast] forecast.get_all
def get_all(*, days: int = 7, errors: Literal['raise'] = 'raise') -> ForecastCollection
def get_all(*, days: int = 7, errors: Literal['collect']) -> BatchResult[Township, Forecast] Get forecasts for all catalog townships.
client.forecast.get_all(*, days: int = 7, errors: Literal['raise'] = 'raise') -> ForecastCollection
client.forecast.get_all(*, days: int = 7, errors: Literal['collect']) -> BatchResult[Township, Forecast]
await async_client.forecast.get_all(*, days: int = 7, errors: Literal['raise'] = 'raise') -> ForecastCollection
await async_client.forecast.get_all(*, days: int = 7, errors: Literal['collect']) -> BatchResult[Township, Forecast] forecast.CountyForecast
county: CountyName
periods: Annotated[tuple[CountyPeriod, ...], ordered(start)] The 36-hour forecast for one county, in three 12-hour periods.
forecast.CountyPeriod
start: Time
end: Time
condition: Text
condition_code: Text
precipitation_probability: Number
min_temperature: Number
max_temperature: Number
comfort: Text One 12-hour period. Temperatures are in °C, probability in %.
DayForecast
date: date
temperature: TemperatureRange
precipitation: PrecipitationForecast
wind: WindForecast
condition: WeatherCondition | None
periods: tuple[ForecastPeriod, ...]
sources: tuple[Source, ...] Available forecast values overlapping one Taiwan calendar date.
Forecast
location: Township
as_of: datetime
sources: tuple[Source, ...]
periods: tuple[ForecastPeriod, ...]
days: tuple[DayForecast, ...]
today: DayForecast | None
tomorrow: DayForecast | None
temperature: NumericSeries Immutable township forecast with Taiwan calendar and source-time views.
Forecast.on
def on(day: date) -> DayForecast | None Return an available Taiwan calendar day.
Forecast.at
def at(instant: datetime) -> ForecastAtTime | None Return only values valid at an instant; naive times are Taiwan time.
Forecast.between
def between(start: datetime, end: datetime) -> Forecast Return a half-open window; naive times are Taiwan time.
Forecast.to_polars
def to_polars() -> pl.DataFrame Export one row per available township calendar date.
Forecast.to_pandas
def to_pandas() -> pd.DataFrame Export the daily schema using nullable Arrow-backed Pandas columns.
Forecast.to_arrow
def to_arrow() -> pa.Table Export the daily schema as a PyArrow table.
ForecastAtTime
time: datetime
periods: tuple[ForecastPeriod, ...] Published values valid at an instant.
ForecastCollection
class ForecastCollection Read-only forecasts indexed by township.
ForecastCollection.to_polars
def to_polars() -> pl.DataFrame Export one row per township and available calendar date.
ForecastCollection.to_pandas
def to_pandas() -> pd.DataFrame Export the daily schema using nullable Arrow-backed Pandas columns.
ForecastCollection.to_arrow
def to_arrow() -> pa.Table Export the daily schema as a PyArrow table.
ForecastPeriod
element: str
sample: ForecastSample[_Value] An individual published forecast element, its value and validity.
ForecastSample
value: T | None
start: datetime
end: datetime | None
source: Source A value at an instant or over a half-open validity interval.
ForecastSample.overlaps
def overlaps(start: datetime, end: datetime) -> bool Whether this sample intersects the requested half-open window.
ForecastSample.contains
def contains(instant: datetime) -> bool Whether this sample is valid at the given instant.
LowerBound
value: float A published value known only to be at least value, such as >= 11.
NumericSeries
samples: tuple[ForecastSample[float], ...] Samples of one numeric forecast element.
NumericSeries.min
def min() -> float | None Return the smallest available sample.
NumericSeries.max
def max() -> float | None Return the largest available sample.
NumericSeries.mean
def mean() -> float | None Return the unweighted mean of available samples.
PrecipitationForecast
max_probability: int | None Maximum published period probability in percent.
TemperatureRange
min: float | None
max: float | None
sampled_min: float | None
sampled_max: float | None Published extrema in °C, with separate extrema of hourly samples.
WeatherCondition
description: str
code: str | None CWA’s weather description and optional category code.
WindForecast
max_speed: float | None
max_speed_is_lower_bound: bool Maximum published wind speed in metres per second.
When max_speed_is_lower_bound is True, at least one period was published as a lower bound and the maximum is at least max_speed.