solarpy.iotools.get_dmi_climate_station_data

solarpy.iotools.get_dmi_climate_station_data#

solarpy.iotools.get_dmi_climate_station_data(station, start, end, parameters=None, time_resolution='hour', map_variables=True, url='https://opendataapi.dmi.dk/v2/climateData/', **kwargs)#

Retrieve data from DMI’s Climate Data API.

The Danish Meteorological Institute (DMI) operates automatic weather stations in Denmark and Greenland.

Parameters:
  • station (str) – DMI station identifier, e.g. '06180' for Copenhagen Airport.

  • start (datetime-like) – First timestamp of the requested period (inclusive). Timezone-naive values are assumed to be UTC.

  • end (datetime-like) – Last timestamp of the requested period (inclusive). Timezone-naive values are assumed to be UTC.

  • parameters (str or list of str, optional) – DMI parameter identifiers to retrieve, e.g. 'mean_temp' or ['mean_temp', 'mean_wind_speed']. If no value is passed, all available parameters for the station are returned. Note, that the parameter naming convention differs from DMI’s observation data API.

  • time_resolution (str, default 'hour') – Temporal resolution of the data. DMI climate data supports 'hour', 'day', 'month', and 'year'. Most standard pandas frequency aliases (e.g. 'h', 'D', 'MS', 'YS') are also accepted and mapped via TIME_RESOLUTION_MAP.

  • map_variables (bool, default True) – Whether to rename column names from DMI parameter IDs to standard pvlib variable names. Parameters without a mapping are not renamed.

  • url (str, optional) – Base URL for the DMI Climate Data API.

  • **kwargs – Additional keyword arguments forwarded to requests.get(), e.g. timeout=30.

Returns:

  • data (pd.DataFrame) – Time series with a DatetimeIndex. For hourly data the timezone is set to UTC.

  • meta (dict) – Station metadata with keys 'station_id', 'name', 'latitude', 'longitude', 'altitude', and 'country'.

Return type:

tuple[DataFrame, dict]

Notes

The DMI Climate Data API is documented at https://www.dmi.dk/friedata/dokumentation/apis/climate-data-api-1. Data availability and available parameters vary by station.

A list of stations can be found here: https://www.dmi.dk/friedata/dokumentation/data/climate-data-stations.

Examples

Retrieve hourly measured mean temperature and irradiance for the Sjælsmark station north of Copenhagen:

>>> import solarpy
>>> data, meta = solarpy.iotools.get_dmi_climate_station_data(
...     station='06188',  # Sjælsmark station id
...     start='2023-06-01',
...     end='2023-06-30',
...     parameters=['mean_temp', 'mean_radiation'],
...     timeout=30,
... )