meteostat / meteostat-python

Access and analyze historical weather and climate data with Python.
https://dev.meteostat.net/python/
MIT License
433 stars 60 forks source link

Some station can not be fetched and return an empty dataframe #65

Closed cminton-hub closed 3 years ago

cminton-hub commented 3 years ago

Issue: Some station id return an empty dataframe while using the python api. When checking using the website, data for the time frame 2020.03.01-2020.05.31 is avaiable. I checked following station using the sample code from: https://dev.meteostat.net/python/hourly.html

What I already noticed, sometimes WMO id or National id are used to fetch the data. But with those 5 stations an empty dataframe is always received.:

country,lon,lat,hight_m,station_name,id_wmo,id_national_1,id_national_2,id_icao,id_iata Germany,13.4710,51.0063,285.00,Wilsdruff-Mohorn,,13654,13654,, Tschechien,14.0333,50.6833,377.00,Usti Nad Labem,11502,11502,,, Tschechien,13.9333,50.55,836.00,Milesovka,11464,11464,,, Tschechien,14.1667,50.4667,158,Doksany,11509,11509,,, Germany,14.2833,51.7667,68.00,Cottbus (Flugplatz),10492,10492,00879,ETHT,CBU

Steps to reproduce:

import pandas as pd
from datetime import datetime
from meteostat import Stations, Point, Hourly

stations = ["13654", "11502", "11464", "11509", "10492"]

for station in stations:
    """define the periode for fetching"""
    start = datetime(2020, 3, 1)
    end = datetime(2020, 5, 31, 23, 59)
    """Get hourly data and opt-out for model data"""
    df_weatherdata = Hourly(station, start, end, model=False)
    df_weatherdata = df_weatherdata.fetch()
    df_weatherdata.reset_index(inplace=True)
    """
    date,time in hour, temperature, dewpoint (Taupunkt), relative air humidity, rainfall, snow, wind direction, wind speed, peak wind speed, air pressure (NN), sonne in min, weather condition code
    "datetime","temp_degc","dwpt_degc","rhum_proz","prcp_mm","snow_mm","wdir_deg","wspd_km/h","wpgt_km/h","pres_hPa","tsun_min","coco","id_national"
    """
    df_weatherdata.rename(columns={"time": "datetime"}, inplace=True)
    df_weatherdata.rename(columns={"temp": "temp_degc"}, inplace=True)
    df_weatherdata.rename(columns={"dwpt": "dwpt_degc"}, inplace=True)
    df_weatherdata.rename(columns={"rhum": "rhum_proz"}, inplace=True)
    df_weatherdata.rename(columns={"prcp": "prcp_mm"}, inplace=True)
    df_weatherdata.rename(columns={"snow": "snow_mm"}, inplace=True)
    df_weatherdata.rename(columns={"wdir": "wdir_deg"}, inplace=True)
    df_weatherdata.rename(columns={"wspd": "wspd_km/h"}, inplace=True)
    df_weatherdata.rename(columns={"wpgt": "wpgt_km/h"}, inplace=True)
    df_weatherdata.rename(columns={"pres": "pres_hPa"}, inplace=True)
    df_weatherdata.rename(columns={"tsun": "tsun_min"}, inplace=True)
    df_weatherdata.rename(columns={"id_national": "datetime"}, inplace=True)
    df_weatherdata = df_weatherdata.assign(id_national=station)
    df_weatherdata = df_weatherdata.astype(
        {
            "datetime": "object",
            "temp_degc": "float64",
            "dwpt_degc": "float64",
            "rhum_proz": "float64",
            "prcp_mm": "float64",
            "snow_mm": "float64",
            "wdir_deg": "float64",
            "wspd_km/h": "float64",
            "wpgt_km/h": "float64",
            "pres_hPa": "float64",
            "tsun_min": "float64",
            "coco": "object",
            "id_national": "object",
        }
    )
    print("---------------------------------------------->")
    print(station)
    print(df_weatherdata)
cminton-hub commented 3 years ago

I tried to change a few things but nothing changed. Any updates?

clampr commented 3 years ago

The data you're looking for isn't available for these stations. Did you opt-out of model data on the website, too? I checked for https://meteostat.net/en/station/10492?t=2020-03-01/2020-03-01 and changed the settings to opt-out of model data (click the cog icon in the navbar) and it doesn't show any data. So it's rather a gap in the time series which we can only fill (maybe) by adding additional imports from national weather services.

cminton-hub commented 3 years ago

Alright thank you.