def movorder(x, order='med', windsize=3, lag='lagged'):
 if (lag == 'lagged'):
  lead = (windsize // 2)
 elif (lag == 'centered'):
  lead = 0
 elif (lag == 'leading'):
  lead = (((- windsize) // 2) + 1)
 else:
  raise ValueError
 if (np.isfinite(order) == True):
  ord = order
 elif (order == 'med'):
  ord = ((windsize - 1) / 2)
 elif (order == 'min'):
  ord = 0
 elif (order == 'max'):
  ord = (windsize - 1)
 else:
  raise ValueError
 xext = expandarr(x, windsize)
 return signal.order_filter(xext, np.ones(windsize), ord)[(windsize - lead):(- (windsize + lead))]

def movorder ( x , order = 'med' , windsize = 3 , lag = 'lagged' ) : if ( lag == 'lagged' ) : lead = ( windsize // 2 ) elif ( lag == 'centered' ) : lead = 0 elif ( lag == 'leading' ) : lead = ( ( ( - windsize ) // 2 ) + 1 ) else : raise ValueError if ( np . isfinite ( order ) == True ) : ord = order elif ( order == 'med' ) : ord = ( ( windsize - 1 ) / 2 ) elif ( order == 'min' ) : ord = 0 elif ( order == 'max' ) : ord = ( windsize - 1 ) else : raise ValueError xext = expandarr ( x , windsize ) return signal . order_filter ( xext , np . ones ( windsize ) , ord ) [ ( windsize - lead ) : ( - ( windsize + lead ) ) ]
moving order statistics parameters x : array time series data order : float or med .