Re: [Matplotlib-users] [SciPy-user] how to plot the result of histogram2d

2008-09-08 Thread Johann Cohen-Tanugi
thanks Johan,
I posted to scipy because of histogram2d being in numpy, sorry about that.
Now the stupid question, why can't imshow directly parse histogram2d, 
without the transitory extent object?
Anyway, I am happy that there is a simple way as explained below!

thanks again,
Johann

John Hunter wrote:
> On Fri, Sep 5, 2008 at 10:36 AM, Johann Cohen-Tanugi
> <[EMAIL PROTECTED]> wrote:
>   
>> hi, I hope someone can quickly point me to some doc.
>> I can do imshow(histogram2d(x,y)[0]) but then I miss the x and y binning
>> correct labels.
>> If I do imshow(histogram2d(x,y)) I get:
>> ERROR: An unexpected error occurred while tokenizing input
>> The following traceback may be corrupted or invalid
>> The error message is: ('EOF in multi-line statement', (115, 0))
>> 
>
> matplotlib questions are best addressed to the matplotlib-users mailing list 
> at
>
>http://lists.sourceforge.net/mailman/listinfo/matplotlib-users
>
> histogram2d returns H, xedges and yedges.  The first argument should
> be passed to imshow, and the second two can be used to get the extents
>
> In [26]: x, y = np.random.randn(2, 10)
>
> In [27]: H, xedges, yedges = np.histogram2d(x, y, bins=50)
>
> In [28]: extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
>
> In [29]: imshow(H, extent=extent)
> Out[29]: 
>
> I
> ___
> SciPy-user mailing list
> [EMAIL PROTECTED]
> http://projects.scipy.org/mailman/listinfo/scipy-user
>   

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] problem with histogram

2008-09-08 Thread Manuel Metz
Antonino Cucchiara wrote:
> Hello list,
> I am trying to run the "histogram_demo_extended.py" on my mac 10.5.
> I installed matplotlib through the scisoft package.
> The normal hist command works fine but when I tried to use "align" or 
> "histtype" keyward I get this kind of error:
> 
> [Macintosh-2:~/optional/examples/pylab_examples] nino% 
> ./histogram_demo_extended.py 
> Traceback (most recent call last):
>   File "./histogram_demo_extended.py", line 15, in 
> n, bins, patches = P.hist(x, 50, normed=1, histtype='stepfilled')
>   File 
> "/scisoft/i386/library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/pyplot.py",
>  
> line 1633, in hist
> ret =  gca().hist(*args, **kwargs)
>   File 
> "/scisoft/i386/library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py",
>  
> line 5064, in hist
> p.update(kwargs)
>   File 
> "/scisoft/i386/library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/artist.py",
>  
> line 394, in update
> raise AttributeError('Unknown property %s'%k)
> AttributeError: Unknown property histtype
> 
> Can someone give me any advice?
> Thanks a lot in advance.
> 
> nino
> 

I guess that you installed matplotlib v0.91.x via scisoft !? The keyword 
"histtype" was introduced in 0.98.0, so you can't use it on your system.

Manuel

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] problem with histogram

2008-09-08 Thread Antonino Cucchiara
Yes, I did indeed.
Is it sufficient replace the matplotlib directory under the scisoft/ 
with the one available from the site (0.98.0) to update it?
I also noticed that the available Fink package is also the 
matplotlib-0.91.0.

Thanks,
Nino

Manuel Metz wrote:
> Antonino Cucchiara wrote:
>   
>> Hello list,
>> I am trying to run the "histogram_demo_extended.py" on my mac 10.5.
>> I installed matplotlib through the scisoft package.
>> The normal hist command works fine but when I tried to use "align" or 
>> "histtype" keyward I get this kind of error:
>>
>> [Macintosh-2:~/optional/examples/pylab_examples] nino% 
>> ./histogram_demo_extended.py 
>> Traceback (most recent call last):
>>   File "./histogram_demo_extended.py", line 15, in 
>> n, bins, patches = P.hist(x, 50, normed=1, histtype='stepfilled')
>>   File 
>> "/scisoft/i386/library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/pyplot.py",
>>  
>> line 1633, in hist
>> ret =  gca().hist(*args, **kwargs)
>>   File 
>> "/scisoft/i386/library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py",
>>  
>> line 5064, in hist
>> p.update(kwargs)
>>   File 
>> "/scisoft/i386/library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/artist.py",
>>  
>> line 394, in update
>> raise AttributeError('Unknown property %s'%k)
>> AttributeError: Unknown property histtype
>>
>> Can someone give me any advice?
>> Thanks a lot in advance.
>>
>> nino
>>
>> 
>
> I guess that you installed matplotlib v0.91.x via scisoft !? The keyword 
> "histtype" was introduced in 0.98.0, so you can't use it on your system.
>
> Manuel
>
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


-- 

Antonino Cucchiara
PhD candidate
Department of Astronomy&Astrophysics
Penn State University
website: www.astro.psu.edu/~cucchiara/


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Re-projecting raster data with Basemap

2008-09-08 Thread Jose Gómez-Dans
Hi,
I am starting to play with Basemap. I have some raster data in 
longitude/latitude (WGS-84, EPSG: 4326).  I would like to plot it using 
imshow, and to then plot some country boundaries and so on and so forth. I 
have studied the plotprecip.py example in Basemap's distribution, but as far 
as i can tell, there's no reprojection of the data there (i.e., the data is 
already in whatever projection Basemap was initiated with). While I can 
reproject the data outside of MPL, I was wondering whether I'm missing 
something, and I can just reproject my data and call imshow within my python 
script.

Cheers,
J



-- 
NERC Centre for Terrestrial Carbon Dynamics,
Department of Geography, University College London
Gower Street, London WC1E 6BT, UK

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] path and bbox

2008-09-08 Thread Evan Mason
Hi, wonder if anyone can help me with path and bbox.  I have a set of ocean
drifter tracks and I want to know if they pass through a particular boxed
area.  This is straightforward to do but I wanted to try to do it with
matplotlib.transforms and matplotlib.path, which look well-suited to this
kind of task using 'intersects_bbox'.

The essence of my code is below.  I have a single drifter track (lon, lat)
and have defined a boxed area.  At no time does the drifter approach or
enter the box - however, the final line,

print track.intersects_bbox(bbox)

returns True, which it shouldn't.  In total I have 340 tracks.  My code says
74 pass though the box, but by counting there should be only about 9.  Any
help appreciated, thanks, Evan


import numpy as N
import numpy.ma as MA
import matplotlib.transforms as BB
import matplotlib.path as PP

In [200]: lon
Out[200]:
masked_array(data = [-15.52 -15.521 -15.541 ..., -- -- --],
  mask = [False False False ...,  True  True  True],
  fill_value=1e+20)

In [201]: lat
Out[201]:
masked_array(data = [29.2 29.2 29.196 ..., -- -- --],
  mask = [False False False ...,  True  True  True],
  fill_value=1e+20)

In [202]: len(lon), len(lat)
Out[202]: (3750, 3750)

track = MA.transpose([lon, lat])
track = PP.Path(track)
bbox = BB.Bbox.from_extents(-15.95, 29.6, -15.9, 29.65)

In [206]: print track.intersects_bbox(bbox)
1
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Re-projecting raster data with Basemap

2008-09-08 Thread Jeff Whitaker
Jose Gómez-Dans wrote:
> Hi,
> I am starting to play with Basemap. I have some raster data in 
> longitude/latitude (WGS-84, EPSG: 4326).  I would like to plot it using 
> imshow, and to then plot some country boundaries and so on and so forth. I 
> have studied the plotprecip.py example in Basemap's distribution, but as far 
> as i can tell, there's no reprojection of the data there (i.e., the data is 
> already in whatever projection Basemap was initiated with). While I can 
> reproject the data outside of MPL, I was wondering whether I'm missing 
> something, and I can just reproject my data and call imshow within my python 
> script.
>
> Cheers,
> J
>
>
>
>   
Jose:  If you data is on a lat/lon grid, you can plot it directly with 
Basemap with projection='cyl'.  If you want to plot it on some other 
projection, you can reproject the data with Basemap quite easily.  The 
test.py script in the examples directory shows how to reproject lat/lon 
data and plot with  imshow for each of the map projections Basemap 
supports.

The basic recipe is this:

import numpy as np
import matplotlib.pyplot as plt
# transform to nx x ny regularly spaced 40km native projection grid
nx = int((m.xmax-m.xmin)/4.)+1; ny = int((m.ymax-m.ymin)/4.)+1
# datain is input data on lat/lon grid described by 1d arrays lons, lats
# (longitudes and latitudes in degrees).
topodat = m.transform_scalar(datain,lons,lats,nx,ny)
# plot image over map with imshow. m is a Basemap instance defining the 
projection
# you want to plot on.
im = m.imshow(topodat,plt.cm.jet)

Note that to plot the data with pcolor/pcolormesh of contourf, you don't 
need to interpolate to a native projection grid.  You can just do

lons, lats = np.meshgrid(lons,lats)
x,y = m(lons,lats)
im = m.pcolormesh(x,y,datain)

-Jeff

-- 
Jeffrey S. Whitaker Phone  : (303)497-6313
Meteorologist   FAX: (303)497-6449
NOAA/OAR/PSD  R/PSD1Email  : [EMAIL PROTECTED]
325 BroadwayOffice : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Multiple column legends

2008-09-08 Thread Jose Gómez-Dans
Hi!
About a year ago, Jouni Seppänen indicated how to put a number of patches in a 
legend. So far so good. Now, it turns out that I do have quite a lot of 
patches to throw into this legend, and it would be nice, rather than to have 
a single column, to have the possibility to arrange these patches (and 
associated labels) into columns. I have looked at the legend object, but 
there is nothing suggesting that things can be shuffled around within the 
legend box itself, some sort of "subplot()" for the legend patches. Am I 
correct in assuming this doesn't exist (yet!). I am running 0.91.2, maybe 
it's already been implemented, but I thought I'd ask!

Cheers!
J


-- 
NERC Centre for Terrestrial Carbon Dynamics,
Department of Geography, University College London
Gower Street, London WC1E 6BT, UK

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] interger to binary

2008-09-08 Thread Marjolaine Rouault
Hi all,

Michael's solution worked like a charm. Thanks to all for your valuable input!

Rgs.

>>> Michael Droettboom <[EMAIL PROTECTED]> 09/05/08 7:54 PM >>>
You could do something like:

def bitget(value, bit_number):
return (value & (1 << bit_number)) != 0

which will return True or False for the given bit number, and this 
function works on numpy arrays.  (Bits are numbered base-0 -- I don't 
know if that matches matlab).

Hope that helps,
Mike

Marjolaine Rouault wrote:
> Hi,
>
> I was wondering if python has the equivalent of the matlab bitget.m function.
>
> I have a large 2 dimensional variable of type uint32 which I must convert to 
> binaries and then find if bit 23 of the binary for each point is 0 or 1. The 
> matlab bitget function is ideal for that but I can't find much in python. The 
> only thing I found was binary_repr which converts to a sting and can only be 
> used for 1 point at a time.
>
> Any suggestions?
>
> Thanks, Marjolaine.
>
>   

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA



-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail 
legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at 
http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their 
support.


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] size of the plot

2008-09-08 Thread Bernardo Martins Rocha
Hi Guys,

how can I set the size of a plot window by, let's say, 320 x 180 and make it 
fix, that is, something like "resize=False". I had a look at the documentation 
but I couldn't figure out which object and method I have to use for this.

Thanks in advance!
Bernardo M. Rocha

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Re-projecting raster data with Basemap

2008-09-08 Thread Jose Gomez-Dans
Jeff,

On Mon, Sep 8, 2008 at 6:48 PM, Jeff Whitaker <[EMAIL PROTECTED]> wrote:

> Note that to plot the data with pcolor/pcolormesh of contourf, you don't
> need to interpolate to a native projection grid.  You can just do
>
> lons, lats = np.meshgrid(lons,lats)
> x,y = m(lons,lats)
> im = m.pcolormesh(x,y,datain)


