天气工具包

PySk的Python项目详细描述


pysky是一个python天气工具包,它提供对许多公共可用天气数据库的访问。pysky的目标是以pythonic的方式提供一个快速、易用的气象数据接口。目前的实施重点是美国国家海洋和大气管理局(noaa)的天气数据,不过未来的天气系统将被纳入其中。特别是,它提供每小时和每天的预测摘要。

使用模块

该工具包有几个命令行脚本,用于返回格式化的天气数据。

要获取预测数据,请使用forecast.py。对于快速而不可靠的预测,forecast.py将使用noaa xml web服务来获取预测信息。对于更健壮的应用程序,forecast.py的用户将希望使用grib2选项。grib2选项下载noaa grib2文件,该文件为整个美国提供预测元素。查询grib2数据比查询xml web服务快得多,效率也高得多。

python bin/download (--grib2-dir=DIR)(--verbose)
python bin/forecast (--hourly)(--grib2-dir=DIR)(--verbose) LATITUDE LONGITUDE

示例:

python bin/download # download to current directory
python bin/download --grib2-dir=/tmp # download data files to /tmp
python bin/forecast --grib2-dir=/tmp -- 38 -81 # get forecast for latitude 38 and longitude -81

forecast操作的输出是以下格式的json编码值:

{
    'daily' : [
        {
            'date' : *date*
            'high' : *high*,
            'low' : *low*,
            'humidity' : *humidity*,
            'precip_day' : *daytime % chance of precip*,
            'precip_night' : *night time % chance of precip*,
            'rain_amount' : *rain amount in inches*,
            'snow_amount' : *snow amount in inches*,
            'weather': *weather description*,
            'symbol': *weather symbol used by NOAA*,
            'wind_sustained': *sustained wind in MPH*,
            'wind_gust': *wind gusts in MPH*
        }, ...
    ],
    'hourly' : [
        {
            'date' : *date*,
            'time' : *time*,
            'temp' : *temperature*,
            'humidity' : *% humidity*,
            'precip' : *% chance of precipitation*,
            'rain_amount' : *rain amount in inches*,
            'snow_amount' : *snow amount in inches*,
            'sky' : *% cloud cover*:
            'weather: *weather description*,
            'wind_sustained': *sustained wind in MPH*,
            'wind_gust': *wind guests in MPH
        }, ...
    ]
 ]

要求

如果使用grib2文件(不是web服务),则必须安装noaa degrib库http://www.nws.noaa.gov/mdl/degrib/。此外,degrib源中包含的geodata目录必须复制到grib2数据目录。

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

推荐PyPI第三方库


热门话题
正在从节点解密字符串。Java中的js?   java未来超时和IO超时   java apache camel多播以异步方式执行聚合   java需要710次尝试在Android和Raspberry Pi之间建立socket连接   在Java中使用“+,”循环绘制形状   java安卓:如何计算两点之间的距离   java多线程Hello World   刷新后缓存共享变量的java Freemarker模板   java我试图通过迭代用整数填充数组,但我得到了ArrayIndexOutOfBoundsException   JNI C++到java 32位图像的不正确显示   java哪个更快:克隆还是使用流?   java cache2k和Generic T不能很好地结合在一起   java如何在读取文件之前更新文件内容?   java如何在GWT中从JSNI方法调用JSNI方法   将MySQL类型文本映射到Java Hibernate的类型   java如何按长度对字符串排序   java RecyclerView:在滚动期间不断更改数据