All Projects → wmo-cop → pyoscar

wmo-cop / pyoscar

Licence: MIT license
Pythonic API to WMO OSCAR

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to pyoscar

binary.com-bot
Scripts for using on Binary.com Bots.
Stars: ✭ 60 (+361.54%)
Mutual labels:  oscar
ungoliant
🕷️ The pipeline for the OSCAR corpus
Stars: ✭ 69 (+430.77%)
Mutual labels:  oscar
pybufrkit
Pure Python toolkit to work with WMO BUFR messages
Stars: ✭ 59 (+353.85%)
Mutual labels:  wmo
Django Oscar
Domain-driven e-commerce for Django
Stars: ✭ 5,152 (+39530.77%)
Mutual labels:  oscar
Remote-SDR
Remote control of 2 Software Design Radio. Receiver and trasmitter. Based on Adalm-Pluto SDR or RTL-SDR or Hack RF SDR and signal processing using GNU Radio on Orange PI. GUI on a web browser.
Stars: ✭ 61 (+369.23%)
Mutual labels:  oscar

pyoscar

Pythonic API to WMO OSCAR

Build Status

Overview

pyoscar provides a Pythonic API atop the WMO OSCAR HTTP API.

Installation

Requirements

Dependencies

Dependencies are listed in requirements.txt. Dependencies are automatically installed during pyoscar installation.

Installing pyoscar

For users

To install the latest stable version:

pip install pyoscar

To keep up to date with stable updates:

pip install pyoscar -U

For developers

# setup virtualenv
python3 -m venv pyoscar
cd pyoscar
source bin/activate

# clone codebase and install
git clone https://github.com/wmo-cop/pyoscar.git
cd pyoscar
python setup.py build
python setup.py install

Running pyoscar via the Command Line

# help
pyoscar --help

# get version
pyoscar --version

# all subcommands support the following options:
# --env (depl or prod, default depl)
# --verbosity (ERROR, WARNING, INFO, DEBUG, default NONE)

# get all station identifiers
pyoscar stations

# get all station identifiers by country
pyoscar stations --country=CAN

# get all station identifiers by program affiliation
pyoscar stations --program=GAW

# get a single station by WIGOS identifier
pyoscar station --identifier 0-20000-0-71151

# get a single station by WIGOS identifier in WIGOS XML format
pyoscar station --identifier 0-20000-0-71151 --format=XML

# add verbose mode (ERROR, WARNING, INFO, DEBUG)
pyoscar station --identifier 0-20000-0-71151 --verbosity=DEBUG

# get contact by country
pyoscar contact -c Canada

# get contact by surname
pyoscar contact -s Karn

# get contact by organization
pyoscar contact -o "Environment Canada"

# upload WMDR XML (to production environment)
pyoscar upload -x /path/to/wmdr.xml -at API_TOKEN -e prod

# upload WMDR XML (to production environment) and save results to file
pyoscar upload -x /path/to/wmdr.xml -at API_TOKEN -e prod -l results.log

# harvest all records
pyoscar harvest --env=prod --directory=/path/to/dir

Using the pyoscar API

from pyoscar import OSCARClient

client = OSCARClient()

# get all Canadian stations
stations = client.get_stations(country='CAN')

# get all Canadian stations
stations = client.get_stations(program='GAW')

# get invididual station report
stn_leo = client.get_station_report('LEO')


# upload WMDR XML

## instantiate client to OSCAR DEPL (default)
client = OSCARClient(api_token='foo')

## ...or to OSCAR production
client = OSCARClient(api_token='foo', env='prod')

with open('some-wmdr-file.xml') as fh:
    data = fh.read()

response = client.upload(data)

Development

Running Tests

# install dev requirements
pip install -r requirements-dev.txt

# run tests like this:
cd tests
python run_tests.py

# or like this:
python setup.py test

# measure code coverage
coverage run --source pyoscar setup.py test
coverage report -m

Releasing

python setup.py sdist bdist_wheel --universal
twine upload dist/*

Code Conventions

Bugs and Issues

All bugs, enhancements and issues are managed on GitHub.

Contact

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].