Commit 928db6ff authored by Florian de Boissieu's avatar Florian de Boissieu
Browse files

remove error raising in MultitempFilteringFilter

parent 63fee473
......@@ -5,6 +5,7 @@ TODO:
- include filtering in pipe before mosaic: how to deal with superimpose? Won't it have a border effect anyway if ROI is at the border of transect?
- Compression of output: http://otb-users.37221.n3.nabble.com/Is-it-possible-to-use-Gdal-raster-compression-LZW-or-DEFLATE-args-in-otbcli-td4030502.html
- example: COMPRESS=LZW, PREDICTOR=2, TILED=YES
- In MultitempFilteringFilter with 'lee' filter the number of looks was set to 4, is it always that value or should we use enl file?
"""
#import argparse
import glob, os, sys, warnings
......@@ -373,16 +374,16 @@ def MultitempFilteringFilter(infiles, outdir, window_radius, outcore_file, enl_f
infiles = [Path(f) for f in infiles]
outdir = Path(outdir)
outfiles = [enl_file] + [outdir / f.name.stripext() + '_filtered.tiff' for f in infiles]
existing = [f for f in outfiles if f.exists()]
outfiles = [outdir / f.name.stripext() + '_filtered.tiff' for f in infiles] # + [enl_file]
# existing = [f.exists() for f in outfiles]
# to_process = [not v for v in existing]
if (len(existing) > 0) and (not overwrite):
if len(existing) != len(outfiles):
raise IOError('Some outputs of MultitempFilteringFilter already exist but not all,'
'set overwrite argument to overwrite:\n\t{}'.format(existing))
if verbose:
print('MultitempFilteringFilter process skipped, files already exists:\n\t{}'.format(existing))
return outfiles
# if (sum(existing) > 0) and (not overwrite):
# if len(existing) != len(outfiles):
# raise IOError('Some outputs of MultitempFilteringFilter already exist but not all,'
# 'set overwrite argument to overwrite:\n\t{}'.format(existing))
# if verbose:
# print('MultitempFilteringFilter process skipped for files that already exists:\n\t{}'.format(list(compress(outfiles, existing))))
"""
app = otb.Registry.CreateApplication('MultitempFilteringFilter')
......@@ -401,18 +402,22 @@ def MultitempFilteringFilter(infiles, outdir, window_radius, outcore_file, enl_f
# print(cmd)
# subprocess.check_call(cmd, shell=False)
"""
i = 1
for f in infiles:
for infile, outfile in zip(infiles, outfiles):
if outfile.exists() and not overwrite:
if verbose:
print('MultitempFilteringFilter process skipped, file already exists: {}'.format(outfile))
continue
pipe = []
if filter == 'mean':
pipe.append(otb.Registry.CreateApplication('Smoothing'))
pipe[-1].SetParameterString('in', f)
pipe[-1].SetParameterString('in', infile)
pipe[-1].SetParameterString('type', 'mean')
pipe[-1].SetParameterString('type.mean.radius', str(window_radius))
pipe[-1].SetParameterString('ram', str(ram))
elif filter == 'lee':
pipe.append(otb.Registry.CreateApplication('Despeckle'))
pipe[-1].SetParameterString('in', f)
pipe[-1].SetParameterString('in', infile)
pipe[-1].SetParameterString('filter', 'lee')
pipe[-1].SetParameterString('filter.lee.rad', str(window_radius))
pipe[-1].SetParameterString('filter.lee.nblooks', '4')
......@@ -423,9 +428,8 @@ def MultitempFilteringFilter(infiles, outdir, window_radius, outcore_file, enl_f
pipe[-1].AddImageToParameterInputImageList('il', pipe[-2].GetParameterOutputImage('out'))
pipe[-1].SetParameterString('exp', 'im2b1*im1b1/im1b2')
pipe[-1].SetParameterString('ram', str(ram))
pipe[-1].SetParameterString('out', outfiles[i])
pipe[-1].SetParameterString('out', outfile)
pipe[-1].ExecuteAndWriteOutput()
i += 1
return outfiles
......
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