EBAS IO
ebas-io is a python package for reading/writing NASA-Ames 1001 files with EBAS extensions (EBAS NASA-Ames).
Downloading the software
Starting with version 1.00.13, the python egg is available in this git repository (dist folder) together with the example scripts. The idea behind the git repo ist to make it easier for users to contribute their software using ebas-io and make it available for other users.
Installation
The ebas-io package can be installed the standard way with easy_install. See the setuptools documentation if easy_install does not work for you.
easy_install ebas_io-3.0.13-py2.7.egg
Please mind that you probably have to have administrator rights ('sudo easy_install ...' on linux/unix machines). Alternatively you may want to install the packages locally for your user (see --prefix in the easy_install documentation).
Attention: changed package structure as of version 3.0.13! Starting with version 3.0.13, all nilu internal dependencies (nilutility, AtmosPhys, fileformats) are now included in the ebas-io egg. This means, the installation is now much simpler. But: users having installed an earlier version should clean their python installation form this old extra packages before installing the new ebas-io package. This can be done as follows:
pip uninstall AtmosPhys pip uninstall fileformats pip uninstall nilutility pip uninstall ebas-io
---
## Examples
Example scripts and test data can be found in the downloaded tarball in the directory 'Examples'.
### Reading EBAS files: ```ebas_read_example.py```
This example shows the main functionality for *reading* EBAS NASA-Ames files. It demonstrates how to:
* open a file
* access and filter the time axes
* access all metadata for each variable
* access variable values and flags
* read data without flags (valid values only)
* look for specific variables in a file (based on metadata)
```bash
./ebas_read_example.py Testdata/DE0001R.20141225000000.20160114101135.uv_abs.ozone.air.1d.1h.DE03L_UBA_We_Mon_0301.DE03L_uv_abs.lev2.nas
The script reads the input file and writes a lot of data about the file as output. See the program code (and the comments within) how things work and compare it to the output. Please notice that the input file contains the ozone variable twice (in different units: ug/m3 and nmol/mol, this was generated for user convenience when the file was generated by the database). However, when reading the file, the nmol/mol varable gets automatically converted to ug/m3 as it would be stored in ebas. If you do not want this behaviour, you can specify the argument --skip_unitconvert in order to avoid this conversion. In this case you will need to use the argument --ignore_parameter as well, otherwise the paramter is rejected because of the wrong ebas unit.
./ebas_read_example.py Testdata/DE0001R.20141225000000.20160114101135.uv_abs.ozone.air.1d.1h.DE03L_UBA_We_Mon_0301.DE03L_uv_abs.lev2.nas --skip_unitconvert --ignore_parameter
Now, the file is read as is, no unit conversion is done, and the ozone variables in both units can be accessed.
ebas_genfile.py
Generating EBAS files: This example shows how to generate a valid EBAS NASA-Ames files for data submission with a script. You can use this script as a template for programming your own data submission software, tailored to your dataflows. This script demonstrates how to:
- set file global metadata
- set the time axes of the file
- define variables
- set variable metadata
- fill in variable values and flags
- write the file
./ebas_genfile.py
will create an output file named NO0042G.20140101110000.20150213125421.passive_puf..air.11mo.3mo.NO01L_puf_42.NO01L_gc_ms.lev2.nas
. Read the program code and discover how the file is generated.
ebas_flatcsv.py
Convert to other file formats: This example originates from a data user's request whether we could deliver EBAS data in a different file format. He wanted to have a simple, flat, highly redundant csv format for easy ingestion of the data into his software. We came up with this short script and he was able to convert the EBAS NASA-Ames files we delivered by himself. No new data format to maintain for us, full control of the interface for the data user.
./ebas_flatcsv.py Testdata/*.nas
All files in the Examples directory are read and the data are written to one flat csv file called 'output.csv'.