嗨,经验丰富的 python 社区。我经常收集磁性数据作为我工作的一部分,但我必须等到我从现场回来处理数据以检查其质量。该数据采用以下格式:-
Time,F,Ef,FP,Easting,Northing,Height 21:51:02,53169.31,-14.3,-17.79,386330.362,7371876.155,540.939
这可以以不同的格式输出,例如 txt、xls 或在本例中为 csv。我的目标是能够在笔记本电脑上快速绘制它并检查数据是否受到污染。使用 Google 引导我进入 stackoverflow 并查看我想出的各种帖子,下面的脚本。谢谢大家的这些帖子。我的问题是我可以读取 csv 文件,但我不明白如何将该数据放入绘图部分并从第 27 行开始删除不需要的数字。我相信你会发现它相当简单,但由于我缺乏经验,过去两周我一直在绕圈子。感谢所有回复的人。
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as ml
f = open("filename.csv")
data = np.genfromtxt('filename.csv', dtype=[('Time',float),('F',float),('Ef',float),
('FP',float),('E',float),('N',float),('H',float)],
comments='"', delimiter=',')
#only here so that I can see the file is being
#read so will probably remove it later
for line in f:
print line
#below is copied from elsewhere in stackoverflow and trying to adapt
#to my needs so at the moment I get this a Duplicate Point Warning.
#So I need to call the above into what is below.
ndata = 100
ny, nx = 100, 200
xmin, xmax = 1, 50
ymin, ymax = 1, 50
x = np.random.randint(xmin, xmax, ndata)
y = np.random.randint(ymin, ymax, ndata)
z = np.random.random(ndata)
xi = np.linspace(xmin, xmax, nx) #
yi = np.linspace(ymin, ymax, ny) #
zi = ml.griddata(x, y, z, xi, yi) #
plt.contour(xi, yi, zi, 15, linewidths = 0.5, colors = 'k')
plt.pcolormesh(xi, yi, zi, cmap = plt.get_cmap('rainbow'))
plt.colorbar()
plt.scatter(x, y, marker = 'o', c = 'b', s = 5, zorder = 10)
plt.xlim(xmin, xmax)
plt.ylim(ymin, ymax)
plt.show()