Exemplo n.º 1
0
notRetrived = []
notRetrivedIndex = []

for k, val in enumerate(uniqueLocations):

    stations = Stations()
    stations = stations.nearby(val[0], val[1])
    station = stations.fetch(1)

    data = Daily(station, start, end)
    data = data.fetch()

    if len(data) > 0:

        data['week'] = data.index.isocalendar().week
        ndst = data.groupby('week').mean()
        localdf = ndst[['tavg', 'prcp', 'pres']]
        disc = localdf.isna().sum().sum()

        if disc > 40:
            notRetrived.append(val)
            notRetrivedIndex.append(k)
            print('Wait')
            time.sleep(4)
            print('Go')
        else:
            container.append(ndst[['tavg', 'prcp', 'pres']])
            retrived.append(val)
            retrivedIndex.append(k)
            print('Wait')
            time.sleep(4)
Exemplo n.º 2
0
        return 1
    else:
        return 0


# Convert wind direction
data['wdir'] = data['wdir'].apply(direction)

# Filter for DEC and JAN only
time = data.index.get_level_values('time')
data = data.loc[((time.map(lambda x: x.month) == 12) |
                 (time.map(lambda x: x.month) == 1))]

# Group annually and aggregate
data = data.groupby(pd.Grouper(level='time', freq='1Y')).agg({
    'wdir': 'sum',
    'tavg': 'mean'
})

# Create chart
fig, ax = plt.subplots(figsize=(8, 6))

# Wind data
ax.set_ylabel('Days with North-East Wind', color='tab:blue')
data['wdir'].plot(
    kind='line',
    ax=ax,
    color='tab:blue',
    title=
    'Correlation between North-East Wind and Low Mean Temperature in DE (DEC & JAN)'
)
from meteostat import Stations, Daily
from datetime import datetime
import matplotlib.pyplot as plt

# Get weather stations by WMO ID
stations = Stations(id=['D1424', '10729', '10803', '10513']).fetch()

# Get names of weather stations
names = stations['name'].to_list()

# Get daily data for 2019
data = Daily(stations, start=datetime(2000, 1, 1), end=datetime(2019, 12, 31))
data = data.aggregate(freq='1Y').fetch()

# Plot data
fig, ax = plt.subplots(figsize=(8, 6))
data.groupby(['station']).plot(x='time',
                               y='tmax',
                               kind='line',
                               legend=True,
                               ax=ax,
                               style='.-',
                               ylabel='Max. Annual Temperature (°C)',
                               title='Max. Temperature Report')
plt.legend(names)

# Show plot
plt.show()