Commit fb4df269 authored by Lozac'h Loic's avatar Lozac'h Loic

Add modelchoice to pipeline serie

parent 0e14cdb0
......@@ -12,7 +12,7 @@ from osgeo import gdal, osr, ogr
from subprocess import Popen, PIPE
maskedlabels, labels, vectorlabels, labelsfield, lulc, agrivalues, ndvi, sarvv, \
slope, slopevalue, sarth, modeldir, output, outformat, sarmode = "","","","","","","","","","","","","","",""
slope, slopevalue, sarth, modeldir, modelchoice, output, outformat, sarmode = "","","","","","","","","","","","","","","",""
def search_files(directory='.', resolution='NDVI', extension='tif', fictype='f'):
......@@ -367,7 +367,14 @@ def wet_or_dry_pipeline(args):
res=select_tfmodel_from_gpm(sardate, args.gpmdir)
def get_model4invertion():
sardate = os.path.basename(sarvv.split("_"))[4]
with open(modelchoice) as mc:
for line in mc:
sline = line.split(";")
if sline[0] == sardate :
return sline[2][:-1]
def short_pipeline(intersectionEnv):
global slopevalue
......@@ -463,13 +470,17 @@ def short_pipeline(intersectionEnv):
print("End of Slope Filtering \n")
if not modelchoice == None :
choix = get_model4invertion()
modelchoix = os.path.join(modeldir,"SavedModel_"+choix)
modelchoix = modeldir
# The following line creates an instance of the Superimpose application
app5 = otbApplication.Registry.CreateApplication("InvertSARModel")
app5.SetParameterInputImage("insarth", app2.GetParameterOutputImage("out") )
app5.SetParameterInputImage("inndvi", app3.GetParameterOutputImage("out")) #ndvisup)
app5.SetParameterInputImage("inlabels", app4.GetParameterOutputImage("out")) # labelssup)
app5.SetParameterString("model.dir", modeldir)
app5.SetParameterString("model.dir", modelchoix)
if not slope == None and len(slope) > 2:
app5.SetParameterInputImage("insarvv", appS.GetParameterOutputImage("out"))
......@@ -728,7 +739,8 @@ if __name__ == "__main__":
# SAR Series pipeline
list_parser = subparsers.add_parser('serie', help="Batch inversion pipeline over a directory of Sentinel-1 images")
list_parser.add_argument('-modeldir', action='store', required=True, help='Directory to find tensorflow model (dry or wet)')
list_parser.add_argument('-modeldir', action='store', required=True, help='Directory to find both wet and dry tensorflow model')
list_parser.add_argument('-modelchoice', action='store', required=False, help='[Optional] Results text file from gpm pipeline')
list_parser.add_argument('-sardir', action='store', required=True, help='Directory to find Sentinel-1 images ')
list_parser.add_argument('-sardirtype', choices=['snap', 's2tile'], default='s2tile', required=False, help='[Optional] Choose between Sentinel-1 images processed by ESA-SNAP software ("Sigma0_VV.img" and "incidenceAngleFromEllipsoid.img" in .data directory) \
AND Sentinel-1 images processed by')
......@@ -868,6 +880,7 @@ if __name__ == "__main__":
modeldir = args.modeldir
modelchoice = args.modelchoice
maskedlabels = args.maskedlabels
slope = args.slope
slopevalue = args.slopevalue
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment