def _lerp(a, b, t, out=None): """ Linearly interpolate from a to b by a factor of t """ diff_b_a = subtract(b, a) # asanyarray is a stop-gap until gh-13105 lerp_interpolation = asanyarray(add(a, diff_b_a * t, out=out)) subtract(b, diff_b_a * (1 - t), out=lerp_interpolation, where=t >= 0.5) if lerp_interpolation.ndim == 0 and out is None: lerp_interpolation = lerp_interpolation[()] # unpack 0d arrays return lerp_interpolation
def CalcLSWI (self, NIR, SWIR, Blue, fill): Blue [Blue >= 0.27] = fill Swir_lower=numpy.where(Blue == fill, fill , add(NIR, SWIR)) Swir_upper=numpy.where(Blue == fill, fill , subtract(NIR, SWIR)) Swir_lower=numpy.where(Swir_lower ==0 , fill, Swir_lower) LSWI=numpy.where(Swir_lower==fill, fill ,Swir_upper/Swir_lower) return LSWI
def CalcNDVI ( self , NIR , Red, fill): Ndvi_lower = numpy.where (NIR == fill, fill , add (NIR , Red)) Ndvi_upper = numpy.where (NIR == fill, fill ,subtract (NIR , Red)) #Mask = Numpy.Greater (Ndvi_lower, 0) Ndvi_lower = numpy.where (Ndvi_lower == 0 , fill , Ndvi_lower) NDVI = numpy.where (Ndvi_lower == fill , fill , Ndvi_upper/Ndvi_lower) return NDVI
def CalcEVI ( self , NIR , Red , Blue, fill ): #for cloud-cover blue >= 0.27 Blue [Blue >= 0.27] = fill Evi_upper = numpy.where (Blue == fill , fill , 2.5 * subtract (NIR , Red)) Evi_lower = numpy.where (Blue == fill , fill , (NIR + (6 * Red) - (7.5 * Blue) + 1)) Evi_lower = numpy.where (Evi_lower == 0 , fill , Evi_lower) EVI = numpy.where(Evi_lower == fill , fill , Evi_upper/Evi_lower) #EVI [EVI <= 0] = fill EVI [EVI >= 1] = fill #EVI = 2.5 * (NIR - Red) / (NIR + 6 * Red - 7.5 * Blue + 1) * mask return EVI
def CalcMLSWI ( self , NIR , SWIR, fill): mlswi_lower = numpy.where (NIR == fill, fill , add (NIR , SWIR)) mlswi_upper = numpy.where (NIR == fill, fill ,subtract (NIR , SWIR)) #Mask = Numpy.Greater (Ndvi_lower, 0) mlswi_lower = numpy.where (mlswi_lower == 0 , fill , mlswi_lower) lower = (1-mlswi_lower) lower = numpy.where (lower == 0 , fill , lower) mlswi = numpy.where (mlswi_lower == fill , fill , (1-mlswi_upper)/lower) #mlswi1= numpy.where (((mlswi>= 0.75) & (mlswi <= 1.0)), 1, 0) #MLSWI = numpy.where (NIR == fill , fill , mlswi1 ) return mlswi
def _ptp(a, axis=None, out=None, keepdims=False): return um.subtract( umr_maximum(a, axis, None, out, keepdims), umr_minimum(a, axis, None, None, keepdims), out, )
def myfunc(x): return clf.predict([Data[0][x], Data[1][x], subtract(Data[0][x], Data[1][x])])
def myfunc(x): ''' 並列に計算したい関数 ''' return clf.predict([Data[0][x], Data[1][x], subtract(Data[0][x], Data[1][x])])
def _ptp(a, axis=None, out=None, keepdims=False): return um.subtract( umr_maximum(a, axis, None, out, keepdims), umr_minimum(a, axis, None, None, keepdims), out )
def CalcDVEL(self, EVI, LSWI, fill): DVEL=numpy.where(LSWI == fill, fill , subtract(EVI,LSWI)) return DVEL
def CalcNDVI(self, NIR, Red): ndvi_lower = add(NIR, Red) ndvi_upper = subtract(NIR, Red) NDVI = numpy.where(ndvi_lower == 0, 0.0, ndvi_upper/ndvi_lower) return NDVI