Skip to main content

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

Installation

$ pip install dmi-open-data

Example

from datetime import datetime
import os

from dmi_open_data import DMIOpenDataClient, Parameter, ClimateDataParameter, OceanographicDataParameter


# 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)

# Init oceanographic data client
ocean_data_client = DMIOpenDataClient(api_key=os.getenv('DMI_OCEAN_DATA_API_KEY'))

# Get oceanographic data
ocean_data = ocean_data_client.get_ocean_data(
    parameter=OceanographicDataParameter.Tw,,
    station_id="31061",
    from_time=datetime(2025, 9, 8),
    to_time=datetime(2025, 9, 10),
    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


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.4.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dmi_open_data-0.1.4-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file dmi_open_data-0.1.4.tar.gz.

File metadata

  • Download URL: dmi_open_data-0.1.4.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for dmi_open_data-0.1.4.tar.gz
Algorithm Hash digest
SHA256 381eb6aac19e9481fd2ffa184464e27f2944dfc605046dc6173ace5e5c032987
MD5 0762ade888548211323fe02a55b2c8c6
BLAKE2b-256 1fe52000f5c6fe6db9d477432dd416cb1ac39f839a4145c4abf42cef5fb93445

See more details on using hashes here.

File details

Details for the file dmi_open_data-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: dmi_open_data-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for dmi_open_data-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f13204f7f57d2b192147a2bd3f6df79c1a3a34e96bda9c559f49a115d528aeca
MD5 8c42c8a1e86fa9e4bd80733f834a3323
BLAKE2b-256 f6aa61de4e57f3d9dc38a40f5d064027c175946c99e0a6a3017ce2504f8f24de

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page