python客户端访问来自德国联邦气象局deutscher wetterdienst(dwd)的天气数据。

dwdweather2的Python项目详细描述


https://img.shields.io/badge/Python-2.7-green.svghttps://img.shields.io/pypi/v/dwdweather2.svghttps://img.shields.io/github/tag/hiveeyes/dwdweather2.svghttps://assets.okfn.org/images/ok_buttons/od_80x15_red_green.pnghttps://assets.okfn.org/images/ok_buttons/oc_80x15_blue.pnghttps://assets.okfn.org/images/ok_buttons/os_80x15_orange_grey.png

dwdwdweather2

从Deutscher Wetterdienst访问天气数据的Python客户端 联邦气象局 德国。

安装

pip install dwdweather2

概要

命令行用法

获取分辨率为hourly的所有电台(默认):

dwdweather stations

使用10_minutes分辨率获取所有电台:

dwdweather stations --resolution 10_minutes

获取最近的站点(第一个参数是经度,第二个参数是纬度):

dwdweather station 7.0 51.0

将电台导出为csv:

dwdweather stations --type csv --file stations.csv

将站点导出为geojson:

dwdweather stations --type geojson --file stations.geojson

在车站获取特定小时的天气(UTC):

dwdweather weather 2667 2019-06-01T15:00

要将导入限制为指定的类别,请运行如下程序:

dwdweather weather 2667 2019-06-01T15:00 --categories air_temperature precipitation pressure

最后,要在执行任何工作之前删除缓存数据库,请使用--reset-cache选项:

dwdweather stations --reset-cache

选择分辨率为10_minutes的数据集:

dwdweather weather 2667 2019-06-01T15:20 --resolution=10_minutes

用作库

fromdatetimeimportdatetimefromdwdweatherimportDwdWeather# Create client object.dw=DwdWeather()# Find closest station to position.closest=dw.nearest_station(lon=7.0,lat=51.0)# 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)print(result)

DwdWeather.query()返回包含 doc/usage-library.rst中列出的可能键。

注释

  • 数据缓存在本地sqlite3数据库中以改进查询 连续调用的性能。
  • “站点缓存”在第一次请求时填充 DwdWeather.stations()DwdWeather.nearest_station()
  • “站点缓存”不会自动刷新。使用 DwdWeather.import_stations()这样做。
  • “度量缓存”在首次访问度量时使用 DwdWeather.query(),并在查询无法执行时更新 从缓存中完成。
  • 默认情况下,缓存位于~/.dwd-weather目录中。 这可以使用的cachepath参数控制 DwdWeather()
  • 在整个历史范围内,每个站点的数据量大约为60 MB 而且很明显会随着时间的推移而增加。
  • 如果查询到天气数据,并且无法从 缓存,数据从服务器加载-即使数据已经 一秒钟前更新的。如果服务器没有 请求的时间(例如,因为它还不可用),这个 不必要地导致网络流量和等待时间。当然是空间 为了改善这里。

许可证

代码许可证

根据麻省理工学院的许可证有关详细信息,请参见文件LICENSE

数据许可证

dwd在 GermanEnglish

状态

这个软件还处于初级阶段。还没有测试用例。只有 使用Python3.6进行测试。使用风险自负。

学分

感谢Marian SteinbachPhilipp Klaus和所有来自 DWD

更改日志

请参阅文件CHANGES.rst

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java快乐,你知道吗   java如何向字符串中的单个单词添加字母   java问题,时间单元增加24分钟   java maven焊接实例失败   用java发送带身份验证的Soap请求   java列表在ListView中找到了信标   java为什么我的图像在y值增加时不会移动?   java错误:找不到适合JsonArrayRequest的构造函数   java如何在不阻塞的情况下将一个对象转换为另一个对象   通过urlconnect的java Kerberos凭据委派?   java是否可以循环一个链接列表来检查特定链接中的2个属性(2个字符串)?   在snackbar中将值分配给变量时发生java错误   java为什么不能更改插入排序的while循环中语句的顺序?