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.

Developer notes

The package is built according to the instructions in the Python Packaging User Guide.

For serialization/deserialisation, most of the Regobs work is done in src/regobslib/submit.py. The project rely heavily on enums. These are available in src/regobslib/types.py. Any outside connections (Regobs, Varsom, APS) is handled in src/regobslib/connection.py.

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-1.0.11.tar.gz (34.8 kB view details)

Uploaded Source

Built Distribution

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

regobslib-1.0.11-py3-none-any.whl (35.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: regobslib-1.0.11.tar.gz
  • Upload date:
  • Size: 34.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for regobslib-1.0.11.tar.gz
Algorithm Hash digest
SHA256 034f58fc72be95d0ecf39f9746fe1b64569465d18d4250eb9610d7ef142296b5
MD5 923f8064ee11be97dff7b56a5cd45ba2
BLAKE2b-256 76577ff8dc8a9c7726885af2445591e494a4bdf3ee368db9eb6165f77bca8436

See more details on using hashes here.

File details

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

File metadata

  • Download URL: regobslib-1.0.11-py3-none-any.whl
  • Upload date:
  • Size: 35.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for regobslib-1.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 ce926b721971f006821c10d9c78075fbc57e5206f998be606b29172813ad3aea
MD5 85853b413daab5e313524e7479c43f7a
BLAKE2b-256 5d8ee69edc22d9cbc3686c606d74d2b0c7ba7f2ce0aba733ab3fcb4d2fd69cd0

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