Pre-seismic and coseismic interogramme generationΒΆ

[55]:
import owslib
from owslib.wps import monitorExecution
import uuid
from owslib.wps import WebProcessingService

from shapely.geometry import box
from shapely.wkt import loads

import lxml.etree as etree

import cioppy

import requests
[3]:
wps_url = 'https://geohazards-tep-marketplace.terradue.com/zoo-bin/zoo_loader.cgi'

wps = WebProcessingService(wps_url, verbose=False, skip_caps=True)

wps.getcapabilities()


[4]:
for index, elem in enumerate(wps.processes):
    print elem.identifier
geohazards_tep_dsm_opt_workflow_1_1
geohazards_tep_dcs_rss_snap_s1_coin_snap_s1_coh_sigma_1_4_5
geohazards_tep_mpic_opt_dcs_mpic_opt_1_2_6
geohazards_tep_dcs_rss_band_combination_band_combination_1_4_0
geohazards_tep_dcs_rss_fullres_full_res_multi_mission_data_browser_1_5_1
geohazards_tep_dcs_insar_diapason_s1_dcs_diapason_s1_1_1
geohazards_tep_dcs_rss_snap_s1_insar_snap_s1_ifg_overall_1_2
geohazards_tep_dcs_rss_band_combination_band_combination_1_1
geohazards_tep_dcs_rss_snap_s1_coin_snap_s1_coh_sigma_1_4_1
geohazards_tep_dcs_rss_fullres_full_res_multi_mission_data_browser_1_8_0
geohazards_tep_dcs_fastvel_wf_fastvel_1_4_2
geohazards_tep_dcs_rss_snap_s1_insar_snap_s1_ifg_overall_1_4
geohazards_tep_dcs_fastvel_wf_fastvel_1_4_3
geohazards_tep_mpic_opt_dcs_mpic_opt_1_2_4
geohazards_tep_dcs_rss_fullres_full_res_multi_mission_data_browser_1_2_2
geohazards_tep_dcs_rss_band_combination_band_combination_1_3_2
geohazards_tep_mpic_opt_dcs_mpic_opt_1_2_3
geohazards_tep_dcs_rss_snap_s1_coin_snap_s1_coh_sigma_1_4_3
geohazards_tep_dcs_stemp_s2_dcs_stemp_s2_1_0_2
geohazards_tep_dcs_rss_fullres_full_res_multi_mission_data_browser_1_9_1
geohazards_tep_mpic_opt_dcs_mpic_opt_1_1
geohazards_tep_dcs_fastvel_wf_fastvel_1_4_4
geohazards_tep_dcs_insar_diapason_diapason_1_0
geohazards_tep_dcs_rss_band_combination_band_combination_1_5_1
geohazards_tep_dcs_rss_fullres_full_res_multi_mission_data_browser_1_6_0
geohazards_tep_dcs_rss_snap_s1_coin_snap_s1_coh_sigma_1_4_7
geohazards_tep_dcs_rss_fullres_full_res_multi_mission_data_browser_1_9_3
geohazards_tep_dcs_insar_diapason_diapason_1_1
geohazards_tep_dcs_rss_snap_s1_coin_snap_s1_coh_sigma_1_4_9
coordinator_geohazards_tep_tg_geohazards_00002_queue_tg_geohazards_00002_queue_1_1
geohazards_tep_dcs_rss_band_combination_band_combination_1_2_1
geohazards_tep_dcs_sar_flood_tool_sar_flood_extraction_1_1
geohazards_tep_dcs_rss_snap_s1_amplitude_change_snap_s1_amplitude_change_1_1
geohazards_tep_dcs_stemp_l8_dcs_stemp_l8_1_0_7
geohazards_tep_dcs_insar_diapason_s1_dcs_diapason_s1_1_1_1
geohazards_tep_dcs_rss_fullres_full_res_multi_mission_data_browser_1_4_0
geohazards_tep_dcs_stemp_s3_dcs_stemp_s3_1_0_3
geohazards_tep_dcs_fastvel_wf_fastvel_1_2
geohazards_tep_dcs_rss_snap_s1_insar_snap_s1_ifg_overall_1_5_2
geohazards_tep_mpic_opt_dcs_mpic_opt_1_2_2
geohazards_tep_dcs_rss_snap_s1_insar_snap_s1_ifg_overall_1_6_2
geohazards_tep_dcs_rss_snap_s1_insar_snap_s1_ifg_overall_1_6_0
geohazards_tep_dcs_sar_flood_tool_sar_flood_extraction_1_0
geohazards_tep_tg_geohazards_00002_queue_tg_geohazards_00002_queue_1_1
coordinator_geohazards_tep_tg_geohazards_00002_via_tg_geohazards_00002_via_1_1
geohazards_tep_dcs_gmtsar_mm_envisat_gmtsar_mm_0_3
geohazards_tep_mpic_opt_dcs_mpic_opt_1_2
geohazards_tep_dcs_rss_snap_s1_insar_snap_s1_ifg_overall_1_5_0
geohazards_tep_dcs_fastvel_wf_fastvel_1_3
GetStatus
geohazards_tep_dcs_gmtsar_mm_s1_gmtsar_mm_0_3
geohazards_tep_tg_geohazards_00002_via_tg_geohazards_00002_via_1_1
geohazards_tep_mpic_opt_dcs_mpic_opt_1_2_5
geohazards_tep_dcs_rss_snap_s1_amplitude_change_snap_s1_amplitude_change_1_5
geohazards_tep_mpic_opt_dcs_mpic_opt_1_2_8
geohazards_tep_dcs_satim_minesar_minesarWorkflow_1_0_1
geohazards_tep_dcs_rss_snap_s1_amplitude_change_snap_s1_amplitude_change_1_3
geohazards_tep_mpic_opt_dcs_mpic_opt_1_2_7
geohazards_tep_dcs_psi_post_proc_ground_projection_1_1_4
geohazards_tep_dcs_rss_snap_s1_coin_snap_s1_coh_sigma_1_2_0
[5]:
process_id = 'geohazards_tep_dcs_insar_diapason_s1_dcs_diapason_s1_1_1_1'

