I just started python three days ago and I am already facing a problem. I couldn't get any information in the www. It looks like a bug - but I think I did s.th. wrong. However I can't find the problem.
Here we go: I have 1 List called "inputData". So all I do is, take out the first 10 entries in each array, fit it with polyfit, save the fit parameters in the variable "linFit" and afterwards substract the fit from my "inputData" and save it in a new list called "correctData". The print line is only to show you the "bug".
If you run the code below and you compare the "inputData" print before and after the procedure, it is different. I have no idea, why... :( However, if you remove one of the two arrays in "inputData", it works fine. Anyone any idea? Thx!
import matplotlib.pyplot as plt
import pylab as np
inputData = [np.array([[ 1.06999998e+01, 1.71811953e-01],
[ 2.94000015e+01, 2.08369687e-01],
[ 3.48000002e+01, 3.70725733e-01],
[ 4.28000021e+01, 4.96874842e-01],
[ 5.16000004e+01, 5.20280702e-01],
[ 6.34000015e+01, 6.79658073e-01],
[ 7.72000008e+01, 7.15826614e-01],
[ 8.08000031e+01, 8.38463318e-01],
[ 9.27000008e+01, 9.07969677e-01],
[ 10.65000000e+01, 10.76921320e-01],
[ 11.65000000e+01, 11.76921320e-01]]),
np.array([[ 0.25999999e+00, 1.21419430e-01],
[ 1.84000009e-01, 2.26843166e-01],
[ 2.41999998e+01, 3.69826150e-01],
[ 3.90000000e+01, 4.12130547e-01],
[ 4.20999985e+01, 5.92435598e-01],
[ 5.22999992e+01, 6.44819438e-01],
[ 6.62999992e+01, 7.23920727e-01],
[ 7.65000000e+01, 8.45791912e-01],
[ 8.22000008e+01, 9.97368264e-01],
[ 9.55000000e+01, 10.48223877e-01]])]
linFit = [['', '']]*15
linFitData = [['', '']]*15
correctData = np.copy(inputData)
print(inputData)
for i, entry in enumerate(inputData):
CUT = np.split(entry, [10], axis=0)
linFitData[i] = CUT[0]
linFit[i] = np.polyfit(linFitData[i][:,0], linFitData[i][:,1], 1)
for j, subentry in enumerate(entry):
correctData[i][j][1] = subentry[1]-subentry[0]*(linFit[i][0]+linFit[i][1])
#print (inputData[0][0][1])
print('----------')
print(inputData)
for i, entry in enumerate(inputData):
plt.plot(entry[:,0], entry[:,1], '.')
plt.plot(linFitData[i][:,0], (linFitData[i][:,0])*(linFit[i][0])+(linFit[i][1]))
#plt.plot(correctData[i][:,0], correctData[i][:,1], '.')