Commit a2538635f3baf347f6e3a45e838b273668a43d5b

Authored by Arthur Vincent
1 parent 971b4e89

ENH : Sentinel-2 validation on sequential mode

data/Config_4Tiles_L8.cfg
... ... @@ -22,10 +22,11 @@ chain:
22 22 #groundTruth:'/mnt/data/home/morind/THEIA_OSO/testChaine/RefData/2014/FR_ALL_2014_V1_ero1cm.shp'
23 23 groundTruth:'/mnt/data/home/vincenta/Shape/FakeData_France.shp'
24 24 dataField:'CODE'
25   - regionPath:'/mnt/data/home/vincenta/Shape/4Tiles_Test.shp'
  25 + #regionPath:'/mnt/data/home/vincenta/Shape/4Tiles_Test.shp'
  26 + regionPath:'/mnt/data/home/vincenta/Shape/Fake_EcoClim_4Tiles.shp'
26 27 regionField:'region'
27 28 model:'/mnt/data/home/vincenta/tmp/2models4Tiles.txt'
28   - mode:'one_region'#one_region or multi_regions or outside
  29 + mode:'outside'#one_region or multi_regions or outside
29 30 runs:'1'
30 31 logPath:''
31 32 ratio:'0.7'
... ...
scripts/common/New_ProcessingChain.py
... ... @@ -21,7 +21,7 @@ python New_ProcessingChain.py -cf /mnt/data/home/vincenta/THEIA_OSO/conf/ConfigC
21 21 """
22 22 import os,sys
23 23 import glob
24   -import argparse
  24 +import argparse,time,shutil
25 25  
26 26 import New_DataProcessing as DP
27 27  
... ... @@ -35,7 +35,10 @@ from Sensors import Spot4
35 35 from Sensors import Landsat8
36 36 from Sensors import Landsat5
37 37 from Sensors import Formosat
  38 +from Sensors import Sentinel_2
38 39 from config import Config
  40 +import fileUtils as fu
  41 +
39 42 interp = dico.interp
40 43 res = dico.res
41 44  
... ... @@ -111,6 +114,9 @@ else:
111 114 parser.add_argument("-iS",dest="ipathS4",action="store",\
112 115 help="Spot Image path",default = None)
113 116  
  117 + parser.add_argument("-iS2", dest="ipathS2", action="store", \
  118 + help="Sentinel2 Image path", default = None)
  119 +
114 120 parser.add_argument("-iF", dest="ipathF", action="store", \
115 121 help=" Formosat Image path",default = None)
116 122  
... ... @@ -212,7 +218,7 @@ imRef = list_Sensor[0].imRef
212 218 sensorRef = list_Sensor[0].name
213 219  
214 220 StackName = fu.getFeatStackName(args.config)
215   -Stack = args.wOut+"/Final/"+StackName
  221 +Stack = args.opath+"/Final/"+StackName
216 222 if not os.path.exists(Stack):
217 223 #Step 1 Creation des masques de bords
218 224 Step = 1
... ... @@ -306,13 +312,21 @@ if not os.path.exists(Stack):
306 312  
307 313 AllFeatures = fu.FileSearch_AND(args.opath,True,"Features",".tif")
308 314 if len(AllFeatures)==1:
309   - if not os.path.exists(args.wOut+"/Final/"):
310   - os.system("mkdir "+args.wOut+"/Final/")
  315 + if not os.path.exists(args.opath+"/Final/"):
  316 + os.system("mkdir "+args.opath+"/Final/")
311 317 shutil.copy(AllFeatures[0],Stack)
  318 + os.remove(AllFeatures[0])
312 319 elif len(AllFeatures)>1:
313   - AllFeatures = " ".join(AllFeatures)
314   - cmd = "otbcli_ConcatenateImages -il "+AllFeatures+" -out "+args.opath+"/Final/"+StackName
  320 + AllFeatures_s = " ".join(AllFeatures)
  321 + cmd = "otbcli_ConcatenateImages -il "+AllFeatures_s+" -out "+args.opath+"/Final/"+StackName
315 322 print cmd
316 323 os.system(cmd)
  324 + for feat in AllFeatures:
  325 + os.remove(feat)
317 326 else:
318 327 raise Exception("No features detected")
  328 +
  329 +
  330 +
  331 +
  332 +
... ...
scripts/common/genCmdFeatures.py
... ... @@ -16,6 +16,7 @@
16 16  
17 17 import argparse,os
18 18 from config import Config
  19 +import fileUtils as fu
19 20  
20 21 def getDateLandsat(pathLandsat,tiles,sensor="Landsat8"):
21 22 """
... ... @@ -96,7 +97,7 @@ def CmdFeatures(testPath,tiles,appliPath,pathL8,pathL5,pathS2,pathConfig,pathout
96 97 os.system("mkdir "+pathout+"/"+tiles[i])
97 98 if pathWd == None:
98 99 #Sequential mode
99   - Allcmd.append("python "+appliPath+"/New_ProcessingChain.py -cf "+pathConfig+" -iL8 "+pathL8+"/Landsat8_"+tiles[i]+" -iL5 "+pathL5+"/Landsat5_"+tiles[i]+" -w "+pathout+"/"+tiles[i]+" --db_L5 "+begDateL5+" --de_L5 "+endDateL5+" --db_L8 "+begDateL8+" --de_L8 "+endDateL8+" -g "+gap+" -wr "+wr+" --db_S2 "+begDateL8+" --de_S2 "+endDateS2)
  100 + Allcmd.append("python "+appliPath+"/New_ProcessingChain.py -cf "+pathConfig+" -iL8 "+pathL8+"/Landsat8_"+tiles[i]+" -iL5 "+pathL5+"/Landsat5_"+tiles[i]+" -w "+pathout+"/"+tiles[i]+" --db_L5 "+begDateL5+" --de_L5 "+endDateL5+" --db_L8 "+begDateL8+" --de_L8 "+endDateL8+" -g "+gap+" -wr "+wr+" -iS2 "+pathS2+"/"+tiles[i]+" --db_S2 "+begDateS2+" --de_S2 "+endDateS2)
100 101 else :
101 102 # HPC
102 103 Allcmd.append("python "+appliPath+"/processingFeat_hpc.py -cf "+pathConfig+" -iL8 "+pathL8+"/Landsat8_"+tiles[i]+" -iL5 "+pathL5+"/Landsat5_"+tiles[i]+" -w $TMPDIR --db_L8 "+begDateL8+" --de_L8 "+endDateL8+" --db_L5 "+begDateL5+" --de_L5 "+endDateL5+" -g "+gap+" -wr "+wr+" --wo "+pathout+"/"+tiles[i]+" -iS2 "+pathS2+"/"+tiles[i]+" --db_S2 "+begDateS2+" --de_S2 "+endDateS2+" > "+logPath+"/"+tiles[i]+"_feat.txt")
... ...
scripts/common/launchChain.py
... ... @@ -111,7 +111,7 @@ def gen_oso_sequential(Fileconfig):
111 111 raise Exception("you can't choose the 'one region' mode and use the fusion mode together")
112 112  
113 113 import launchChainSequential as lcs
114   - lcs.launchChainSequential(TESTPATH, LISTTILE, L8PATH, L5PATH, PYPATH, TILEPATH, Fileconfig, PATHREGION, REGIONFIELD, MODEL, GROUNDTRUTH, DATAFIELD, Fileconfig, Nsample, REARRANGE_PATH,MODE,REARRANGE_FLAG,CLASSIFMODE,NOMENCLATURE,COLORTABLE,RATIO)
  114 + lcs.launchChainSequential(TESTPATH, LISTTILE, L8PATH, L5PATH, S2PATH, PYPATH, TILEPATH, Fileconfig, PATHREGION, REGIONFIELD, MODEL, GROUNDTRUTH, DATAFIELD, Fileconfig, Nsample, REARRANGE_PATH,MODE,REARRANGE_FLAG,CLASSIFMODE,NOMENCLATURE,COLORTABLE,RATIO)
115 115  
116 116 def gen_jobGenCmdFeatures(JOBPATH,LOGPATH,Fileconfig):
117 117 jobFile = open(JOBPATH,"w")
... ...
scripts/common/launchChainSequential.py
... ... @@ -35,7 +35,7 @@ import fileUtils as fu
35 35 import genCmdSplitShape as genCmdSplitS
36 36 import shutil
37 37  
38   -def launchChainSequential(PathTEST, tiles, pathTilesL8, pathTilesL5,pathNewProcessingChain, pathTilesFeat, configFeature, shapeRegion, field_Region, model, shapeData, dataField, pathConf, N, REARRANGE_PATH,MODE,REARRANGE_FLAG,CLASSIFMODE,NOMENCLATURE,COLORTABLE,RATIO):
  38 +def launchChainSequential(PathTEST, tiles, pathTilesL8, pathTilesL5, pathTilesS2, pathNewProcessingChain, pathTilesFeat, configFeature, shapeRegion, field_Region, model, shapeData, dataField, pathConf, N, REARRANGE_PATH,MODE,REARRANGE_FLAG,CLASSIFMODE,NOMENCLATURE,COLORTABLE,RATIO):
39 39  
40 40  
41 41 if PathTEST!="/" and os.path.exists(PathTEST):
... ... @@ -90,7 +90,7 @@ def launchChainSequential(PathTEST, tiles, pathTilesL8, pathTilesL5,pathNewProce
90 90 os.mkdir(cmdPath+"/fusion")
91 91 os.mkdir(cmdPath+"/splitShape")
92 92  
93   - feat = GFD.CmdFeatures(PathTEST,tiles,pathNewProcessingChain,pathTilesL8,pathTilesL5,pathConf,pathTilesFeat,None)
  93 + feat = GFD.CmdFeatures(PathTEST,tiles,pathNewProcessingChain,pathTilesL8,pathTilesL5,pathTilesS2,pathConf,pathTilesFeat,None)
94 94 for i in range(len(feat)):
95 95 print feat[i]
96 96 os.system(feat[i])
... ...