This python module provides several extensions for xarray in one package. Currently there are three extensions:
xsuite.xcdoSupport cdo command line tool from within xarrayxsuite.xtendExtend xarray.Datasets and xarray.DataArrays with functionsxsuite.backend.xstoresAdditional datastores for different formats
cdo version 1.9.0 is currently not supported. The toolset does not support the
returnCdfcommand anymore. An issue has been opened.
The module is compatible with py2 and py3 and can be installed via pip install .
This repository is a collection of several extensions for xarray. Therefore
we will describe each extension by itself. Starting with 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 instanceThe module supports:
- Concatenation of operators.
- Syntax checking for each operator.
- Lazy execution via
.result()keyword.
More information can be found here.
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 instanceTwo things are important for using xtend:
- The python scripts need to have a
main(arg0, ..)function. This function will be called byxtend. - The first argument
arg0in the main function must be representing axr.Datasetforxtend.xtend_dataset()or axr.DataArrayforxtend.xtend_dataarray(). - The method under which the python script will be saved is the filename. Like
in the example given above the file
anomalies.pywill be called byds.xtend.anomalies().
More information can be found here.