In [1]:
%%bash
export WPS_SERVICE="https://bovec.dkrz.de/ows/proxy/emu?Service=WPS&Request=GetCapabilities&Version=1.0.0"
birdy -h
In [2]:
%%bash
export WPS_SERVICE="https://bovec.dkrz.de/ows/proxy/emu?Service=WPS&Request=GetCapabilities&Version=1.0.0"
birdy hello -h
In [3]:
%%bash
export WPS_SERVICE="https://bovec.dkrz.de/ows/proxy/emu?Service=WPS&Request=GetCapabilities&Version=1.0.0"
birdy hello --name stranger
The WPSClient
function creates a mock python module whose functions actually call a remote WPS process. The
docstring and signature of the function are dynamically created from the remote's process description. If you type wps.
and then press Tab
, you should see a drop-down list of available processes. Simply call help
on each process of type ?
after the process to print the docstring for that process.
In [4]:
from birdy import WPSClient
url = "https://bovec.dkrz.de/ows/proxy/emu?Service=WPS&Request=GetCapabilities&Version=1.0.0"
wps = WPSClient(url)
help(wps.binaryoperatorfornumbers)
Type wps.
and the press Tab
, you should see a drop-down list of available processes.
In [5]:
# wps.
In [6]:
resp = wps.binaryoperatorfornumbers(1, 2, operator='add')
print(resp)
resp.get()
Out[6]:
For instance, the inout
function returns a wide variety of data types (float, integers, dates, etc) all of which are converted into a corresponding python type.
In [7]:
wps.inout().get()
Out[7]:
For ComplexData
objects, WPS servers often return a reference to the output (an http link) instead of the actual data. This is useful if that output is to serve as an input to another process, so as to avoid passing back and forth large files for nothing.
With birdy
, the outputs are by default return values are the references themselves, but it's also possible to download these references in the background and convert them into python objects. To trigger this automatic conversion, set asobj
to True
when calling the get
method. In the example below, we're using a dummy process called output_formats
, whose first output is a netCDF file, and second output is a json file. With asobj=True
, the netCDF file is opened and returned as a netcdf4.Dataset
instance, and the json file into a dictionary.
In [8]:
out = wps.output_formats()
nc, json = out.get()
print(out.get())
ds, json = out.get(asobj=True)
print(json)
ds
Out[8]:
In [9]:
cli = WPSClient('http://cp4cds-cn1.dkrz.de/wps')
response = cli.cmip5_regridder()
In [10]:
from IPython.display import Image
result = response.get()
Image(result.preview)
Out[10]: