Re: Ploting an array[][] on Jyhton

  • To: Cicero Augusto Wollmane Zandona <cicero@xxxxxxxxxx>
  • Subject: Re: Ploting an array[][] on Jyhton
  • From: Tom Whittaker <tomw@xxxxxxxxxxxxx>
  • Date: Wed, 29 Aug 2001 21:16:11 -0500 (CDT)
Cicero:

Disregard my last note -- I don't need to see your file...I just needed to
stare at your code a little more. ;-)

The problem is that you are _not_ creating a List that looks like:
[(1,2,3),(2,3,4),(3,4,5)...]

instead, you have made at List that looks like:
[[(1,2,3)],[(2,3,4)],[(3,4,5)]...]

that is, one too many levels of nesting!

Here is why:

> matriz = []
> file=open("radar200108291645Z.dat",'rb')
> for i in range(512):
>       linha = []
>       g=file.read(2048)
>       linha.append(struct.unpack('512f',g)) 

linha is a List, but "struct.unpack" will return a Tuple (an immutable
list), so the one element of the List linha contains one Tuple. 

>       matriz.append(linha)

So to do what you need, change what's inside your for loop to be simply:
      g=file.read(2048)
      matriz.append(struct.unpack('512f',g))

and you should be fine.

> f=field(matriz)
> plot(f)
> 

tom
--
Tom Whittaker
University of Wisconsin-Madison
SSEC/CIMSS


  • 2001 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: