yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #16559
[Question #662552]: python and wrong number of columns
New question #662552 on Yade:
https://answers.launchpad.net/yade/+question/662552
Hi,
I tried to plot a graph but when I run my script, I received the following error:
ozge@ozge-Inspiron-15-7000-Gaming:~/workspace$ python plottt.py
Traceback (most recent call last):
File "plottt.py", line 55, in <module>
store(a1,dataFile1)
File "plottt.py", line 7, in store
data=loadtxt(textFile,skiprows=1)
File "/usr/lib/python2.7/dist-packages/numpy/lib/npyio.py", line 927, in loadtxt
% line_num)
ValueError: Wrong number of columns at line 87
There isn't any problem about column numbers. It is probably about the format of the data. However, I do not know hot to fix it.
If anyone helps me about this issue, I'll be appreciated.
thanks,
ozge
here is my script:
def store(var,textFile):
data=loadtxt(textFile,skiprows=1)
it=[]
t=[]
e1=[]
e2=[]
e3=[]
ev=[]
s1=[]
s2=[]
s3=[]
q=[]
tc=[]
sc=[]
c=[]
uf=[]
for i in range(0,len(data)):
it.append(float(data[i,3]))
t.append(float(data[i,8]))
e1.append(-float(data[i,0]))
e2.append(-float(data[i,1]))
e3.append(-float(data[i,2]))
ev.append(float(data[i,0]) + float(data[i,1]) + float(data[i,2]))
s1.append(-float(data[i,4]))
s2.append(-float(data[i,5]))
s3.append(-float(data[i,6]))
q.append(-float(data[i,5])+float(data[i,4]))
tc.append(float(data[i,9]))
sc.append(float(data[i,7]))
c.append(float(data[i,9]) + float(data[i,7]))
uf.append(float(data[i,10]))
var.append(it)
var.append(t)
var.append(e1)
var.append(e2)
var.append(e3)
var.append(ev)
var.append(s1)
var.append(s2)
var.append(s3)
var.append(q)
var.append(tc)
var.append(sc)
var.append(c)
var.append(uf)
## data input
dataFile1='test'
a1=[]
store(a1,dataFile1)
### data plot
rcParams.update({'legend.numpoints':1,'font.size': 30,'axes.labelsize':35,'xtick.major.pad':5,'ytick.major.pad':9,'legend.fontsize':30})
lw=3
ms=8
figure(0,figsize=(12,10))
ax1=subplot(1,1,1)
xlabel(r'$\varepsilon_1$ [millistrain]')
ax1.plot([x*1e3 for x in a1[3]],[x/1e6 for x in a1[9]],'-b',linewidth=lw)
ax1.axis(ymin=0)
ylabel(r'$\sigma_1 - \sigma_3$ [MPa]')
ax2=ax1.twinx()
ax2.plot([x*1e3 for x in a1[3]],a1[10],'--g',linewidth=lw)
ax2.plot([x*1e3 for x in a1[3]],a1[11],'--r',linewidth=lw)
ylabel('microcracks [-]')
legend(('tensile','shear'),1)
####
show()
--
You received this question notification because your team yade-users is
an answer contact for Yade.