Commit 295e55de authored by Gaetano Raffaele's avatar Gaetano Raffaele
Browse files

ENH: clip both sides with different parameters.

parent 53089786
......@@ -11,9 +11,9 @@ def temporalSmoothing(fld,
date_jul=True,
ext='tif',
sgdeg=4,
sgrad=6,
clip_valid=23,
clip_both_sides=True):
sgrad=3,
clip_left=0,
clip_right=0):
lst = sorted(glob.glob(fld + '/' + template + '*.' + ext))
......@@ -31,16 +31,14 @@ def temporalSmoothing(fld,
cmd += ['-dates',fld+'/dates.txt','-out',fld+'/SmoothedSeries.tif','uint16','-interp','sg','-interp.sg.deg',str(sgdeg),'-interp.sg.rad',str(sgrad)]
subprocess.call(cmd)
if clip_valid > 0:
if clip_left > 0 or clip_right > 0:
cmd = ['otbcli_BandMathX', '-il', fld+'/SmoothedSeries.tif', '-out', fld+'ClippedSmoothedSeries.tif','uint16','-exp']
clip_end = len(lst)
if clip_both_sides:
clip_end -= clip_valid
clip_end = len(lst) - clip_right
with open(fld + '/dates.clipped.txt','wb') as cdf:
with open(fld + '/dates.txt','rb') as df:
dts = df.readlines()
expr = []
for n in range(clip_valid,clip_end):
for n in range(clip_left,clip_end):
expr.append('im1b'+str(n+1))
cdf.write(dts[n])
cmd += ['{' + ';'.join(expr) + '}']
......
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