Test the data transformation applicationΒΆ

This Jupyter Notebook to query the catalog for a set of Sentinel-1 SLC products, creates a Web Processing Service (WPS) request invoking the data transformation application that was deployed in the Deploy step, monitors the WPS request execution and finally retrieves the data transformation execution results

  • First do the imports of the Python libraries required
In [ ]:
import os
import owslib
from owslib.wps import monitorExecution
from owslib.wps import WebProcessingService
import lxml.etree as etree
import cioppy
import numpy as np
from shapely.wkt import loads
from shapely.geometry import box
import getpass
from datetime import datetime, timedelta
import dateutil.parser
import folium
import py_earthquakes
import geopandas as gp
import nbformat as nbf

ciop = cioppy.Cioppy()
  • Read the data pipeline configuration information:
In [ ]:
%store -r

nb_config = os.path.join('..', 'configuration.ipynb')

nb = nbf.read(nb_config, 4)

exec(nb['cells'][1]['source']) in globals(), locals()

app = dict([('artifact_id', app_artifact_id),
            ('version', app_version),
            ('repository', repository),
            ('community', community)])

app_process_id = '%s_%s_%s_%s' % (app['community'].replace('-', '_'), app['artifact_id'].replace('-', '_'), app['artifact_id'].replace('-', '_'), app['version'].replace('.', '_'))
app_process_id
  • Connect to the WPS server
In [ ]:
wps_url = 'https://ec-better-apps-deployer.terradue.com/zoo-bin/zoo_loader.cgi'

wps = WebProcessingService(wps_url,
                           verbose=False,
                           skip_caps=True)
  • Do a GetCapabilities WPS request and list the process:
In [ ]:
wps.getcapabilities()
In [ ]:
for index, elem in enumerate(wps.processes):
    print(index, elem.identifier)
  • Select the process and print the title and abstract after having submited a WPS DescribeProcess request
In [ ]:
process = wps.describeprocess(app_process_id)
In [ ]:
process.title
In [ ]:
process.abstract
  • List the WPS process inputs:
In [ ]:
for data_input in process.dataInputs:
    print data_input.identifier
  • Select master and slave products
In [ ]:
source = ['https://catalog.terradue.com/sentinel1/search?format=atom&uid=S1A_IW_SLC__1SDV_20161030T163141_20161030T163208_013722_01603F_4094',
          'https://catalog.terradue.com/sentinel1/search?format=atom&uid=S1A_IW_SLC__1SDV_20161018T163141_20161018T163208_013547_015AEB_5994']
  • Create a Python dictionary with the inputs:
In [ ]:
inputs = [('source', ','.join(source)),
          ('format', 'GeoTIFF-BigTIFF'),
          ('quotation', 'No'),
          ('_T2Username', 'floeschau')]
  • Submit the Execute WPS request:
In [ ]:
execution = owslib.wps.WPSExecution(url=wps.url)

execution_request = execution.buildRequest(app_process_id,
                                           inputs,
                                           output=[('result_osd', False)])

execution_response = execution.submitRequest(etree.tostring(execution_request))

execution.parseResponse(execution_response)
  • Monitor the request:
In [ ]:
execution.statusLocation
In [ ]:
monitorExecution(execution)
  • Check the outcome of the processing request
In [ ]:
execution.isSucceded()
  • Search for the results produced
In [ ]:
for output in execution.processOutputs:
    print(output.identifier)
In [ ]:
results_osd = execution.processOutputs[0].reference
In [ ]:
results_osd
In [ ]:
api_key = getpass.getpass('The %s Ellip API key:' % data_pipeline)
In [ ]:
data_pipeline = 'better-ethz-00001'

recast_process_id = 'dataPublication'
recast_wps_url = 'https://recast.terradue.com/t2api/ows'

wps = WebProcessingService(recast_wps_url,
                           verbose=False,
                           skip_caps=False)

recast_inputs = [('items', results_osd),
                 ('index', data_pipeline),
                 ('_T2ApiKey', api_key),
                 ('_T2Username', data_pipeline)]

recast_execution = wps.execute(recast_process_id,
                               recast_inputs,
                               output = [('result_osd', True)])


monitorExecution(recast_execution, sleepSecs=60)

etree.fromstring(recast_execution.processOutputs[0].data[0]).xpath('./@href')[0]