我正在尝试将四个列表中的数据保存到带有np.savetxt的txt文件中,我收到一个错误。我以前从未使用过这个,也不确定数组类型和格式说明符是什么。
'Create a txt file with my lat, lon, alt, and time data, with each in a seperate column'
#np.savetxt('file_numpy.txt', zip(lat, lon, alt, ), fmt="%i %5.2f")
np.savetxt('file_numpy.txt', zip(myT, lat, lon, alt))
错误:
TypeError Traceback (most recent call last)
<ipython-input-11-ecd6fd3c8a48> in <module>()
10
11 #np.savetxt('file_numpy.txt', zip(lat, lon, alt, ), fmt="%i %5.2f")
---> 12 np.savetxt('file_numpy.txt', zip(myT, lat, lon, alt))
/Users/mrmenzel/anaconda/lib/python2.7/site-packages/numpy/lib/npyio.pyc in savetxt(fname, X, fmt, delimiter, newline, header, footer, comments)
1217 raise TypeError("Mismatch between array dtype ('%s') and "
1218 "format specifier ('%s')"
-> 1219 % (str(X.dtype), format))
1220 if len(footer) > 0:
1221 footer = footer.replace('\n', '\n' + comments)
TypeError: Mismatch between array dtype ('|S32') and format specifier ('%.18e %.18e %.18e %.18e')
我的数据:
Lat:
[<Latitude 27.689176073130298 deg>, <Latitude 48.45032120487385 deg>, <Latitude 48.364205712585104 deg>, <Latitude 27.538849564221568 deg>, <Latitude -0.03713701451174661 deg>, <Latitude -27.6161238116795 deg>, <Latitude -48.41635545462272 deg>, <Latitude -48.38265336989975 deg>, <Latitude -27.529850683687265 deg>, <Latitude 0.0929886673818169 deg>]
Lon:
[<Longitude -11.245369984319288 deg>, <Longitude 24.602646508968856 deg>, <Longitude 77.51869866724904 deg>, <Longitude 113.20045826221023 deg>, <Longitude 135.11667887191157 deg>, <Longitude 157.05927178662643 deg>, <Longitude -167.1439210586291 deg>, <Longitude -114.16647366586022 deg>, <Longitude -78.40457926191569 deg>, <Longitude -56.45443351644551 deg>]
Alt:
[<Quantity 409193.55555070826 m>, <Quantity 418422.38904031017 m>, <Quantity 419775.9010528204 m>, <Quantity 412775.65686140396 m>, <Quantity 407430.35452421894 m>, <Quantity 410337.3219834759 m>, <Quantity 415810.49056818814 m>, <Quantity 414410.9036345114 m>, <Quantity 406680.40398573445 m>, <Quantity 402944.3590314008 m>]
Time:
['2000-01-01 12:09:16.000', '2000-01-01 12:18:32.000', '2000-01-01 12:27:48.000', '2000-01-01 12:37:04.000', '2000-01-01 12:46:20.000', '2000-01-01 12:55:36.000', '2000-01-01 13:04:52.000', '2000-01-01 13:14:08.000', '2000-01-01 13:23:24.000', '2000-01-01 13:32:40.000']