From 554a6595eff24e371b1608c1a456629abc951766 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ga=C3=ABlle=20USSEGLIO?= <gaelle.usseglio@cnes.fr>
Date: Thu, 19 Mar 2020 13:42:58 +0000
Subject: [PATCH] ENH : New organization and cleaning for python_src repository

---
 python_src/SAR_MultiSlc.json                  |  46 -
 python_src/SAR_MultiSlc_IW.json               |  33 -
 python_src/diapOTB_OLD.py                     | 532 ----------
 python_src/diapOTB_S1IW_OLD.py                | 905 ------------------
 .../ex_config_MultiSlc_CosmoS1SM.json         |  61 ++
 .../ex_config/ex_config_MultiSlc_IW.json      |  51 +
 .../ex_config_diapOTB_Cosmo.json}             |   0
 .../ex_config_diapOTB_S1IW.json}              |   0
 .../ex_config_diapOTB_S1SM.json}              |   0
 9 files changed, 112 insertions(+), 1516 deletions(-)
 delete mode 100644 python_src/SAR_MultiSlc.json
 delete mode 100644 python_src/SAR_MultiSlc_IW.json
 delete mode 100644 python_src/diapOTB_OLD.py
 delete mode 100644 python_src/diapOTB_S1IW_OLD.py
 create mode 100644 python_src/ex_config/ex_config_MultiSlc_CosmoS1SM.json
 create mode 100644 python_src/ex_config/ex_config_MultiSlc_IW.json
 rename python_src/{ex_config_Cosmo.json => ex_config/ex_config_diapOTB_Cosmo.json} (100%)
 rename python_src/{ex_config_S1IW.json => ex_config/ex_config_diapOTB_S1IW.json} (100%)
 rename python_src/{ex_config_S1SM.json => ex_config/ex_config_diapOTB_S1SM.json} (100%)

