Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Plot problem.. ?? No sign at all

Reply
Thread Tools

Plot problem.. ?? No sign at all

 
 
Ritchy lelis
Guest
Posts: n/a
 
      07-05-2010
hello guys..

I'm new at python programming and i'm having some problems with a
script that i have been developing for my final project of my
graduation.

I have a script that is supposed to make a plot of a
"Residuo" (waveform) witch is an output of a ADC ( Analogic To Digital
Converter) for the first stage of the Flash pipiline ADC
structure.This script doesn't show any syntax errors but it doesn't
show no waveform at all at the plot window.

I'm worried about this situation so I came here looking for help since
I am new to the Python language.


-----------------------------------------------------------------------

from pylab import*

Vref = arange(1, 20, 0.02)
Vi = arange(1, 10,0.1)

for i in Vref:
for n in Vi:
if n > i/4:
V0 = 2*n-i
elif (-i/4) <= n and n <= i/4:
V0 = 2*n
elif Vi < -i/4:
V0 = 2*n+i
else:
print "Try Again"
##print V0
plot (V0)boboz10

--------------------------------------------------------------------------------

 
Reply With Quote
 
 
 
 
MRAB
Guest
Posts: n/a
 
      07-05-2010
Ritchy lelis wrote:
> hello guys..
>
> I'm new at python programming and i'm having some problems with a
> script that i have been developing for my final project of my
> graduation.
>
> I have a script that is supposed to make a plot of a
> "Residuo" (waveform) witch is an output of a ADC ( Analogic To Digital
> Converter) for the first stage of the Flash pipiline ADC
> structure.This script doesn't show any syntax errors but it doesn't
> show no waveform at all at the plot window.
>
> I'm worried about this situation so I came here looking for help since
> I am new to the Python language.
>
>
> -----------------------------------------------------------------------
>
> from pylab import*
>
> Vref = arange(1, 20, 0.02)
> Vi = arange(1, 10,0.1)
>
> for i in Vref:
> for n in Vi:
> if n > i/4:
> V0 = 2*n-i
> elif (-i/4) <= n and n <= i/4:
> V0 = 2*n
> elif Vi < -i/4:
> V0 = 2*n+i
> else:
> print "Try Again"
> ##print V0
> plot (V0)boboz10
>
> --------------------------------------------------------------------------------
>

Only the first 2 'if' conditions are ever true, so nothing is ever
plotted.

Also, I don't know what you're trying to do here:

elif Vi < -i/4:

because Vi is an array and i is a float. If Python ever tried to execute
it there would be a ValueError exception:

ValueError: The truth value of an array with more than one element is
ambiguous.
Use a.any() or a.all()
 
Reply With Quote
 
 
 
 
Ritchy lelis
Guest
Posts: n/a
 
      07-06-2010
On 6 jul, 16:18, Alan G Isaac <(E-Mail Removed)> wrote:
> On 7/6/2010 8:05 AM, Ritchy lelis wrote:
>
> > *1 - "import numpy as np
> > * * * import matplotlib.pyplot as plt"

>
> > * * * In what help's me making the call's of the libraries that way?

>
> http://bytebaker.com/2008/07/30/python-namespaces/
>
> > *2 - What's the instruction linspace means/does?

>
> *>>> help(np.linspace)
> * * * * *Help on function linspace in module numpy.core.function_base:
>
> * * * * *linspace(start, stop, num=50, endpoint=True, retstep=False)
> * * * * * * *Return evenly spaced numbers over a specified interval.
>
> * * * * * * *Returns `num` evenly spaced samples, calculated over the
> * * * * * * *interval [`start`, `stop` ].
>
> > *3 - Last but more important: "V0 = ... #create an array" if I
> > *understood, there i'm supposed to introduce the for loop as in my
> > *initial example. correct?

>
> It is better to create your arrays without looping,
> if possible. *But create it however you wish.
> (Note than numpy arrays have a fixed length;
> create a Python list if you wish to append to it.)
>
> Cheers,
> Alan Isaac


-------------------------------------------------

My intention with de for loop was to iterate each point of the arrays
Vi and Vref at the math calculations. The V0 it's the result of the
math expressions between the Vi and Vref. I can't just create one V0
by a function set by parametters (i don't see how).

Could you give a clue?

Cheers

Ritchy
 
Reply With Quote
 
Ritchy lelis
Guest
Posts: n/a
 
      07-06-2010
On 6 jul, 17:29, Alan G Isaac <(E-Mail Removed)> wrote:
> On 7/6/2010 12:11 PM, Ritchy lelis wrote:
>
> > My intention with de for loop was to iterate each point of the arrays
> > Vi and Vref at the math calculations. The V0 it's the result of the
> > math expressions between the Vi and Vref. I can't just create one V0
> > by a function set by parametters (i don't see how).

>
> Unfortunately I cannot make sense of the code you posted.
> Provide a detailed description in words (or psuedocode)
> of what you are trying to accomplish. *Be very careful
> and detailed is you want a useful response.
>
> Alan Isaac


hummm...

ok, i will try to make that detailed description. Maybe i have not
been so clear because my inglish suck's
However i have a tutorial and another document that my teacher gave
me, i could send you it if you allowed me. It's the 2 best document's
i've seen about ADC.

Ritchy

 
Reply With Quote
 
Johan Grönqvist
Guest
Posts: n/a
 
      07-07-2010
2010-07-06 19:18, Ritchy lelis skrev:
> On 6 jul, 17:29, Alan G Isaac<(E-Mail Removed)> wrote:
>> Unfortunately I cannot make sense of the code you posted.
>> Provide a detailed description in words (or psuedocode)
>> of what you are trying to accomplish. Be very careful
>> and detailed is you want a useful response.
>>
>> Alan Isaac

>
> hummm...
>
> ok, i will try to make that detailed description.


I can tell you why I do not understand from your posted code what you
are trying to do.

Firstly, I do not understand if you are trying to plot a surface, a set
of curves, or a curve, or just a set of points? In your posted code, the
plot command is part of the else clause, and my guess is that you never
intend the else-clause to be executed at all.

In your code snippet you loop over two arrays (Vi and Vref), compute a
scalar value V0, and all plot-commands you issue are of the form
plot(V0). This will probably draw a line of one point (for each value in
Vi and Vref), which may not be what you want, and if it draws anything
at all, then all points will be drawn at the same x-value, which is also
probably not what you want.

Secondly, how are the Vi and Vref related to your axes? I assume you
want to plot all values you compute for V0, but as a function of what?
When I use the plot command, I usually give it (at least) two arguments,
where the first is the x-axis, and the second is the y-axis.

After I have understood those things, the next question would be about
the maths relating the Vi and Vref values to the V0 values, but I do not
think I will understand those until after the above points are explained
clearer.

I definitely think your english is not a problem here.



Johan

 
Reply With Quote
 
Ritchy lelis
Guest
Posts: n/a
 
      07-11-2010
On 7 jul, 08:38, Johan Grönqvist <(E-Mail Removed)> wrote:
> 2010-07-06 19:18, Ritchy lelis skrev:
>
> > On 6 jul, 17:29, Alan G Isaac<(E-Mail Removed)> *wrote:
> >> Unfortunately I cannot make sense of the code you posted.
> >> Provide a detailed description in words (or psuedocode)
> >> of what you are trying to accomplish. *Be very careful
> >> and detailed is you want a useful response.

>
> >> Alan Isaac

>
> > hummm...

>
> > ok, i will try to make that detailed description.

>
> I can tell you why I do not understand from your posted code what you
> are trying to do.
>
> Firstly, I do not understand if you are trying to plot a surface, a set
> of curves, or a curve, or just a set of points? In your posted code, the
> plot command is part of the else clause, and my guess is that you never
> intend the else-clause to be executed at all.
>
> In your code snippet you loop over two arrays (Vi and Vref), compute a
> scalar value V0, and all plot-commands you issue are of the form
> plot(V0). This will probably draw a line of one point (for each value in
> Vi and Vref), which may not be what you want, and if it draws anything
> at all, then all points will be drawn at the same x-value, which is also
> probably not what you want.
>
> Secondly, how are the Vi and Vref related to your axes? I assume you
> want to plot all values you compute for V0, but as a function of what?
> When I use the plot command, I usually give it (at least) two arguments,
> where the first is the x-axis, and the second is the y-axis.
>
> After I have understood those things, the next question would be about
> the maths relating the Vi and Vref values to the V0 values, but I do not
> think I will understand those until after the above points are explained
> clearer.
>
> I definitely think your english is not a problem here.
>
> Johan


hi Johan

Thanks for the interest in my problem... really appreciate.

About the plot draw it's a curve that it's a set of points wich it's
the result of the comput of the Vref and Vi together. I don't know if
i had to make a break instruction (like in other's languages) after
the "If" instructions if i want the else-condition to be executed? ...
(do you have some sujestions?)
Anyway i have a picture of a tuturial that i found but in this forum i
can't post it. That pic would show what a really want...

Relatively to the axis, the Vi takes the x-axis and the Vref takes the
y-axis.

As i said, i have a good 2 pic of a doc that has the information about
this ADC that i'm developing.

I would appreciate more of your help, if you permit me i could send
you those 2 pic and i guarantee that you would got the certain vision
of the problem.

I'll be waiting for your answer, i thing that you can help me.

Cheers.

Ritchy Lelis
 
Reply With Quote
 
Johan Grönqvist
Guest
Posts: n/a
 
      07-11-2010
2010-07-11 02:12, Ritchy lelis skrev:
> On 7 jul, 08:38, Johan Grönqvist<(E-Mail Removed)> wrote:
>
> About the plot draw it's a curve that it's a set of points wich it's
> the result of the comput of the Vref and Vi together. I don't know if
> i had to make a break instruction (like in other's languages) after
> the "If" instructions if i want the else-condition to be executed? ...
> (do you have some sujestions?)


I would have expected a code structure similar to this:

(NOTE: This is a very inefficient solution, and not the one suggested
earlier, but it is closer to the code snippet you posted originally, and
it does produce a plot.)

----------------------
import numpy as np
import matplotlib.pyplot as plt
Vref = np.linspace(1,20, 100)
Vi = np.linspace(1,10,100)

for ref in Vref: # Loop over Vref and Vi
for i in Vi:
if i > ref/4: # Compute V0
V0 = 2*i-ref
elif (-ref/4) <= ref and ref <= ref/4:
V0 = 2*i
elif i < -ref/4:
V0 = 2*i+ref
plt.plot(i, V0, ".") # Plot one single point at x = i, y = V0
plt.show() # Display the plot in a window
----------------------


> Anyway i have a picture of a tuturial that i found but in this forum i
> can't post it. That pic would show what a really want...


Can you give a link?

>
> Relatively to the axis, the Vi takes the x-axis and the Vref takes the
> y-axis.



To me this sound like you want to make a 3D-plot, as there is the
x-axis, the y-axis, and V0. Is this correct? Is V0 on a z-axis?

>
> As i said, i have a good 2 pic of a doc that has the information about
> this ADC that i'm developing.
>


I looked on wikipedia
<http://en.wikipedia.org/wiki/Analog-to-digital_converter>, and saw some
figures. Is any of those similar to what you look for?

I see that they have (Vi - Vref) on the x-axis, and the computed value
on the y-axis.

Regards

Johan

 
Reply With Quote
 
Ritchy lelis
Guest
Posts: n/a
 
      07-11-2010
On 11 jul, 13:28, Johan Grönqvist <(E-Mail Removed)> wrote:
> 2010-07-11 02:12, Ritchy lelis skrev:
>
> > On 7 jul, 08:38, Johan Grönqvist<(E-Mail Removed)> *wrote:

>
> > About the plot draw it's a curve that it's a set of points wich it's
> > the result of the comput of the Vref and Vi together. I don't know if
> > i had to make a break instruction (like in other's languages) after
> > the "If" instructions if i want the else-condition to be executed? ...
> > (do you have some sujestions?)

>
> I would have expected a code structure similar to this:
>
> (NOTE: This is a very inefficient solution, and not the one suggested
> earlier, but it is closer to the code snippet you posted originally, and
> it does produce a plot.)
>
> ----------------------
> import numpy as np
> import matplotlib.pyplot as plt
> Vref = np.linspace(1,20, 100)
> Vi = np.linspace(1,10,100)
>
> for ref in Vref: # Loop over Vref and Vi
> * * *for i in Vi:
> * * * * *if *i > ref/4: # Compute V0
> * * * * * * *V0 = 2*i-ref
> * * * * *elif (-ref/4) <= ref and ref <= ref/4:
> * * * * * * *V0 = 2*i
> * * * * *elif i < -ref/4:
> * * * * * * *V0 = 2*i+ref
> * * * * *plt.plot(i, V0, ".") # Plot one single point at x = i, y = V0
> plt.show() # Display the plot in a window
> ----------------------
>
> > Anyway i have a picture of a tuturial that i found but in this forum i
> > can't post it. That pic would show what a really want...

>
> Can you give a link?
>
>
>
> > Relatively to the axis, the Vi takes the x-axis and the Vref takes the
> > y-axis.

>
> To me this sound like you want to make a 3D-plot, as there is the
> x-axis, the y-axis, and V0. Is this correct? Is V0 on a z-axis?
>
>
>
> > As i said, i have a good 2 pic of a doc that has the information about
> > this ADC that i'm developing.

>
> I looked on wikipedia
> <http://en.wikipedia.org/wiki/Analog-to-digital_converter>, and saw some
> figures. Is any of those similar to what you look for?
>
> I see that they have (Vi - Vref) on the x-axis, and the computed value
> on the y-axis.
>
> Regards
>
> Johan


Hi

Yes those fig look's familiar to me but for now the objective its to
get that residue transfer function (1.5-Bit-Per-Stage Pipelined ADC).

I found in http://amesp02.tamu.edu/~sanchez/ADC...ne_lecture.PDF
there are some fig and explanations on page's 9-13. Can you take a
look there please?

Also you can take a look in http://www.maxim-ic.com/app-notes/index.mvp/id/1023
(I think there it´s more information than the first link i gave you).

I'll be waiting for sujestions.

Thank's

 
Reply With Quote
 
Ritchy lelis
Guest
Posts: n/a
 
      07-13-2010
On 11 Jul, 17:39, Ritchy lelis <(E-Mail Removed)> wrote:
> On 11 jul, 13:28, Johan Grönqvist <(E-Mail Removed)> wrote:
>
>
>
>
>
> > 2010-07-11 02:12, Ritchy lelis skrev:

>
> > > On 7 jul, 08:38, Johan Grönqvist<(E-Mail Removed)> *wrote:

>
> > > About the plot draw it's a curve that it's a set of points wich it's
> > > the result of the comput of the Vref and Vi together. I don't know if
> > > i had to make a break instruction (like in other's languages) after
> > > the "If" instructions if i want the else-condition to be executed? ....
> > > (do you have some sujestions?)

>
> > I would have expected a code structure similar to this:

>
> > (NOTE: This is a very inefficient solution, and not the one suggested
> > earlier, but it is closer to the code snippet you posted originally, and
> > it does produce a plot.)

>
> > ----------------------
> > import numpy as np
> > import matplotlib.pyplot as plt
> > Vref = np.linspace(1,20, 100)
> > Vi = np.linspace(1,10,100)

>
> > for ref in Vref: # Loop over Vref and Vi
> > * * *for i in Vi:
> > * * * * *if *i > ref/4: # Compute V0
> > * * * * * * *V0 = 2*i-ref
> > * * * * *elif (-ref/4) <= ref and ref <= ref/4:
> > * * * * * * *V0 = 2*i
> > * * * * *elif i < -ref/4:
> > * * * * * * *V0 = 2*i+ref
> > * * * * *plt.plot(i, V0, ".") # Plot one single point at x = i, y = V0
> > plt.show() # Display the plot in a window
> > ----------------------

>
> > > Anyway i have a picture of a tuturial that i found but in this forum i
> > > can't post it. That pic would show what a really want...

>
> > Can you give a link?

>
> > > Relatively to the axis, the Vi takes the x-axis and the Vref takes the
> > > y-axis.

>
> > To me this sound like you want to make a 3D-plot, as there is the
> > x-axis, the y-axis, and V0. Is this correct? Is V0 on a z-axis?

>
> > > As i said, i have a good 2 pic of a doc that has the information about
> > > this ADC that i'm developing.

>
> > I looked on wikipedia
> > <http://en.wikipedia.org/wiki/Analog-to-digital_converter>, and saw some
> > figures. Is any of those similar to what you look for?

>
> > I see that they have (Vi - Vref) on the x-axis, and the computed value
> > on the y-axis.

>
> > Regards

>
> > Johan

>
> Hi
>
> Yes those fig look's familiar to me but for now the objective its to
> get that residue transfer function (1.5-Bit-Per-Stage Pipelined ADC).
>
> I found inhttp://amesp02.tamu.edu/~sanchez/ADC-pipeline_lecture.PDF
> there are some fig and explanations on page's 9-13. Can you take a
> look there please?
>
> Also you can take a look inhttp://www.maxim-ic.com/app-notes/index.mvp/id/1023
> (I think there it´s more information than the first link i gave you).
>
> I'll be waiting for sujestions.
>
> Thank's- Ocultar texto citado -
>
> - Mostrar texto citado -


hi

This is how looks like the flash residue transference function that i
was talking about...

http://www.iadc.ca/Imran_ADC_tutoria...s/image048.gif

I'm suposed to obtain a figure like that in my plot.

Somebody help me please.

Cheers
 
Reply With Quote
 
Ritchy lelis
Guest
Posts: n/a
 
      07-13-2010
On 11 Jul, 17:39, Ritchy lelis <(E-Mail Removed)> wrote:
> On 11 jul, 13:28, Johan Grönqvist <(E-Mail Removed)> wrote:
>
>
>
>
>
> > 2010-07-11 02:12, Ritchy lelis skrev:

>
> > > On 7 jul, 08:38, Johan Grönqvist<(E-Mail Removed)> *wrote:

>
> > > About the plot draw it's a curve that it's a set of points wich it's
> > > the result of the comput of the Vref and Vi together. I don't know if
> > > i had to make a break instruction (like in other's languages) after
> > > the "If" instructions if i want the else-condition to be executed? ....
> > > (do you have some sujestions?)

>
> > I would have expected a code structure similar to this:

>
> > (NOTE: This is a very inefficient solution, and not the one suggested
> > earlier, but it is closer to the code snippet you posted originally, and
> > it does produce a plot.)

>
> > ----------------------
> > import numpy as np
> > import matplotlib.pyplot as plt
> > Vref = np.linspace(1,20, 100)
> > Vi = np.linspace(1,10,100)

>
> > for ref in Vref: # Loop over Vref and Vi
> > * * *for i in Vi:
> > * * * * *if *i > ref/4: # Compute V0
> > * * * * * * *V0 = 2*i-ref
> > * * * * *elif (-ref/4) <= ref and ref <= ref/4:
> > * * * * * * *V0 = 2*i
> > * * * * *elif i < -ref/4:
> > * * * * * * *V0 = 2*i+ref
> > * * * * *plt.plot(i, V0, ".") # Plot one single point at x = i, y = V0
> > plt.show() # Display the plot in a window
> > ----------------------

>
> > > Anyway i have a picture of a tuturial that i found but in this forum i
> > > can't post it. That pic would show what a really want...

>
> > Can you give a link?

>
> > > Relatively to the axis, the Vi takes the x-axis and the Vref takes the
> > > y-axis.

>
> > To me this sound like you want to make a 3D-plot, as there is the
> > x-axis, the y-axis, and V0. Is this correct? Is V0 on a z-axis?

>
> > > As i said, i have a good 2 pic of a doc that has the information about
> > > this ADC that i'm developing.

>
> > I looked on wikipedia
> > <http://en.wikipedia.org/wiki/Analog-to-digital_converter>, and saw some
> > figures. Is any of those similar to what you look for?

>
> > I see that they have (Vi - Vref) on the x-axis, and the computed value
> > on the y-axis.

>
> > Regards

>
> > Johan

>
> Hi
>
> Yes those fig look's familiar to me but for now the objective its to
> get that residue transfer function (1.5-Bit-Per-Stage Pipelined ADC).
>
> I found inhttp://amesp02.tamu.edu/~sanchez/ADC-pipeline_lecture.PDF
> there are some fig and explanations on page's 9-13. Can you take a
> look there please?
>
> Also you can take a look inhttp://www.maxim-ic.com/app-notes/index.mvp/id/1023
> (I think there it´s more information than the first link i gave you).
>
> I'll be waiting for sujestions.
>
> Thank's- Ocultar texto citado -
>
> - Mostrar texto citado -


hi

This is how looks like the flash residue transference function that i
was talking about...

http://www.iadc.ca/Imran_ADC_tutoria...s/image048.gif

I'm suposed to obtain a figure like that in my plot.

Somebody help me please.

Cheers
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
$ sign to gb pound sign PWB Computer Support 6 02-19-2007 03:06 AM
Automatic sign-up and sign-in across different domains without cookies? Jimmy ASP .Net 1 11-21-2006 04:41 PM
Automatic sign-up and sign-in between different domains without cookies? Jimmy Javascript 3 11-20-2006 01:28 PM
J sign instead of ? sign Harold Potter esq. Computer Support 5 04-16-2005 02:19 PM
Variable size plot symbols, variable hue plot colors in Python (MatPlotLib) ? Dr. Colombes Python 1 02-10-2005 08:49 PM



Advertisments