OK, I've gone down the pcolormesh route. Results is very nice. However, if I
try to save my file as an EPS or PDF, it takes a long time, and the
resulting PDF is 12Mb (!). The equivalent EPS is of the order of 500MB
(), and the PNG is around 100kb (!). I have a really hard time
rendering either the EPS or the PDF, and I guess that using pcolormesh
somehow sticks all the pixels into the resulting "page". My image size is
around 1000x2500 pixels, and I'm not particularly bothered if it is smoothed
for "presentation purposes" (in fact, I think I can see some aliasing, but
don't have the plot in front of me right now).

I don't recall this problem when using imshow (no basemap involved). Is this
a pcolormesh "feature" (or converseley, an imshow feature?). Is there some I
can make my plots be as reasonable as other MPL plots that are mostly
vectors rather than rasters?

Cheers,
J



-- 
Centre for Terrestrial Carbon Dynamics
Department of Geography, University College London
Gower Street, London WC1E 6BT, UK
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [SciPy-user] how to plot the result of histogram2d

2008-09-08 Thread Eric Firing
Johann Cohen-Tanugi wrote:
> thanks Johan,
> I posted to scipy because of histogram2d being in numpy, sorry about that.
> Now the stupid question, why can't imshow directly parse histogram2d, 
> without the transitory extent object?

imshow is a general image display function; it would not make sense to 
customize it to match histogram2d.

You may want to use Axes.pcolorfast instead.  Example using ipython -pylab:

In [1]:import numpy as np

In [2]:x, y = np.random.randn(2, 10)

In [3]:H, xedges, yedges = np.histogram2d(x, y, bins=50)

In [4]:fig = figure()

In [5]:ax = fig.add_subplot(111)

In [6]:ax.pcolorfast?

In [7]:ax.pcolorfast(xedges, yedges, H)
Out[7]:

In [8]:draw()

Eric

> Anyway, I am happy that there is a simple way as explained below!
> 
> thanks again,
> Johann
> 
> John Hunter wrote:
>> On Fri, Sep 5, 2008 at 10:36 AM, Johann Cohen-Tanugi
>> <[EMAIL PROTECTED]> wrote:
>>   
>>> hi, I hope someone can quickly point me to some doc.
>>> I can do imshow(histogram2d(x,y)[0]) but then I miss the x and y binning
>>> correct labels.
>>> If I do imshow(histogram2d(x,y)) I get:
>>> ERROR: An unexpected error occurred while tokenizing input
>>> The following traceback may be corrupted or invalid
>>> The error message is: ('EOF in multi-line statement', (115, 0))
>>> 
>> matplotlib questions are best addressed to the matplotlib-users mailing list 
>> at
>>
>>http://lists.sourceforge.net/mailman/listinfo/matplotlib-users
>>
>> histogram2d returns H, xedges and yedges.  The first argument should
>> be passed to imshow, and the second two can be used to get the extents
>>
>> In [26]: x, y = np.random.randn(2, 10)
>>
>> In [27]: H, xedges, yedges = np.histogram2d(x, y, bins=50)
>>
>> In [28]: extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
>>
>> In [29]: imshow(H, extent=extent)
>> Out[29]: 
>>

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Re-projecting raster data with Basemap

2008-09-08 Thread Jeff Whitaker
Jose Gomez-Dans wrote:
> Jeff,
>
> On Mon, Sep 8, 2008 at 6:48 PM, Jeff Whitaker <[EMAIL PROTECTED] 
> > wrote:
>
> Note that to plot the data with pcolor/pcolormesh of contourf, you
> don't need to interpolate to a native projection grid.  You can
> just do
>
> lons, lats = np.meshgrid(lons,lats)
> x,y = m(lons,lats)
> im = m.pcolormesh(x,y,datain)
>
>
> OK, I've gone down the pcolormesh route. Results is very nice. 
> However, if I try to save my file as an EPS or PDF, it takes a long 
> time, and the resulting PDF is 12Mb (!). The equivalent EPS is of the 
> order of 500MB (), and the PNG is around 100kb (!). I have a 
> really hard time rendering either the EPS or the PDF, and I guess that 
> using pcolormesh somehow sticks all the pixels into the resulting 
> "page". My image size is around 1000x2500 pixels, and I'm not 
> particularly bothered if it is smoothed for "presentation purposes" 
> (in fact, I think I can see some aliasing, but don't have the plot in 
> front of me right now).
>
> I don't recall this problem when using imshow (no basemap involved). 
> Is this a pcolormesh "feature" (or converseley, an imshow feature?). 
> Is there some I can make my plots be as reasonable as other MPL plots 
> that are mostly vectors rather than rasters?
>
> Cheers,
> J

Jose:  Basemap has nothing to do with it.  I suspect you would see the 
same PDF and EPS sizes with imshow.  I don't know of anyway around it, 
other than using high-resolution PNG files instead of EPS/PDF.

-Jeff

-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC  R/PSD1FAX   : (303)497-6449
325 BroadwayBoulder, CO, USA 80305-3328


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] path and bbox

