Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
maurov committed Apr 14, 2018
1 parent f7646f9 commit d691b7e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions sloth/math/deglitch.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
"""Deglitch utility"""
"""Deglitch utilities"""

import numpy as np
import pandas as pd

def remove_spikes(x_data, y_spiky_data, threshold=3):
# convert data to pandas DataFrame
HAS_PANDAS = False
try:
import pandas as pd
HAS_PANDAS = True
except:
pass

def remove_spikes(x_data, y_spiky_data, threshold=0):
"""remove spikes using pandas"""
if (not HAS_PANDAS):
return np.zeros_like(y_spiky_data)
df = pd.DataFrame(y_spiky_data);
df['filtered'] = pd.rolling_median(df, window=3, center=True).fillna(method='bfill').fillna(method='ffill')
diff = df['filtered'].as_matrix()-y_spiky_data
Expand Down

0 comments on commit d691b7e

Please sign in to comment.