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='ensembleRobustness')
for input in p.dataInputs:
printInputOutput(input)
print '\n'
In [6]:
files = []
for i in range(1,16): #
#files.append('file:///home/estimr1/EUCLEIA/indices/RX5day/DJF/RX5day_DJF_HadGEM3-A-N216_historical_r1i1p%s_19600101-20131230.nc' % (i))
files.append('file:///home/estimr1/EUCLEIA/indices/TG/yr/TG_yr_HadGEM3-A-N216_historical_r1i1p%s_19600101-20131230.nc' % (i))
In [7]:
files
Out[7]:
In [8]:
from os.path import join
execute = wps.execute(
identifier="ensembleRobustness", #indices_clipping",
inputs=[
("resource",files[0]),
("resource",files[1]),
# ("resource",files[2]),
# ("resource",files[3]),
# ("resource",files[4]),
# ("resource",files[5]),
# ("resource",files[6]),
# ("resource",files[7]),
# ("resource",files[8]),
# ("resource",files[9]),
# ("resource",files[10]),
# ("resource",files[11]),
# ("resource",files[12]),
# ("resource",files[13]),
# ("resource",files[14])
# ("timeslice",'10')
])
monitorExecution(execute, sleepSecs=5)
print execute.getStatus()
In [ ]:
In [16]:
for o in execute.processOutputs:
print o.reference
In [20]:
from flyingpigeon.ensembleRobustness import worker
In [21]:
files = []
for i in range(1,16): #
files.append('/home/estimr1/EUCLEIA/indices/TG/DJF/TG_DJF_HadGEM3-A-N216_historical_r1i1p%s_19600101-20131230.nc' % (i))
signal, low_agreement_mask, high_agreement_mask, graphic, text = worker(resource=files, start=1960, end=2000,
timeslice=20, variable='TG')
from IPython.display import Image
Image(filename=graphic)
Out[21]:
In [9]:
import requests
In [10]:
r = ''
for i in range(1,16):
r= '%sresource={resource%s};' % (r,i)
print r
In [11]:
async_req_url = "{wps_url}?" +\
"request=Execute" +\
"&service=WPS" +\
"&version=1.0.0" +\
"&identifier=ensembleRobustness" +\
"&DataInputs="+r+\
"&storeExecuteResponse=true" +\
"&status=true"
In [12]:
url=async_req_url.format(
wps_url=wps_url,
resource1=files[0],
resource2=files[1],
resource3=files[2],
resource4=files[3],
resource5=files[4],
resource6=files[5],
resource7=files[6],
resource8=files[7],
resource9=files[8],
resource10=files[9],
resource11=files[10],
resource12=files[11],
resource13=files[12],
resource14=files[13],
resource15=files[14]
)
print url
In [13]:
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 [14]:
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 )