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.3.tar.gz (32.1 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.3-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: regobslib-0.2.3.tar.gz
  • Upload date:
  • Size: 32.1 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.22.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.10

File hashes

Hashes for regobslib-0.2.3.tar.gz
Algorithm Hash digest
SHA256 ac3f5628b0e02b9f2c959aa328d8b281038671368babf027c91eca70ef3b99bf
MD5 6f41f88bfc94c77319dc48b4e2f1ec6a
BLAKE2b-256 c304d94fd5b1eb0ac71dde66e6babbdba1b46fbb9bd2c6e5785f346ef2049ce3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: regobslib-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 32.7 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.22.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.10

File hashes

Hashes for regobslib-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5a1b4d04dce90852f98fdda34fa4d5015608c93079c3c74dbc4bf52ee75b297a
MD5 3c0de9592d08c603feb6e24380c58d7a
BLAKE2b-256 0e9ac90bf53c23e575ea75b950ab20a99c4f79b400ec6f89d560c55368bc7a69

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