In the function below I only want to use the data after the first 5600 elements in the list, so I delete that in this function, but everytime I call this function it deletes the first 5600 elements of the already shorter list. Is there a way to fix this?
def aardbeving(output,kolom):
sd = np.std(baseline(output,20*tijdstap(output),kolom),ddof=1)
for i in range(5600):
del output[0]
verschil = np.diff(channel(output,kolom))
for i in range(len(verschil)):
if abs(verschil[i]) > 5*sd:
starttijd = -10 + i/tijdstap(output)
return starttijd
Rather than deleting the begining of output take a slice of every thing after 5600. This does not change output as short is just a local reference to the data, not a copy.
John
it deletes 5600 elements every time because delete removes the element from the list and you won’t be able to get back the original list once it deletes an element. Rather try slicing like max suggested, however if you alter any element in slice the original list might get affected(unless you are fine with it), I would suggest you create a deep copy of the slice and then operate on it.