process = wps.describeprocess(process_id)

[6]:
process.title
[6]:
'DIAPASON InSAR Sentinel-1 TOPSAR(IW,EW)'
[7]:
process.abstract
[7]:
'DIAPASON is an InSAR tool suite developed by the French Space Agency (CNES) and maintained by ALTAMIRA INFORMATION.This service performs an InSAR workflow on Sentinel-1 TOPSAR (IW,EW) data, producing interferograms, amplitude and coherence maps.To run this service , specify master and slave Sentinel-1 SLC images.'
[8]:
for input in process.dataInputs:
    print(input.identifier)
master
pol
slave
aoi
psfiltx
unwrap
_T2Username
[42]:
aoi_wkt = 'POLYGON ((22.6115 38.4244, 22.6115 39.4244, 21.6115 39.4244, 21.6115 38.4244, 22.6115 38.4244))'

polarization = 'VV'
psfiltx = 0.5
unwrap = 'false'
[43]:
pair_coseismic = ['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']

pair_preseismic = ['https://catalog.terradue.com/sentinel1/search?format=atom&uid=S1A_IW_SLC__1SDV_20161018T163141_20161018T163208_013547_015AEB_5994', 'https://catalog.terradue.com/sentinel1/search?format=atom&uid=S1A_IW_SLC__1SDV_20161006T163141_20161006T163208_013372_01554F_F08D']
[44]:
executions = []
status_locations = []

execution = owslib.wps.WPSExecution(url=wps.url)

for pair in [pair_coseismic, pair_preseismic]:

    inputs = [('master', pair[0]),
              ('slave', pair[1]),
              ('pol', polarization),
              ('aoi', '%s,%s,%s,%s' % (loads(aoi_wkt).bounds[0],
                       loads(aoi_wkt).bounds[1],
                       loads(aoi_wkt).bounds[2],
                       loads(aoi_wkt).bounds[3])),
              ('psfiltx', str(psfiltx)),
              ('unwrap', unwrap),
              ('_T2Username', 'fbrito')]

    execution = owslib.wps.WPSExecution(url=wps.url)

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


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

    execution.parseResponse(execution_response)

    executions.append(execution)
    status_locations.append(execution.statusLocation)
[45]:
print status_locations
['http://geohazards-tep-marketplace.terradue.com/zoo-bin/zoo_loader.cgi?request=Execute&service=WPS&version=1.0.0&Identifier=GetStatus&DataInputs=sid=73b8a52a-85df-11e8-a347-0242ac110009&RawDataOutput=Result', 'http://geohazards-tep-marketplace.terradue.com/zoo-bin/zoo_loader.cgi?request=Execute&service=WPS&version=1.0.0&Identifier=GetStatus&DataInputs=sid=73d1011a-85df-11e8-bdf2-0242ac110009&RawDataOutput=Result']
[47]:
osds = []

for execution in executions:
    monitorExecution(execution)
    print execution.isSucceded()

    osds.append(execution.processOutputs[0].reference)
