DMI Open Data API
Simple Python interface to the The Danish Meteorological Institute's (DMI) v2 Open Data API.
Forked from this repo to add support for more data sources as well as pandas output.
Currently the following APIs are supported:
- climateDataAPI
- forecastedr
- metObsAPI
See API status here
Requirements
- Python 3.9+
- API Keys for the different Open Data APIs: see https://dmiapi.govcloud.dk/#!/apis
Installation
$ pip install dmi-open-data-pandas
Examples
Forecast API
from dmi_open_data import DMIOpenDataClient
# initialize client with API key stored in env variable
client = DMIOpenDataClient(env_var_name="DMI_FORECAST_EDR_API_KEY")
# get list of models available
models = client.get_models(as_df=True)
# get info about a specific model
model_info = client.get_models("harmonie_dini_sf")
# list parameters available for specific model
params = client.list_model_parameters("harmonie_dini_sf", as_df=True)
# get a forecast for wind speed and temperature
fc = client.get_forecast(
latitude=55.767247,
longitude=12.464263,
parameter=["temperature-0m", "wind-speed-10m"]
)
Observations and Climate Data API
from dmi_open_data import DMIOpenDataClient, Parameter, ClimateDataParameter
from datetime import datetime
import pandas as pd
# initialize client with API key stored in env variable
client = DMIOpenDataClient(env_var_name="DMI_API_KEY")
# get all stations
stations = client.get_stations()
# get station closest to a lat-lon
closest_station = client.get_closest_station(
latitude=55.767247,
longitude=12.464263,
)
# Get available parameters
parameters = client.list_observation_parameters()
# Get temperature observations from DMI station in given time period
observations = client.get_observations(
parameter=Parameter.TempDry,
station_id=closest_station['properties']['stationId'],
from_time=datetime(2021, 7, 20),
to_time=datetime(2021, 7, 24),
limit=1000
)
# you can also use the simple parameter string, and ask to return a pandas dataframe
observations = client.get_observations(
parameter="temp_dry",
station_id=closest_station['properties']['stationId'],
from_time=datetime(2021, 7, 20),
to_time=datetime(2021, 7, 24),
as_df=True
)
# initialize climate data client
climate_data_client = DMIOpenDataClient(env_var_name='DMI_CLIMATE_DATA_API_KEY')
# get climate data, also using pandas Timestamps
climate_data = climate_data_client.get_climate_data(
parameter=ClimateDataParameter.MeanTemp,
station_id=closest_station['properties']['stationId'],
from_time=pd.Timestamp("2023-01-01"),
to_time=pd.Timestamp("2023-01-03"),
time_resolution='day',
as_df=True
)
Tests
Run tests (after installing pytest)
$ python -m pytest
Contributing
Please send an email to edu230991@gmail.com. We welcome contributions!
Release files for dmi-open-data-pandas 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dmi_open_data_pandas-0.1.tar.gz | 11.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dmi_open_data_pandas-0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:20.5 kB
Release files / dmi_open_data_pandas-0.1.tar.gz
| Download URL | dmi_open_data_pandas-0.1.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a6f917e0d657b2e90e5bd2a3513ee655a2ea0a46afd275f513a7dd36989df2e
|
|
BLAKE2b-256 checksum How to use checksums |
79e209831e13a711688028f6b4f8ed02f347e097b8ef8a6112e8760e2dbf3b88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Release files / dmi_open_data_pandas-0.1-py3-none-any.whl
| Download URL | dmi_open_data_pandas-0.1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c5a508d9a0193efd16f16fca821f90901a01e4332aa641fdb62431d73bdef88a
|
|
BLAKE2b-256 checksum How to use checksums |
74acca5460a6872262b7220b92339225447a6b87c13d0d35cc6fe9f1db74c086
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|