I'm a novice with python, but I have timeseries data and I'm looking to plot the number of times my threshold was exceeded as a function of my threshold value. For example, as my threshold value increases, the number of times it is exceeded should decrease.
I have tried initializing an array and appending each exceeding value into it within a while loop, iterating through each of my threshold values as well as my dataset simultaneously, then counting up the number of values for each threshold and plotting those.
After this, I'm interested in including a constraint that it has to last for 2 or more consecutive datapoints.
What I've tried:
count = [] # row i includes all values over threshold x[i]
counter = 0
x = np.linspace(10, 40, 1440)
y = np.empty(1440,dtype=object) # element i is the count over threshold with threshold x[i]
d = minutedata[1]
i=0
j=0
# outer is x threshold data, inner is checking each observation datapoint with a certain x threshold value
for j, x_thresh in enumerate(x):
for i, el in enumerate(data):
if el > x_thresh: # in jth x element, running through data
counter += 1 # adding in values over threshold
y[i] = counter # makes a vector for each threshold containing values over threshold
counter = 0
but currently all of my y values come out as None. I know there's an issue with my loops somewhere but I'm not sure what.
Any help or suggestions are very appreciated!