meteostat-python icon indicating copy to clipboard operation
meteostat-python copied to clipboard

Station data differs from DWD

Open sv1990 opened this issue 4 months ago • 0 comments

When downloading the data for station D3490 I get different data than directly from DWD. The DWD data has a gap between 2021-07 and 2021-11 while the data downloaded through meteostat has values there.

Code for reproduction

Meteostat

from datetime import datetime

import meteostat

stations = meteostat.Stations()
stations = stations.nearby(50.541821, 7.119770)
station = stations.fetch(1)
print(station["name"])
df_meteostat = meteostat.Daily(station, datetime(2021, 1, 1), datetime(2021, 12, 31)).fetch()

This prints

id
D3490    Neuenahr, Bad-Ahrweiler
Name: name, dtype: object

DWD

from io import BytesIO
from zipfile import ZipFile

import pandas as pd
import requests

response = requests.get(
    "https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/daily/kl/historical/tageswerte_KL_03490_19480101_20241231_hist.zip"
)
with ZipFile(BytesIO(response.content)).open(
    "produkt_klima_tag_19480101_20241231_03490.txt"
) as f:
    df_dwd = pd.read_csv(f, sep=";")
    df_dwd["date"] = pd.to_datetime(df_dwd.MESS_DATUM, format="%Y%m%d")
    df_dwd = df_dwd[df_dwd.date.dt.year == 2021]
    df_dwd.columns = df_dwd.columns.str.strip()
    df_dwd = df_dwd.set_index("date")

Plotting

from matplotlib import pyplot as plt

fig, ax = plt.subplots()
df_meteostat.plot(y="prcp", ax=ax, label="meteostat")
df_dwd.plot(y="RSK", ax=ax, label="dwd")
plt.legend(title="Precipation")
Image

Is the data downloaded through meteostat somehow interpolated? Or is another source used? For the dates where both downloads have values they are agreeing at least for precipation which is what I am currently interested in.

sv1990 avatar Sep 04 '25 09:09 sv1990