def  medfilter(cls, data, L, fw=[]):
    """medfilter(cls, data, L)

    Filter each column of data using a window of width L.
    Replace each value with its median from the surrounding window.
    Inspired by http://staff.washington.edu/bdjwww/medfilt.py .

    Optionally, specify feature weights so they can factor in
    to the median calculation.  Any zero-valued weights make the
    median calculation ignore those items.  Values greater than
    zero are NOT weighted; they all participate normally.
    """

    if data == []: 
      print 'Error: empty data; cannot filter.'
      return data