EPA AirNow空气质量API的轻量级Python包装器
pyairnow的Python项目详细描述
pyairnow:AirNow API的薄型Python包装器
pyairnow
是一个简单、经过测试的瘦客户端库,用于与
AirNow美国环保署空气质量指数API。在
Python版本
pyairnow
当前支持并测试于:
- Python 3.6
- Python 3.7
- Python 3.8
安装
pipinstallpyairnow
API密钥
您可以从 the AirNow API site。确保你 阅读并理解API使用的期望和限制,这可以 在the AirNow FAQ找到。在
使用
^{pr2}$默认情况下,库通过每个协程创建到AirNow的新连接。
如果你正在调用大量的协同程序(或者仅仅想挤出
每一秒的运行时节省),一个
^{ClientSession
可以使用
对于连接池:
importasyncioimportdatetimefromaiohttpimportClientSessionfrompyairnowimportWebServiceAPIasyncdefmain()->None:asyncwithClientSession()assession:client=WebServiceAPI('your-api-key',session=session)# ...asyncio.run(main())
库提供了两个方便的函数来在AQI和 污染物浓度。看到了吗 this EPA document 更多细节。在
frompyairnow.convimportaqi_to_concentration,concentration_to_aqi# Supported Pollutants# --------------------# Ozone ('O3'): ppm# pm2.5 ('PM2.5'): ug/m^3# pm10 ('PM10'): ug/m^3# Carbon Monoxide ('CO'): ppm# Sulfur Dioxide ('SO2'): ppm# Nitrogen Dioxide ('NO2'): ppm# Returns AQI = 144 for pm2.5 of 53.0 ug/m^3aqi_to_concentration(144,'PM2.5')# Returns Cp = 53.0 ug/m^3concentration_to_aqi(53.0,'PM2.5')
贡献
- Check for open features/bugs 或者start a discussion on one。在
- Fork the repository。在
- 安装Poetry并设置开发工作区:
poetry install
- 编写新功能或错误修复代码。在
- 编写涵盖新功能的测试。在
- 运行测试并确保100%的代码覆盖率:
make test
- 运行linter以确保100%的代码样式正确性:
make lint
- 使用任何新文档更新
README.md
。在 - 将您自己添加到
AUTHORS.md
。在 - 提交请求!在
- 项目
标签: