Coder Social home page Coder Social logo

wmo-cop / pyshadoz Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 290 KB

pyshadoz is a pure Python package to read and write NASA Southern Hemisphere ADditional OZonesondes (SHADOZ) data.

Home Page: https://tropo.gsfc.nasa.gov/shadoz/

License: Other

Python 100.00%
shadoz nasa ozonesonde

pyshadoz's Introduction

pyshadoz

Build Status

Overview

pyshadoz is a pure Python package to read and write NASA Southern Hemisphere ADditional OZonesondes (SHADOZ) data.

Versions 5 and 6 are supported.

Installation

The easiest way to install pyshadoz is via the Python pip utility:

pip3 install pyshadoz

Requirements

Dependencies

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

Installing pyshadoz

# setup virtualenv
virtualenv --system-site-packages -p python3 pyshadoz
cd pyshadoz
source bin/activate

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

Running

# help
pyshadoz --help

# get version
pyshadoz --version

# parse a single shadoz file
pyshadoz -f </path/to/shadoz_file>

# add verbose mode
pyshadoz -v -f </path/to/shadoz_file>

# parse a directory of shadoz files
pyshadoz -d </path/to/directory>

# parse a directory of shadoz files recursively
pyshadoz -r -d </path/to/directory>

Using the API

from pyshadoz import SHADOZ

# read SHADOZ data
with open('/path/to/directory') as ff:
    s = SHADOZ(ff)

    for key, value in s.metadata:
        print(key, value)

    print(s.data_fields)
    print(s.data_fields_units)
    print(len(s.data))

    # get index of a data field
    index = s.get_data_index('W Dir')

    # get index of a data field and data field unit
    index = s.get_data_index('W Dir', 'deg')

    # get all data
    data = s.get_data()

    # get data by index
    data = s.get_data(by_index=index)

    # get all data by field
    data = s.get_data('W Spd')

    # get all data by field and unit
    data = s.get_data('O3', 'ppmv')

# read SHADOZ data using convenience functions
# parse file
s = load('/path/to/shadoz_file.dat')  # returns SHADOZ object

# parse string
with open('/path/to/shadoz_file.dat') as ff:
    shadoz_string = ff.read()
s = loads(shadoz_string)  # returns SHADOZ object

# write SHADOZ data
s = SHADOZ()
# build metadata dict
s.metadata['NASA/GSFC/SHADOZ Archive'] = 'http://croc.gsfc.nasa.gov/shadoz'
....
# build data fields
s.data_fields = ['Time', 'Press', 'Alt', 'Temp', 'RH', 'O3', 'O3', 'O3',
                 'W Dir', 'W Spd', 'T Pump', 'I O3', 'GPSLon', 'GPSLat',
                 'GPSAlt']

# build data field units
s.data_fields_units = ['sec','hPa','km', 'C', '%', 'mPa', 'ppmv', 'du', 'deg',
                       'm/s', 'C', 'uA', 'deg', 'deg', 'km']

# build data
s.data = [
    [0, 1013.85, 0.01, 24.22, 71.0, 32.91, 32.91, 0.0, 32.91, 5.29, 32.91, 9000.0, -155.049, 19.717, 0.041],
    [0, 1013.66, 0.012, 23.89, 70.0, 32.79, 32.79, 0.049, 32.79, 5.01, 32.79, 9000.0, -155.049, 19.717, 0.045]
]

# serialize data to file
shadoz_data = s.write()
with open('new_shadoz_file.dat', 'w') as ff:
    ff.write(shadoz_data)

Development

Running Tests

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

# run tests like this:
python3 pyshadoz/tests/run_tests.py

# or this:
python3 setup.py test

Releasing

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

Code Conventions

Bugs and Issues

All bugs, enhancements and issues are managed on GitHub.

Contact

pyshadoz's People

Contributors

tomkralidis avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

joergklausen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.