Jeff,
Nevermind...

I figured out the problem...
It appears that the grads mpl interface (pygrads) wasn't creating an
appropriate mask for the data.
All of the '-9.99e+8' values that correspond to 'undefined' points weren't
being masked out, and were thus causing quiver to freak out & try to draw
some extreme vector arrows...

I fixed the mask, and it works fine now...
Sorry for the bother, but thanks anyway for the help...

Regards,
P.R.


-----Original Message-----
From: Jeff Whitaker [mailto:jsw...@fastmail.fm] 
Sent: 2009-08-11 11:05 PM
To: P.R.
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] problem with basemap/quiver with latest
versions of basemap&mpl

P.R. wrote:
> Ok, I upgraded to numpy 1.30 and the problem still showed up...
> Im still getting those strange diagonal line defects.
> (looks as if some of the edge arrow polygons are being
clipped/drawn/closed
> improperly & thus 'dragged' across the plot area???)
>
> I attached my x,y,u,v arrays...
>   

P.R.  The file appears to be corrupted:

   In [4]: from numpy import load

In [5]: load('xy_uv.npz').files
Out[5]: ['y', 'x', 'u', 'v']

In [6]: load('xy_uv.npz')['u']
---------------------------------------------------------------------------
BadZipfile                                Traceback (most recent call last)

/Users/jsw/python/basemap/<ipython console> in <module>()

/opt/local/lib/python2.5/site-packages/numpy/lib/io.pyc in 
__getitem__(self, key)
    110             key += '.npy'
    111         if member:
--> 112             bytes = self.zip.read(key)
    113             if bytes.startswith(format.MAGIC_PREFIX):
    114                 value = cStringIO.StringIO(bytes)

/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/zi
pfile.pyc 
in read(self, name)
    477         fheader = self.fp.read(30)
    478         if fheader[0:4] != stringFileHeader:
--> 479             raise BadZipfile, "Bad magic number for file header"
    480
    481         fheader = struct.unpack(structFileHeader, fheader)

BadZipfile: Bad magic number for file header

-Jeff

> Here's my basemap setup...
>
m=bm(projection='cyl',llcrnrlat=20,urcrnrlat=30,llcrnrlon=-100,urcrnrlon=-80
> ,resolution='h')      
>
> though it might not help much, here's the exact export from pygrads
> (ga.expr() exports from grads into a customized masked array in python)
> 'dirpw' is the grads variable being imported into mpl.
>
> U = ga.expr('(-1*sin(dirpw*3.1414/180))')
> V = ga.expr('(-1*cos(dirpw*3.1414/180))')
> X,Y=m(*np.meshgrid(U.grid.lon,U.grid.lat))
>
> I then was also doing this to convert to simple ndarrays
> (a while back, I was recommended this method to solve a problem I was
having
> with quiver performing really slowly when using those grads masked arrays
as
> input)
>
> x,y,u,v = delete_masked_points(X.ravel(), Y.ravel(), U.ravel(), V.ravel())
>
> Let me know if you need anything else...
>
> Thanks,
> P.R.
>
>
> -----Original Message-----
> From: Jeff Whitaker [mailto:jsw...@fastmail.fm] 
> Sent: 2009-08-11 9:26 PM
> To: P.R.
> Cc: matplotlib-users@lists.sourceforge.net
> Subject: Re: [Matplotlib-users] problem with basemap/quiver with latest
> versions of basemap&mpl
>
> P.R. wrote:
>   
>> Hi,
>> I just updated to the latest versions of mpl & basemap.
>> Im getting strange output when using the quiver function from basemap
(see
>> attached image).
>>
>> I ran the quiver_demo scripts for both basemap & also mpl, and the output
>> looked normal.
>>
>> Im using pygrads, a python interface to GrADS, in order to generate my
>> X,Y,U,V input arrays for quiver.
>> I can provide these arrays if needed...
>>
>> The data imported using pygrads previously worked fine (prior to updating
>>     
> to
>   
>> the new versions).
>>
>> Before I start diving into the pygrads code in order to troubleshoot, I
>> wanted to first check to see if this issue is a possible quiver bug in
the
>> new version(s)...
>>
>> Or, were there any significant changes to the mpl/basemap code with
>>     
> respect
>   
>> to how quiver works???
>>
>> Here's the basic method Im using...
>> U = <my_pygrads_imported_U>
>> V = <my_pygrads_imported_V>
>> X,Y=m(*np.meshgrid(U.grid.lon,U.grid.lat))
>> #x,y,u,v = delete_masked_points(X.ravel(), Y.ravel(), U.ravel(),
>>     
> V.ravel())
>   
>> cs2 = m.quiver(X,Y,U,V,*kwargs)
>>
>> again, this *used* to work fine, prior to the updates...
>>
>> Please help,
>> Thanks,
>> P.Romero
>>   
>>     
>
> P.R.:  I can't see anything wrong - you'd better post your data so we 
> can try it.  You might also try to upgrade to numpy 1.3.0, if you 
> haven't already, I know there were some masked array changes between 
> 1.2.1 and 1.3.
>
> -Jeff



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to