In [1]:
"""Python WPS execute"""
from owslib.wps import WebProcessingService, monitorExecution, printInputOutput
from os import system
In [2]:
wps_url = "http://localhost:8093/wps"
#wps_url = "http://birdhouse-lsce.extra.cea.fr:8093/wps"
wps = WebProcessingService(url=wps_url, verbose=False)
In [3]:
print wps.identification.title
In [4]:
for process in wps.processes:
print '%s : \t %s' % (process.identifier, process.abstract)
In [5]:
p = wps.describeprocess(identifier='sdm')
for input in p.dataInputs:
printInputOutput(input)
print '\n'
In [6]:
resources = ['/home/nils/.conda/envs/birdhouse/var/lib/cache/pywps/esgf1.dkrz.de/thredds/fileServer/cordex/cordex/output/EUR-11/CLMcom/ICHEC-EC-EARTH/historical/r12i1p1/CLMcom-CCLM4-8-17/v1/day/tas/v20140515/tas_EUR-11_ICHEC-EC-EARTH_historical_r12i1p1_CLMcom-CCLM4-8-17_v1_day_20010101-20051231.nc',
'/home/nils/.conda/envs/birdhouse/var/lib/cache/pywps/esgf1.dkrz.de/thredds/fileServer/cordex/cordex/output/EUR-11/CLMcom/ICHEC-EC-EARTH/historical/r12i1p1/CLMcom-CCLM4-8-17/v1/day/pr/v20140515/pr_EUR-11_ICHEC-EC-EARTH_historical_r12i1p1_CLMcom-CCLM4-8-17_v1_day_20010101-20051231.nc',
'/home/nils/.conda/envs/birdhouse/var/lib/cache/pywps/esgf1.dkrz.de/thredds/fileServer/cordex/cordex/output/EUR-11/CLMcom/ICHEC-EC-EARTH/historical/r12i1p1/CLMcom-CCLM4-8-17/v1/day/tasmin/v20140515/tasmin_EUR-11_ICHEC-EC-EARTH_historical_r12i1p1_CLMcom-CCLM4-8-17_v1_day_20010101-20051231.nc']
In [7]:
resources
Out[7]:
In [8]:
gbif_url = 'http://api.gbif.org/v1/occurrence/download/request/0013848-160118175350007.zip'
In [ ]:
indices = ['TG_JJA', 'TNn_Jan', 'PRCPTOT_JJA']
In [26]:
period='all'
In [10]:
import requests
In [16]:
r = ''
for i in range(1,4):
r= '%sresource={resource%s};' % (r,i)
r = r + 'gbif={gbif1};'
l = ''
for i in range(1,4):
l= '%sindices={indices%s};' % (l,i)
r = r + l
print r
In [22]:
async_req_url = "{wps_url}?" +\
"request=Execute" +\
"&service=WPS" +\
"&version=1.0.0" +\
"&identifier=sdm" +\
"&DataInputs=resource={resource1};resource={resource2};resource={resource3};gbif={gbif1};period={period}=indices={indices1};indices={indices2};indices={indices3}"+ \
"&storeExecuteResponse=true" +\
"&status=true"
In [27]:
url=async_req_url.format(
wps_url=wps_url,
resource1=resources[0],
resource2=resources[1],
resource3=resources[2],
gbif1=gbif_url,
indices1=indices[0],
indices2=indices[1],
indices3=indices[2],
period=period,
)
print url
In [28]:
r = requests.get(url)
from lxml import etree
from io import BytesIO
tree = etree.parse(BytesIO(r.content))
#print etree.tostring(tree)
status_url = tree.getroot().get("statusLocation")
print status_url
In [29]:
r = requests.get(status_url)
print r.status_code
print r.text
In [ ]:
graphic = 'http://localhost:8090/wpsoutputs/flyingpigeon/output_graphic-5442f43a-ce61-11e5-a317-434222d428b1.png'
from IPython.display import Image
from IPython.core.display import HTML
Image(url= graphic )