Client library for Regobs
Project description
regobslib — A Regobs client library
This client library aim to simplify interaction with the Regobs API v5.
Prerequisites
- A client ID for the test or prod environment, contact regobs@nve.no to acquire this.
- A user account for the test or prod environment. Register here:
- Test environment: https://test-konto.nve.no/
- Prod environment: https://konto.nve.no/
- Basic knowledge about snow science nomenclature. For more info, see the following resources:
Installation
To install using pip
:
pip install regobslib
Example programs
Searching for data
Here is an example program searching for weather observations in Ofoten.
from regobslib import *
connection = Connection(prod=True)
results = connection.search(SnowRegistration, regions=[SnowRegion.OFOTEN], observation_types=[Weather])
print(f"Length of results: {len(results)}\n")
print("First result")
print(results[0])
print("\nIterates over results")
for result in results:
print(f"Id: {result.id}, Observer: {result.observer.nickname}, Date: {result.obs_time}")
Submitting data
Below is a simple program demonstrating how to register a whumpf sound at a given location and time.
from regobslib import *
import datetime as dt
# Contact regobs@nve.no to get a client ID.
CLIENT_ID = "00000000-0000-0000-0000-000000000000"
# Create a user at https://test-konto.nve.no/ or https://konto.nve.no/
USERNAME = "ola.nordmann@example.com"
PASSWORD = "P4ssw0rd"
# First we create an empty SnowRegistration object
reg = SnowRegistration(REGOBS_TZ.localize(dt.datetime(2021, 8, 17, 9, 48)),
Position(lat=68.4293, lon=18.2572))
# Then we add a DangerSign observation to it
reg.add_danger_sign(DangerSign(DangerSign.Sign.WHUMPF_SOUND))
# Authenticate to Regobs to be able to submit observations
connection = Connection(prod=False).authenticate(USERNAME, PASSWORD, CLIENT_ID)
# Send our SnowRegistration to Regobs
stored_reg = connection.submit(reg)
print(stored_reg)
For a more extensive demonstration, refer to demo.py.
Documentation
We have yet to write documentation, but the function declarations are written with type hints and most parameters are enums, so the code in submit.py may help you on your way. A properly set up IDE will also use the type hints and enums to inform you about your alternatives.
You can also use GitHubs built-in code navigation to quickly find the definition of a class or method in the example code.
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
File details
Details for the file regobslib-1.0.9.tar.gz
.
File metadata
- Download URL: regobslib-1.0.9.tar.gz
- Upload date:
- Size: 34.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bdf1b3174da84cc099c0fd23f86c1130079fb9c5d077576a0f124f84505e5fa |
|
MD5 | 6bd6cb98470090cbdc32cabf3cb885c5 |
|
BLAKE2b-256 | 30c9ff76536381595f5d60e5ae522bf2d31589c3b9aa5b24f14bb38347ea34de |
File details
Details for the file regobslib-1.0.9-py3-none-any.whl
.
File metadata
- Download URL: regobslib-1.0.9-py3-none-any.whl
- Upload date:
- Size: 35.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c263d87a1ddde296f0911565bf8c8a9ee573235aeda230489a7432ed7b971752 |
|
MD5 | 2960ce8ab2904b4d73337bf929a6356f |
|
BLAKE2b-256 | 2683e5c15e0ba91b86c61a60003e07511242cdf1479da9277d1d9c37dcd4492a |