Added weighted median function and tests

`mask` removes negative weights (not just zeros) so in those cases `sum(w)` and `sum(wt)` will be different.  Can put this in the `if` block above it, though.