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 xarrayxsuite.xtend
Extend xarray.Datasets and xarray.DataArrays with functionsxsuite.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.
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 instance
The 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 instance
Two 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
arg0
in the main function must be representing axr.Dataset
forxtend.xtend_dataset()
or axr.DataArray
forxtend.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 byds.xtend.anomalies()
.
More information can be found here.