I have a problem regarding numpy arrays. Here is a while loop solution I came up with but its run time is way too long. the array SG1_stresses has little under two million rows and the values are for example 34.3241. time_list contains the time values corresponding to the SG1_stresses.
amplitude_limit = 10
index = 1
count = 1
while index < len(SG1_stress):
if (abs(SG1_stress[index]) - abs(SG1_stress[index - 1])
< amplitude_limit):
np.delete(SG1_stress, index, 0)
np.delete(time_list, index, 0)
count += 1
else:
index += 1
Here I would also like to repeat the while loops process so that all the remaining values in SG1_stresses have a difference greater than the set amplitude_limit. For example if we have
SG1_stresses |
---|
59 |
23 |
43 |
55 |
it would boil down to
SG1_stresses |
---|
59 |
55 |
I tried adding another outer While loop to perform the inner loop until there is nothing to remove and that is what the count variable is for.
JLarikka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.