Skip to main content

Library for fetching weather information from Finnish Meteorological Institute (FMI)

Project description

Test Last commit Latest version in GitHub Latest version in PyPi

Finnish Meteorological Institute Weather

Library for fetching weather information from Finnish Meteorological Institute (FMI).

Originally build for personal use because I wanted to create FMI integration for Home Assistant.

BETA WARNING! This is still under heavy development. The public API is not frozen yet so DO NOT consider it to be stable. Any version can have breaking changes.

How to use

Working example can be found in example.py.

Install

$ pip install fmi-weather-client 

Get a weather by place name

import fmi_weather_client

weather = fmi_weather_client.weather_by_place_name("Mäkkylä, Espoo")

Selected weather station depends on FMI service. Be aware, that sometimes FMI service does pretty poor job at selecting a station that provides meaningful data. For example, at the time of writing weather from Sipoo returns data from a station that measures cloud coverage and nothing more. Another example is Kaivopuisto, Helsinki which returns data from a station that seems to be unavailable or broken.

If place name is not known or weather data is not available, the following exception is thrown:

fmi_weather_client.errors.NoWeatherDataError

Get a weather by coordinates

import fmi_weather_client

weather = fmi_weather_client.weather_by_coordinates(63.361604, 27.392607)

Returned data is from the closest weather station. Just like with place name search, station might return very little data or nothing at all. If there are no stations within 90 km or weather data is not available, the following exception is thrown:

fmi_weather_client.errors.NoWeatherDataError

Get a combination weather

import fmi_weather_client

weather = fmi_weather_client.weather_multi_station(69.016989, 21.465569)

Returned data is combination of multiple stations. Closest station is checked first and if some variables are missing, next station is checked. This way it is likely to get all variables it is possible that some data comes from a station that is quite far away.

Returned station name and observation time is always the closest station. If there are no stations within 90 km or weather data is not available, the following exception is thrown:

fmi_weather_client.errors.NoWeatherDataError

Get a forecast

You can get the forecast using a place name or coordinates and the behaviour is the same. The code tries to fetch the forecast for the next 6 days but looks like FMI provides it only for the next 3. You can also define the timestep between forecasts. Default is 24 hours.

forecast = fmi_weather_client.forecast_by_place_name("Jäppilä, Pieksämäki")
forecast2 = fmi_weather_client.forecast_by_coordinates(28.62406, 67.6894, timestep_hours=12)

Weather data

Available weather information depends on the weather station. Currently supported fields:

  • Station name
  • Station latitude
  • Station longitude
  • Observation time
  • Temperature (°C)
  • Humidity (%)
  • Wind speed (m/s)
  • Wind gust (m/s)
    • Maximum gust wind in the past 10 minutes
  • Wind direction (°)
  • Dew point (°C)
  • Precipitation amount (mm)
    • Amount of rain in the past hour
  • Precipitation intensity (mm/h)
  • Pressure (hPa)
  • Visibility (m)
  • Cloud coverage
    • Cloud coverage is indicated as 1/8 sky.
    • 0.0 means no clouds
    • 4.0 means half cloudy
    • 8.0 means overcast
  • Snow depth (cm)
  • Current weather as WaWa code (Documentation in Finnish)

Observation data contains two fields: value and unit. You can also just print the observation object to get a string representation:

print('Temperature: %s' % weather.temperature)

# Output: Temperature: 1.4 °C

Forecast data

  • Geopotential height (m)
  • Temperature (°C)
  • Pressure (hPa)
  • Humidity (%)
  • Wind direction (°)
  • Wind speed (m/s)
  • Wind U component (m/s)
  • Wind V component (m/s)
  • Wind max (m/s)
  • Wind gust (m/s)
  • Dew point (°)
  • Cloud cover (%)
  • Symbol Documentation in Finnish
  • Precipitation amount 1h (mm/h)
  • Precipitation amount (mm)

There are also other data regarding cloud coverage, radiation and land-sea mask. I have no idea what these really are so it is best to check FMI documentation.

Development

Setup

Create and activate a virtual environment

$ python -m venv venv
$ source venv/bin/activate

Install required packages

$ python -m pip install -r requirements.txt
$ python -m pip install -r requirements-dev.txt

When you stop working, deactivate virtual environment

$ deactivate

Run tests

$ pytest

Run code quality tools

$ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude venv
$ flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127  --exclude venv

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

fmi-weather-client-0.0.5.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

fmi_weather_client-0.0.5-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file fmi-weather-client-0.0.5.tar.gz.

File metadata

  • Download URL: fmi-weather-client-0.0.5.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5

File hashes

Hashes for fmi-weather-client-0.0.5.tar.gz
Algorithm Hash digest
SHA256 6da67a702cdd2780b7f21b36ca02320b48fe4dac7e8b6777f717b4e88eab6717
MD5 8cd31a4bcc5d50e3350dc3c98be73638
BLAKE2b-256 4465183d4bde320fcf932f0beb3d974db057e1ee17e9a79d4200132e265112ad

See more details on using hashes here.

File details

Details for the file fmi_weather_client-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: fmi_weather_client-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 27.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5

File hashes

Hashes for fmi_weather_client-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4d5d243effcdd2fc381c132d684f417985f7fe768d23f3a240a823733f6eb18a
MD5 4412101dccc11151bc0400cf0f96d54f
BLAKE2b-256 dd36f778afb07818ed2b2a9b6e195161741fd3f8a183cf047cce72037f761f59

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