code: def uniform_fltr(dem, fsize=7):
      
      print("Applying uniform filter with size %s" % fsize)
      #Note, ndimage doesn't properly handle ma - convert to nan
      from scipy.ndimage.filters import unifiform_filter
      dem_filt_med = uniform_filter(dem.filled(np.nan), fsize)
      #Now mask all nans
      out = np.ma.fix_invalid(dem_filt_med, copy=False, fill_value=dem.fill_value)
      out.set_fill_value(dem.fill_value)
      return out
docs: Uniform (mean) filter
      
      Note: suffers from significant ringing