diff --git a/python_src/SAR_MultiSlc.json b/python_src/SAR_MultiSlc.json
deleted file mode 100644
index 04384b1..0000000
--- a/python_src/SAR_MultiSlc.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
-    "Global": {
-	"in": 
-	{
-	    "SRTMShapefile": "/work/scratch/azzonim/Stage2019/geoid_srtm/srtm.shp",
-	    "Datalake": "/work/ALT/swot/swotpub/MNT/SRTM_30_hgt/",
-	    "Geoid": "/work/scratch/azzonim/Stage2019/geoid_srtm/egm96.grd"
-	}
-    },
-    
-    "Pre_Processing": {
-	"out": 
-	{
-	    "doppler_file": "dop0.txt"
-	},
-	"parameter":
-	{
-	    "ML_gain": 0.1
-	}
-    },
-    "Metadata_Correction": 
-    {
-	"out": 
-	{
-	    "fine_metadata_file": "fine_metadata.txt"
-	},
-	"parameter":
-	{
-	    "activate": false,
-	    "GridStep_range": 150,
-	    "GridStep_azimut": 150
-	}
-    },
-    "DIn_SAR": 
-    {
-	"parameter":
-	{
-	    "GridStep_range": 150,
-	    "GridStep_azimut": 150,
-	    "Grid_Threshold": 0.3,
-	    "Grid_Gap_S1": 1000,
-	    "Grid_Gap_Co": 0.7,
-	    "Interferogram_gain": 0.1
-	}
-    }
-}
diff --git a/python_src/SAR_MultiSlc_IW.json b/python_src/SAR_MultiSlc_IW.json
deleted file mode 100644
index c3770c5..0000000
--- a/python_src/SAR_MultiSlc_IW.json
+++ /dev/null
@@ -1,33 +0,0 @@
-{
-    "Global": {
-	"in": 
-	{
-	    "SRTMShapefile": "/work/scratch/azzonim/Stage2019/geoid_srtm/srtm.shp",
-	    "Datalake": "/work/ALT/swot/swotpub/MNT/SRTM_30_hgt/",
-	    "Geoid": "/work/scratch/azzonim/Stage2019/geoid_srtm/egm96.grd"
-	}
-    },
-    
-    "Pre_Processing": {
-	"out": 
-	{
-	    "doppler_file": "dop0.txt"
-	},
-	"parameter":
-	{
-	    "ML_gain": 0.1
-	}
-    },
-    "Ground": {},
-    "DIn_SAR": 
-    {
-	"parameter":
-	{
-	    "GridStep_range": 25,
-	    "GridStep_azimut": 5,
-	    "Grid_Threshold": 0.3,
-	    "Grid_Gap": 30,
-	    "Interferogram_gain": 0.1
-	}
-    }
-}
diff --git a/python_src/diapOTB_OLD.py b/python_src/diapOTB_OLD.py
deleted file mode 100644
index a39c35d..0000000
--- a/python_src/diapOTB_OLD.py
+++ /dev/null
@@ -1,532 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
-#
-# This file is part of Orfeo Toolbox
-#
-#     https://www.orfeo-toolbox.org/
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import print_function
-
-__author__ = "POC-THALES"
-__version__ = "0.1"
-__status__ = "Developpement"
-__date__ = "27/10/2017"
-__last_modified__ = "27/10/2017"
-
-# Imports
-import sys
-import logging
-import json
-from jsonschema import validate
-import os
-import argparse
-import h5py
-
-import otbApplication as otb
-
-
-# Streamer to our log file
-class StreamToLogger(object):
-    """
-    Fake file-like stream object that redirects writes to a logger instance.
-    """
-    def __init__(self, logger, log_level=logging.INFO):
-        self.logger = logger
-        self.log_level = log_level
-
-    def write(self, buf):
-        for line in buf.rstrip().splitlines():
-            self.logger.log(self.log_level, line.rstrip())
-
-    def flush(self):
-        for handler in self.logger.handlers:
-            handler.flush()
-
-
-def validate_json(json, schema):
-    try:
-        validate(json, schema)
-    except Exception as valid_err:
-        print("Invalid JSON: {err}".format(err=valid_err))
-        return False
-    else:
-        # Realise votre travail
-        print("Valid JSON")
-        return True
-
-# string to bool
-def str2bool(v):
-  return v.lower() in ("yes", "true", "t", "1") 
-
-
-# Main
-if __name__ == "__main__":
-    
-    # Check arguments
-    parser = argparse.ArgumentParser()
-    parser.add_argument("configfile", help="input conguration file for the application DiapOTB")
-    args = parser.parse_args()
-    print(args.configfile)
-
-    # Logger initialization
-    logger = logging.getLogger(__name__)
-    logger.setLevel(logging.INFO)
-    
-    LogFormatter = logging.Formatter('%(filename)s :: %(levelname)s :: %(message)s')
-
-    # Create console handler with a high log level (warning level)
-    stream_handler = logging.StreamHandler()
-    stream_handler.setLevel(logging.WARNING)
-
-    # Add Handlers
-    logger.addHandler(stream_handler)
-    
-
-    # Read and Load the configuration file
-    try:
-        with open(args.configfile, 'r') as f:
-            dataConfig = json.load(f)
-            
-    except Exception as err:
-        logger.critical("Impossible to read or load JSON configuration file : {err}. Check its path and content.".format(err=args.configfile))
-        quit()
-
-    # Load schema (into DiapOTB install)
-    diapOTB_install = os.getenv('DIAPOTB_INSTALL')
-    if diapOTB_install is not None and os.path.exists(diapOTB_install):
-        schemas_path = os.path.join(diapOTB_install, "json_schemas")
-        if os.path.exists(schemas_path):
-            schema_S1SM = os.path.join(schemas_path, "schema_S1SM.json")
-            
-            try:
-                with open(schema_S1SM, "r") as sch:
-                    dataSchema = json.load(sch)
-            except Exception as err:
-                logger.critical("Impossible to read or load JSON configuration file : {err}. Check its path and content.".format(err=schema_S1SM))
-                quit()
-                    
-            # Check Json file
-            jsonIsValid = validate_json(dataConfig, dataSchema)
-
-            if not jsonIsValid :
-                logger.critical("Error, provided config file does not match requirements")
-                quit()
-
-    # Get dictionaries
-    dict_Global = dataConfig['Global']
-    dict_PreProcessing = dataConfig['Pre_Processing']
-    dict_Metadata_Correction = dataConfig['Metadata_Correction']
-    dict_DInSAR = dataConfig['DIn_SAR']
-
-    # Get elements from configuration file
-    # Global
-    master_Image = dict_Global['in']['Master_Image_Path']
-    slave_Image =  dict_Global['in']['Slave_Image_Path']
-    dem =  dict_Global['in']['DEM_Path']
-    output_dir = dict_Global['out']['output_dir']
-
-    satellite = "default"
-    mode = "default"
-
-    if 'sensor' in dict_Global:
-        satellite = dict_Global['sensor']['satellite']
-        mode = dict_Global['sensor']['mode']
-
-    # Pre_Processing
-    ml_range = dict_PreProcessing['parameter']['ML_range'] 
-    ml_azimut = dict_PreProcessing['parameter']['ML_azimut']
-    ml_gain = dict_PreProcessing['parameter']['ML_gain']
-    dop_file = dict_PreProcessing['out']['doppler_file']
-
-    # Metadata_Correction
-    activateMetadataCorrection = dict_Metadata_Correction['parameter']['activate']
-    ml_simu_range = ml_range
-    ml_simu_azimut = ml_azimut
-    ml_simu_gain = 1.
-    ml_correlSimu_range = ml_range
-    ml_correlSimu_azimut = ml_azimut
-    correlSimu_gridstep_range = dict_Metadata_Correction['parameter']['GridStep_range']
-    correlSimu_gridstep_azimut = dict_Metadata_Correction['parameter']['GridStep_azimut']
-    fine_metadata_file = dict_Metadata_Correction['out']['fine_metadata_file']
-
-    # DIn_SAR
-    geoGrid_gridstep_range = dict_DInSAR['parameter']['GridStep_range']
-    geoGrid_gridstep_azimut = dict_DInSAR['parameter']['GridStep_azimut']
-    geoGrid_threshold = dict_DInSAR['parameter']['Grid_Threshold']
-    geoGrid_gap = dict_DInSAR['parameter']['Grid_Gap']
-    ml_geoGrid_range = ml_range
-    ml_geoGrid_azimut = ml_azimut
-    gain_interfero = dict_DInSAR['parameter']['Interferogram_gain']
-    
-    if (geoGrid_threshold < 0) or (geoGrid_threshold > 1) :
-        logger.critical("Error, Wrong Threshold for fine deformation grid")
-
-    # Check if images exist
-    if not os.path.exists(master_Image) :
-        logger.critical("{img} does not exist. Check its path.".format(img=master_Image))
-        quit()
-    if not os.path.exists(slave_Image) :
-        logger.critical("{img} does not exist. Check its path.".format(img=slave_Image))
-        quit()
-    if not os.path.exists(dem) :
-        logger.critical("{img} does not exist. Check its path.".format(img=dem))
-        quit()
-    if not os.path.exists(output_dir):
-        print("The output directory does not exist and will be created")
-        os.makedirs(output_dir)
-    else :
-        print("The output directory exists. Some files can be overwritten")
-
-
-    # File handler for the logger
-    # Create file handler which logs even info messages (used as stdout redirection)
-    file_handler = logging.FileHandler(os.path.join(output_dir, 'info.log'), 'a')
-    file_handler.setLevel(logging.INFO)
-    file_handler.setFormatter(LogFormatter)
-
-    # Add Handlers
-    logger.addHandler(file_handler)
-
-    # Redirect stdout and stderr to logger 
-    s1 = StreamToLogger(logger, logging.INFO)
-    stdout_saveWrite = sys.stdout.write # Save stdout.write to print some info into the console
-    stdout_saveFlush = sys.stdout.flush # Save stdout.flush to print some info into the console
-    sys.stdout.write = s1.write # Replace stdout.write by our StreamToLogger 
-    sys.stdout.flush = s1.flush # Replace stdout.flush by our StreamToLogger
-    stdout_save = s1 # Different object
-    stdout_save.write = stdout_saveWrite # Restore stdout.write into stdout_save
-    stdout_save.flush = stdout_saveFlush # Restore stdout.write into stdout_save
-
-    # Recap of input parameter into info.log
-    logger.info("########### Input Parameters for the current execution ############## ")
-    logger.info(" Pre_Processing : ")
-    logger.info("ml_range : {param}".format(param=ml_range))
-    logger.info("ml_azimut : {param}".format(param=ml_azimut))
-    logger.info("ml_gain : {param}".format(param=ml_gain))
-    logger.info("dop_file : {param}".format(param=dop_file))
-
-    # Metadata_Correction
-    logger.info(" Metadata_Correction : ")
-    logger.info("activateMetadataCorrection : {param}".format(param=activateMetadataCorrection))
-    if activateMetadataCorrection :
-        logger.info("ml_simu_range : {param}".format(param=ml_simu_range))
-        logger.info("ml_simu_azimut : {param}".format(param=ml_simu_azimut))
-        logger.info("ml_simu_gain : {param}".format(param=ml_simu_gain))
-        logger.info("ml_correlSimu_range : {param}".format(param=ml_correlSimu_range))
-        logger.info("ml_correlSimu_azimut : {param}".format(param=ml_correlSimu_azimut))
-        logger.info("correlSimu_gridstep_range : {param}".format(param=correlSimu_gridstep_range))
-        logger.info("correlSimu_gridstep_azimut : {param}".format(param=correlSimu_gridstep_azimut))
-        logger.info("fine_metadata_file : {param}".format(param=fine_metadata_file))
-
-    # DIn_SAR
-    logger.info(" DIn_SAR : ")
-    logger.info("geoGrid_gridstep_range : {param}".format(param=geoGrid_gridstep_range))
-    logger.info("geoGrid_gridstep_azimut : {param}".format(param=geoGrid_gridstep_azimut))
-    logger.info("geoGrid_threshold : {param}".format(param=geoGrid_threshold))
-    logger.info("geoGrid_gap : {param}".format(param=geoGrid_gap))
-    logger.info("ml_geoGrid_range : {param}".format(param=ml_geoGrid_range))
-    logger.info("ml_geoGrid_azimut : {param}".format(param=ml_geoGrid_azimut))
-    logger.info("gain_interfero : {param}".format(param=gain_interfero))
-    
-
-    logger.info("########### Input Images for the current execution ############## ")
-        
-    master_Image_base = os.path.basename(master_Image)
-    slave_Image_base = os.path.basename(slave_Image)
-
-    # Check extension (if .h5 => HDF5 file => Cosmo Sensor)
-    master_ext = master_Image.split(".")[-1:]
-    slave_ext = slave_Image.split(".")[-1:]
-
-    logger.info("master_ext = {ext}".format(ext=master_ext[0]))
-    logger.info("slave_ext = {ext}".format(ext=slave_ext[0]))
-
-    
-    if master_ext[0] == "h5" :
-        master_H5 = h5py.File(master_Image, 'r')
-        lDataSet_master = list(master_H5.keys())
-       
-
-        if len(lDataSet_master) != 1 :
-            logger.critical("Error, H5 input files does not contain the expected dataset")
-            quit()
-
-        if lDataSet_master[0] != "S01" :
-            logger.critical("Error, H5 input files does not contain the expected dataset")
-            quit()
-
-        master_S01 = dict(master_H5['S01'])
-        
-        if not 'SBI' in master_S01:
-            logger.critical("H5 input files does not contain the expected dataset")
-            quit()
-
-        # Change the name of master and slave image to read directly the //S01/SBI
-        master_Image = "HDF5:" + master_Image + "://S01/SBI"
-        # Adapt sattelite
-        satellite = "cosmo"
-
-
-    if slave_ext[0] == "h5" :      
-        slave_H5 = h5py.File(slave_Image, 'r')
-        lDataSet_slave = list(slave_H5.keys())
-
-        if len(lDataSet_slave) != 1 :
-            logger.critical("H5 input files does not contain the expected dataset")
-            quit()
-
-        if lDataSet_slave[0] != "S01" :
-            logger.critical("H5 input files does not contain the expected dataset")
-            quit()
-
-        slave_S01 = dict(slave_H5['S01'])
-        
-        if not 'SBI' in slave_S01 :
-            logger.critical("H5 input files does not contain the expected dataset")
-            quit()
-        
-        slave_Image = "HDF5:" + slave_Image + "://S01/SBI"
-
-    logger.info("master_Image = {img}".format(img=master_Image))
-    logger.info("slave_Image = {img}".format(img=slave_Image))
-    logger.info("dem : {param}".format(param=dem))
-
-    print("\n Beginning of DiapOTB processing \n", file=stdout_save)
-    logger.info("############ Beginning of DiapOTB processing ##############")
-
-    ####################### Pre Processing Chain ##########################
-    ######## SARDoppler Application #######
-    print("\n Doppler Application \n", file=stdout_save)
-    logger.info("Doppler Application")
-    # Master
-    dopFile = open(os.path.join(output_dir, dop_file), "w")
-    dopFile.write("Doppler for master image : " + os.path.basename(master_Image_base)+ "\n")
-    dopFile.close()
-    appDoppler0Master = otb.Registry.CreateApplication("SARDoppler0")
-    appDoppler0Master.SetParameterString("insar", master_Image)
-    appDoppler0Master.SetParameterString("outfile", os.path.join(output_dir, dop_file))
-    appDoppler0Master.SetParameterString("ram", "4000")
-    appDoppler0Master.ExecuteAndWriteOutput()
-
-    # Slave
-    dopFile = open(os.path.join(output_dir, dop_file), "a")
-    dopFile.write("Doppler for slave image : " + os.path.basename(slave_Image_base) + "\n")
-    dopFile.close()
-    appDoppler0Slave = otb.Registry.CreateApplication("SARDoppler0")
-    appDoppler0Slave.SetParameterString("insar", slave_Image)
-    appDoppler0Slave.SetParameterString("outfile", os.path.join(output_dir, dop_file))
-    appDoppler0Slave.SetParameterString("ram", "4000")
-    appDoppler0Slave.ExecuteAndWriteOutput()
-
-
-    ####### SARMultiLook Application #######
-    print("\n MultiLook Application \n", file=stdout_save)
-    logger.info("MultiLook Application")
-    # Master
-    master_Image_ML = os.path.splitext(master_Image_base)[0] + "_ml" + str(ml_azimut) + str(ml_range) + ".tif"
-    appMultiLookMaster = otb.Registry.CreateApplication("SARMultiLook")
-    appMultiLookMaster.SetParameterString("incomplex", master_Image)
-    appMultiLookMaster.SetParameterString("out", os.path.join(output_dir, master_Image_ML))
-    appMultiLookMaster.SetParameterInt("mlran",ml_range)
-    appMultiLookMaster.SetParameterInt("mlazi",ml_azimut)
-    appMultiLookMaster.SetParameterFloat("mlgain", ml_gain)
-    appMultiLookMaster.SetParameterString("ram", "4000")
-    appMultiLookMaster.ExecuteAndWriteOutput()
-
-    # Slave
-    slave_Image_ML = os.path.splitext(slave_Image_base)[0] + "_ml" + str(ml_azimut) + str(ml_range) + ".tif"
-    appMultiLookSlave = otb.Registry.CreateApplication("SARMultiLook")
-    appMultiLookSlave.SetParameterString("incomplex", slave_Image)
-    appMultiLookSlave.SetParameterString("out", os.path.join(output_dir, slave_Image_ML))
-    appMultiLookSlave.SetParameterInt("mlran",ml_range)
-    appMultiLookSlave.SetParameterInt("mlazi",ml_azimut)
-    appMultiLookSlave.SetParameterFloat("mlgain", ml_gain)
-    appMultiLookSlave.SetParameterString("ram", "4000")
-    appMultiLookSlave.ExecuteAndWriteOutput()
-
-
-
-
-    # ######################## Metadata Correction Chain #############################
-    if activateMetadataCorrection :        
-        ######## SARDEMToAmplitude Application (Simu_SAR step) #######
-        print("\n SARDEMToAmplitude Application \n", file=stdout_save)
-        logger.info("SARDEMToAmplitude Application")
-        amplitude_simu_image = os.path.splitext(master_Image_base)[0] + "_simuSAR" + "_ml" + str(ml_simu_azimut) + str(ml_simu_range) + ".tif"
-        appDEMToAmplitude = otb.Registry.CreateApplication("SARDEMToAmplitude")
-        appDEMToAmplitude.SetParameterString("insar", master_Image)
-        appDEMToAmplitude.SetParameterString("indem", dem)
-        appDEMToAmplitude.SetParameterString("out", os.path.join(output_dir, amplitude_simu_image))
-        appDEMToAmplitude.SetParameterInt("mlran",ml_simu_range)
-        appDEMToAmplitude.SetParameterInt("mlazi",ml_simu_azimut)
-        appDEMToAmplitude.SetParameterFloat("mlgain", ml_simu_gain)
-        appDEMToAmplitude.SetParameterInt("nodata", -32768)
-        appDEMToAmplitude.SetParameterString("ram", "4000")
-        #appDEMToAmplitude.Execute()
-        appDEMToAmplitude.ExecuteAndWriteOutput()
-
-
-        ######## SARCorrelationGrid Application (Correl step) #######
-        print("\n SARCorrelationGrid Application \n", file=stdout_save)
-        logger.info("SARCorrelationGrid Application")
-        correl_grid = "correl_simu" + "_gridstep" + str(correlSimu_gridstep_azimut) + str(correlSimu_gridstep_range) + ".tif"
-        appCorGrid = otb.Registry.CreateApplication("SARCorrelationGrid")
-        appCorGrid.SetParameterString("inmaster", os.path.join(output_dir, master_Image_ML))
-        appCorGrid.SetParameterString("inslave", os.path.join(output_dir, amplitude_simu_image))
-        #appCorGrid.SetParameterInputImage("inslave", appDEMToAmplitude.GetParameterOutputImage("out")) # Input image 
-        appCorGrid.SetParameterString("out", os.path.join(output_dir, correl_grid))
-        appCorGrid.SetParameterInt("mlran",ml_correlSimu_range)
-        appCorGrid.SetParameterInt("mlazi",ml_correlSimu_azimut)
-        appCorGrid.SetParameterInt("gridsteprange", correlSimu_gridstep_range)
-        appCorGrid.SetParameterInt("gridstepazimut", correlSimu_gridstep_azimut)
-        appCorGrid.SetParameterString("ram", "4000")
-        #appCorGrid.Execute()
-        appCorGrid.ExecuteAndWriteOutput()
-
-
-        ######## SARFineMetadata Application (Correct_snrt step) #######
-        print("\n SARFineMetadata Application \n", file=stdout_save)
-        logger.info("SARFineMetadata Application")
-        appFineMetadata = otb.Registry.CreateApplication("SARFineMetadata")
-        appFineMetadata.SetParameterString("insar", master_Image)
-        appFineMetadata.SetParameterString("ingrid", os.path.join(output_dir, correl_grid))
-        #appFineMetadata.SetParameterInputImage("ingrid", appCorGrid.GetParameterOutputImage("out")) # Input image 
-        appFineMetadata.SetParameterFloat("stepmax", 0.1)
-        appFineMetadata.SetParameterFloat("threshold", 0.3)
-        appFineMetadata.SetParameterString("outfile", os.path.join(output_dir, fine_metadata_file))
-        appFineMetadata.ExecuteAndWriteOutput()
-
-
-
-
-    
-    ######################## DIn_SAR Chain #############################
-    ######## SARDEMProjection Application #######
-    print("\n SARDEMProjection Application \n", file=stdout_save)
-    logger.info("SARDEMProjection Application")
-    # Master
-    demProj_Master = "demProj_Master.tif"
-    appDEMProjectionMaster = otb.Registry.CreateApplication("SARDEMProjection")
-    appDEMProjectionMaster.SetParameterString("insar", master_Image)
-    appDEMProjectionMaster.SetParameterString("indem", dem)
-    if activateMetadataCorrection :
-        appDEMProjectionMaster.SetParameterString("infilemetadata", os.path.join(output_dir, fine_metadata_file))
-    appDEMProjectionMaster.SetParameterString("withxyz", "true")
-    appDEMProjectionMaster.SetParameterInt("nodata", -32768)
-    appDEMProjectionMaster.SetParameterString("out", os.path.join(output_dir, demProj_Master))
-    appDEMProjectionMaster.SetParameterString("ram", "4000")
-    appDEMProjectionMaster.ExecuteAndWriteOutput()
-
-    # Slave
-    demProj_Slave = "demProj_Slave.tif"
-    appDEMProjectionSlave = otb.Registry.CreateApplication("SARDEMProjection")
-    appDEMProjectionSlave.SetParameterString("insar", slave_Image)
-    appDEMProjectionSlave.SetParameterString("indem", dem)
-    appDEMProjectionSlave.SetParameterString("withxyz", "true");
-    appDEMProjectionSlave.SetParameterInt("nodata", -32768)
-    appDEMProjectionSlave.SetParameterString("out", os.path.join(output_dir, demProj_Slave))
-    appDEMProjectionSlave.SetParameterString("ram", "4000")
-    appDEMProjectionSlave.ExecuteAndWriteOutput()
-
-
-    ######## SARFineDeformationGrid Application (geo_grid step) #######
-    print("\n SARFineDeformationGrid Application \n", file=stdout_save)
-    logger.info("SARFineDeformationGrid Application")
-    fine_grid = "fineDeformationGrid.tif"
-    appFineDeformationGrid = otb.Registry.CreateApplication("SARFineDeformationGrid")
-    appFineDeformationGrid.SetParameterString("indem", dem)
-    appFineDeformationGrid.SetParameterString("insarmaster", master_Image)
-    appFineDeformationGrid.SetParameterString("insarslave", slave_Image)
-    appFineDeformationGrid.SetParameterString("inmlmaster", os.path.join(output_dir, master_Image_ML))
-    appFineDeformationGrid.SetParameterString("inmlslave", os.path.join(output_dir, slave_Image_ML))
-    appFineDeformationGrid.SetParameterString("indemprojmaster", os.path.join(output_dir, demProj_Master))
-    appFineDeformationGrid.SetParameterString("indemprojslave", os.path.join(output_dir, demProj_Slave))
-    appFineDeformationGrid.SetParameterInt("mlran", ml_geoGrid_range)
-    appFineDeformationGrid.SetParameterInt("mlazi", ml_geoGrid_azimut)
-    appFineDeformationGrid.SetParameterInt("gridsteprange", geoGrid_gridstep_range)
-    appFineDeformationGrid.SetParameterInt("gridstepazimut", geoGrid_gridstep_azimut)
-    appFineDeformationGrid.SetParameterFloat("threshold", geoGrid_threshold)
-    appFineDeformationGrid.SetParameterFloat("gap", geoGrid_gap)
-    appFineDeformationGrid.SetParameterString("out", os.path.join(output_dir, fine_grid))
-    # Projection is not reliable for cosmo sensor => correction of all values with correlation grid
-    if satellite == "cosmo" or satellite == "CSK" :
-        appFineDeformationGrid.SetParameterString("advantage", "correlation")
-    appFineDeformationGrid.SetParameterString("ram", "4000")
-    appFineDeformationGrid.ExecuteAndWriteOutput()
-
-    
-    ######## SARCoRegistration Application (changeo step) #######
-    print("\n SARCoRegistration Application \n", file=stdout_save)
-    logger.info("SARCoRegistration Application")
-    slave_Image_CoRe = os.path.splitext(slave_Image_base)[0] + "_coregistrated.tif"
-    appCoRegistration = otb.Registry.CreateApplication("SARCoRegistration")
-    appCoRegistration.SetParameterString("insarmaster", master_Image)
-    appCoRegistration.SetParameterString("insarslave", slave_Image)
-    appCoRegistration.SetParameterString("ingrid",  os.path.join(output_dir, fine_grid))
-    appCoRegistration.SetParameterInt("gridsteprange", geoGrid_gridstep_range)
-    appCoRegistration.SetParameterInt("gridstepazimut", geoGrid_gridstep_azimut)
-    appCoRegistration.SetParameterFloat("doppler0", appDoppler0Slave.GetParameterFloat("doppler0"))
-    appCoRegistration.SetParameterInt("sizetiles", 50)
-    appCoRegistration.SetParameterInt("margin", 7)
-    appCoRegistration.SetParameterInt("nbramps", 257)
-    appCoRegistration.SetParameterString("ram", "4000")
-    appCoRegistration.SetParameterString("out", os.path.join(output_dir, slave_Image_CoRe))
-    appCoRegistration.ExecuteAndWriteOutput()
-
-    
-    ######## SARCartesianMeanEstimation Application #######
-    print("\n SARCartesianMeanEstimation Application \n")
-    logger.info("SARCartesianMeanEstimation Application")
-    # Master
-    master_cartesian_mean = "CartMeanMaster.tif"
-    master_cartesianperline_mean = "CartMeanPerLineMaster.tif"
-    appCartMeanMaster = otb.Registry.CreateApplication("SARCartesianMeanEstimation")
-    appCartMeanMaster.SetParameterString("insar", master_Image)
-    appCartMeanMaster.SetParameterString("indem", dem)
-    appCartMeanMaster.SetParameterString("indemproj",  os.path.join(output_dir, demProj_Master))
-    appCartMeanMaster.SetParameterInt("indirectiondemc", appDEMProjectionMaster.GetParameterInt("directiontoscandemc"))
-    appCartMeanMaster.SetParameterInt("indirectiondeml", appDEMProjectionMaster.GetParameterInt("directiontoscandeml"))
-    appCartMeanMaster.SetParameterInt("mlran", 1)
-    appCartMeanMaster.SetParameterInt("mlazi", 1)
-    appCartMeanMaster.SetParameterString("ram", "4000")
-    appCartMeanMaster.SetParameterString("out",  os.path.join(output_dir, master_cartesian_mean))
-    appCartMeanMaster.ExecuteAndWriteOutput()
-
-
-    ######## SARRobustInterferogram Application (interf step) #######
-    print("\n SARRobustInterferogram Application \n", file=stdout_save)
-    logger.info("SARRobustInterferogram Application")
-    interferogram = "interferogram.tif"
-    appInterferogram = otb.Registry.CreateApplication("SARRobustInterferogram")
-    appInterferogram.SetParameterString("insarmaster", master_Image)
-    appInterferogram.SetParameterString("incoregistratedslave", os.path.join(output_dir, slave_Image_CoRe))
-    appInterferogram.SetParameterString("insarslave", slave_Image)
-    appInterferogram.SetParameterString("ingrid",  os.path.join(output_dir, fine_grid))
-    appInterferogram.SetParameterString("incartmeanmaster", os.path.join(output_dir, master_cartesian_mean))
-    appInterferogram.SetParameterInt("mlran", ml_range)
-    appInterferogram.SetParameterInt("mlazi", ml_azimut)
-    appInterferogram.SetParameterInt("gridsteprange", geoGrid_gridstep_range)
-    appInterferogram.SetParameterInt("gridstepazimut", geoGrid_gridstep_azimut)
-    appInterferogram.SetParameterFloat("gain", gain_interfero)
-    appInterferogram.SetParameterString("ram", "4000")
-    appInterferogram.SetParameterString("out", os.path.join(output_dir, interferogram))
-    appInterferogram.ExecuteAndWriteOutput()
-
-
-    print("\n End of DiapOTB processing \n", file=stdout_save)
-    logger.info("############# End of DiapOTB processing ##############")
diff --git a/python_src/diapOTB_S1IW_OLD.py b/python_src/diapOTB_S1IW_OLD.py
deleted file mode 100644
index d5a8364..0000000
--- a/python_src/diapOTB_S1IW_OLD.py
+++ /dev/null
@@ -1,905 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
-#
-# This file is part of Orfeo Toolbox
-#
-#     https://www.orfeo-toolbox.org/
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import print_function
-
-__author__ = "POC-THALES"
-__version__ = "0.1"
-__status__ = "Developpement"
-__date__ = "11/12/2018"
-__last_modified__ = "11/12/2018"
-
-# Imports
-import logging
-import json
-from jsonschema import validate
-import os
-import sys
-import argparse
-import re
-
-import otbApplication as otb
-
-# Streamer to our log file
-class StreamToLogger(object):
-    """
-    Fake file-like stream object that redirects writes to a logger instance.
-    """
-    def __init__(self, logger, log_level=logging.INFO):
-        self.logger = logger
-        self.log_level = log_level
-
-    def write(self, buf):
-        for line in buf.rstrip().splitlines():
-            self.logger.log(self.log_level, line.rstrip())
-
-    def flush(self):
-        for handler in self.logger.handlers:
-            handler.flush()
-
-
-def validate_json(json, schema):
-    try:
-        validate(json, schema)
-    except Exception as valid_err:
-        print("Invalid JSON: {}".format(valid_err))
-        return False
-    else:
-        # Realise votre travail
-        print("Valid JSON")
-        return True
-
-# string to bool
-def str2bool(v):
-    return v.lower() in ("yes", "true", "t", "1") 
-
-# Bursts selection (according to anx time values)
-def selectBurst(dictMaster, dictSlave, firstBurst, lastBurst, nbBurstSlave, validBurstMaster, validBurstSlave):
-    
-    key1Burst = "support_data.geom.bursts.burst["
-    
-    # Initialize the output lists (empty lists)
-    validBurstMaster.clear()
-    validBurstSlave.clear()
-    
-    # Loop on Master bursts
-    for id_B in range(firstBurst, lastBurst+1):
-        keyBurstMaster = key1Burst + str(id_B) + "].azimuth_anx_time"
-        
-        # Get the anx time for the current burst (into Master Image)
-        anxMaster = float(dictMaster[keyBurstMaster])
-
-        # Loop on slave bursts to find the closest anx time
-        minDiff = 200
-        id_B_save = id_B
-        for id_B_slave in range(0, nbBurstSlave):
-            keyBurstSlave = key1Burst + str(id_B_slave) + "].azimuth_anx_time"
-
-            # Get anx time for slave burst
-            anxSlave = float(dictSlave[keyBurstSlave])
-            
-            # Comparaison between master and slave
-            diff = abs(anxMaster - anxSlave)
-            
-            if minDiff > diff :
-                minDiff = diff
-                id_B_save = id_B_slave
-
-        # Check if difference between the anx time is valid (must be inferior to 1)
-        if minDiff < 1. :
-            # Fill lists with master Burst_id and the selected slave burst_id
-            validBurstMaster.append(id_B)
-            validBurstSlave.append(id_B_save)
-            
-
-
-# Main
-if __name__ == "__main__":
-    
-    # Check arguments
-    parser = argparse.ArgumentParser()
-    parser.add_argument("configfile", help="input conguration file for the application DiapOTB")
-    args = parser.parse_args()
-    print(args.configfile)
-
-    # Logger initialization
-    logger = logging.getLogger(__name__)
-    logger.setLevel(logging.INFO)
-    
-    LogFormatter = logging.Formatter('%(filename)s :: %(levelname)s :: %(message)s')
-
-    # Create console handler with a high log level (warning level)
-    stream_handler = logging.StreamHandler()
-    stream_handler.setLevel(logging.WARNING)
-
-    # Add Handlers
-    logger.addHandler(stream_handler)
-
-    # Read and Load the configuration file
-    try:
-        with open(args.configfile, 'r') as f:
-            dataConfig = json.load(f)
-            
-    except Exception as err:
-        logger.critical("Impossible to read or load JSON configuration file : {err}. Check its path and content.".format(err=args.configfile))
-        quit()
-
-    # Load schema (into DiapOTB install)
-    diapOTB_install = os.getenv('DIAPOTB_INSTALL')
-    if diapOTB_install is not None and os.path.exists(diapOTB_install):
-        schemas_path = os.path.join(diapOTB_install, "json_schemas")
-        if os.path.exists(schemas_path):
-            schema_S1IW = os.path.join(schemas_path, "schema_S1IW.json")
-    
-            try:
-                with open(schema_S1IW, "r") as sch:
-                    dataSchema = json.load(sch)
-            except Exception as err:
-                logger.critical("Impossible to read or load JSON configuration file : {err}. Check its path and content.".format(err=schema_S1SM))
-                quit()
-
-            # Check Json file
-            jsonIsValid = validate_json(dataConfig, dataSchema)
-
-            if not jsonIsValid :
-                logger.critical("Error, provided config file does not match requirements")
-                quit()
-
-    # Get dictionaries
-    dict_Global = dataConfig['Global']
-    dict_PreProcessing = dataConfig['Pre_Processing']
-    dict_Ground = dataConfig['Ground']
-    dict_DInSAR = dataConfig['DIn_SAR']
-   
-         
-    # Get elements from dictionaries
-    # Global
-    master_Image = dict_Global['in']['Master_Image_Path']
-    slave_Image =  dict_Global['in']['Slave_Image_Path']
-    dem =  dict_Global['in']['DEM_Path']
-    output_dir = dict_Global['out']['output_dir']
-    
-    # Pre_Processing
-    ml_range = dict_PreProcessing['parameter']['ML_range'] 
-    ml_azimut = dict_PreProcessing['parameter']['ML_azimut']
-    ml_gain = dict_PreProcessing['parameter']['ML_gain']
-    dop_file = dict_PreProcessing['out']['doppler_file']
-    
-    # Ground
-    
-    # DIn_SAR
-    geoGrid_gridstep_range = dict_DInSAR['parameter']['GridStep_range']
-    geoGrid_gridstep_azimut = dict_DInSAR['parameter']['GridStep_azimut']
-    geoGrid_threshold = dict_DInSAR['parameter']['Grid_Threshold']
-    geoGrid_gap = dict_DInSAR['parameter']['Grid_Gap']
-    ml_geoGrid_range = ml_range
-    ml_geoGrid_azimut = ml_azimut
-    gain_interfero = dict_DInSAR['parameter']['Interferogram_gain']
-    # esd loop 
-    esd_AutoMode = False # automatic mode to apply a threshold inside the esd loop
-    esd_NbIter = 0
-    
-    if 'ESD_iter' in dict_DInSAR['parameter']:
-        esd_NbIter = dict_DInSAR['parameter']['ESD_iter']
-        if not isinstance(esd_NbIter, int) :
-            esd_AutoMode = True
-            esd_NbIter = 10 # 10 iterations maximum for automatic mode
-    else :
-        esd_AutoMode = True
-        esd_NbIter = 10 # 10 iterations maximum for automatic mode
-   
-
-    # Check Threshold
-    if (geoGrid_threshold < 0) or (geoGrid_threshold > 1) :
-        logger.critical("Error, Wrong Threshold for fine deformation grid")
-        geoGrid_threshold = 0.3
-
-    # Check if images/dem exist
-    if not os.path.exists(master_Image) :
-        logger.critical("{img} does not exist. Check its path.".format(img=master_Image))
-        quit()
-    if not os.path.exists(slave_Image) :
-        logger.critical("{img} does not exist. Check its path.".format(img=slave_Image))
-        quit()
-    if not os.path.exists(dem) :
-        logger.critical("{img} does not exist. Check its path.".format(img=dem))
-        quit()
-    if not os.path.exists(output_dir):
-        print("The output directory does not exist and will be created")
-        os.makedirs(output_dir)
-    else :
-        print("The output directory exists. Some files can be overwritten")
-
-
-    # File handler for the logger
-    # Create file handler which logs even info messages (used as stdout redirection)
-    file_handler = logging.FileHandler(os.path.join(output_dir, 'info.log'), 'a')
-    file_handler.setLevel(logging.INFO)
-    file_handler.setFormatter(LogFormatter)
-
-    # Add Handlers
-    logger.addHandler(file_handler)
-
-    # Redirect stdout and stderr to logger 
-    s1 = StreamToLogger(logger, logging.INFO)
-    stdout_saveWrite = sys.stdout.write # Save stdout.write to print some info into the console
-    stdout_saveFlush = sys.stdout.flush # Save stdout.flush to print some info into the console
-    sys.stdout.write = s1.write # Replace stdout.write by our StreamToLogger 
-    sys.stdout.flush = s1.flush # Replace stdout.flush by our StreamToLogger
-    stdout_save = s1 # Different object
-    stdout_save.write = stdout_saveWrite # Restore stdout.write into stdout_save
-    stdout_save.flush = stdout_saveFlush # Restore stdout.write into stdout_save
-
-     # Recap of input parameter into info.log
-    logger.info("########### Input Parameters for the current execution ############## ")
-    logger.info(" Pre_Processing : ")
-    logger.info("ml_range : {param}".format(param=ml_range))
-    logger.info("ml_azimut : {param}".format(param=ml_azimut))
-    logger.info("ml_gain : {param}".format(param=ml_gain))
-    logger.info("dop_file : {param}".format(param=dop_file))
-
-    # DIn_SAR
-    logger.info(" DIn_SAR : ")
-    logger.info("geoGrid_gridstep_range : {param}".format(param=geoGrid_gridstep_range))
-    logger.info("geoGrid_gridstep_azimut : {param}".format(param=geoGrid_gridstep_azimut))
-    logger.info("geoGrid_threshold : {param}".format(param=geoGrid_threshold))
-    logger.info("geoGrid_gap : {param}".format(param=geoGrid_gap))
-    logger.info("ml_geoGrid_range : {param}".format(param=ml_geoGrid_range))
-    logger.info("ml_geoGrid_azimut : {param}".format(param=ml_geoGrid_azimut))
-    logger.info("gain_interfero : {param}".format(param=gain_interfero))
-    logger.info("esd_AutoMode : {param}".format(param=esd_AutoMode))
-    logger.info("esd_NbIter : {param}".format(param=esd_NbIter))
-
-    logger.info("########### Input Images for the current execution ############## ")
-    logger.info("master_Image : {param}".format(param=master_Image))
-    logger.info("slave_Image : {param}".format(param=slave_Image))
-    logger.info("dem : {param}".format(param=dem))
-
-    # check Burst index      
-    master_Image_base = os.path.basename(master_Image)
-    slave_Image_base = os.path.basename(slave_Image)
-    
-    # Retrieve some information about our input images
-    ReadImageInfo = otb.Registry.CreateApplication("ReadImageInfo")
-    ReadImageInfo.SetParameterString("in", master_Image)
-    ReadImageInfo.SetParameterString("keywordlist", "true")
-    ReadImageInfo.Execute()
-    
-    keywordMaster = ReadImageInfo.GetParameterString("keyword")
-    keywordlistMaster = ReadImageInfo.GetParameterString("keyword").split("\n")
-    keywordlistMaster = filter(None, keywordlistMaster)
-    dictKWLMaster = { i.split(':')[0] : re.sub(r"[\n\t\s]*", "", i.split(':')[1]) for i in keywordlistMaster }
-
-    ReadImageInfo.SetParameterString("in", slave_Image)
-    ReadImageInfo.SetParameterString("keywordlist", "true")
-    ReadImageInfo.Execute()
-    
-    keywordSlave = ReadImageInfo.GetParameterString("keyword")
-    keywordlistSlave = ReadImageInfo.GetParameterString("keyword").split("\n")
-    keywordlistSlave = filter(None, keywordlistSlave)
-    dictKWLSlave = { i.split(':')[0] : re.sub(r"[\n\t\s]*", "", i.split(':')[1]) for i in keywordlistSlave }
-    
-    # Check header version
-    if int(dictKWLMaster['header.version']) < 3 or int(dictKWLSlave['header.version']) < 3 :
-        logger.critical("Upgrade your geom file")
-        quit()
-
-    # Get information about DEM (spacing, size ..)
-    ReadDEMInfo = otb.Registry.CreateApplication("ReadImageInfo")
-    ReadDEMInfo.SetParameterString("in", dem)
-    ReadDEMInfo.SetParameterString("keywordlist", "true")
-    ReadDEMInfo.Execute()
-
-    spacingXDEM = ReadDEMInfo.GetParameterFloat("spacingx")
-    estimatedGroundSpacingXDEM = ReadDEMInfo.GetParameterFloat("estimatedgroundspacingx")
-    spacingYDEM = ReadDEMInfo.GetParameterFloat("spacingy")
-    estimatedGroundSpacingYDEM = ReadDEMInfo.GetParameterFloat("estimatedgroundspacingy")
-
-    # Choose advantage for correlation or projection according to DEM resolution
-    advantage = "projection" # By default projection
-    
-    if estimatedGroundSpacingXDEM > 40. or estimatedGroundSpacingYDEM > 40. :
-        advantage = "correlation" # Correlation if resolution > 40 m
-        logger.warning("Resolution of the input DEM is inferior to 40 meters : A correlation will be used to correct all deformation grids")
-        
-        
-    # Selection of bursts
-    keyBurst = "support_data.geom.bursts.burst[" + str(0) + "].azimuth_anx_time" 
-
-    # Check the index of bursts
-    minNbBurst = min([int(dictKWLMaster['support_data.geom.bursts.number']), int(dictKWLSlave['support_data.geom.bursts.number'])])
-
-    firstBurst = 0
-    lastBurst = minNbBurst
-    burstIndexOk = True
-
-    try:
-        if 'parameter' in dict_Global:
-            if 'burst_index' in dict_Global['parameter']:
-                burstList = dict_Global['parameter']['burst_index'].split('-');
-                burstList = [int(i) for i in burstList]
-            
-                if len(burstList) == 2 :
-                    firstBurst = min(burstList)
-                    lastBurst = max(burstList)
-    except Exception as err:
-        logger.critical("Wrong burst index")
-        quit()
-                
-    if minNbBurst < firstBurst or minNbBurst < lastBurst or lastBurst < 0 or firstBurst < 0 :
-        logger.critical("Wrong burst index")
-        quit()
-   
-    validBurstMaster = [] 
-    validBurstSlave = []
-    nbBurstSlave = int(dictKWLSlave['support_data.geom.bursts.number'])
-    selectBurst(dictKWLMaster, dictKWLSlave, firstBurst, lastBurst, nbBurstSlave, validBurstMaster, validBurstSlave)
-
-    if len(validBurstMaster) == 0 or len(validBurstSlave) == 0 :
-        logger.critical("Wrong burst index (slave index does not match with master index)")
-        quit()
-
-    # Update firstBurst and lastBurst with selected Burst for master image
-    firstBurst = validBurstMaster[0]
-    lastBurst = validBurstMaster[len(validBurstMaster)-1]
-
- 
-    # Create directory for each burst
-    for burstId in range(validBurstMaster[0], validBurstMaster[len(validBurstMaster)-1]+1):
-        if not os.path.exists(os.path.join(output_dir, "burst" + str(burstId))):
-            os.makedirs(os.path.join(output_dir, "burst" + str(burstId)))
-
-
-    print("\n Beginning of DiapOTB processing (S1 IW mode) \n", file=stdout_save)
-    logger.info("############ Beginning of DiapOTB processing  (S1 IW mode) ##############")
-                        
-    ####################### Pre Processing Chain ##########################
-    # Initialisation of doppler file 
-    dopFile = open(os.path.join(output_dir, dop_file), "w")
-    dopFile.close()
-
-    # Master
-    print("\n Master Pre-Processing \n", file=stdout_save)
-    logger.info("Master Pre-Processing")
-
-    dop0Master = []
-    
-    for id_loop in range(0, len(validBurstMaster)):
-        #burstId = id_loop + firstBurst
-        burstId = validBurstMaster[id_loop]
-   
-        print("\n BurstId = " + str(burstId) + "\n", file=stdout_save)
-        logger.info("BurstId = {ind}".format(ind=burstId))
-
-        burst_dir = os.path.join(output_dir, "burst" + str(burstId))
-
-        ######## SARBurstExtraction Application #######
-        print("\n Burst Extraction Application \n", file=stdout_save)
-        logger.info("Burst Extraction Application")
-        burstM = os.path.splitext(master_Image_base)[0] + "_burst" + str(burstId) + ".tif"
-        appBurstExtractionMaster = otb.Registry.CreateApplication("SARBurstExtraction")
-        appBurstExtractionMaster.SetParameterString("in", master_Image)
-        appBurstExtractionMaster.SetParameterString("out", os.path.join(burst_dir, burstM))
-        appBurstExtractionMaster.SetParameterInt("burstindex", burstId)
-        appBurstExtractionMaster.SetParameterString("allpixels", "true")
-        appBurstExtractionMaster.SetParameterString("ram", "4000")
-        appBurstExtractionMaster.ExecuteAndWriteOutput()
-
-        ######## SARDeramp Application #######
-        print("\n Deramping Application \n", file=stdout_save)
-        logger.info("Deramping Application")
-        burstDerampM = os.path.splitext(master_Image_base)[0] + "_burst" + str(burstId) + "_deramp" + ".tif"
-        appDerampMaster = otb.Registry.CreateApplication("SARDeramp")
-        appDerampMaster.SetParameterString("in", os.path.join(burst_dir, burstM))
-        appDerampMaster.SetParameterString("out", os.path.join(burst_dir, burstDerampM))
-        appDerampMaster.SetParameterString("ram", "4000")
-        appDerampMaster.ExecuteAndWriteOutput()
-        
-        ######## SARDoppler Application #######
-        print("\n Doppler Application \n", file=stdout_save)
-        logger.info("Doppler Application")
-        dopFile = open(os.path.join(output_dir, dop_file), "a")
-        dopFile.write("Doppler for master image : " + os.path.basename(master_Image_base)+ " for burst_index = " + str(burstId) + "\n")
-        dopFile.close()
-        appDoppler0Master = otb.Registry.CreateApplication("SARDoppler0")
-        appDoppler0Master.SetParameterString("insar", os.path.join(burst_dir, burstDerampM))
-        appDoppler0Master.SetParameterString("outfile", os.path.join(output_dir, dop_file))
-        appDoppler0Master.SetParameterString("ram", "4000")
-        appDoppler0Master.ExecuteAndWriteOutput()
-
-        dop0Master.append(appDoppler0Master.GetParameterFloat('doppler0'))
-
-        ####### SARMultiLook Application #######
-        print("\n MultiLook Application \n", file=stdout_save)
-        logger.info("MultiLook Application")
-        master_Image_ML = os.path.splitext(master_Image_base)[0] + "_burst" + str(burstId) + "_ml" + str(ml_azimut) + str(ml_range) + ".tif"
-        appMultiLookMaster = otb.Registry.CreateApplication("SARMultiLook")
-        appMultiLookMaster.SetParameterString("incomplex", os.path.join(burst_dir, burstDerampM))
-        appMultiLookMaster.SetParameterString("out", os.path.join(burst_dir, master_Image_ML))
-        appMultiLookMaster.SetParameterInt("mlran",ml_range)
-        appMultiLookMaster.SetParameterInt("mlazi",ml_azimut)
-        appMultiLookMaster.SetParameterFloat("mlgain", ml_gain)
-        appMultiLookMaster.SetParameterString("ram", "4000")
-        appMultiLookMaster.ExecuteAndWriteOutput()
-
-    # Slave
-    print("\n Slave Pre-Processing \n", file=stdout_save)
-    logger.info("Slave Pre-Processing")
-
-    dop0Slave = []
-  
-    for id_loop in range(0, len(validBurstMaster)):
-        #burstId = id_loop + firstBurst
-        burstId = validBurstMaster[id_loop]
-        burstId_slave = validBurstSlave[id_loop]
-
-        print("\n BurstId = " + str(burstId) + "\n", file=stdout_save)
-        logger.info("BurstId = {ind}".format(ind=burstId))
-
-
-        burst_dir = os.path.join(output_dir, "burst" + str(burstId))
-
-        ######## SARBurstExtraction Application #######
-        print("\n Burst Extraction Application \n", file=stdout_save)
-        logger.info("Burst Extraction Application")
-        burstS = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId_slave) + ".tif"
-        appBurstExtractionSlave = otb.Registry.CreateApplication("SARBurstExtraction")
-        appBurstExtractionSlave.SetParameterString("in", slave_Image)
-        appBurstExtractionSlave.SetParameterString("out", os.path.join(burst_dir, burstS))
-        appBurstExtractionSlave.SetParameterInt("burstindex", burstId_slave)
-        appBurstExtractionSlave.SetParameterString("allpixels", "true")
-        appBurstExtractionSlave.SetParameterString("ram", "4000")
-        appBurstExtractionSlave.ExecuteAndWriteOutput()
-    
-        ######## SARDeramp Application #######
-        print("\n Deramping Application \n", file=stdout_save)
-        logger.info("Deramping Application")
-        burstDerampS = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId_slave) + "_deramp" + ".tif"
-        appDerampSlave = otb.Registry.CreateApplication("SARDeramp")
-        appDerampSlave.SetParameterString("in", os.path.join(burst_dir, burstS))
-        appDerampSlave.SetParameterString("out", os.path.join(burst_dir, burstDerampS))
-        appDerampSlave.SetParameterString("ram", "4000")
-        appDerampSlave.ExecuteAndWriteOutput()
-        
-        ######## SARDoppler Application #######
-        print("\n Doppler Application \n", file=stdout_save)
-        logger.info("Doppler Application")
-        dopFile = open(os.path.join(output_dir, dop_file), "a")
-        dopFile.write("Doppler for slave image : " + os.path.basename(slave_Image_base) + " for burst_index = " + str(burstId_slave) + "\n")
-        dopFile.close()
-        appDoppler0Slave = otb.Registry.CreateApplication("SARDoppler0")
-        appDoppler0Slave.SetParameterString("insar", os.path.join(burst_dir, burstDerampS))
-        appDoppler0Slave.SetParameterString("outfile", os.path.join(output_dir, dop_file))
-        appDoppler0Slave.SetParameterString("ram", "4000")
-        appDoppler0Slave.ExecuteAndWriteOutput()
-
-        dop0Slave.append(appDoppler0Slave.GetParameterFloat('doppler0'))
-
-        ####### SARMultiLook Application #######
-        print("\n MultiLook Application \n", file=stdout_save)
-        logger.info("MultiLook Application")
-        slave_Image_ML = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId_slave) + "_ml" + str(ml_azimut) + str(ml_range) + ".tif"
-        appMultiLookSlave = otb.Registry.CreateApplication("SARMultiLook")
-        appMultiLookSlave.SetParameterString("incomplex", os.path.join(burst_dir, burstDerampS))
-        appMultiLookSlave.SetParameterString("out", os.path.join(burst_dir, slave_Image_ML))
-        appMultiLookSlave.SetParameterInt("mlran",ml_range)
-        appMultiLookSlave.SetParameterInt("mlazi",ml_azimut)
-        appMultiLookSlave.SetParameterFloat("mlgain", ml_gain)
-        appMultiLookSlave.SetParameterString("ram", "4000")
-        appMultiLookSlave.ExecuteAndWriteOutput()
-
-
-    ######################### Ground Chain #############################
-    # Master
-    print("\n Master Ground chain \n", file=stdout_save)
-    logger.info("Master Ground Application")
-
-    gainMaster = []
-    directionDEMMaster = []
-    
-    for id_loop in range(0, len(validBurstMaster)):
-        #burstId = id_loop + firstBurst
-        burstId = validBurstMaster[id_loop]
-        
-        print("\n BurstId = " + str(burstId) + "\n", file=stdout_save)
-        logger.info("BurstId = {ind}".format(ind=burstId))
-
-        burst_dir = os.path.join(output_dir, "burst" + str(burstId))
-
-        burstDerampM = os.path.splitext(master_Image_base)[0] + "_burst" + str(burstId) + "_deramp" + ".tif"
-        
-    
-        ######## SARDEMProjection Application #######
-        print("\n SARDEMProjection Application \n", file=stdout_save)
-        logger.info("SARDEMProjection Application")
-        demProj_Master = "demProj" +  "_burst" + str(burstId) +"_Master.tif"
-        appDEMProjectionMaster = otb.Registry.CreateApplication("SARDEMProjection")
-        appDEMProjectionMaster.SetParameterString("insar", os.path.join(burst_dir, burstDerampM))
-        appDEMProjectionMaster.SetParameterString("indem", dem)
-        appDEMProjectionMaster.SetParameterString("withxyz", "true")
-        appDEMProjectionMaster.SetParameterInt("nodata", -32768)
-        appDEMProjectionMaster.SetParameterString("out", os.path.join(burst_dir, demProj_Master))
-        appDEMProjectionMaster.SetParameterString("ram", "4000")
-        appDEMProjectionMaster.ExecuteAndWriteOutput()
-        
-        gainMaster.append(appDEMProjectionMaster.GetParameterFloat('gain'))
-        directionDEMMaster.append([appDEMProjectionMaster.GetParameterInt('directiontoscandemc'), appDEMProjectionMaster.GetParameterInt('directiontoscandeml')])
-
-        ######### SARCartesianMeanEstimation Application #######
-        print("\n SARCartesianMeanEstimation Application \n", file=stdout_save)
-        logger.info("SARCartesianMeanEstimation Application")
-        master_cartesian_mean = "CartMeanMaster" +  "_burst" + str(burstId) + ".tif"
-        appCartMeanMaster = otb.Registry.CreateApplication("SARCartesianMeanEstimation")
-        appCartMeanMaster.SetParameterString("insar", os.path.join(burst_dir, burstDerampM))
-        appCartMeanMaster.SetParameterString("indem", dem)
-        appCartMeanMaster.SetParameterString("indemproj",  os.path.join(burst_dir, demProj_Master))
-        appCartMeanMaster.SetParameterInt("indirectiondemc", appDEMProjectionMaster.GetParameterInt("directiontoscandemc"))
-        appCartMeanMaster.SetParameterInt("indirectiondeml", appDEMProjectionMaster.GetParameterInt("directiontoscandeml"))
-        appCartMeanMaster.SetParameterInt("mlran", 1)
-        appCartMeanMaster.SetParameterInt("mlazi", 1)
-        appCartMeanMaster.SetParameterString("ram", "4000")
-        appCartMeanMaster.SetParameterString("out",  os.path.join(burst_dir, master_cartesian_mean))
-        appCartMeanMaster.ExecuteAndWriteOutput()
-
-
-    print (directionDEMMaster)
-
-    # Slave
-    print("\n Slave Ground chain \n", file=stdout_save)
-    logger.info("Slave Ground Application")
-
-    gainSlave = []
-    directionDEMSlave = []
-    
-    for id_loop in range(0, len(validBurstMaster)):
-        #burstId = id_loop + firstBurst
-        burstId = validBurstMaster[id_loop]
-        burstId_slave = validBurstSlave[id_loop]
-
-        print("\n BurstId = " + str(burstId) + "\n", file=stdout_save)
-        logger.info("BurstId = {ind}".format(ind=burstId))
-
-        burst_dir = os.path.join(output_dir, "burst" + str(burstId))
-
-        burstDerampS = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId_slave) + "_deramp" + ".tif"
-
-        print("\n SARDEMProjection Application \n", file=stdout_save)
-        logger.info("SARDEMProjection Application")
-        demProj_Slave = "demProj" +  "_burst" + str(burstId_slave) + "_Slave.tif"
-        appDEMProjectionSlave = otb.Registry.CreateApplication("SARDEMProjection")
-        appDEMProjectionSlave.SetParameterString("insar", os.path.join(burst_dir, burstDerampS))
-        appDEMProjectionSlave.SetParameterString("indem", dem)
-        appDEMProjectionSlave.SetParameterString("withxyz", "true");
-        appDEMProjectionSlave.SetParameterInt("nodata", -32768)
-        appDEMProjectionSlave.SetParameterString("out", os.path.join(burst_dir, demProj_Slave))
-        appDEMProjectionSlave.SetParameterString("ram", "4000")
-        appDEMProjectionSlave.ExecuteAndWriteOutput()
-        
-    
-    ######################## DIn_SAR Chain #############################
-    print("\n DIn_SAR chain \n", file=stdout_save)
-    logger.info("DIn_SAR chain")
-
-    counter = 0
-    list_of_Interferograms = []
-    list_of_Grids = []
-    
-    for id_loop in range(0, len(validBurstMaster)):
-        #burstId = id_loop + firstBurst
-        burstId = validBurstMaster[id_loop]
-        burstId_slave = validBurstSlave[id_loop]
-        
-        print("\n BurstId = " + str(burstId) + "\n", file=stdout_save)
-        logger.info("BurstId = {ind}".format(ind=burstId))
-
-        burst_dir = os.path.join(output_dir, "burst" + str(burstId))
-        
-        burstM = os.path.splitext(master_Image_base)[0] + "_burst" + str(burstId) + ".tif"
-        burstS = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId_slave) + ".tif"
-        
-        burstDerampM = os.path.splitext(master_Image_base)[0] + "_burst" + str(burstId) + "_deramp" + ".tif"
-        burstDerampS = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId_slave) + "_deramp" + ".tif"
-
-        master_Image_ML = os.path.splitext(master_Image_base)[0] + "_burst" + str(burstId) + "_ml" + str(ml_azimut) + str(ml_range) + ".tif"
-        slave_Image_ML = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId_slave) + "_ml" + str(ml_azimut) + str(ml_range) + ".tif"
-        
-
-        demProj_Master = "demProj" +  "_burst" + str(burstId) +"_Master.tif"
-        demProj_Slave = "demProj" +  "_burst" + str(burstId_slave) + "_Slave.tif"
-        master_cartesian_mean = "CartMeanMaster" +  "_burst" + str(burstId) + ".tif"
-    
-
-        ######## Step 1 : SARFineDeformationGrid #######
-        ######## SARFineDeformationGrid Application (geo_grid step) #######
-        print("\n SARFineDeformationGrid Application \n", file=stdout_save)
-        logger.info("SARFineDeformationGrid Application")
-        fine_grid = "fineDeformationGrid"+ "_burst" + str(burstId) + ".tif"
-        appFineDeformationGrid = otb.Registry.CreateApplication("SARFineDeformationGrid")
-        appFineDeformationGrid.SetParameterString("indem", dem)
-        appFineDeformationGrid.SetParameterString("insarmaster", os.path.join(burst_dir, burstDerampM))
-        appFineDeformationGrid.SetParameterString("insarslave", os.path.join(burst_dir, burstDerampS))
-        appFineDeformationGrid.SetParameterString("inmlmaster", os.path.join(burst_dir, master_Image_ML))
-        appFineDeformationGrid.SetParameterString("inmlslave", os.path.join(burst_dir, slave_Image_ML))
-        appFineDeformationGrid.SetParameterString("indemprojmaster", os.path.join(burst_dir, demProj_Master))
-        appFineDeformationGrid.SetParameterString("indemprojslave", os.path.join(burst_dir, demProj_Slave))
-        appFineDeformationGrid.SetParameterInt("mlran", ml_geoGrid_range)
-        appFineDeformationGrid.SetParameterInt("mlazi", ml_geoGrid_azimut)
-        appFineDeformationGrid.SetParameterInt("gridsteprange", geoGrid_gridstep_range)
-        appFineDeformationGrid.SetParameterInt("gridstepazimut", geoGrid_gridstep_azimut)
-        appFineDeformationGrid.SetParameterFloat("threshold", geoGrid_threshold)
-        appFineDeformationGrid.SetParameterFloat("gap", geoGrid_gap)
-        appFineDeformationGrid.SetParameterString("advantage", advantage)
-        appFineDeformationGrid.SetParameterString("out", os.path.join(burst_dir, fine_grid))
-        appFineDeformationGrid.SetParameterString("ram", "4000")
-        appFineDeformationGrid.ExecuteAndWriteOutput()
-
-        list_of_Grids.append(os.path.join(burst_dir, fine_grid))
-        
-        ####### Step 3 : SARCoRegistration + SARDeramp + SARRobustInterferogram #######
-        ####### SARCoRegistration Application (changeo step) #######
-        print("\n SARCoRegistration Application \n", file=stdout_save)
-        logger.info("SARCoRegistration Application")
-        slave_Image_CoRe = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId) + "_coregistrated.tif"
-        appCoRegistration = otb.Registry.CreateApplication("SARCoRegistration")
-        appCoRegistration.SetParameterString("insarmaster", os.path.join(burst_dir, burstDerampM))
-        appCoRegistration.SetParameterString("insarslave", os.path.join(burst_dir, burstDerampS))
-        appCoRegistration.SetParameterString("ingrid",  os.path.join(burst_dir, fine_grid))
-        appCoRegistration.SetParameterInt("gridsteprange", geoGrid_gridstep_range)
-        appCoRegistration.SetParameterInt("gridstepazimut", geoGrid_gridstep_azimut)
-        appCoRegistration.SetParameterFloat("doppler0", dop0Slave[burstId-firstBurst])
-        appCoRegistration.SetParameterInt("sizetiles", 50)
-        appCoRegistration.SetParameterInt("margin", 7)
-        appCoRegistration.SetParameterInt("nbramps", 5121) #256*2*10+1
-        appCoRegistration.SetParameterString("ram", "4000")
-        appCoRegistration.SetParameterString("out", os.path.join(burst_dir, slave_Image_CoRe))
-        appCoRegistration.ExecuteAndWriteOutput()
-
-        ######## SARDeramp Application (reramp mode) #######
-        print("\n Deramping Application \n", file=stdout_save)
-        logger.info("Deramping Application")
-        # Slave (CoRegistrated)
-        burstCoReRerampS = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId) + "_coregistrated_reramp" + ".tif"
-        appDerampSlave = otb.Registry.CreateApplication("SARDeramp")
-        appDerampSlave.SetParameterString("in", os.path.join(burst_dir, slave_Image_CoRe))
-        appDerampSlave.SetParameterString("out", os.path.join(burst_dir, burstCoReRerampS))
-        appDerampSlave.SetParameterString("reramp", "true")
-        appDerampSlave.SetParameterString("shift", "true")
-        appDerampSlave.SetParameterString("ingrid", os.path.join(burst_dir, fine_grid))
-        appDerampSlave.SetParameterString("inslave", os.path.join(burst_dir, burstDerampS))
-        appDerampSlave.SetParameterInt("gridsteprange", geoGrid_gridstep_range)
-        appDerampSlave.SetParameterInt("gridstepazimut", geoGrid_gridstep_azimut)
-        appDerampSlave.SetParameterString("ram", "4000")
-        appDerampSlave.ExecuteAndWriteOutput()
-
-        ######## SARRobustInterferogram Application (interf step) #######
-        print("\n SARRobustInterferogram Application \n", file=stdout_save)
-        logger.info("SARRobustInterferogram Application")
-        interferogram_path = os.path.join(burst_dir, "interferogram" + "_burst" + str(burstId) + ".tif")
-        
-        if esd_NbIter > 0 :
-            esd_dir = os.path.join(burst_dir, "esd")
-
-            if not os.path.exists(esd_dir):
-                os.makedirs(esd_dir)
-
-            interferogram_path = os.path.join(esd_dir, "interferogram" + "_burst" + str(burstId) + "_iter" + str(0) + ".tif")
-        
-        appInterferogram = otb.Registry.CreateApplication("SARRobustInterferogram")
-        appInterferogram.SetParameterString("insarmaster", os.path.join(burst_dir, burstM))
-        appInterferogram.SetParameterString("incoregistratedslave", os.path.join(burst_dir, burstCoReRerampS))
-        appInterferogram.SetParameterString("insarslave", os.path.join(burst_dir, burstS))
-        appInterferogram.SetParameterString("ingrid",  os.path.join(burst_dir, fine_grid))
-        appInterferogram.SetParameterString("incartmeanmaster", os.path.join(burst_dir, master_cartesian_mean))
-        appInterferogram.SetParameterInt("mlran", 1)
-        appInterferogram.SetParameterInt("mlazi", 1)
-        appInterferogram.SetParameterInt("marginran", 1)
-        appInterferogram.SetParameterInt("marginazi", 1)
-        appInterferogram.SetParameterInt("gridsteprange", geoGrid_gridstep_range)
-        appInterferogram.SetParameterInt("gridstepazimut", geoGrid_gridstep_azimut)
-        appInterferogram.SetParameterFloat("gain", gain_interfero)
-        appInterferogram.SetParameterString("ram", "4000")
-        appInterferogram.SetParameterString("out", interferogram_path)
-        appInterferogram.ExecuteAndWriteOutput()
-
-        list_of_Interferograms.append(interferogram_path)
-        counter = counter + 1
-
-
-    ######## Step 4 : ESD Loop (SARESD + SARGridOffset + Step 3) #######
-    print ("Beginning of ESD Loop", file=stdout_save)
-    logger.info("Beginning of ESD Loop")
-    
-    if esd_NbIter > 0 :
-        
-        azimut_shift_esd = []
-        azimut_shift_esd_global =  [0.] * (lastBurst-firstBurst)
-        
-        for iter_esd in range(1, esd_NbIter+1) :
-
-            print ("Iteration number = {number}".format(number=iter_esd), file=stdout_save)
-            logger.info("Iteration number = {number}".format(number=iter_esd))
-
-            # Clear all azimut shifts
-            azimut_shift_esd[:] = []
-
-            for id_loop in range(0, len(validBurstMaster)):
-                #burstId = id_loop + firstBurst
-                burstId = validBurstMaster[id_loop]
-            
-                print("\n BurstId = " + str(burstId) + "\n", file=stdout_save)
-                logger.info("BurstId = {ind}".format(ind=burstId))
-                
-                # Paths
-                burst_dir = os.path.join(output_dir, "burst" + str(burstId))
-                esd_dir = os.path.join(burst_dir, "esd")
-                esd_path = os.path.join(esd_dir, "esdOut" + "_burst" + str(burstId) + "_iter" + str(0) + ".tif")
-            
-                # Check number of burst index (not SARESD for lastBurst)
-                if burstId < lastBurst :
-                    ######## SARESD Application #######
-                    print("\n ESD Application \n", file=stdout_save)
-                    logger.info("Beginning of ESD Loop")
-                    appESD = otb.Registry.CreateApplication("SARESD")
-                    appESD.SetParameterString("ininterfup", list_of_Interferograms[burstId-firstBurst])
-                    appESD.SetParameterString("ininterflow", list_of_Interferograms[burstId-firstBurst+1])
-                    appESD.SetParameterString("insar", master_Image)
-                    appESD.SetParameterInt("burstindex", burstId)
-                    appESD.SetParameterFloat("threshold", 0.3)
-                    appESD.SetParameterInt("mlazi", 1)
-                    appESD.SetParameterString("ram", "4000")
-                    appESD.SetParameterString("out", esd_path)
-                    appESD.Execute()
-
-                    azimut_shift_esd.append(appESD.GetParameterFloat('azishift'))
-        
-            # Clear our list of interferograms
-            list_of_Interferograms[:] = []
-            
-            for id_loop in range(0, len(validBurstMaster)):
-                #burstId = id_loop + firstBurst
-                burstId = validBurstMaster[id_loop]
-                burstId_slave = validBurstSlave[id_loop]
-            
-                # Paths
-                burst_dir = os.path.join(output_dir, "burst" + str(burstId))
-                esd_dir = os.path.join(burst_dir, "esd")
-                gridOffset_path = os.path.join(esd_dir, "gridOffOut" + "_burst" + str(burstId) + "_iter" + str(0) + ".tif")
-                
-                burstM = os.path.splitext(master_Image_base)[0] + "_burst" + str(burstId) + ".tif"
-                burstS = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId_slave) + ".tif"
-                burstDerampM = os.path.splitext(master_Image_base)[0] + "_burst" + str(burstId) + "_deramp" + ".tif"
-                burstDerampS = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId_slave) + "_deramp" + ".tif"
-                master_cartesian_mean = "CartMeanMaster" +  "_burst" + str(burstId) + ".tif"
-
-                # Adjust azimut shift according to the burstId
-                aziShift = 0.
-                if burstId == (lastBurst - 1) :
-                    # Only accumulation between iterations
-                    azimut_shift_esd_global[burstId-firstBurst] += azimut_shift_esd[burstId-firstBurst]
-                    aziShift = azimut_shift_esd_global[burstId-firstBurst]
-                elif burstId == lastBurst :
-                    # Same as the lastBurst -1 
-                    aziShift = azimut_shift_esd_global[burstId - 1 - firstBurst]
-                else : 
-                    # Accumulation of means between the current burstId and the next index 
-                    azimut_shift_esd_global[burstId-firstBurst] += ((azimut_shift_esd[burstId-firstBurst] + 
-                                                                     azimut_shift_esd[burstId-firstBurst+1])/2)
-                    aziShift = azimut_shift_esd_global[burstId-firstBurst]
-                
-                # Offset of deformation grid with the azimut shift
-                ######## SARGridOffset Application #######
-                print("\n GridOffset Application \n", file=stdout_save)
-                logger.info("GridOffset Application")
-                appGridOff = otb.Registry.CreateApplication("SARGridOffset")
-                appGridOff.SetParameterString("ingrid", list_of_Grids[burstId-firstBurst])
-                appGridOff.SetParameterFloat("offsetran", 0.)
-                appGridOff.SetParameterFloat("offsetazi", aziShift)
-                appGridOff.SetParameterString("ram", "4000")
-                appGridOff.SetParameterString("out", gridOffset_path)
-                appGridOff.Execute()
-
-                ######## Step 3 : SARCoRegistration + SARDeramp + SARRobustInterferogram #######
-                ######## SARCoRegistration Application (changeo step) #######
-                print("\n SARCoRegistration Application \n", file=stdout_save)
-                logger.info("SARCoRegistration Application")
-                slave_Image_CoRe = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId) + "_coregistrated.tif"
-                appCoRegistration = otb.Registry.CreateApplication("SARCoRegistration")
-                appCoRegistration.SetParameterString("insarmaster", os.path.join(burst_dir, burstDerampM))
-                appCoRegistration.SetParameterString("insarslave", os.path.join(burst_dir, burstDerampS))
-                appCoRegistration.SetParameterInputImage("ingrid", appGridOff.GetParameterOutputImage("out"))
-                appCoRegistration.SetParameterInt("gridsteprange", geoGrid_gridstep_range)
-                appCoRegistration.SetParameterInt("gridstepazimut", geoGrid_gridstep_azimut)
-                appCoRegistration.SetParameterFloat("doppler0", dop0Slave[burstId-firstBurst])
-                appCoRegistration.SetParameterInt("sizetiles", 50)
-                appCoRegistration.SetParameterInt("margin", 7)
-                appCoRegistration.SetParameterInt("nbramps", 5121) #256*2*10+1
-                appCoRegistration.SetParameterString("ram", "4000")
-                appCoRegistration.SetParameterString("out", os.path.join(esd_dir, slave_Image_CoRe))
-                appCoRegistration.Execute()
-            
-                ######## SARDeramp Application (reramp mode) #######
-                print("\n Deramping Application \n", file=stdout_save)
-                logger.info("Deramping Application")
-                # Slave (CoRegistrated)
-                burstCoReRerampS = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId) + "_coregistrated_reramp" + ".tif"
-                appDerampSlave = otb.Registry.CreateApplication("SARDeramp")
-                appDerampSlave.SetParameterInputImage("in", 
-                                                      appCoRegistration.GetParameterOutputImage("out"))
-                appDerampSlave.SetParameterString("out", os.path.join(esd_dir, burstCoReRerampS))
-                appDerampSlave.SetParameterString("reramp", "true")
-                appDerampSlave.SetParameterString("shift", "true")
-                appDerampSlave.SetParameterInputImage("ingrid", appGridOff.GetParameterOutputImage("out"))
-                appDerampSlave.SetParameterString("inslave", os.path.join(burst_dir, burstDerampS))
-                appDerampSlave.SetParameterInt("gridsteprange", geoGrid_gridstep_range)
-                appDerampSlave.SetParameterInt("gridstepazimut", geoGrid_gridstep_azimut)
-                appDerampSlave.SetParameterString("ram", "4000")
-                appDerampSlave.Execute()
-                
-                ######## SARRobustInterferogram Application (interf step) #######
-                print("\n SARRobustInterferogram Application \n", file=stdout_save)
-                logger.info("SARRobustInterferogram Application")
-                interferogram_path = os.path.join(esd_dir, "interferogram" + "_burst" + str(burstId) + "_iter" + str(iter_esd) + ".tif")
-                
-                appInterferogram = otb.Registry.CreateApplication("SARRobustInterferogram")
-                appInterferogram.SetParameterString("insarmaster", os.path.join(burst_dir, burstM))
-                appInterferogram.SetParameterInputImage("incoregistratedslave", 
-                                                               appDerampSlave.GetParameterOutputImage("out"))
-                appInterferogram.SetParameterString("insarslave", os.path.join(burst_dir, burstS))
-                appInterferogram.SetParameterInputImage("ingrid", appGridOff.GetParameterOutputImage("out"))
-                appInterferogram.SetParameterString("incartmeanmaster", 
-                                                    os.path.join(burst_dir, master_cartesian_mean))
-                appInterferogram.SetParameterInt("mlran", 1)
-                appInterferogram.SetParameterInt("mlazi", 1)
-                appInterferogram.SetParameterInt("marginran", 1)
-                appInterferogram.SetParameterInt("marginazi", 1)
-                appInterferogram.SetParameterInt("gridsteprange", geoGrid_gridstep_range)
-                appInterferogram.SetParameterInt("gridstepazimut", geoGrid_gridstep_azimut)
-                appInterferogram.SetParameterFloat("gain", gain_interfero)
-                appInterferogram.SetParameterString("ram", "4000")
-                appInterferogram.SetParameterString("out", interferogram_path)
-                appInterferogram.ExecuteAndWriteOutput()
-                    
-                # Store the new interferogram paths
-                list_of_Interferograms.append(interferogram_path)
-        
-            # Check azimuth shift to end esd loop if automatic mode enabled
-            if esd_AutoMode : 
-                absMax_aziShift = abs(max(azimut_shift_esd_global, key=abs))
-                if absMax_aziShift < 0.01 :
-                    break
-        
-    ######## Step 5 : SARConcatenateBursts #######
-    ######### SARConcatenateBursts (for interferograms) #########
-    print("\n SARConcatenateBursts Application (for interferograms) \n", file=stdout_save)
-    logger.info("SARConcatenateBursts Application")
-    interferogram_swath = "interferogram_swath.tif"
-    appCon = otb.Registry.CreateApplication("SARConcatenateBursts")
-    appCon.SetParameterStringList("il", list_of_Interferograms)
-    appCon.SetParameterString("insar", master_Image)
-    appCon.SetParameterInt("burstindex", firstBurst)
-    appCon.SetParameterString("out", os.path.join(output_dir, interferogram_swath))
-    appCon.SetParameterString("ram", "4000")
-    appCon.ExecuteAndWriteOutput()
-    
-
-    print("\n End of DiapOTB processing (S1 IW mode) \n", file=stdout_save)
-    logger.info("############ End of DiapOTB processing  (S1 IW mode) ##############")
diff --git a/python_src/ex_config/ex_config_MultiSlc_CosmoS1SM.json b/python_src/ex_config/ex_config_MultiSlc_CosmoS1SM.json
new file mode 100644
index 0000000..ebd6587
--- /dev/null
+++ b/python_src/ex_config/ex_config_MultiSlc_CosmoS1SM.json
@@ -0,0 +1,61 @@
+{
+    "Global": {
+        "in":
+        {
+            "SRTM_Shapefile": "pathToSHP/srtm.shp",
+            "SRTM_Path": "pathToSRTM_30_hgt/",
+            "Geoid": "pathToGeoid/egm96.grd",
+            "Master_Image": "image_1.tiff",
+            "Start_Date": "20150809",
+            "End_Date": "20150902",
+            "Input_Path": "pathToInputDir"
+        },
+        "out":
+        {
+            "Output_Path": "pathToOutputDir"
+        },
+        "parameter":
+        {
+            "clean" : "true"
+        }
+    },
+
+    "Pre_Processing": {
+        "out":
+        {
+            "doppler_file": "dop0.txt"
+        },
+        "parameter":
+        {
+            "ML_gain": 0.1,
+            "ML_ran": 3,
+            "ML_azi": 3
+        }
+    },
+    "Metadata_Correction":
+    {
+        "out":
+        {
+            "fine_metadata_file": "fine_metadata.txt"
+        },
+        "parameter":
+        {
+            "activate": false,
+            "GridStep_range": 150,
+            "GridStep_azimut": 150
+        }
+    },
+    "DIn_SAR":
+    {
+        "parameter":
+        {
+            "GridStep_range": 150,
+            "GridStep_azimut": 150,
+            "Grid_Threshold": 0.3,
+            "Grid_Gap": 1000,
+            "Interferogram_gain": 0.1,
+            "Activate_Interferogram": "yes",
+            "Spacingxy": 0.0001
+        }
+    }
+}
diff --git a/python_src/ex_config/ex_config_MultiSlc_IW.json b/python_src/ex_config/ex_config_MultiSlc_IW.json
new file mode 100644
index 0000000..64f3043
--- /dev/null
+++ b/python_src/ex_config/ex_config_MultiSlc_IW.json
@@ -0,0 +1,51 @@
+{
+    "Global": {
+        "in":
+        {
+            "SRTM_Shapefile": "pathToSHP/srtm.shp",
+            "SRTM_Path": "pathToSRTM_30_hgt/",
+            "Geoid": "pathToGeoid/egm96.grd",
+            "Master_Image": "image_1.tiff",
+            "Start_Date": "20150809",
+            "End_Date": "20150902",
+            "Input_Path": "pathToInputDir"
+        },
+        "out":
+        {
+            "Output_Path": "pathToOutputDir"
+        },
+        "parameter":
+        {
+            "clean" : "true",
+            "burst_index": "0-8",
+            "optram" : 4000
+        }
+    },
+
+    "Pre_Processing": {
+        "out":
+        {
+            "doppler_file": "dop0.txt"
+        },
+        "parameter":
+        {
+	    "ML_ran": 5,
+ 	    "ML_azi": 1,
+            "ML_gain": 0.1
+        }
+    },
+    "Ground": {},
+    "DIn_SAR":
+    {
+        "parameter":
+        {
+            "GridStep_range": 25,
+            "GridStep_azimut": 5,
+            "Grid_Threshold": 0.3,
+            "Grid_Gap": 1000,
+            "Interferogram_gain": 0.1,
+	    "ESD_iter": 2
+        }
+    }
+}
+
diff --git a/python_src/ex_config_Cosmo.json b/python_src/ex_config/ex_config_diapOTB_Cosmo.json
similarity index 100%
rename from python_src/ex_config_Cosmo.json
rename to python_src/ex_config/ex_config_diapOTB_Cosmo.json
diff --git a/python_src/ex_config_S1IW.json b/python_src/ex_config/ex_config_diapOTB_S1IW.json
similarity index 100%
rename from python_src/ex_config_S1IW.json
rename to python_src/ex_config/ex_config_diapOTB_S1IW.json
diff --git a/python_src/ex_config_S1SM.json b/python_src/ex_config/ex_config_diapOTB_S1SM.json
similarity index 100%
rename from python_src/ex_config_S1SM.json
rename to python_src/ex_config/ex_config_diapOTB_S1SM.json
-- 
GitLab