Skip to content

ucyo/xsuite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

xsuite

This python module provides several extensions for xarray in one package. Currently there are three extensions:

  • xsuite.xcdo Support cdo command line tool from within xarray
  • xsuite.xtend Extend xarray.Datasets and xarray.DataArrays with functions
  • xsuite.backend.xstores Additional datastores for different formats

cdo version 1.9.0 is currently not supported. The toolset does not support the returnCdf command anymore. An issue has been opened.

Installation

The module is compatible with py2 and py3 and can be installed via pip install .

Usage

This repository is a collection of several extensions for xarray. Therefore we will describe each extension by itself. Starting with xcdo.

xcdo

The xcdo module integrates the climate data operators (cdo) with xarray. It is possible to use all operators provided by the cdo toolset to be used on xr.Dataset instances.

Here is an example:

from xsuite import xcdo, load_data

ds = load_data('pre', decode_times=False)

ds.xcdo.mermean().zonmean().result()  # this will return a xr.Dataset instance

The module supports:

  • Concatenation of operators.
  • Syntax checking for each operator.
  • Lazy execution via .result() keyword.

More information can be found here.

xtend

The xtend module aims to provide easy on-the-fly extension of xarray.Dataset and xarray.DataArray instances.

Here is an example:

import os
import xsuite
import xarray as xr
from xsuite import xtend

folder = './examples/'
print(os.listdir(folder))  # Output: ['anomalies.py', ]
xtend.xtend_dataarray(folder)

ds = xsuite.load_data('toy')
ds.tmin.xtend.anomalies()  # this will return an xr.DataArray instance

Two things are important for using xtend:

  • The python scripts need to have a main(arg0, ..) function. This function will be called by xtend.
  • The first argument arg0 in the main function must be representing a xr.Dataset for xtend.xtend_dataset() or a xr.DataArray for xtend.xtend_dataarray().
  • The method under which the python script will be saved is the filename. Like in the example given above the file anomalies.py will be called by ds.xtend.anomalies().

More information can be found here.

About

Xtensions for Xarray

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages