Test the data transformation application for WFP-01-01-02

This Jupyter Notebook to query the catalog for a set of Sentinel-1 SLC products (one slave product and its related master files), 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 [1]:
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

import getpass

ciop = cioppy.Cioppy()

from datetime import datetime, timedelta
import dateutil.parser
import folium
import nbformat as nbf
In [2]:
%store -r

nb_config = os.path.join('../operations', '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('.', '_'))

In [3]:
app_process_id
Out[3]:
'ec_better_ewf_wfp_01_01_02_ewf_wfp_01_01_02_0_18'
  • Define the search parameters: the catalog series OpenSearch endpoint, the time of interest and the area of interest
In [4]:
series = 'https://catalog.terradue.com/sentinel1/search'

start_date = '2018-08-08T04:47:30'
stop_date = '2018-08-08T04:47:32'

geom = 'MULTIPOLYGON (((26.832 9.5136, 28.6843 9.5136, 28.6843 7.8009, 26.832 7.8009, 26.832 9.5136)), ((21.29611111111111 39.58638888888889, 21.29611111111111 41.032, 19.89788888888889 41.032, 19.89788888888889 39.58638888888889, 21.29611111111111 39.58638888888889)), ((-5.5 17.26, -1.08 17.26, -1.08 13.5, -5.5 13.5, -5.5 17.26)), ((67.7116 37.9032, 68.791 37.9032, 68.791 36.9211, 67.7116 36.9211, 67.7116 37.9032)))'


  • Search for Sentinel-1 GRD products in one of the polygons of the area of interest
In [5]:
wkt = loads(geom)[1]
AoI=wkt.wkt
In [6]:
AoI
Out[6]:
'POLYGON ((21.29611111111111 39.58638888888889, 21.29611111111111 41.032, 19.89788888888889 41.032, 19.89788888888889 39.58638888888889, 21.29611111111111 39.58638888888889))'
In [7]:
aoi=np.asarray([t[::-1] for t in list(wkt.exterior.coords)]).tolist()
In [8]:
search_params = dict([('geom', AoI),
                     ('start', start_date),
                     ('stop', stop_date),
                      ('pt', 'SLC'),
                      ('psn','S1A')
                     ])

slave = ciop.search(end_point = series,
                     params = search_params,
                     output_fields='self,enclosure,identifier,wkt,track,startdate,platform',
                     model='EOP')
In [9]:
discovery_locations = []

for index, elem in enumerate(slave):
    discovery_locations.append([t[::-1] for t in list(loads(elem['wkt']).exterior.coords)])

    print(index, elem['identifier'] + ' ' + elem['track'] + ' ' + elem['startdate'])
(0, 'S1A_IW_SLC__1SDV_20180808T044730_20180808T044757_023150_0283C3_27C9 153 2018-08-08T04:47:30.6081240Z')
(1, 'S1A_IW_SLC__1SDV_20180808T044704_20180808T044732_023150_0283C3_4936 153 2018-08-08T04:47:04.9239470Z')
  • Plot the result products for the selected AoI
In [10]:
lat = (loads(AoI).bounds[3]+loads(AoI).bounds[1])/2
lon = (loads(AoI).bounds[2]+loads(AoI).bounds[0])/2

zoom_start = 4

m = folium.Map(location=[lat, lon], zoom_start=zoom_start)

radius = 4
folium.CircleMarker(
    location=[lat, lon],
    radius=radius,
    color='#FF0000',
    stroke=False,
    fill=True,
    fill_opacity=0.9,
    opacity=1,
    popup='{} pixels'.format(radius),
    tooltip='I am in pixels, centre of AoI',
).add_to(m)

folium.PolyLine(
    locations=aoi,
    color='green',
    weight=1,
    opacity=1,
    smooth_factor=0,
).add_to(m)

folium.PolyLine(
    locations=discovery_locations,
    color='orange',
    weight=1,
    opacity=1,
    smooth_factor=0,
).add_to(m)

m.save(os.path.join('results', 'wfp-01-01-02-search.html'))

m
Out[10]:
Green polygon is our AOI, yellow one(s) is the search result(s).
  • Setting parameters for master search
In [11]:
s1_index = 0
In [12]:
if slave[s1_index]['platform']=='S1B':
    master_platform='S1A'
else:
    master_platform='S1B'
In [13]:
master_platform
Out[13]:
'S1B'