True
True
[56]:
access_token = 'eyJ2ZXIiOiIyIiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYiLCJraWQiOiJRdldZU0xtOGxiUzBmUUdaN1hrSktROXo3a3BPM1k2UU93cE5sNmkxc25vIn0.eyJzdWIiOiJqZnJ0QDAxYzlnbW5uM3MxcDRmMHBrMHA0eDkwZXkxXC91c2Vyc1wvZmJyaXRvIiwic2NwIjoibWVtYmVyLW9mLWdyb3VwczpmYnJpdG8ub3duZXIgYXBpOioiLCJhdWQiOiJqZnJ0QDAxYzlnbW5uM3MxcDRmMHBrMHA0eDkwZXkxIiwiaXNzIjoiamZydEAwMWM5Z21ubjNzMXA0ZjBwazBwNHg5MGV5MSIsImV4cCI6MTUzMTQyNDE2NCwiaWF0IjoxNTMxNDIwNTY0LCJqdGkiOiI5YWE1ZmU3OS1lMzVjLTRmZjctOWIzMi03ZGM5MjU1NWY1MDAifQ.ACotzfyhI1WAdsx93tg9ePmoHvYn75AIfNHOS1yRBWaQSwrFcu9DQ-0Wpr7Mh1Gq9U6cMSkP0ERje6lGXkhA8JPuY1rRgG2ICrVeDI8y6nGxzzcScrsAQno24Tg6JDhsbscvtVTGM2WmHJbU0Ug_4a6Wx6K4QzwxWfLMrxyh1epttta3GmbJ68Vbwqrrjc6o5oSUxnmfLDup66JspM5cLKnhzmnlERTAu9FVAaXbVArO3XIHBEX0xSySLKppT2qutUVmzfsosBU5xVHy9H586fEJU3BdSoO7-Zuw3pTnY1n9457nn49hOrGn8MTsqZXG3Eel73az51GMobsqs17Pyw'

headers = {'Authorization': 'Bearer %s' % access_token,
           'User-Agent': 'curl/t2Client'}

ciop = cioppy.Cioppy()

for results_osd in osds:

    search_results = ciop.search(end_point=results_osd,
                         params=[],
                         output_fields='identifier,enclosure',
                         model='GeoTime',
                        timeout=50000)

    for index, elem in enumerate(search_results):

        r = requests.get(elem['enclosure'], headers=headers)

        filename = elem['enclosure'][elem['enclosure'].rfind('/')+1:]

        print ('Download %s as %s' % (elem['enclosure'], filename))

        open(filename, 'wb').write(r.content)
Download https://store.terradue.com/fbrito/_results/workflows/geohazards_tep_dcs_insar_diapason_s1_dcs_diapason_s1_1_1_1/run/73b8a52a-85df-11e8-a347-0242ac110009/0000133-180619124933648-oozie-oozi-W/amp_13722_13547_ortho.tiff as amp_13722_13547_ortho.tiff
Download https://store.terradue.com/fbrito/_results/workflows/geohazards_tep_dcs_insar_diapason_s1_dcs_diapason_s1_1_1_1/run/73b8a52a-85df-11e8-a347-0242ac110009/0000133-180619124933648-oozie-oozi-W/coh_13722_13547_ortho.tiff as coh_13722_13547_ortho.tiff
Download https://store.terradue.com/fbrito/_results/workflows/geohazards_tep_dcs_insar_diapason_s1_dcs_diapason_s1_1_1_1/run/73b8a52a-85df-11e8-a347-0242ac110009/0000133-180619124933648-oozie-oozi-W/pha_13722_13547_ortho.tiff as pha_13722_13547_ortho.tiff
Download https://store.terradue.com/fbrito/_results/workflows/geohazards_tep_dcs_insar_diapason_s1_dcs_diapason_s1_1_1_1/run/73b8a52a-85df-11e8-a347-0242ac110009/0000133-180619124933648-oozie-oozi-W/logs.zip as logs.zip
Download https://store.terradue.com/fbrito/_results/workflows/geohazards_tep_dcs_insar_diapason_s1_dcs_diapason_s1_1_1_1/run/73d1011a-85df-11e8-bdf2-0242ac110009/0000132-180619124933648-oozie-oozi-W/amp_13547_13372_ortho.tiff as amp_13547_13372_ortho.tiff
Download https://store.terradue.com/fbrito/_results/workflows/geohazards_tep_dcs_insar_diapason_s1_dcs_diapason_s1_1_1_1/run/73d1011a-85df-11e8-bdf2-0242ac110009/0000132-180619124933648-oozie-oozi-W/coh_13547_13372_ortho.tiff as coh_13547_13372_ortho.tiff
Download https://store.terradue.com/fbrito/_results/workflows/geohazards_tep_dcs_insar_diapason_s1_dcs_diapason_s1_1_1_1/run/73d1011a-85df-11e8-bdf2-0242ac110009/0000132-180619124933648-oozie-oozi-W/pha_13547_13372_ortho.tiff as pha_13547_13372_ortho.tiff
Download https://store.terradue.com/fbrito/_results/workflows/geohazards_tep_dcs_insar_diapason_s1_dcs_diapason_s1_1_1_1/run/73d1011a-85df-11e8-bdf2-0242ac110009/0000132-180619124933648-oozie-oozi-W/logs.zip as logs.zip
[ ]: