Re: [Tutor] unsupported operand
Well, I tried to check and I do not have that problem any more..but i have the clear script as follows and a couple of question regarding to this: # coding: utf-8 from pylab import * import numpy import matplotlib.pyplot as pyplot import matplotlib.mlab as mlab #tmax=360 with open(ourtest_out.list, r) as f: t = numpy.array([float(v) for v in f.readline().split()[1:]]) for t, filename in enumerate(ourtest_out.list): a = numpy.loadtxt(ourtest_out.list, skiprows=3) Conc=[] #Conc = a[:, 200] Conc.append(a[:,200]) #Conc = a[0:, tmax+1:] plot(Conc,t) show() My main problem is, i do try to see the plot of Conc according to time. I have a graph without any data! Basically, I have a program written in FORTRAN including conc, time, etc. calculation. The out put data shows that I do have concentration. However, i am not able to have a plot based on time. I should mention that I did have run the model (fortran) for concentration according to the number of layer (N=200) and defined the concentration like this Conc(0:N). Perhaps the reason that I am not able to see the concentration with time is because of this definition. BUT, still if I do plot based on pyplot.pcolor, I have a nice and seems correct graph. So, actually, I am not sure what is the problem for showing the regular/linear plot. I hope I made it clear now.. Would it be possible to give me some hint please? Thank you in advance, Sue On Sun, Dec 18, 2011 at 2:07 AM, Steven D'Aprano st...@pearwood.info wrote: stm atoc wrote: and this is the error that I got: Would you like us to guess which line causes the error? Please show the ENTIRE traceback. Do not retype it from memory, paraphrase or simplify it, or otherwise change it in any way. Copy and paste it. TypeError: unsupported operand type(s) for -: 'list' and 'int' What would you suggest? The code sample you showed did not include any subtractions. This hints that perhaps you are not showing us all of the code you are actually running. The full traceback will answer that one way or the other. Otherwise, I suggest you look at the line which the traceback prints. It probably has something like result = a - b (or some other subtraction). Look for the two variables: one of them is set to a list. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] unsupported operand
On 18/12/11 22:35, stm atoc wrote: Well, I tried to check and I do not have that problem any more..but i have the clear script as follows and a couple of question regarding to this: # coding: utf-8 from pylab import * import numpy import matplotlib.pyplot as pyplot import matplotlib.mlab as mlab #tmax=360 with open(ourtest_out.list, r) as f: t = numpy.array([float(v) for v in f.readline().split()[1:]]) for t, filename in enumerate(ourtest_out.list): a = numpy.loadtxt(ourtest_out.list, skiprows=3) You do realize that you are throwing away the t that you created above? And I'm pretty sure this loop is not doing what you think it is... Lets try an experiment at the ? prompt: for t,f in enumerate('testing'): ...print t,f ... 0 t 1 e 2 s 3 t 4 i 5 n 6 g Is that what you would have expected? Conc=[] Conc.append(a[:,200]) What is a? plot(Conc,t) show() HTH -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] unsupported operand
Hi there, I would like to define concentration array based on time and then plot it. Here is the profile: from pylab import * import numpy import array import math tmax=1*3600 t = 1. outfile=open('ourtest_out.list','w') N = 100 Conc1 = arange([0, tmax]) outfile.close() lw = 2.0 #linewidth dpi = 96 figure(figsize=(12,6),dpi=dpi) pyplot.plot(Conc1, t,'r-',label='Conc' ) savefig('Conc.png') show() and this is the error that I got: TypeError: unsupported operand type(s) for -: 'list' and 'int' What would you suggest? Thank you, Sue ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] unsupported operand
I would suggest a few things, like variable naming style consistency or the unused file that you open and close. You also have an unused lw variable, and does dpi really need to be a variable? Its only used once, why not hard code it. But the main thing I suggest, is posting the 'complete' traceback, so we can see what caused the error. I'm gonna take a wild guess at it being the pyplot.plot call though, due to the data types that its moaning about. Bodsda Sent from my BlackBerry® wireless device -Original Message- From: stm atoc stm.at...@googlemail.com Sender: tutor-bounces+bodsda=googlemail@python.org Date: Sat, 17 Dec 2011 21:30:17 To: tutorTutor@python.org Subject: [Tutor] unsupported operand Hi there, I would like to define concentration array based on time and then plot it. Here is the profile: from pylab import * import numpy import array import math tmax=1*3600 t = 1. outfile=open('ourtest_out.list','w') N = 100 Conc1 = arange([0, tmax]) outfile.close() lw = 2.0 #linewidth dpi = 96 figure(figsize=(12,6),dpi=dpi) pyplot.plot(Conc1, t,'r-',label='Conc' ) savefig('Conc.png') show() and this is the error that I got: TypeError: unsupported operand type(s) for -: 'list' and 'int' What would you suggest? Thank you, Sue ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] unsupported operand
stm atoc wrote: and this is the error that I got: Would you like us to guess which line causes the error? Please show the ENTIRE traceback. Do not retype it from memory, paraphrase or simplify it, or otherwise change it in any way. Copy and paste it. TypeError: unsupported operand type(s) for -: 'list' and 'int' What would you suggest? The code sample you showed did not include any subtractions. This hints that perhaps you are not showing us all of the code you are actually running. The full traceback will answer that one way or the other. Otherwise, I suggest you look at the line which the traceback prints. It probably has something like result = a - b (or some other subtraction). Look for the two variables: one of them is set to a list. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor