无效DWD天气数据客户端
dwdweather的Python项目详细描述
访问dwd天气数据的python客户端(德国)
安装
pip install dwdweather
快速参考(python模块)
fromdwdweatherimportDwdWeatherfromdatetimeimportdatetime# create clientdw=DwdWeather()# Find closest station to positionclosest=dw.nearest_station(lon=7,lat=51)# The hour you're interested in.# The example is 2014-03-22 12:00 (UTC).query_hour=datetime(2014,3,22,12)result=dw.query(station_id=closest["station_id"],hour=query_hour)printresult
DwdWeather.query()返回具有以下键的dict:
- station_id:站点标识符,作为int.
- datetime:小时为int,例如2013011212。
- precipitation_fallen:是否有降水 一小时内,0表示不,1表示是。
- precipitation_form:待办事项
- precipitation_height:小时降水高度,单位:mm,as 漂浮。
- precipitation_quality_level:数据质量级别,如int.
- soiltemp_1_depth:第一次土壤温度测量,深度 米,如浮子。
- soiltemp_1_temperature:第一次土壤温度测量, 以摄氏度为单位的温度,如浮子。
- soiltemp_2_depth:第二次土壤温度测量,深度 米,如浮子。
- soiltemp_2_temperature:第二次土壤温度测量, 以摄氏度为单位的温度,如浮子。
- soiltemp_3_depth:第三次土壤温度测量,深度 米,如浮子。
- soiltemp_3_temperature:第三次土壤温度测量, 以摄氏度为单位的温度,如浮子。
- soiltemp_4_depth:第四次土壤温度测量,深度 米,如浮子。
- soiltemp_4_temperature:第四次土壤温度测量, 以摄氏度为单位的温度,如浮子。
- soiltemp_5_depth:第五次土壤温度测量,深度 米,如浮子。
- soiltemp_5_temperature:第五次土壤温度测量, 以摄氏度为单位的温度,如浮子。
- soiltemp_quality_level:土壤温度质量水平,内部值
- solar_quality_level:太阳数据的质量级别,如int.
- solar_duration:以分钟为单位的日照持续时间,以整数表示。
- solar_sky:待办事项
- solar_global:待办事项
- solar_atmosphere:待办事项
- solar_zenith:待办事项
- sun_duration:以分钟为单位的每小时日照时间,如浮子。
- sun_quality_level:阳光数据的质量水平,如int.
- sun_structure_version:版本号,作为int.
- temphum_humidity:以百分比表示的相对空气湿度,如浮子。
- temphum_quality_level:空气温度和 湿度数据,如Int.
- temphum_structure_version:版本号,作为int.
- temphum_temperature:以摄氏度为单位的空气温度,如 漂浮。
- wind_direction:风向,单位为度,整数(0-360)。
- wind_quality_level:风数据质量级别,如int.
- wind_speed:以米每秒为单位的风速,作为浮标。
- wind_structure_version:版本号,作为int.
命令行实用程序:
获取最近的站点(第一个参数是经度,第二个参数是纬度):
$ dwdweather station 7.0 51.0
获取所有电台:
$ dwdweather stations
将电台导出为csv:
$ dwdweather stations -t csv -f stations.csv
将站点导出为geojson:
$ dwdweather stations -t geojson -f stations.geojson
在车站获取特定小时的天气(UTC):
$ dwdweather weather 2667 2014060122
一些注释
- 数据缓存在本地sqlite3数据库中,用于快速查询。
- 当第一次请求 DwdWeather.stations()或DwdWeather.nearest_station()
- 不会自动刷新站点缓存。使用 DwdWeather.import_stations()这样做。
- 首次访问度量值时,将使用 DwdWeather.query(),并在查询无法执行时更新 缓存已满。
- 默认情况下,缓存位于~/.dwd-weather目录中。这个 可以使用的cachepath参数影响 DwdWeather()。
- 每个站点的数据量大约为60 MB,可用于完整的历史扩展 这当然会在未来发展。
- 如果查询到天气数据,并且无法从 缓存,每次查询时都从服务器加载数据。即使 数据已在前一秒更新。如果服务器没有 请求时间的数据(例如,因为它还不可用) 导致多余的网络流量和等待时间。当然还有空间 这里有进步。
状态
这个软件还处于初级阶段。还没有测试用例。只有 使用了unter python 2.7.5。在你自己的RIS上使用K.
许可证(代码)
根据MTI许可证授权。有关详细信息,请参见文件许可证。