コード例 #1
0
from meteostat import Stations, Daily
from datetime import datetime
import matplotlib.pyplot as plt

data = Daily(['10637'], start = datetime(2018, 1, 1), end = datetime(2018, 12, 31))
data = data.normalize().aggregate(freq = '1W').fetch()

data.plot(x = 'time', y = ['tavg', 'tmin', 'tmax'], kind = 'line')
plt.show()
コード例 #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
"""
Spatial sampling with Meteostat
"""

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

# Get 20 random weather stations in Germany
stations = Stations(country='DE', daily=datetime(2005, 1,
                                                 1)).fetch(limit=20,
                                                           sample=True)

# Get daily data
data = Daily(stations,
             max_threads=5,
             start=datetime(1980, 1, 1),
             end=datetime(2019, 12, 31))

# Normalize data and aggregate
data = data.normalize().aggregate(freq='5Y', spatial=True).fetch()

# Plot chart
data.plot(y=['tavg'],
          kind='line',
          title='Sampled DE Annual Mean Temperature from 1980 to 2019')
plt.show()
コード例 #4
0
"""
Example: Aggregation

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 datetime import datetime
import matplotlib.pyplot as plt
from meteostat import Daily

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

# Get daily data
data = Daily('10637', start, end)

# Group & aggregate weekly
data = data.normalize().aggregate(freq='1W').fetch()

# Plot chart
data.plot(y=['tavg', 'tmin', 'tmax'])
plt.show()
コード例 #5
0
from meteostat import Stations, Daily
from datetime import datetime
import matplotlib.pyplot as plt

stations = Stations(country='US', daily=datetime(2005, 1, 1)).sample(5).fetch()

data = Daily(stations,
             max_threads=5,
             start=datetime(1980, 1, 1),
             end=datetime(2019, 12, 31))
data = data.normalize().aggregate(freq='1Y', spatial=True).fetch()

data.plot(y=['tavg'],
          kind='line',
          title='Average US Annual Temperature from 1980 to 2019')
plt.show()
コード例 #6
0
from datetime import datetime
import json
import matplotlib.pyplot as plt
from meteostat import Stations, Daily
stations = Stations(lat=53.9, lon=27.5667, daily=datetime(2019, 1, 1))
#data = Daily(station, start = datetime(2018, 1, 1), end = datetime(2018, 12, 31))
station = stations.fetch(1)
data = Daily(station, start=datetime(2019, 11, 1), end=datetime(2020, 11, 30))
data = data.fetch()
print(data)
data.plot(kind='scatter', x='snow', y='tmin')
plt.show()
#data.to_csv('wlastyear.csv', encoding='utf-8', date_format='%Y/%m/%d',na_rep='NULL')