Giter Club home page Giter Club logo

cdochain's Introduction

[DEPRECATED] cdochain ❗ ❗

Please use github.com/ucyo/xsuite

This module helps create chains of cdo commands for easy manipulation of climate data.

Features

  • Method execution is lazy and gets processed only on function call Chain.execute().
  • Input supports Unix style pathname pattern search.
    • The Input will be first run with glob and checked if several files match.
      If that is the case a temporary file will be created.
  • Output can be a file on disc, an netCDF4.Dataset or (not) masked numpy.ndarray.

Installation

python3.5 -m pip install cdochain --pre

--- or ---

git clone https://github.com/OnionNinja/cdochain.git
cd cdochain
python3.5 setup.py install

TL;DR

from cdochain import chaining as cch

input = './tests/testdata/sresa1b_ncar_ccsm3-example.nc'
output = './enso34-mm.nc'
data = cch.Chain(ifile=input, ofile=output)
enso34 = data.sellonlatbox(190,240,-5,5).monmean()
out = enso34.execute()

Usage

This module implements method chaining for the Climate Data Operators (CDO) tool from the Max Planck Institute for Meteorology. Let us start:

from cdochain import chaining as cch

For initialisation one has to define input, output, and may define several options.

Input

Now we have to define the files we want to work on:

  • To use one file
input = './tests/testdata/sresa1b_ncar_ccsm3-example.nc'
  • To use several files you can give a Unix style pattern
input = './tests/testdata/*.nc'

This creates a temporary file

Output

For defining the output we have several options.

  • To output a file on disc:
data = cch.Chain(ifile=input, ofile='/path/to/output.nc')
  • To output an netcdf4.Dataset object:
data = cch.Chain(ifile=input, ofile='netCDF4')
  • To output an numpy.ndarray object:
data = cch.Chain(ifile=input, ofile='array:<var>')  # numpy.ndarray
# or
data = cch.Chain(ifile=input, ofile='maarray:<var>')  # masked numpy.ndarray

<var> defines the variable to be extracted and saved to numpy.ndarray.

Options

As for options one can use the same as described on the CDO website. The default is options='-O -f nc'.

Operations

The operations defined in CDO can now be used on the data element.

analysis = data.sellonlatbox(190,240,-5,5).sellevidx(1).mermean()
fn = analysis.execute()

Have fun :neckbeard:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.