I have a repeating signal that varies a little bit with each cycle of a process that repeats roughly every second, though the duration and the contents of each cycle vary from each other a little bit within some parameters. There are a thousand x,y coordinates for every second of my signal data. A small, but important, segment of the data within each cycle is corrupted, and I want to replace each corrupted segment with an upward facing parabola.
For each data segment that needs to be replaced by the parabola, I have the x,y coordinates of three points. The vertex/minimum is one of those points. And the other two points are the left and right tops of the upward-facing U-shape that is the parabola. In other words, the left top is the x,y coordinate pair of the lowest x value in the domain of this function, while the right top is the x,y coordinate pair of the highest x value in the domain of this function. The y-coordinates of the left top and right top are equal to each other, and are the two highest y-values in the data segment.
How can I write the code to plot the remaining data points in this upward facing parabola? Remember that this function needs to be called 60 or 70 times for every minute of data, and that the shape/formula of the parabola will need to change every time this function is called, in order to account for different relationships between these three pairs of x,y coordinates in each resulting parabola.
def ReplaceCorruptedDataWithParabola(Xarray, Yarray, LeftTopX, LeftTopY
, LeftTopIndex, MinX, MinY, MinIndex
, RightTopX, RightTopY, RightTopIndex):
# Step One: Derive the formula for the upward-facing parabola using
# the following data from the three points:
LeftTopX,LeftTopY,LeftTopIndex
MinX,MinY,MinIndex
RightTopX,RightTopY,RightTopIndex
# Step Two: Use the formula derived in step one to plot the parabola in
# the places where the corrupted data used to reside:
for n in Xarray[LeftTopX:RightTopX]:
Yarray[n]=[_**The formula goes here**_]
return Yarray
Note: Xarray and Yarray are each single-column vectors with data at each index that links the two arrays as sets of x,y coordinates. They are both numpy arrays. Xarray contains time information and does not change, but Yarray contains signal data, including the corrupted segment that will be replaced with the parabolic data that needs to be calculated by this function.