woudc-formats

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


Keywords
Ozone, O3, Ultraviolet, Radiation, UV, Index, Dobson, Units, Archives, World, Data, Centre, WOUDC, Non-standard, FormatSHADOZ, AMES, BAS, Masterfile
License
MIT
Install
pip install woudc-formats==0.2.0

Documentation

Build Status Build status Downloads this month on PyPI Latest release License

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. Writers: WOUDC totalozone daily summary (master file).

Installation Instructions

Requirements

woudc-formats requires Python 2.7, pywoudc and woudc-extcsv

Dependencies

See requirements.txt

Setup

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

Usage

Command Line Interface

usage: woudc-formats.py --format {SHADOZ, BAS, AMES-2160, AMES-2160-Boulder, totalozone-masterfile} --inpath PATH/FILENAME --outpath 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 and AMES
    --outpath: indicate the the path to output file, including output filename
    --logfile: path to log file, including file name
    --loglevel: define log level for logging

Optional Arguments:
    --metadata: a dictionary formatted string containing some specified station metadation information
            ex: {"station": "XXX", "agency": "XXX", "inst type": "ECC", "inst number": "XXXXX", "SA": "XX" }

API

usage: 
import woudc_formats
ecsv = woudc_formats.load(In_Format, InPut_File_Path)
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, metadata) : Take input file path and return ext-csv object, metadata is required for AMES file for most cases, see optional arguments for Command Line Interface for more detail.
woudc_formats.loads(In_Format,String_of_InPut_file,  metadata) : Take string represenataion of input file and return ext-csv object. Metadata is required for AMES file for most cases, 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

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> --metadata '{"station": "Boulder", "agency": "ukmo", "SA": "XXX", "inst type": "ECC", "inst number": "6A3412"}'