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


Flyingpigeon

In [4]:
for process in wps.processes:
    print '%s : \t %s' % (process.identifier, process.abstract)


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 the selected European administrative region defined in the GADM database (v2.5) 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 reference period.
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 analogue pressure pattern for reanalyses data sets
analogs_model : 	 Search for days with analogue pressure pattern in a climate model data set
analogs_compare : 	 Search in a dataset for days with analogue pressure pattern for a given period in a reanalyses dataset
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 presence/absence data and climate indices
sdm_csv : 	 Species distribution model for tree species based on GBIF presence/absence data and climate indices
robustness : 	 Calculates the robustness as the ratio of noise to signal in an ensemle of timeseries
plot_timeseries : 	 Outputs some timeseries of the file field means. Spaghetti 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 rainfall: 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.
spatial_analog : 	 Spatial analogs based on climate indices

In [7]:
p = wps.describeprocess(identifier='segetalflora')
for input in p.dataInputs:
    printInputOutput(input)
    print '\n'


 identifier=resouce, title=NetCDF Files, abstract=NetCDF File, data type=ComplexData
 Supported Value: mimeType=application/x-netcdf, encoding=None, schema=None
 Default Value: mimeType=application/x-netcdf, encoding=None, schema=None 
 minOccurs=1, maxOccurs=1000


 identifier=climate_type, title=Climate type, abstract=Select climate type, data type=//www.w3.org/TR/xmlschema-2/#string
 Allowed Value: 1
 Allowed Value: 2
 Allowed Value: 3
 Allowed Value: 4
 Allowed Value: 5
 Allowed Value: 6
 Allowed Value: 7
 Allowed Value: all
 Default Value: 3 
 minOccurs=0, maxOccurs=8


 identifier=culture_type, title=Culture type, abstract=Select culture type, data type=//www.w3.org/TR/xmlschema-2/#string
 Allowed Value: fallow
 Allowed Value: intensive
 Allowed Value: extensive
 Default Value: fallow 
 minOccurs=0, maxOccurs=8


Call WPS with oswlib


In [15]:
from os import listdir
from os import path

nc_dir = '/home/nils/birdhouse/var/lib/pywps/cache/malleefowl/esgf1.dkrz.de/thredds/fileServer/cordex/cordex/output/EUR-11/MPI-CSC/MPI-M-MPI-ESM-LR/historical/r1i1p1/MPI-CSC-REMO2009/v1/sem/tas/v20160419/'
resources = [path.join('file://' + nc_dir, nc) for nc in listdir(nc_dir)]

In [16]:
resources


Out[16]:
['file:///home/nils/birdhouse/var/lib/pywps/cache/malleefowl/esgf1.dkrz.de/thredds/fileServer/cordex/cordex/output/EUR-11/MPI-CSC/MPI-M-MPI-ESM-LR/historical/r1i1p1/MPI-CSC-REMO2009/v1/sem/tas/v20160419/tas_EUR-11_MPI-M-MPI-ESM-LR_historical_r1i1p1_MPI-CSC-REMO2009_v1_sem_199012-200011.nc',
 'file:///home/nils/birdhouse/var/lib/pywps/cache/malleefowl/esgf1.dkrz.de/thredds/fileServer/cordex/cordex/output/EUR-11/MPI-CSC/MPI-M-MPI-ESM-LR/historical/r1i1p1/MPI-CSC-REMO2009/v1/sem/tas/v20160419/tas_EUR-11_MPI-M-MPI-ESM-LR_historical_r1i1p1_MPI-CSC-REMO2009_v1_sem_200012-200511.nc']

In [ ]:
from os.path import join

execute = wps.execute(
    identifier="segetalflora", #indices_clipping",
    inputs=[
       ("resource",resources[0]),
       ("resource",resources[1]),
       ('culture_type', 'fallow'),
       ('climate_type', '3')
           ])
monitorExecution(execute, sleepSecs=5)
print execute.getStatus()

In [26]:
for o in execute.processOutputs:
    print o.reference


http://localhost:8090/wpsoutputs/flyingpigeon/out_tasmean-d99eaef0-a807-11e6-a39a-142d277ef1f3.tar

call the module only


In [3]:
from flyingpigeon import segetalflora as sf
from os import listdir, path


/home/nils/.conda/envs/flyingpigeon/lib/python2.7/site-packages/ocgis/util/environment.py:33: UserWarning: Consider setting the system environment variable "GDAL_DATA=/home/nils/.conda/envs/flyingpigeon/share/gdal" to improve load performance
  warn(msg)

In [4]:
tasdir = '/home/nils/data/tests/segetalflora/'
nc_tasmean = [path.join(tasdir, nc ) for nc in listdir(tasdir)]

In [7]:
reload(sf)
nc_sf = sf.get_segetalflora(resource=nc_tasmean)


/home/nils/.conda/envs/flyingpigeon/lib/python2.7/site-packages/ocgis/calc/eval_function.py:1: RuntimeWarning: overflow encountered in power
  import re

In [8]:
nc_sf


Out[8]:
['./sffallow3_EUR-11_MPI-M-MPI-ESM-LR_historical_r1i1p1_CLMcom-CCLM4-8-17_v1_yr_19910115-20051016.nc',
 './sffallow3_EUR-11_MPI-M-MPI-ESM-LR_historical_r2i1p1_MPI-CSC-REMO2009_v1_yr_19910115-20051016.nc',
 './sffallow3_EUR-11_ICHEC-EC-EARTH_historical_r3i1p1_DMI-HIRHAM5_v1_yr_19910116-20051016.nc',
 './sffallow3_EUR-11_MOHC-HadGEM2-ES_historical_r1i1p1_KNMI-RACMO22E_v2_yr_19910116-20051016.nc',
 './sffallow3_EUR-11_CNRM-CERFACS-CNRM-CM5_historical_r1i1p1_CLMcom-CCLM4-8-17_v1_yr_19910115-20051016.nc',
 './sffallow3_EUR-11_ICHEC-EC-EARTH_historical_r12i1p1_CLMcom-CCLM4-8-17_v1_yr_19910115-20051016.nc',
 './sffallow3_EUR-11_MOHC-HadGEM2-ES_historical_r1i1p1_CLMcom-CCLM4-8-17_v1_yr_19910116-20051016.nc',
 './sffallow3_EUR-11_MPI-M-MPI-ESM-LR_historical_r1i1p1_MPI-CSC-REMO2009_v1_yr_19910115-20051016.nc',
 './sffallow3_EUR-11_ICHEC-EC-EARTH_historical_r1i1p1_KNMI-RACMO22E_v1_yr_19910115-20051016.nc']

In [9]:
sf.get_segetalflora?

In [ ]: