我对Python很陌生。。。我很难将一维数组的内容插入到一个非线性方程中,这样我才能最终绘制出结果。我的代码如下:
import numpy as np
import matplotlib.pyplot as plt
def readfiles(file_list):
""" read <TAB> delemited files as strings
ignoring '# Comment' lines """
data = []
for fname in file_list:
data.append(
np.genfromtxt(fname,
comments='#', # skip comment lines
delimiter='\t',
dtype ="|S", autostrip=True).T)
return data
data = readfiles(['CR1000_rawMeasurements_15m.txt'])
def column(matrix, i):
return [row[i] for row in matrix]
x = column(data,18)
for i in x:
thermTemp1_degC = 1/(1.401E-3 + 2.377E-4*np.log(i) + 9.730E-8*np.log(i)**3)-273.15
我所能成功做的就是从我的数据中提取我需要的列。当我运行这个脚本时,会得到“TypeError:Not implemented for this type.”(我的1d数组x现在只是一列零。)如何修复这个问题?你知道吗
这里有几点需要说明。你知道吗
返回正确的列
您在注释中给出的数组有点奇怪,但是您可以使用numpy检索列:
执行计算
因为
x
是一个numpy数组(如果使用上面的列代码),所以不需要将其放入for循环中:这里
thermTemp1_degC
是一个与x
大小相同的numpy数组。你知道吗相关问题 更多 >
编程相关推荐