From b703fa77d4a53ede88e90e9c4dd6d1e69700f355 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ga=C3=ABlle=20USSEGLIO?= <gaelle.usseglio@cnes.fr>
Date: Mon, 17 Dec 2018 12:49:53 +0000
Subject: [PATCH] ENH : New chain for IW processing (part 2 : Ground and DINSAR
 chain

---
 include/otbSARInterferogramImageFilter.txx |  12 +-
 python_src/diapOTB_S1IW.py                 | 307 +++++++++++++--------
 python_src/ex_config_S1IW.ini              |   8 +-
 3 files changed, 203 insertions(+), 124 deletions(-)

diff --git a/include/otbSARInterferogramImageFilter.txx b/include/otbSARInterferogramImageFilter.txx
index 92a6791..dbd00a1 100644
--- a/include/otbSARInterferogramImageFilter.txx
+++ b/include/otbSARInterferogramImageFilter.txx
@@ -322,10 +322,10 @@ namespace otb
      ///////// Checks margin with ML factors (for averaging) /////////////
      if (m_MLRan != 0 || m_MLAzi != 0)
        {
-	 if (m_MLRan < m_MarginRan || m_MLAzi < m_MarginAzi)
-	   {
-	     itkExceptionMacro(<<"Margin for averaging can't be superior to ML Factors.");   
-	   } 
+	 //if (m_MLRan < m_MarginRan || m_MLAzi < m_MarginAzi)
+	 // {
+	 //   itkExceptionMacro(<<"Margin for averaging can't be superior to ML Factors.");   
+	 // } 
        }
 
     
@@ -888,8 +888,10 @@ namespace otb
 		    double mod_Acc = sqrt(complexMulConjTab_Re[colCounter]*complexMulConjTab_Re[colCounter] + 
 					  complexMulConjTab_Im[colCounter]*complexMulConjTab_Im[colCounter]);
 
+		    int countPixel = (m_MLRan + 2*m_MarginRan) * (m_MLAzi + 2*m_MarginAzi);
+
 		    // Amplitude
-		    outPixel[0] = m_Gain * sqrt((complexMulConjTab_Mod[colCounter]/(m_MLRan*m_MLAzi)));
+		    outPixel[0] = m_Gain * sqrt((complexMulConjTab_Mod[colCounter]/(countPixel)));
 		    
 		    // Phase
 		    outPixel[1] = std::atan2(complexMulConjTab_Im[colCounter], 
diff --git a/python_src/diapOTB_S1IW.py b/python_src/diapOTB_S1IW.py
index b454a18..145bb9d 100644
--- a/python_src/diapOTB_S1IW.py
+++ b/python_src/diapOTB_S1IW.py
@@ -68,7 +68,7 @@ def ConfigCheck(config):
     globalList = ["Master_Image_Path", "Slave_Image_Path", "DEM_Path", "output_dir", "burst_index"]
     preProcessingList = ["ML_range", "ML_azimut", "ML_gain", "doppler_file"]
     GroundList = []
-    dInSARList = []
+    dInSARList = ["GridStep_range", "GridStep_azimut", "Grid_Threshold", "Grid_Gap", "Interferogram_gain"]
 
     dictOfSections = {'Global': globalList, 'Pre_Processing': preProcessingList, 'Ground' : GroundList, 'DIn_SAR' : dInSARList}
 
@@ -130,17 +130,18 @@ if __name__ == "__main__":
     # Ground
     
     # DIn_SAR
-    # geoGrid_gridstep_range = int(ConfigSectionMap(Config, "DIn_SAR")['gridstep_range'])
-    # geoGrid_gridstep_azimut = int(ConfigSectionMap(Config, "DIn_SAR")['gridstep_azimut'])
-    # geoGrid_threshold = float(ConfigSectionMap(Config, "DIn_SAR")['grid_threshold'])
-    # geoGrid_gap = float(ConfigSectionMap(Config, "DIn_SAR")['grid_gap'])
-    # ml_geoGrid_range = ml_range
-    # ml_geoGrid_azimut = ml_azimut
-    # gain_interfero = float(ConfigSectionMap(Config, "DIn_SAR")['interferogram_gain'])
-    # activateOrthoInterferogram = str2bool(ConfigSectionMap(Config, "DIn_SAR")['interferogram_ortho'])
+    geoGrid_gridstep_range = int(ConfigSectionMap(Config, "DIn_SAR")['gridstep_range'])
+    geoGrid_gridstep_azimut = int(ConfigSectionMap(Config, "DIn_SAR")['gridstep_azimut'])
+    geoGrid_threshold = float(ConfigSectionMap(Config, "DIn_SAR")['grid_threshold'])
+    geoGrid_gap = float(ConfigSectionMap(Config, "DIn_SAR")['grid_gap'])
+    ml_geoGrid_range = ml_range
+    ml_geoGrid_azimut = ml_azimut
+    gain_interfero = float(ConfigSectionMap(Config, "DIn_SAR")['interferogram_gain'])
+    activateOrthoInterferogram = str2bool(ConfigSectionMap(Config, "DIn_SAR")['interferogram_ortho'])
 
-    # if (geoGrid_threshold < 0) or (geoGrid_threshold > 1) :
-    #     print("Wrong Threshold for fine deformation grid")
+    if (geoGrid_threshold < 0) or (geoGrid_threshold > 1) :
+        print("Wrong Threshold for fine deformation grid")
+        geoGrid_threshold = 0.3
 
 
     # Check if images exist
@@ -269,7 +270,7 @@ if __name__ == "__main__":
 
         ####### SARMultiLook Application #######
         print("\n MultiLook Application \n")
-        master_Image_ML = os.path.splitext(master_Image_base)[0] + "_burst " + str(burstId) + "_ml" + str(ml_azimut) + str(ml_range) + ".tif"
+        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))
@@ -324,7 +325,7 @@ if __name__ == "__main__":
 
         ####### SARMultiLook Application #######
         print("\n MultiLook Application \n")
