pyoscar
Pythonic API to WMO OSCAR
Overview
pyoscar provides a Pythonic API atop the WMO OSCAR HTTP API.
For R enthusiasts
For those interested in using R, the oscarr project provides an R wrapper to the pyoscar Python module for the R community.
Installation
Requirements
- Python 3
- virtualenv or Conda
Dependencies
Dependencies are listed in requirements.txt. Dependencies are automatically installed during pyoscar installation.
Installing pyoscar
For users
To install the latest stable version:
pip3 install pyoscar
To keep up to date with stable updates:
pip3 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
python3 setup.py build
python3 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 all stations by station name (partial names are supported)
pyoscar stations --station-name toronto
# get a single station by WIGOS identifier
pyoscar station 0-20000-0-71151
# get a single station by WIGOS identifier in summary mode
pyoscar station 0-20000-0-71151 --summary
# get a single station by WIGOS identifier in WIGOS XML format
pyoscar station 0-20000-0-71151 --format=XML
# get a single station by WIGOS identifier in WIGOS XML format in summary mode
pyoscar station 0-20000-0-71151 --format=XML --summary
# add verbose mode (ERROR, WARNING, INFO, DEBUG)
pyoscar station 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
# use only GML ids is TRUE by default; use --no-gml-ids to set to FALSE
pyoscar upload -x /path/to/wmdr.xml -at API_TOKEN -e prod -l results.log --no-gml-ids
# 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('0-20000-0-71758')
# get invididual station report in summary mode
stn_leo = client.get_station_report('0-20000-0-71758', summary=True)
# 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
pip3 install -r requirements-dev.txt
# run tests like this:
cd tests
python3 run_tests.py
# or like this:
python3 setup.py test
# measure code coverage
coverage run --source pyoscar setup.py test
coverage report -m
Releasing
create release (x.y.z is the release version)
vi pyoscar/__init__.py # update __version__
git commit -am 'update release version x.y.z'
git push origin master
git tag -a x.y.z -m 'tagging release version x.y.z'
git push --tags
# upload to PyPI
rm -fr build dist *.egg-info
python3 setup.py sdist bdist_wheel --universal
twine upload dist/*
# publish release on GitHub (https://github.com/wmo-cop/pyoscar/releases/new)
# bump version back to dev
vi pyoscar/__init__.py # update __version__
git commit -am 'back to dev'
git push origin master
Code Conventions
Bugs and Issues
All bugs, enhancements and issues are managed on GitHub.
Contact
Metadata
Release files for pyoscar 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyoscar-0.9.0.tar.gz | 12.1 kB | Without provenance | Details for pyoscar-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyoscar-0.9.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for pyoscar-0.9.0-py2.py3-none-any.whl |
Total release size: 23.5 kB
Release files / pyoscar-0.9.0.tar.gz
| Download URL | pyoscar-0.9.0.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b29a2c161a3a06b2da966bdaddedb6cf6ea5701e698e3d61f28db75f81d8cdb2
|
|
BLAKE2b-256 checksum How to use checksums |
eb17d4aec119b42374a6c65ec9a408eea9a36d05f86b11cf628d2f9b0e5cc63c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/1.1.3 pkginfo/1.9.6 requests/2.28.2 requests-toolbelt/0.8.0 tqdm/4.64.1 CPython/3.7.12
|
Release files / pyoscar-0.9.0-py2.py3-none-any.whl
| Download URL | pyoscar-0.9.0-py2.py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
e25710460d578b6bc716755000b2eaa7ef1aaaf257fff2cb5bcbf1c8c4176055
|
|
BLAKE2b-256 checksum How to use checksums |
06752e751c910cbc0937753d480b59a273070e5725494d057525fbdd4845a5e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/1.1.3 pkginfo/1.9.6 requests/2.28.2 requests-toolbelt/0.8.0 tqdm/4.64.1 CPython/3.7.12
|
Security for pyoscar 0.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.