WPS call for analogs detection and visualisation


In [1]:
##############################
# load the required libraries 
#############################

from owslib.wps import WebProcessingService, monitorExecution, printInputOutput

from os import system
import time

In [2]:
#################################################
# connect to the compute provider hosting the WPS
#################################################

wps_url = "http://birdhouse-lsce.extra.cea.fr:8093/wps"
#wps_url = "http://localhost:8093/wps"
wps = WebProcessingService(url=wps_url, verbose=False)

In [3]:
##########################################
# print some information about the service
##########################################

print wps.identification.title + ':'
print '#############'
for process in wps.processes:
    print '%s : \t %s' % (process.identifier, process.abstract)


Flyingpigeon:
#############
subset_continents : 	 Returns only the selected polygon for each input dataset
subset_countries : 	 Returns only the selected polygon for each input dataset
subset_regionseurope : 	 Returns only the selected polygon for each input dataset
subset_points : 	 Extract Timeseries for specified coordinates from gridded datasets
indices_simple : 	 Climate indices based on one single input variable.
indices_percentile : 	 Climate indices based on one single input variable and the percentile of a referece refperiod.
weatherregimes_reanalyse : 	 Weather Regimes based on pressure patterns, fetching selected Realayses Datasets
weatherregimes_model : 	 Weather Regimes based on pressure patterns, fetching selected Realayses Datasets
weatherregimes_projection : 	 Weather Regimes detection based on trained reference statistics
analogs_detection : 	 Search for days with analog pressure pattern
analogs_viewer : 	 Visualisation of text output of analogue process
segetalflora : 	 Species biodiversity of segetal flora. Imput files: variable:tas , domain: EUR-11 or EUR-44
sdm_gbifsearch : 	 Species distribution model for tree species based on GBIF presens/absence data and climate indices
sdm_csv : 	 Species distribution model for tree species based on GBIF presens/absence data and climate indices
plot_timeseries : 	 Plots of the filesmeans over time. Spagetti and uncertainty plot
fetch : 	 This process downloads resources (limited to 50GB)             to the local file system of the birdhouse compute provider
wps_c4i_simple_indice : 	 Computes single input indices of temperature TG, TX, TN, TXx, TXn, TNx, TNn, SU, TR, CSU, GD4, FD, CFD, ID, HD17; of rainfal: CDD, CWD, RR, RR1, SDII, R10mm, R20mm, RX1day, RX5day; and of snowfall: SD, SD1, SD5, SD50. This processes is also available in Climate4Impact and uses ICCLIM.

In [4]:
#################################################
# print some information about a specific process
#################################################

# to recieve informations uncomment the follwing lines

#p = wps.describeprocess(identifier='analogs_detection')
#for input in p.dataInputs:
#    printInputOutput(input)
#    print '\n'

There are different ways to call a WPS service. The following cells are examples of the same process execution with different execution settings.


In [5]:
# get information about the call command:
wps.execute?

In [6]:
#####################
# execute the process
#####################

# call asyncon with sleepSecs

start_time = time.time()

execute = wps.execute(
    identifier="analogs_detection", 
    inputs=[("dist",'euclidean')], async=True)

monitorExecution(execute, sleepSecs=1)

print time.time() - start_time, "seconds"

print execute.getStatus()

for o in execute.processOutputs:
    print o.reference


19.2587840557 seconds
ProcessSucceeded
http://birdhouse-lsce.extra.cea.fr:8090/wpsoutputs/flyingpigeon/analogs-90b86fc4-4cdf-11e6-b6cb-03216ea57d1a.txt
http://birdhouse-lsce.extra.cea.fr:8090/wpsoutputs/flyingpigeon/config-90b86fc4-4cdf-11e6-b6cb-03216ea57d1a.txt

In [7]:
#####################
# execute the process
#####################

# call syncron

start_time = time.time()

execute = wps.execute(
    identifier="analogs_detection", 
    inputs=[("dist",'euclidean')], async=False)

print time.time() - start_time, "seconds"

print execute.getStatus()

for o in execute.processOutputs:
    print o.reference


22.6755769253 seconds
ProcessSucceeded
http://birdhouse-lsce.extra.cea.fr:8090/wpsoutputs/flyingpigeon/analogs-9c3590b6-4cdf-11e6-b6cb-03216ea57d1a.txt
http://birdhouse-lsce.extra.cea.fr:8090/wpsoutputs/flyingpigeon/config-9c3590b6-4cdf-11e6-b6cb-03216ea57d1a.txt

In [8]:
# case 1, async

inputs=[("dateSt",'2013-01-01'),("dateEn",'2014-12-31'),("refSt",'1990-01-01'),("refEn",'1995-12-31')]
start_time = time.time()

execute = wps.execute(identifier="analogs_detection", inputs=inputs, async=True)

monitorExecution(execute, sleepSecs=1)

print time.time() - start_time, "seconds"

print execute.getStatus()

for o in execute.processOutputs:
    print o.reference


123.897141933 seconds
ProcessSucceeded
http://birdhouse-lsce.extra.cea.fr:8090/wpsoutputs/flyingpigeon/analogs-a9bb27d2-4cdf-11e6-b6cb-03216ea57d1a.txt
http://birdhouse-lsce.extra.cea.fr:8090/wpsoutputs/flyingpigeon/config-a9bb27d2-4cdf-11e6-b6cb-03216ea57d1a.txt

In [ ]:

Analogs Viewer

Another process called 'analogs_viewer' creates interactive charts using dc.js, output as an HTML file, to visualize the analogs_detection output.


In [12]:
# the output of the previous analogs_detection process

analogs_output = execute.processOutputs[0].reference
print analogs_output


http://birdhouse-lsce.extra.cea.fr:8090/wpsoutputs/flyingpigeon/analogs-a9bb27d2-4cdf-11e6-b6cb-03216ea57d1a.txt

In [10]:
##########################################
# print some information about the process
##########################################

p = wps.describeprocess(identifier='analogs_viewer')
for input in p.dataInputs:
    printInputOutput(input)
    print '\n'


 identifier=resource, title=Analogues, abstract=Analogues text file, data type=ComplexData
 Supported Value: mimeType=text/plain, encoding=None, schema=None
 Default Value: mimeType=text/plain, encoding=None, schema=None 
 minOccurs=1, maxOccurs=1



In [13]:
###########################################
# and execute the process for visualisation 
###########################################

viewer = wps.execute(identifier="analogs_viewer", 
                     inputs=[('resource', analogs_output)], 
                     async=False)

print viewer.getStatus()
for o in viewer.processOutputs:
    print o.reference


ProcessSucceeded
http://birdhouse-lsce.extra.cea.fr:8090/wpsoutputs/flyingpigeon/output_html-daf0f66e-4ce0-11e6-b6cb-03216ea57d1a.html
None

In [ ]: