How to calculate a significant value of a definite curve/shaded region in a graph? The attached graph below consists of $4.5$ seconds of pattern which I have recorded via a hardware device.



The $x$-axis is the timestamp value in seconds and the $y$-axis is the hardware value. The values are taken on $0.01$ seconds of interval.

As seen in the graph, there is a definite pattern/curve from $0.5$ to $3$ seconds. I tried calculating a definite value using the below steps:


Taking 2.5 seconds block starting from $0$ Blocks: $0 - 2.5$, $0.01 - 2.51$, $0.02 - 2.52$, etc.
Now divide this $2.5$ second block into $5$ parts of $0.5$ seconds interval blocks. $(2.5/5 = 0.5)$
So, first block of $0 - 2.5$ will give: $0, 0.5, 1.0, 1.5, 2.0, 2.5$
Now I have calculated the slope of these values $(x_2-x_1/y_2-y_1)$. This will give me $5$ slope values.
Lastly I have added these values, $(\textrm{Slope}_1 + \textrm{Slope}_2+\ldots + \textrm{Slope}_5)/5$ to get a single average value.


The thing is this value is definite for the time block of $0.5 - 3$ seconds (the curve which I want to identify), but sometimes it comes for other time blocks also.

Also, second issue is, In the current graph, most of the values start from near $0$ or at $0$ on the $y$-axis. In real time, values can start from $-1$ or $1$ also, but the curve will still be the same, I have tested it.

I think the only way is to calculate the value of the curve, as the $y$ values are not definite, but the curve shape is. In real time I would have around $30$ seconds of data and I need to check if any $2.5$ seconds from those $30$ seconds contains a curve like this.
You can use cross-correlation to detect a known signal in a received/measured signal. Here is an example using python and numpy/scipy:

pattern = lambda t: 0.8*(abs(t-1) &lt; 1).astype(int) * np.sin(-2*np.pi*t/2)
Fs = 100.0
t = np.arange(-1, 15, 1/Fs)
t_samp = np.arange(-0.5, 2, 1/Fs)

sigma = 0.02  # add some noise to the measurement

rx = -1+0.1*(t-3)+pattern(t) + pattern(t-4)+pattern(t-9) + np.sqrt(sigma) * np.random.randn(len(t))
patsamples = pattern(t_samp)

plt.subplot(221)
plt.plot(t, rx)
plt.ylim((-4,4))
plt.title('The received signal')

plt.subplot(222)
plt.plot(t_samp, patsamples)
plt.title('The pattern you look for')

plt.subplot(212)
metric = np.correlate(rx, patsamples, 'same')
plt.plot(t, metric)
plt.title('The correlation metric')
plt.grid(True)

peaks = scipy.signal.find_peaks_cwt(-metric, np.array([2.5])/Fs, min_snr=0.5)
peaks = np.array(peaks)
peaks = peaks[metric[peaks]&gt;40]
plt.stem(t[peaks], metric[peaks])
plt.tight_layout()




As you see, this works also when there is an offset or a constant slope in the received signal. In the correlation metric you see peaks, which you need to detect. There is the scipy.signal function find_peaks_cwt, however it is not very intuitively usable. For better/easier implementation of find_peaks you can have a look at this page.