Giter Site home page Giter Site logo

rhkarls / sondera Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 85 KB

sondera is a python package providing clients for accessing Swedish hydrology and meteorology related open data. Data sources currently include SMHI open data API and SGU groundwater API.

License: MIT License

Python 100.00%
hydrology meteorological-data open-data hydrological-data meterology observations python sgu smhi climate

sondera's Introduction

sondera

pypi_shield pypi_license tests_workflow Documentation Status

Overview

sondera is a python package providing clients for accessing Swedish hydrology and meteorology related open data and observations.

Download stream discharge, groundwater levels, climate and weather observations and more from stations across Sweden. Data sources currently include Swedish Meteorological and Hydrological Institute (SMHI) open data API and Swedish Geological Survey (SGU) groundwater API.

Consider the API unstable, it may change at short or no notice.

Data sources and licenses

It is the end users responsibility to adhere to the license of each respective data provider. See the links to the licenses below.

The following clients are currently implemented or under implementation:

Observations

Model products

Parameters available

Hydrometric parameters

  • Stream discharge
  • Groundwater level

Weather and climate parameters

More than 40 parameters, including

  • Precipitation
  • Air temperature
  • Wind speed
  • Solar radiation (station data via MetObs, distributed data via Strång)

Requirements and installation

Requirements:

numpy
pandas
geopandas
requests
tqdm

Install from pypi using pip

pip install sondera

General description and example usage

Observational data which is linked to a station is returned as a DataSeries object, which contains metadata information in addition to the observed data series.

Modelling products are returned as the data series only, which is either a pandas Series or DataFrame, or xarray for multi-dimensional data.

# Example getting hourly air temperature for the latest months from
# SMHI station Stockholm-Observatoriekullen A  (number 98230)
from sondera.clients.smhi import MetObsClient, ParametersMetObs

client = MetObsClient()
# For the parameter we can pass either the ParametersMetObs enum
# or simply the SMHI integer id (which is 1 for hourly air temperature)
air_temp = client.get_observations(parameter=ParametersMetObs.TemperatureAirHour,
                         station=98230,
                         period='latest-months')

# observations are stored under "data" attribute as a pandas.Series
air_temp.data.head(5)
timestamp
2021-12-31 01:00:00    4.9
2021-12-31 02:00:00    4.2
2021-12-31 03:00:00    3.5
2021-12-31 04:00:00    3.1
2021-12-31 05:00:00    3.0
Name: TemperatureAirHour, dtype: float64

# additional data, such as quality tags are stored under "aux_data"
air_temp.aux_data.head(5)
                    quality
timestamp                  
2021-12-31 01:00:00       G
2021-12-31 02:00:00       G
2021-12-31 03:00:00       G
2021-12-31 04:00:00       G
2021-12-31 05:00:00       G

# information on the station is also available, such as name, id, coordinates,
# and history
air_temp.station
Station(name='Stockholm-Observatoriekullen A', id=98230, agency='SMHI', 
        position=Coordinate(y=59.341681, x=18.054928, z=43.133, epsg_xy=4326, epsg_z=5613),
        station_type=<StationType.MetStation: 2>, active_station=True, 
        active_period=[Timestamp('1996-10-01 00:00:00'), Timestamp('2022-05-10 07:00:00')],
        last_updated=Timestamp('2022-05-10 07:00:00'), station_info={}, 
        position_history=[{'from': Timestamp('1996-10-01 00:00:00'), 
                           'to': Timestamp('2022-05-10 07:00:00'), 
                           'position': Coordinate(y=59.341681, x=18.054928, z=43.133,
                                                  epsg_xy=4326, epsg_z=5613)}])

Feedback and issues

Please report issues here: https://github.com/rhkarls/sondera/issues

General feedback is most welcome, please post that as well under issues.

sondera's People

Contributors

rhkarls avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

sondera's Issues

BUG: OSError on Windows when station has negative posix timestamps (anything before 1970)

When trying to get data from station with activity before 1970 this error is thrown, for example smhi met station 180960

from sondera.clients.smhi import MetObsClient, ParametersMetObs
metclient = MetObsClient()
data = metclient.get_observations(ParametersMetObs.PrecipitationDayAt06, 180960, 'latest-months')

Traceback (most recent call last):
...    
  File "C:\Users\user\Miniconda3\envs\cf_data\lib\site-packages\sondera\clients\smhi\metobs.py", line 263, in _create_data_obj
    pos_i = {'from': dt.datetime.utcfromtimestamp(pos['from'] / 1000),

OSError: [Errno 22] Invalid argument

Release 0.0.2

WIP List of things to fix/add:

  • Issue #1. Fix negative posix timestamps
  • ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.