Skip to content

Instantly share code, notes, and snippets.

@brianray
Created June 10, 2020 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianray/4a04effa92a1701b8d284b51f9e0328d to your computer and use it in GitHub Desktop.
Save brianray/4a04effa92a1701b8d284b51f9e0328d to your computer and use it in GitHub Desktop.
import scipy.signal as sg
def decimate_rolling(df, size=100):
out = []
for name in names[:n_samples]:
inds = np.arange(0, len(df), 8000) ## TODO
for i, j in zip(inds[:-1], inds[1:]):
dij = d[i:j]
dij = sg.decimate(dij, 2, ftype="iir")[::2]
out.append(dij)
return fs, speech, wav_names
out = df.resample('5Min', label='right', closed='right').sum().drop("state", axis=1)
for ss in (100, ):
for sss in sensor_list:
print(ss)
print(sss)
xdf = df[df.sensor.str.contains(sss)]
xdf['rolling'] = xdf['state'].rolling(window=ss).sum()
xdf2 = xdf.resample('5Min', label='right', closed='right').sum()
xdf2.drop(["state", ], axis=1).plot()
img = f"{base_path}/{sss}_sum_{ss}.png"
plt.savefig(img)
print(img)
out[f"{sss}_{ss}"] = xdf2['rolling'].values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment