A Python library for accessing the Norwegian Meteorological Institute frost.met.no API
Project description
Frostrose
frostrose is a Python library for easy access to the Norwegian Meteorological Institute's frost.met.no API. It simplifies the process of fetching weather data from various endpoints.
Installation
pip install frostrose
Usage
Setting up the Client
You can use the FrostClient either by setting an environment variable FROST_CLIENT_ID or by providing the client ID directly during instantiation.
Using an Environment Variable
Set the environment variable FROST_CLIENT_ID with your API key:
export FROST_CLIENT_ID='your_api_key_here'
Then, in your Python code:
from frostrose import FrostClient
client = FrostClient()
Providing Client ID on Instantiation
Alternatively, you can provide the client ID directly:
from frostrose import FrostClient
client = FrostClient('your_api_key_here')
Working with Sources (Weather Stations)
Weather stations are referred to as "sources" in the frost.met.no API. frostrose provides methods to find sources by name, near a specific longitude and latitude, or near another source.
Finding Sources by Name
from frostrose import Sources
sources = Sources(client)
sources.fetch_all_sources()
tynset_sources = sources.get_sources_with_name_icontains('tynset')
Finding Sources Near a Specific Location
nearby_sources = sources.get_sources_within_radius_of_lonlat(lon=5.1963, lat=59.2555, radius_km=50)
Finding Sources Near Another Source
nearby_sources_of_id = sources.get_sources_within_radius_of_source_id('SN47230', radius_km=50)
Finding Weather Elements
To find available weather elements:
from frostrose import Elements
elements = Elements(client)
elements_data = elements.get_elements()
Getting Observation Time Series
To get an observation time series for a specific weather element:
from frostrose import Observations
observations = Observations(client)
temperature = observations.get_data_for_source_element_for_period('SN9580', 'air_temperature', date_start='2023-01-01')
Converting to Pandas DataFrame
To convert the observation time series into a pandas DataFrame:
import pandas as pd
flat_data = temperature.to_flat_dict_list()
df = pd.DataFrame.from_records(flat_data)
License
Frostrose is licensed under the MIT License. See the LICENSE file for more details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file frostrose-0.1.1.tar.gz.
File metadata
- Download URL: frostrose-0.1.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.6 Darwin/23.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d56aa5cc74da60bd5f75df0e1b9b7cdfccb6b60f52637b11b398bca1d492c6fc
|
|
| MD5 |
c2975a405aa7f72844bdb6bc9df9f574
|
|
| BLAKE2b-256 |
3609af4cd22a94aefa44936b116d854d9228b555a67122ccab08808e061ae041
|
File details
Details for the file frostrose-0.1.1-py3-none-any.whl.
File metadata
- Download URL: frostrose-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.6 Darwin/23.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd3247f2d7d0eba6a0614f2ea9d93fafd3cf8d7161f6da407152fc6dd2d6fabd
|
|
| MD5 |
4f9b28e45d1ac92928ca866e9e554835
|
|
| BLAKE2b-256 |
aad26c7d14c8e0f0fdf649bc6d0dd5a980630103402bb16729f8073e97d8dbf3
|