Let’s say we want to take the derivative of a signal, but it is too rough, so some smoothing is required. Does the order of operations matter? Which should be done first? Smoothing or differentiation?
import stuff
import numpy as npimport matplotlib.pyplot as pltimport pandas as pdimport seaborn as snssns.set(style="ticks", font_scale=1.5) # white graphs, with large and legible lettersfrom matplotlib.dates import DateFormatterimport matplotlib.dates as mdates# %matplotlib widget
fig, ax = plt.subplots(1, 1, figsize=(8,6))ax.plot(df['grad_of_smooth_of_level'], label="first smooth data, then take gradient")ax.plot(df['smooth_of_grad_of_level'], label="first take gradient of data, then smooth it")ax.legend()ax.set(ylabel="rate of change (m/day)");