Skip to main content

Client library for Regobs

Project description

regobslib — A Regobs client library

This client library aim to simplify interaction with the Regobs API v5.

Prerequisites

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

regobslib-0.2.7.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

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

regobslib-0.2.7-py3-none-any.whl (34.2 kB view details)

Uploaded Python 3

File details

Details for the file regobslib-0.2.7.tar.gz.

File metadata

  • Download URL: regobslib-0.2.7.tar.gz
  • Upload date:
  • Size: 33.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.6.4 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.11

File hashes

Hashes for regobslib-0.2.7.tar.gz
Algorithm Hash digest
SHA256 8e5cbb8f8312b536c063d2962ad97101dbd0cbbf685dd16f9849e96441c63a47
MD5 5994a5dd3b954568ce76668d8b715998
BLAKE2b-256 610922ce24ddfaf2072b114bf37756fc2178d4f5695ff4e8faa32b1d18100e5b

See more details on using hashes here.

File details

Details for the file regobslib-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: regobslib-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 34.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.6.4 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.11

File hashes

Hashes for regobslib-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 bb5765d4c23b27c7f71c76ba43109abb24cc21a72693bb1a906939743f0d1421
MD5 09e0e870e61228695102720ae0397c95
BLAKE2b-256 13f566d320bc4d44314a16996129452e73ef26663ce502cdf71ab2e58001a53b

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