-        slave_Image_ML = os.path.splitext(slave_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) + "_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))
@@ -336,117 +337,187 @@ if __name__ == "__main__":
 
 
     ######################### Ground Chain #############################
+    # Master
+    print("\n Master Ground chain \n")
+
+    gainMaster = []
+    directionDEMMaster = []
+    
+    for burstId in range(firstBurst, lastBurst+1):
+        
+        print("\n BurstId = " + str(burstId) + "\n")
+
+        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")
+        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.SetParameterEmpty("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")
+        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")
 
+    gainSlave = []
+    directionDEMSlave = []
+    
+    for burstId in range(firstBurst, lastBurst+1):
+        
+        print("\n BurstId = " + str(burstId) + "\n")
+
+        burst_dir = os.path.join(output_dir, "burst" + str(burstId))
+
+        burstDerampS = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId) + "_deramp" + ".tif"
+        
+        demProj_Slave = "demProj" +  "_burst" + str(burstId) + "_Slave.tif"
+        appDEMProjectionSlave = otb.Registry.CreateApplication("SARDEMProjection")
+        appDEMProjectionSlave.SetParameterString("insar", os.path.join(burst_dir, burstDerampS))
+        appDEMProjectionSlave.SetParameterString("indem", dem)
+        appDEMProjectionSlave.SetParameterEmpty("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 #############################
-    # ######## SARDEMProjection Application #######
-    # print("\n SARDEMProjection Application \n")
-    # # 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.SetParameterEmpty("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.SetParameterEmpty("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")
-    # 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.SetParameterInt("patchsize", 20)
-    # appFineDeformationGrid.SetParameterInt("subpixel", 10)
-    # appFineDeformationGrid.SetParameterFloat("threshold", geoGrid_threshold)
-    # appFineDeformationGrid.SetParameterFloat("gap", geoGrid_gap)
-    # appFineDeformationGrid.SetParameterString("out", os.path.join(output_dir, fine_grid))
-    # appFineDeformationGrid.SetParameterString("ram", "4000")
-    # appFineDeformationGrid.ExecuteAndWriteOutput()
+    print("\n DIn_SAR chain \n")
 
+    counter = 0
     
-    # ######## SARCoRegistration Application (changeo step) #######
-    # print("\n SARCoRegistration Application \n")
-    # 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()
+    for burstId in range(firstBurst, lastBurst+1):
+        
+        print("\n BurstId = " + str(burstId) + "\n")
+
+        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) + ".tif"
+        
+        burstDerampM = os.path.splitext(master_Image_base)[0] + "_burst" + str(burstId) + "_deramp" + ".tif"
+        #burstDerampM = os.path.join("/work/ADM/hpc/ussegliog/Diapason/DiapOTB/Test_Data_Diapason/IW_firstTest_SACLAY/Diapason/burst" + str(burstId),  "14780_SLC_DERAMP.tiff")
+        burstDerampS = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId) + "_deramp" + ".tif"
+        #burstDerampS = os.path.join("/work/ADM/hpc/ussegliog/Diapason/DiapOTB/Test_Data_Diapason/IW_firstTest_SACLAY/Diapason/burst" + str(burstId),  "14955_SLC_DERAMP.tiff")
+
+        master_Image_ML = os.path.splitext(master_Image_base)[0] + "_burst" + str(burstId) + "_ml" + str(ml_azimut) + str(ml_range) + ".tif"
+        #master_Image_ML = os.path.join("/work/ADM/hpc/ussegliog/Diapason/DiapOTB/Test_Data_Diapason/IW_firstTest_SACLAY/Diapason/burst" + str(burstId),  "14780_ml15.tiff")
+        slave_Image_ML = os.path.splitext(slave_Image_base)[0] + "_burst" + str(burstId) + "_ml" + str(ml_azimut) + str(ml_range) + ".tif"
+        #slave_Image_ML = os.path.join("/work/ADM/hpc/ussegliog/Diapason/DiapOTB/Test_Data_Diapason/IW_firstTest_SACLAY/Diapason/burst" + str(burstId),  "14955_ml15.tiff")
+        
+
+        demProj_Master = "demProj" +  "_burst" + str(burstId) +"_Master.tif"
+        demProj_Slave = "demProj" +  "_burst" + str(burstId) + "_Slave.tif"
+        master_cartesian_mean = "CartMeanMaster" +  "_burst" + str(burstId) + ".tif"
+    
+        ######## SARFineDeformationGrid Application (geo_grid step) #######
+        print("\n SARFineDeformationGrid Application \n")
+        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.SetParameterInt("patchsize", 20)
+        appFineDeformationGrid.SetParameterInt("subpixel", 10)
+        appFineDeformationGrid.SetParameterFloat("threshold", geoGrid_threshold)
+        appFineDeformationGrid.SetParameterFloat("gap", geoGrid_gap)
+        appFineDeformationGrid.SetParameterString("out", os.path.join(burst_dir, fine_grid))
+        appFineDeformationGrid.SetParameterString("ram", "4000")
+        appFineDeformationGrid.ExecuteAndWriteOutput()
 
     
-    # ######## SARCartesianMeanEstimation Application #######
-    # print("\n SARCartesianMeanEstimation Application \n")
-    # # 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")
-    # interferogram = "interferogram.tif"
-    # interferogram_ortho = "interferogram_ortho.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))
-    # if activateOrthoInterferogram :
-    #     appInterferogram.SetParameterEmpty("ortho", True)
-    #     appInterferogram.SetParameterString("indem", dem)
-    #     appInterferogram.SetParameterString("outopt", os.path.join(output_dir, interferogram_ortho))
-    # appInterferogram.ExecuteAndWriteOutput()
+        ######## SARCoRegistration Application (changeo step) #######
+        print("\n SARCoRegistration Application \n")
+        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[counter])
+        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")
+         # 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("ram", "4000")
+        appDerampSlave.ExecuteAndWriteOutput()
+
+        ######## SARRobustInterferogram Application (interf step) #######
+        print("\n SARRobustInterferogram Application \n")
+        interferogram = "interferogram" + "_burst" + str(burstId) + ".tif"
+        interferogram_ortho = "interferogram_ortho" + "_burst" + str(burstId) + ".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("insarmaster", os.path.join(burst_dir, burstDerampM))
+        #appInterferogram.SetParameterString("incoregistratedslave", os.path.join(burst_dir, slave_Image_CoRe))
+        #appInterferogram.SetParameterString("insarslave", os.path.join(burst_dir, burstDerampS))
+        appInterferogram.SetParameterString("ingrid",  os.path.join(burst_dir, fine_grid))
+        appInterferogram.SetParameterString("incartmeanmaster", os.path.join(burst_dir, master_cartesian_mean))
+        #appInterferogram.SetParameterInt("mlran", ml_range)
+        #appInterferogram.SetParameterInt("mlazi", ml_azimut)
+        appInterferogram.SetParameterInt("mlran", 1)
+        appInterferogram.SetParameterInt("mlazi", 1)
+        appInterferogram.SetParameterInt("marginran", 16)
+        appInterferogram.SetParameterInt("marginazi", 4)
+        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(burst_dir, interferogram))
+        if activateOrthoInterferogram :
+            appInterferogram.SetParameterEmpty("ortho", True)
+            appInterferogram.SetParameterString("indem", dem)
+            appInterferogram.SetParameterString("outopt", os.path.join(burst_dir, interferogram_ortho))
+        appInterferogram.ExecuteAndWriteOutput()
+
+        counter = counter + 1
diff --git a/python_src/ex_config_S1IW.ini b/python_src/ex_config_S1IW.ini
index 493e3d8..27a9942 100644
--- a/python_src/ex_config_S1IW.ini
+++ b/python_src/ex_config_S1IW.ini
@@ -15,4 +15,10 @@ doppler_file = dop0.txt
 
 
 
-[DIn_SAR]
\ No newline at end of file
+[DIn_SAR]
+GridStep_range = 150	
+GridStep_azimut = 150
+Grid_Threshold = 0.3
+Grid_Gap = 0.7
+Interferogram_gain = 0.
+Interferogram_ortho = no
\ No newline at end of file
-- 
GitLab