Simple Python interface to the The Danish Meteorological Institute's (DMI) Open Data API metObs v2.
Project description
DMI Open Data API
Simple Python interface to the The Danish Meteorological Institute's (DMI) v2 Open Data API.
Weather data from Denmark and Greenland are publicly available through DMI's Open Data API. Fetch raw weather observations from all available weather stations in Denmark and Greenland. Parameters available include temperature, windspeed, humidity, pressure, _precipitation__, and many more.
Requirements
- Python 3.6+
- API Key for metObs v2 from DMI Open Data
- (Optional) API Key for climateData v2 from DMI Open Data
Installation
$ pip install dmi-open-data
Example
from datetime import datetime
import os
from dmi_open_data import DMIOpenDataClient, Parameter, ClimateDataParameter
# Get 10 stations
client = DMIOpenDataClient(api_key=os.getenv('DMI_API_KEY'))
stations = client.get_stations(limit=10)
# Get all stations
stations = client.get_stations()
# Get DMI station
dmi_station = next(
station
for station in stations
if station['properties']['name'].lower() == 'dmi')
# Get closest station
closest_station = client.get_closest_station(
latitude=55.707722,
longitude=12.562119)
# Get available parameters
parameters = client.list_parameters()
# Get temperature observations from DMI station in given time period
observations = client.get_observations(
parameter=Parameter.TempDry,
station_id=dmi_station['properties']['stationId'],
from_time=datetime(2021, 7, 20),
to_time=datetime(2021, 7, 24),
limit=1000)
# Init climate data client
climate_data_client = DMIOpenDataClient(api_key=os.getenv('DMI_CLIMATE_DATA_API_KEY'))
# Get climate data
climate_data = climate_data_client.get_climate_data(
parameter=ClimateDataParameter.MeanTemp,
station_id=dmi_station['properties']['stationId'],
from_time=datetime(2021, 7, 20),
to_time=datetime(2021, 7, 24),
time_resolution='day',
limit=1000)
API Key
API Key can be obtained for free at the DMI Open Data.
Tests
Run tests
$ python -m unittest discover tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dmi-open-data-0.1.2.tar.gz
(7.8 kB
view details)
File details
Details for the file dmi-open-data-0.1.2.tar.gz
.
File metadata
- Download URL: dmi-open-data-0.1.2.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86bfc3f7f691356c6cd511689ef58cb554f92e093c78193533b196018cf9efac |
|
MD5 | b5ca9a2f8c890b31fa5b57592dd89aea |
|
BLAKE2b-256 | 143bd74cf382aa097287cbed77571dced3282ba41e39090abf1a82ad0e7a402c |