2008-09-08 Thread Eric Firing
Evan Mason wrote:
> Hi, wonder if anyone can help me with path and bbox.  I have a set of 
> ocean drifter tracks and I want to know if they pass through a 
> particular boxed area.  This is straightforward to do but I wanted to 
> try to do it with matplotlib.transforms and matplotlib.path, which look 
> well-suited to this kind of task using 'intersects_bbox'.
> 
> The essence of my code is below.  I have a single drifter track (lon, 
> lat) and have defined a boxed area.  At no time does the drifter 
> approach or enter the box - however, the final line,
> 
> print track.intersects_bbox(bbox)
> 
> returns True, which it shouldn't.  In total I have 340 tracks.  My code 
> says 74 pass though the box, but by counting there should be only about 
> 9.  Any help appreciated, thanks, Evan
> 
> 
> import numpy as N
> import numpy.ma  as MA
> import matplotlib.transforms as BB
> import matplotlib.path as PP
> 
> In [200]: lon
> Out[200]:
> masked_array(data = [-15.52 -15.521 -15.541 ..., -- -- --],
>   mask = [False False False ...,  True  True  True],
>   fill_value=1e+20)
> 
> In [201]: lat
> Out[201]:
> masked_array(data = [29.2 29.2 29.196 ..., -- -- --],
>   mask = [False False False ...,  True  True  True],
>   fill_value=1e+20)
> 
> In [202]: len(lon), len(lat)
> Out[202]: (3750, 3750)
> 
> track = MA.transpose([lon, lat])
> track = PP.Path(track)
> bbox = BB.Bbox.from_extents(-15.95, 29.6, -15.9, 29.65)
> 
> In [206]: print track.intersects_bbox(bbox)
> 1

Evan,

Can you strip the problem down more?  That is, find one track that is 
misdiagnosed, and then try to find the shortest segment of it that still 
gets misdiagnosed.  You could try subsampling and/or chopping chunks off 
the ends.  If you can get it down to a track with only a few points, so 
that you can email a very short but complete script with illustrative 
data, that would make it much easier for someone to figure out what is 
going on.

I suspect it is related to the masked values.  If you strip the masked 
points out of your lon and lat arrays, do you get the same result?
Try making an example with only 3 points, say with the middle one 
masked, and then unmasked.

Eric

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Next problem: pixel-to-pixel alpha variation

2008-09-08 Thread David Goldsmith
Hi, folks.  OK, I'm trying to set the alpha channel, pixel by pixel, using 
figimage w/ the data being of the "luminance" type (i.e., an MxN array).  The 
Users Guide indicates that figimage takes an alpha= keyword argument, and it 
doesn't crash when I pass an array for this value, but subsequently when I try 
to draw it using fig.draw(canvas.get_renderer()), I get:

>>> fig.draw(canvas.get_renderer())
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\python25\lib\site-packages\matplotlib\figure.py", line 607, in draw
im.draw(renderer)
  File "C:\python25\lib\site-packages\matplotlib\image.py", line 597, in draw
im = self.make_image()
  File "C:\python25\lib\site-packages\matplotlib\image.py", line 583, in make_im
age
x = self.to_rgba(self._A, self._alpha)
  File "C:\python25\lib\site-packages\matplotlib\cm.py", line 76, in to_rgba
x = self.cmap(x, alpha=alpha, bytes=bytes)
  File "C:\python25\lib\site-packages\matplotlib\colors.py", line 423, in __call
__
alpha = min(alpha, 1.0) # alpha must be between 0 and 1
ValueError: The truth value of an array with more than one element is ambiguous.
 Use a.any() or a.all()

which to me "smells" as if the array-valued alpha is the problem.  

Clearly (?) I can do what I'm after if I use MxNx4 data, but is that the only 
way to have a varying alpha?

Thanks!

DG





  

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users