Finding spot and fitting exponent to measurement data

38 Views Asked by At

I'm measuring a physical process which behaves like in the plot shown below. There is an external action (blue line) which produces a response on a measuring element (orange line) which has a response similar to $-Ae^{-Bx}$.

Example plot

I need to solve 2 problems here. The thing I'm looking for is how far the response goes (when does the curve flatten out) and the slope of this curve. Unfortunately the initial action is too short for the output to reach a steady state. Also the delay between the action and response is not the same every time and these events may be spaced with varying time intervals.

Currently I have to find each event and manually cut out the "exponential" part of the plot and fit a curve to it. Ideally I'd like to have a "detection" mechanism running on the stream of data, like a convolution or something similar, which would signal when it encounters the exponential segments and cut them out for fitting a curve, but with different $A$ and $B$ i can' really do it that way. The response signal also has noise and drift, but that's an issue for later.

Any suggestions how to do this? I have Python at my disposal, but Matlab will do as well.

EDIT

I've added an example of the data in question, which can be found here: https://pastebin.com/iPtzq3Uc (I'm not sure if this is a suitable way to post csv data here, so please correct me if im doing it wrong).

The baseline is not flat (and might drift) but the "events" are clearly visible. When I'm looking for is:

  1. The time (x) at which the event starts (i.e. where the rise starts).
  2. The exponent (or other function) that would fit the data best.
  3. Automatically limit the number of data points used for fitting (i.e. find there the plot of interest "ends")

I'm looking for a general tool, not a direct solution for this particular dataset. Other datasets will differ in sampling frequency, time and all that. I'd like to learn a tool that could help me with these kinds of problems.