Skip to content

tatarinova/cdo-bindings

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Cdo.{rb,py} - Use Ruby/Python to access the power of CDO

This package contains the module Cdo, which implements a ruby/python style access to the Climate Data operators CDO. CDO is a command line tool for processing gridded data. Its main focus if climate data, but it can by used for other purposes to. It accepts input formats GRIB1, GRIB2, NetCDF and several Fortran binary formats.

Installation

Ruby Installation

Download and install cdo.rb via rubygems:

gem install cdo

Python Installation

Download and install cdo.py via pypi:

pip install cdo

Requirements

Cdo.{rb,py} requires a working CDO binary, but has not special requirement to ruby or python. For returning multi-dimensional arrays (numpy for python, narray for ruby) addtional netcdf-io modules are needed. These are scipy for python and ruby-netcdf for ruby.

Usage

Run operators

The Ruby module can be used directly after loading it. For python an instance has to be created first

cdo = Cdo()
  • File information

    Cdo.infov(:input => ifile)       (ruby)
    Cdo.showlevels(:input => ifile)
    
    cdo.infov(input=ifile)         (python)
    cdo.showlevels(input=ifile)
  • Operators with user defined regular output files

    Cdo.timmin(:input => ifile ,:output => ofile) (ruby)
    cdo.timmin(input = ifile,output = ofile)    (python)
  • Use temporary output files

    tminFile = Cdo.timmin(:input => ifile) (ruby)
    tminFile = cdo.timmin(input = ifile) (python)
  • Operators with options

    Cdo.remap([gridfile,weightfile],:input => ifile, :output => ofile) (ruby)
    cdo.remap([gridfile,weightfile],input => ifile, output => ofile) (python)
  • Set global CDO options

    Cdo.copy(:input => ifile, :output => ofile,:options => "-f nc4") (ruby)
    cdo.copy(input = ifile, output = ofile,options = "-f nc4")     (python)
  • Return multi-dimension arrrays

    temperatures = Cdo.fldmin(:input => ifile,:returnArray => true).var('T').get   (rb, version < 1.2.0)
    temperatures = cdo.fldmin(input = ifile,:returnArray = True).variables['T'][:] (py, version < 1.2.0)
    temperatures = Cdo.fldmin(:input => ifile,:returnCdf => true).var('T').get    (rb, version >= 1.2.0)
    temperatures = cdo.fldmin(input = ifile,:returnCdf = True).variables['T'][:]  (py, version >= 1.2.0)
    temperatures = Cdo.fldmin(:input => ifile,:returnArray => 'T')                (rb, version >= 1.2.0)
    temperatures = cdo.fldmin(input = ifile,:returnArray = 'T')                   (py, version >= 1.2.0)

More examples can be found in test/cdo-examples.rb and on the homepage: code.zmaw.de/projects/cdo/wiki/Cdo%7Brbpy%7D

Tempfile helpers

Cdo.{rb,py} includes a simple tempfile wrapper, which make live easier, when write your own scripts

Support, Issues, Bugs, …

Please use the forum or ticket system of CDOs official web page: code.zmaw.de/projects/cdo

Changelog

  • next:

    - return arrays/lists of output files, which are created by split* operators
      suggestion from Karl-Hermann Wieners
    - support object interface in the ruby version (easy setup of options during initializaion, thread safety)
  • 1.2.3

    - bugfix release: adjust library/feature check to latest cdo-1.6.2  release
  • 1.2.2

    - allow arrays in additions to strings for input argument
    - add methods for checking the IO libraries of CDO and their versions
    - optionally return None on error (suggestion from Alex Loew, python only)
  • 1.2.1:

    - new return option: Masked Arrays
      if the new keyword returnMaArray is given, its value is taken as variable
      name and a masked array wrt to its FillValues is returned
      contribution for python by Alex Loew
    - error handling: return stderr in case of non-zero return value + raise exception
      contribution for python from Estanislao Gonzalez
    - autocompletion and built-in documentation through help() for interactive use
      contribution from Estanislao Gonzalez [python]
    - Added help operator for displaying help interactively [ruby]
  • 1.2.0: API change:

    - Ruby now uses the same keys like the python interface, i.e. :input and :output
      instead of :in and :out
    - :returnArray will accept a variable name, for which the multidimesional
      array is returned
  • 1.1.0: API change:

    - new option :returnCdf : will return the netcdf file handle, which was formerly
      done via :returnArray
    - new options :force : if set to true the cdo call will be run even if the given
      output file is presen, default: false

License

Cdo.{rb,py} makes use of the GPLv2 License, see COPYING


Other stuff

Author

Ralf Mueller <[email protected]>

Requires

CDO version 1.5.x or newer

License

Copyright 2011-2013 by Ralf Mueller Released under GPLv2 license. See the COPYING file included in the distribution.

About

Language bindings for CDO

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published