I get a TypeError:
Traceback (most recent call last):
File "...Transients_tP100us.py", line 20, in <module>
temp[key] = data[key]["Temperature"].reshape((num_temp, num_dp)).T
TypeError: 'numpy.int32' object does not support item assignment
running this script:
import numpy as np
transient_files = {"50ms": "Transients_50ms.TXT",
"500ms": "Transients_500ms.TXT",
"5000ms": "Transients_5000ms.TXT"}
num_dp = 513
num_temp = 37
data = {}
time = {}
temp = {}
cap = {}
for key, value in transient_files.items():
data[key] = np.genfromtxt(value, delimiter=";", names=[
"Time", "Temperature", "Capacitance"])
time[key] = data[key]["Time"].reshape((num_temp, num_dp)).T
temp[key] = data[key]["Temperature"].reshape((num_temp, num_dp)).T
cap[key] = data[key]["Capacitance"].reshape((num_temp, num_dp)).T * 1e-12
If I only run the Transient_50ms.TXT file, it runs without an error, it's only thrown for the two other files. The only difference between the files is, that the 50ms file doesn't have negative values in the third column, the others have.
So two lines, with and without negative values in the datafiles look like this:
5.065E-01; 3.270E+02;-1.182E-01
6.832E-03; 3.391E+02; 7.501E-01
I made a check with:
for i in np.arange(0, len(data[key]["Time"])):
if type(data[key]["Time"][i]) is not np.float64:
print(i)
for i in np.arange(0, len(data[key]["Temperature"])):
if type(data[key]["Temperature"][i]) is not np.float64:
print(i)
for i in np.arange(0, len(data[key]["Capacitance"])):
if type(data[key]["Capacitance"][i]) is not np.float64:
print(i)
to see if all entries are really recognized as np.float64, which is the case. I guess it's a problem with parsing the data file, especially with the negative values, but I have no idea where the problem is and how to solve it.
pandas?tempbefore going into the second Loop?