Repository navigation
Releases
v0.3.0
canairy 0.3.0 renames the package (air_pollution → canairy) and the Hamburg client (luftmessnetz → hh), and fixes the Hamburg client silently returning only the last month of longer date ranges. Upgrading requires code changes; see below.
Upgrading from 0.2.x
-
Python 3.12 or newer is required. (
canairy.ubaalready failed to import on 3.11 in 0.2.2.) -
The distribution is now
canairy(wasair-pollution). Remove the old one withpip uninstall air-pollution. -
Rename imports:
0.2.x 0.3.0 air_pollution.ubacanairy.ubaair_pollution.luftmessnetzcanairy.hhLuftmessnetzClientHHClientStation,StationData,Component,ComponentData,Core,ThresholdHHStation,HHStationData,HHComponent,HHComponentData,HHCore,HHThresholdThe HH models can now be imported from
canairy.hhdirectly. -
HH date ranges are checked:
start/endcombined with a timespan other than"custom", or astartafterend, now raiseValueError. -
The downloader Docker image is now tagged
canairy_downloader(wasde.uke.iam.air-pollution_downloader).
Hamburg: complete date ranges
The Hamburg API cuts custom ranges to the latest 31 days for 1h, 8hg and 24hg, and to the latest 365 days for 24h, without reporting an error. In 0.2.x, a request for a year of hourly data returned only its last month. get_station_data and get_component_data now request long ranges in windows within these limits and join the results, so a year of hourly data takes about 12 requests.
Related changes:
start/endwithout atimespanare sent as a custom range. Before, the API ignored them and returned its default span.- A missing
endmeans now in Hamburg, also on machines that run in UTC. An open range that starts in the future returns[]. - Naive
start/endare read as Hamburg time and timezone-aware ones are converted, so a timestamp from a previous result can be passed back as is. HHStationData.valueisfloat | None. It wasint, which failed validation on most real ranges: values are decimals, and missing hours arenull.
Other fixes
Both clients
- When retries run out, the original error is raised right away. Before, the client waited another 256 s and then failed with an unrelated
AttributeErrororTypeError.
Hamburg
- Sends one GET per request instead of HEAD + GET, which halves the requests the API receives. The HEAD was neither retried nor counted by the 120/min rate limit.
- Requests time out after 60 s instead of 5 s.
- Logs through its module logger instead of the root logger.
UBA
- Client errors (4xx other than 429) are raised at once instead of being tried 8 times with 8.5 minutes of backoff.
get_stationswithdt_startbut nodt_stopno longer raisesTypeError.get_componentsandget_scopescheck the API's column order and raiseValueErrorif it changes, instead of assigning values to the wrong fields.
Dependencies
- Requires
hishel>=1.0(0.2.2 declared>=0.1.2but needed 1.x). - Adds
tzdata, so Hamburg time also works on slim Docker images and Windows. - Drops the unused
httpx-limiter.
Known issue
aq-downloader requests each year up to 31 December of the following year, so files of consecutive years overlap. Deduplicate after loading.