diff --git a/ipart/AR_detector.py b/ipart/AR_detector.py index 516461b..df1b8b4 100644 --- a/ipart/AR_detector.py +++ b/ipart/AR_detector.py @@ -763,7 +763,13 @@ def partPeaks(cropmask, cropidx, orislab, area, min_area, max_ph_ratio, ele=morphology.diamond(fill_radius//2) gap=cropmask-mask1 - op=morphology.opening(mask1, selem=ele) + + try: + op=morphology.opening(mask1, selem=ele) + except: + # version >= 0.19 changes to footprint + op=morphology.opening(mask1, footprint=ele) + gap2=morphology.reconstruction(gap, mask1-op+gap) mask1=np.where(mask1-gap2<=0, 0, mask1) #gap2=morphology.dilation(gap, selem=ele) @@ -1621,7 +1627,11 @@ def paddedClosing(mask, ele, pad, has_cv): if has_cv: padmask=cv.morphologyEx(padmask, cv.MORPH_CLOSE, ele) else: - padmask=morphology.closing(padmask, selem=ele) + try: + padmask=morphology.closing(padmask, selem=ele) + except: + # version >= 0.19 changes to footprint + padmask=morphology.closing(padmask, footprint=ele) # trim padmask=padmask[tuple([slice(pad,-pad), slice(pad,-pad)])] return padmask diff --git a/ipart/thr.py b/ipart/thr.py index e6953e2..69f4fa5 100644 --- a/ipart/thr.py +++ b/ipart/thr.py @@ -102,12 +102,20 @@ def THR(ivtNV, kernel, oroNV=None, high_terrain=600, verbose=True): if verbose: print('\n# : Computing erosion ...') - lm=morphology.erosion(ivt, selem=ele) + try: + lm=morphology.erosion(ivt, selem=ele) + except TypeError: + # version >= 0.19 changes to footprint + lm=morphology.erosion(ivt, footprint=ele) if verbose: print('\n# : Computing reconstruction ...') - ivtrec=morphology.reconstruction(lm, ivt, method='dilation', selem=rec_ele) + try: + ivtrec=morphology.reconstruction(lm, ivt, method='dilation', selem=rec_ele) + except TypeError: + # version >= 0.19 changes to footprint + ivtrec=morphology.reconstruction(lm, ivt, method='dilation', footprint=rec_ele) # perform an extra reconstruction over land if oroNV is not None: @@ -116,8 +124,14 @@ def THR(ivtNV, kernel, oroNV=None, high_terrain=600, verbose=True): oro_rs=oro_rs[None,...] oro_rs=np.repeat(oro_rs, len(ivt), axis=0) - ivtrec_oro=morphology.reconstruction(lm*oro_rs, ivt, method='dilation', - selem=rec_ele) + try: + ivtrec_oro=morphology.reconstruction(lm*oro_rs, ivt, method='dilation', + selem=rec_ele) + except TypeError: + # version >= 0.19 changes to footprint + ivtrec_oro=morphology.reconstruction(lm*oro_rs, ivt, method='dilation', + footprint=rec_ele) + ivtano=np.ma.maximum(ivt-ivtrec, (ivt-ivtrec_oro)*oro_rs) else: ivtano=ivt-ivtrec @@ -386,12 +400,20 @@ def THRCyclicLongitude(ivt, kernel, oro=None, high_terrain=600, verbose=True): if verbose: print('\n# : Computing erosion ...') - lm=morphology.erosion(ivt.data, selem=ele) + try: + lm=morphology.erosion(ivt.data, selem=ele) + except TypeError: + # version >= 0.19 changes to footprint + lm=morphology.erosion(ivt.data, footprint=ele) if verbose: print('\n# : Computing reconstruction ...') - ivtrec=recon.reconstruction(lm, ivt, method='dilation', selem=rec_ele) + try: + ivtrec=recon.reconstruction(lm, ivt, method='dilation', selem=rec_ele) + except TypeError: + # version >= 0.19 changes to footprint + ivtrec=recon.reconstruction(lm, ivt, method='dilation', footprint=rec_ele) # perform an extra reconstruction over land if oro is not None: @@ -399,8 +421,14 @@ def THRCyclicLongitude(ivt, kernel, oro=None, high_terrain=600, verbose=True): oro_rs=funcs.addExtraAxis(oro_rs,axis=0) oro_rs=np.repeat(oro_rs, len(ivt), axis=0) + try: ivtrec_oro=recon.reconstruction(lm*oro_rs, ivt, method='dilation', selem=rec_ele) + except TypeError: + # version >= 0.19 changes to footprint + ivtrec_oro=recon.reconstruction(lm*oro_rs, ivt, method='dilation', + footprint=rec_ele) + ivtano=MV.maximum(ivt-ivtrec, (ivt-ivtrec_oro)*oro_rs) else: ivtano=ivt-ivtrec