Skip to main content

Python library for converting non-standard formats to WOUDC extended CSV format

Project description

[![Build Status](https://travis-ci.org/woudc/woudc-formats.png?branch=master)](https://travis-ci.org/woudc/woudc-formats)
[![Build status](https://ci.appveyor.com/api/projects/status/02koln2pe4ap5kvd/branch/master?svg=true)](https://ci.appveyor.com/project/tomkralidis/woudc-formats)
[![Downloads this month on PyPI](https://img.shields.io/pypi/dm/woudc-formats.svg)](http://pypi.python.org/pypi/woudc-formats)
[![Latest release](https://img.shields.io/pypi/v/woudc-formats.svg)](http://pypi.python.org/pypi/woudc-formats)
[![License](https://img.shields.io/github/license/woudc/woudc-formats.svg)](https://github.com/woudc/woudc-formats)

# WOUDC Format Converter

woudc-formats is a Python package used to perform various transformations
from/to WOUDC supported formats.
Currently supported features include:

Readers: SHADOZ, BAS, NASA AMES files, Vaisala.
Writers: WOUDC totalozone [daily summary](https://woudc.org/archive/Summaries/TotalOzone/Daily_Summary/FileFormat_DV.txt) (master file).

### Installation Instructions

## Requirements
woudc-formats requires Python 2.7, [pywoudc](https://github.com/woudc/pywoudc), [pyshadoz](https://github.com/WMO-ET-WDC/pyshadoz), and [woudc-extcsv](https://github.com/woudc/woudc-extcsv)

## Dependencies
See `requirements.txt`
- [pywoudc](https://github.com/woudc/pywoudc)
- [woudc-extcsv](https://github.com/woudc/woudc-extcsv)
- [pyshadoz](https://github.com/WMO-ET-WDC/pyshadoz)

## Setup
```bash
git clone https://github.com/woudc/woudc-formats.git && cd woudc-formats
python setup.py install
```

## Usage

### Command Line Interface
```bash
usage: woudc-formats.py --format {SHADOZ, BAS, AMES-2160, Vaisala, totalozone-masterfile} --inpath PATH/FILENAME --logfile PATH/LOGFILE --loglevel {DEBUG, CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET}

Required Arguments:
--format: indicate input file format
--inpath: import filename and path, for SHADOZ, BAS, Vaisala, and AMES-2160
--logfile: path to log file, including file name
--loglevel: define log level for logging

Optional Arguments:
--outpath: indicate the output file path, by default is 'INPATH.csv'
--station: station name in WOUDC
--agency: agency name in WOUDC
--metadata: a dictionary formatted string containing some specified station metadation information
ex: {"inst type": "ECC", "inst number": "XXXXX", "SA": "XX" , "ID" : "XXX", "country": "XXX", "GAW_ID": "XXX"}

Importance:
For AMES-2160 format, --agency argument is required in order to process the file.
For Vaisala format, --station and --agency in arguments and 'ID', 'GAW_ID', 'country', and 'SA' arguments in --metadata are required in order to process the file.
```

### API
```bash
usage:
import woudc_formats
ecsv = woudc_formats.load(In_Format, InPut_File_Path, station, agency)
if ecsv is not None:
woudc_formats.dump(ecsv, Output_file_path)

OR

import woudc_formats
with open(input_file_path) as ff
ff.read()
ecsv = woudc_formats.loads(In_Format, s)
if ecsv is not None:
woudc_formats.dump(ecsv, Output_file_path)

Optional Method:
woudc_formats.load(In_Format, InPut_File_Path, station, agency, metadata) : Take input file path and return ext-csv object, agency is required for AMES file and metadata is required for Vaisala, see optional arguments for Command Line Interface for more detail.
woudc_formats.loads(In_Format,String_of_InPut_file, station, agency, metadata) : Take string represenataion of input file and return ext-csv object. Station and agency are required for AMES file and metadata is required for Vaisala, see optional arguments for Command Line Interface for more detail.
woudc_formats.dump(ecsv, Output_file_path) : Take ext-csv object and produce output file.
woudc_formats.dumps(ecsv) : Take ext-csv object and prints to screen.
```
### Example
```bash
woudc-formats.py --format SHADOZ --inpath ./bin/SAMPLE.dat --outpath ./bin/SAMPLE.csv --logfile ./bin/LOG.log --loglevel DEBUG
woudc-formats.py --format totalozone-masterfile --inpath <full local or web path to totalozone snapshot> --outpath <output path> --loglevel <log level> --logfile <log file>
woudc-formats.py --format AMES-2160 --inpath <full local path to AMES file> --outpath <output path> --loglevel <log level> --logfile <log file> --agency XXX --metadata '{"SA": "XXX", "inst type": "ECC", "inst number": "6A3412"}'

For Agency 'AWI-NM':
woudc-formats.py --format AMES-2160 --inpath INPATH --logfile log.log --loglevel DEBUG --agency AWI-NM
```

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

woudc-formats-0.2.0.tar.gz (31.7 kB view details)

Uploaded Source

File details

Details for the file woudc-formats-0.2.0.tar.gz.

File metadata

File hashes

Hashes for woudc-formats-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5d6962d48a8270474813eb374be421610a3243dfa078d1db1ea63406be32c5db
MD5 e1983d311f2c69ed385e638bcc4fd9d5
BLAKE2b-256 c60a1e43257fcb2cc856722b0c128c3d9394b01fc71ffd7d4b476dcd26760c99

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