diff --git a/contrib/stack/stripmapStack/Stack.py b/contrib/stack/stripmapStack/Stack.py index 818393e..0caa9b2 100755 --- a/contrib/stack/stripmapStack/Stack.py +++ b/contrib/stack/stripmapStack/Stack.py @@ -74,7 +74,18 @@ class config(object): else: self.f.write('useGPU : False\n') self.f.write('##########################'+'\n') - + + def createWaterMask(self, function): + + self.f.write('##########################'+'\n') + self.f.write(function+'\n') + self.f.write('createWaterMask : '+'\n') + self.f.write('dem_file : ' + self.dem +'\n') + self.f.write('lat_file : ' + self.latFile +'\n') + self.f.write('lon_file : ' + self.lonFile +'\n') + self.f.write('output : ' + self.waterMaskFile + '\n') + self.f.write('##########################'+'\n') + def geo2rdr(self, function): self.f.write('##########################'+'\n') @@ -311,8 +322,7 @@ class run(object): self.runf.write(self.text_cmd+'stripmapWrapper.py -c '+ configName+'\n') def master_focus_split_geometry(self, stackMaster, config_prefix, split=False, focus=True, native=True): - ######## - # focusing master and producing geometry files + """focusing master and producing geometry files""" configName = os.path.join(self.configDir, config_prefix + stackMaster) configObj = config(configName) configObj.configure(self) @@ -329,11 +339,19 @@ class run(object): counter += 1 if split: - configObj.slc = os.path.join(configObj.slcDir,stackMaster+self.raw_string+'.slc') - configObj.outDir = configObj.slcDir - configObj.shelve = os.path.join(configObj.slcDir, 'data') - configObj.splitRangeSpectrum('[Function-{0}]'.format(counter)) - + configObj.slc = os.path.join(configObj.slcDir,stackMaster+self.raw_string+'.slc') + configObj.outDir = configObj.slcDir + configObj.shelve = os.path.join(configObj.slcDir, 'data') + configObj.splitRangeSpectrum('[Function-{0}]'.format(counter)) + counter += 1 + + # generate water mask in radar coordinates + configObj.latFile = os.path.join(self.workDir, 'geom_master/lat.rdr') + configObj.lonFile = os.path.join(self.workDir, 'geom_master/lon.rdr') + configObj.waterMaskFile = os.path.join(self.workDir, 'geom_master/waterMask.rdr') + configObj.createWaterMask('[Function-{0}]'.format(counter)) + counter += 1 + configObj.finalize() del configObj self.runf.write(self.text_cmd+'stripmapWrapper.py -c '+ configName+'\n') diff --git a/contrib/stack/stripmapStack/createWaterMask.py b/contrib/stack/stripmapStack/createWaterMask.py index 97f9875..5946655 100755 --- a/contrib/stack/stripmapStack/createWaterMask.py +++ b/contrib/stack/stripmapStack/createWaterMask.py @@ -40,6 +40,7 @@ def createParser(): help='output filename of water mask in radar coordinates') return parser + def cmdLineParse(iargs = None): ''' Command line parser. @@ -85,11 +86,12 @@ def download_waterMask(bbox, dem_file): #inps.waterBodyGeo = sw.defaultName(inps.bbox) sw.outputFile = os.path.join(out_dir, sw.defaultName(bbox)) sw._noFilling = False - #sw._fillingValue = -1.0 - sw._fillingValue = 0.0 + sw._fillingValue = -1.0 #fill pixels without DEM data with value of -1, same as water body + #sw._fillingValue = 0.0 sw.stitch(bbox[0:2], bbox[2:]) return sw.outputFile + def geo2radar(geo_file, rdr_file, lat_file, lon_file): #inps.waterBodyRadar = inps.waterBodyGeo + '.rdr' sw = SWBDStitcher() @@ -100,6 +102,7 @@ def geo2radar(geo_file, rdr_file, lat_file, lon_file): #imageMath.py -e='a*b' --a=filt_20100911_20101027.int --b=watermask.14alks_4rlks.msk -o filt_20100911_20101027_masked.int -t cfloat -s BIL + def main(iargs=None): inps = cmdLineParse(iargs) @@ -108,6 +111,7 @@ def main(iargs=None): geo2radar(geo_file, inps.outfile, inps.latName, inps.lonName) return + if __name__ == '__main__' : ''' creates a water mask and transforms to radar Coord