Skip to main content

Get weather data

Project description

這是什麼?

WeatherData 是收集了氣象局的開放氣象資料以及安吉氣象決策的預報資料。

所有資料都整合在 WeatherData 的後台伺服器中,使用這個套件就不需要再自行開發爬蟲爬取氣象局,只要輸入位置(經緯度或縣市鄉鎮名),即可取得天氣資料。

安裝

$ pip install WeatherData

如何開始

>>> import WeatherData as wd
>>> wd.obs.get(citytown='台北市中正區')
# 回傳最新一次觀測時間的資料
{
    'lat': 25.046058,
    'lon': 121.516565,
    'dtime': '2022-03-17T08:00+00:00',
    'ws': 2.7,
    'tx': 26.7,
    'rh': 58.3,
    'pres': 1004.1,
    'wd': 307.3039482779834,
    'precp_hour': 0.0,
    'cloud': 0.28
}

>>> from datetime import datetime
>>> wd.obs.get(lat=21., lon=124., dtime=datetime(2021,12,31))
# 回傳指定觀測時間的資料
{
    'lat': 21.0,
    'lon': 124.0,
    'dtime': '2021-12-31T00:00+00:00',
    'ws': 0.0,
    'tx': 0.0,
    'rh': 0.0,
    'pres': 0.0,
    'wd': 270.0,
    'precp_hour': 0.0,
    'cloud': 0
}

>>> wd.fcst.get(lat=21., lon=124.)
# 回傳最新一次預報的所有資料,總共資料長度 14 天,每小時一筆,共 336 筆資料
[{
    'dtime': '2022-04-13T00:00:00+00:00',
    'wd': 97.5,
    'ws': 6.1,
    'wg': 7.3,
    'precp': -999.0,
    'cloud': 50.9,
    'tx': 25.5,
    'rh': 73.5,
    'pres': 1008.5,
    'lat': 20.0,
    'lon': 120.0
}, {
    'dtime': '2022-04-13T01:00:00+00:00',
    'wd': 99.1,
    'ws': 5.5,
    'wg': 6.5,
    'precp': 0.0,
    'cloud': 47.8,
    'tx': 25.6,
    'rh': 75.0,
    'pres': 1008.4,
    'lat': 20.0,
    'lon': 120.0
}, {
    'dtime': '2022-04-13T02:00:00+00:00',
    'wd': 104.2,
    'ws': 5.1,
    'wg': 6.0,
    'precp': 0.0,
    'cloud': 49.4,
    'tx': 25.6,
    'rh': 74.6,
    'pres': 1008.3,
    'lat': 20.0,
    'lon': 120.0
}...]

參數說明

輸入參數

  • dtime: 資料時間(UTC)
  • citytown: 縣市+鄉鎮
  • lat: 緯度
  • lon: 經度

輸出參數

  • dtime: 資料時間(UTC)
  • wd: 風向(方位角 0~360度 北向為0)
  • ws: 風速(m/s)
  • wg: 最大陣風風速(m/s)
  • precp: 預報小時雨量(mm)
  • precp_hour: 觀測小時雨量(mm)
  • cloud: 雲量 0~100
  • tx: 溫度(攝氏溫度)
  • rh: 相對濕度
  • pres: 大氣壓力(hPa)
  • lat: 緯度(度)
  • lon: 經度(度)

錯誤排除

requests.exceptions.HTTPError: 503 Server Error: Service Temporarily Unavailable

如果出現以上 503 Server Error , 可以等個 10 秒鐘再試試看。

資料來源

所有預報資料均來自中央氣象局及安吉氣象決策公司等機構提供,本公司並未進行任何天氣預報。

License

免責聲明

本專案提供的所有內容均用於教育、非商業用途。資料僅供參考,對於資料內容任何錯誤、更新延誤或傳輸中斷,本公司均不負任何責任。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

WeatherData-0.0.21.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

WeatherData-0.0.21-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file WeatherData-0.0.21.tar.gz.

File metadata

  • Download URL: WeatherData-0.0.21.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for WeatherData-0.0.21.tar.gz
Algorithm Hash digest
SHA256 fae71afcdaeee4ae31599c42f45c81847c20df3b5587e418ba1ea33089b2d6df
MD5 e6211f9a7049b3521cc0926f10f6f6e1
BLAKE2b-256 60890212277ddef55ffb6a26f68aeef56767967686379cf91525ee1df799aad6

See more details on using hashes here.

File details

Details for the file WeatherData-0.0.21-py3-none-any.whl.

File metadata

  • Download URL: WeatherData-0.0.21-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for WeatherData-0.0.21-py3-none-any.whl
Algorithm Hash digest
SHA256 c5af2d28efee3b79c1cd2d7859f3ca303e5a795f2b7183945e2c2e31f4629f4f
MD5 abd10421c2e1f1f85f19dee3a08b20a1
BLAKE2b-256 e0a80de037a9f5e10e43487565da49ff7916728f5281ae585a43875d61ff0345

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page