Python code for GEOS-Chem

From Geos-chem
Revision as of 13:44, 28 May 2013 by Bmy (Talk | contribs) (New page: == Overview == == Development Teams == {| border=1 cellspacing=0 cellpadding=5 |- bgcolor="#CCCCCC" !Institution !Contacts !Package !Description !Status |- |U. Edinburgh (UK) |Liang Fen...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

Development Teams

Institution Contacts Package Description Status
U. Edinburgh (UK) Liang Feng
U. Liege (Belgium) Emanuel Mahieu
Benoit Bovy
PyGchem
U. Florida (USA) Barron Henderson bpch
City University of Hong Kong Gerrit Kuhlman
U. Wisconsin-Madison Andre Perkins

Information about existing Python packages

bpch to netCDF converter

[barronh@ufl.edu Barron Henderson] wrote:

I wanted to clarify a little bit about my own project, which I have named simply bpch. bpch is registered with pypi (and installable with the command `pip install bpch`).
bpch is netcdf-like reader for bpch files returns a netcdf-like object with CF-1.6 compliant meta-data. The interface for bpch mimics the netcdf4-python interface (the successor to SciPy.io.netcdf.netcdffile).
If the bpch module is called from the command line (see below), it creates a netcdf file. If the module is used in a python program, then no netcdf file is created. At the command line, it also supports nco-like dimension and variable subsetting. Optionally, it can output figures and animations as well.
Example command line:
   $ python -m bpch ctm.bpch -o ctm.bpch.nc
would create ctm.bpch.nc that is readable by Panoply. The output is not currently readable by IDV because of some dimension naming assumptions for vertical dimensions.
In script form, the bpch module is simple a reader. The script below would simply print out some statistics twice. The first time demonstrates the netcdf3-classic style and the second demonstrates the netcdf4 style. The module uses numpy array structures, so it is fully compatible with matplotlib plotting functions.
   #!/usr/bin/env python
   #--Begin Script--
   from bpch import bpch
   import numpy as np
   f = bpch('ctm.bpch')
   key = 'IJ-AVG-$_Ox'
   v = f.variables[key]
   print key
   print v.units, v.dimensions
   print 'Min, Median, Max, Mean, Std:', v[:].min(), np.median(v[:]), v[:].max(), v[:].mean(), v[:].std()
   group = 'IJ-AVG-$'
   key = 'Ox'
   v = f.groups[group].variables[key]
   print key
   print v.units, v.dimensions
   print 'Min, Median, Max, Mean, Std:', v[:].min(), np.median(v[:]), v[:].max(), v[:].mean(), v[:].std()
   #--End Script--

--Bob Y. 09:44, 28 May 2013 (EDT)