コード例 #1
0
from meteostat import Stations, Daily

pageviews = pd.read_csv('pageviews.csv',
                        index_col='Date',
                        parse_dates=['Date'])

# Mehrere Threads für schnellere Downloads
Daily.max_threads = 6

# Zeitliche Periode
start = datetime(2019, 12, 1)
end = datetime(2020, 11, 30)

# 50 Zufällige Wetterstationen in Deutschland
stations = Stations()
stations = stations.region('DE')
stations = stations.inventory('daily', (start, end))
stations = stations.fetch(limit=50, sample=True)

# Tageswerte laden
weather = Daily(stations, start, end)

# Daten monatlich aggregieren
weather = weather.aggregate('1MS', spatial=True).fetch()

# Titel des Diagramms
TITLE = 'Interesse an Klimaanlagen & Max. Temperaturen in Deutschland'

# Darstellung der Seitenaufrufe
ax = pageviews['Klimaanlage'].plot(color='tab:blue', title=TITLE)
ax.set_ylabel('Seitenaufrufe', color='tab:blue')
コード例 #2
0
"""

from datetime import datetime
import matplotlib.pyplot as plt
from meteostat import Stations, Daily

# Configuration
Daily.max_threads = 5

# Time period
start = datetime(1980, 1, 1)
end = datetime(2019, 12, 31)

# Get random weather stations in the US
stations = Stations()
stations = stations.region('US')
stations = stations.inventory('daily', (start, end))
stations = stations.fetch(limit=20, sample=True)

# Get daily data
data = Daily(stations, start, end)

# Normalize & aggregate
data = data.normalize().aggregate('1Y', spatial=True).fetch()

# Chart title
TITLE = 'Average US Annual Temperature from 1980 to 2019'

# Plot chart
data.plot(y=['tavg'], title=TITLE)
plt.show()
コード例 #3
0
ファイル: region.py プロジェクト: tnfru/meteostat-python
"""
Example: Select weather stations by country & state

Meteorological data provided by Meteostat (https://dev.meteostat.net)
under the terms of the Creative Commons Attribution-NonCommercial
4.0 International Public License.

The code is licensed under the MIT license.
"""

from meteostat import Stations

# Get stations in Ontario
stations = Stations()
stations = stations.region('CA', 'ON')

# Print count to console
print('Stations in Ontario:', stations.count())