0
I’m having a problem reading the data from a dictionary I created to save data rebuilt by a function...
The dictionary is written whenever the value of Amp and t is rebuilt in loop col. At each loop of Row the dictionary is saved in a list.
Excerpt from the code where the dictionary is written:
def OptimalFilter(inNoiseMatrix, inSi, inGsig, inDgSig):
AmpTime = Verif = dict()
ListData = []
for row in range(0,1000):
for col in range(0,9):
...
...
Amp = mm(aCoef.T,Si)
t = mm(bCoef.T,Si)/mm(aCoef.T,Si)
AmpTime.update({'E_Cell_'+str(col+1): Amp, 't_Cell_'+str(col+1): t})
ListData.append(AmpTime)
return ListData
I checked the reconstruction by printing the values of Amp and t and are correct. The problem occurs when I am processing the data from the list that the function returns. When choosing a dictionary key and iterating in the lists the value is equal:
AmpTimeXTvalid = OptimalFilter(Noise[3000:], XTvalid, gSig[3000:], DgSig[3000:])
for i in range(20):
print(AmpTimeXTvalid[i]['E_Cell_1'])
9975.71782251447
9975.71782251447
9975.71782251447
9975.71782251447
9975.71782251447
9975.71782251447
9975.71782251447
9975.71782251447
9975.71782251447
9975.71782251447
9975.71782251447
9975.71782251447
9975.71782251447
9975.71782251447
What I did wrong in writing/reading the dictionary?
Thanks for the suggestion... after a while I found the mistake. It is in the fact that I forgot to clean the dictionary before entering the loop col. After removing the location of the line
AmpTime = Verif = dict()
for before entering the loop col worked properly.– mssandes