Skip to main content

Python bindings to multiple weather station vendor APIs

Project description

Multi Weather API

Consistent Python bindings for select commercial weather station APIs, such as Zentra Cloud REST API v3, created for MSU EnviroWeather Project.

Background

This is inspired by python bindings for v1 of the Zentra API from the Montana Climate office : MSU Agricultural Weather Office

The EnviroWeather system from the MSU Agricultural Weather Office will interface with weather stations (select list of vendors) deployed and owned privately. Since each vendor has a differrent REST/Web API to access station's weather data, this package aims to provide a consistent interface to all of those stations in order to make it easy for incoporating them into a data pipeline.

Installation

The Multi-Weather API is currently available on PyPI. Install using pip:

pip install multiweatherapi

Usage

>>> from multiweatherapi import multiweatherapi
>>> param = {'sn': 'STATION_ID',
...          'apikey': 'API_KEY',
...          'apisec': 'API_SECRET'}
>>> resp = multiweatherapi.get_reading('davis', **param)
>>> resp.resp_raw # raw JSON response of the reading
>>> resp.resp_parsed # parsed JSON response into list of dict for EnviroWeather project

Refer to the respective link below for parameter and authentication requirements of weather station vendor APIs

Supported Python Versions

Python 3.6 and higher are supported.

Supported Station Time Zones

Currently following time zones are supported:

Name Description
HT US/Hawaii
AT US/Alaska
PT US/Pacific
MT US/Mountain
CT US/Central
ET US/Eastern

Requirements

Outputs

  • API Response (JSON)

    The (raw) API response is formatted in JSON and 0th element illustrates the metadata of the API call and 1st (and onward - Davis stations) element(s) depicts weather station measurements retrieved from the API call.

    [
      {
        "vendor": "spectrum",
        "station_id": "50400123",
        "start_datetime": "2022-05-26 12:08:07",
        "end_datetime": "2022-05-26 13:08:07",
        "timezone": "ET",
        "request_time": "2022-05-27 12:08:07",
        "python_binding_version": "0.0.17"
      },
      {
        "EquipmentRecords": [
          {
            "SerialNumber": "50400123",
            "TimeStamp": "2022-05-26T16:10:00",
            "SensorData": [
              {
                "ChannelNumber": 0,
                "PortNumber": "A",
                "SensorNumber": 0,
                "SensorType": "Rainfall",
                "TimeStamp": "2022-05-26T16:10:00",
                "FormattedTimeStamp": "2022-05-26 16:10",
                "Value": "0.00",
                "AccumlatedValue": "0.00",
                "DecimalValue": 0.0,
                "AccumlatedDecimalValue": 0.0,
                "Units": "inches",
                "ValueType": "Average"
              },
              ...
      }
    ]
    
  • Transformed Response (List of Dict)

    The transformed response is formatted in list (array) of Python dict object. Each dict object consists of that measurements that stakeholders are interested in and the metadata that would be used to facilitate data loading into the backend.

    [
      {
        "station_id": "50400123",
        "request_datetime": "2022-05-27 12:08:07",
        "pcpn": 0.0,
        "data_datetime": "2022-05-26 16:10",
        "atemp": 21.0,
        "relh": "92.3"
      },
      ...
    ]
    

License

Released under the MIT License

Testing the package

If you want to test without installing via PIP, there is a script get_sample_data.py in the main directory which requires a configuration file named '.env' in the root folder.

$ pip install -r requirements.txt
$ python get_sample_data.py rainwise /Users/jhp/Desktop/

Please refer to docs/get_sample_data.md for detail documentation of get_sample_data.py

see also docs/Test Suite Doco.py for more formal tests and how to provide station configuration file

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

multiweatherapi-0.0.25.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

multiweatherapi-0.0.25-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file multiweatherapi-0.0.25.tar.gz.

File metadata

  • Download URL: multiweatherapi-0.0.25.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.0 urllib3/1.26.9 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.13

File hashes

Hashes for multiweatherapi-0.0.25.tar.gz
Algorithm Hash digest
SHA256 c2fc09245d75c88d8e9443b044d244bc475c0a34f1bf28e585459dc5ec7279fd
MD5 ed7d58d32a0283d6f82b4e1c30b4a8da
BLAKE2b-256 803bf52db0eb8bd7014a88876ed07a545af209c48d1952e9bd860be3dc4d2cc4

See more details on using hashes here.

File details

Details for the file multiweatherapi-0.0.25-py3-none-any.whl.

File metadata

  • Download URL: multiweatherapi-0.0.25-py3-none-any.whl
  • Upload date:
  • Size: 35.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.0 urllib3/1.26.9 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.13

File hashes

Hashes for multiweatherapi-0.0.25-py3-none-any.whl
Algorithm Hash digest
SHA256 83e1802cd5a0471879ed0d12425bface057283fb1f01bd17e3d20f8e5ce6d2ec
MD5 62dd583e84dd41729b7875c99a92fc55
BLAKE2b-256 5ac4d2c05479e6b0dc62d4531fd482bc5c8da364db6faccbfbdf5af963434b50

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page