I have quite a few sensors in the field that measure water pressure. In the past the height of these sensors have been changed quite a few times creating jumps in the timese
You can try it like this:
import numpy as np
import matplotlib.pyplot as plt
import h5py
%matplotlib inline
# I'm not sure that you need all of this packedges
filepath = 'measurment.hdf5'
with h5py.File(filepath, 'r') as hdf:
data_y = hdf['y'][:]
data_x = hdf['x'][:]
data = data_y
delta_max = 1 # maximum difference in y between two points
delta = 0 # running correction value
data_cor = [] # corrected array
data_cor.append(data[0:1]) # we append two first points
for i in range(len(data_x)-2): # two first points are allready appended
i += 2
delta_i = data[i] - data[i-1]
if np.abs(delta_i) > delta_max:
delta += (delta_i - (data_cor[i-1] - data_cor[i-2]))
data_cor.append(data[i]-delta)
else:
data_cor.append(data[i]-delta)
plt.plot(data_x, data_cor)