Re: [Matplotlib-users] Rectangle Bug

2012-09-07 Thread Phil Elson
This seems to a be common misconception...

I guess in future, we could add a check to the add_patch method to see if
the given artist already has an associated Axes, and if it does, emit a
warning.



On 7 September 2012 07:42, Eric Firing  wrote:

> On 2012/09/06 8:35 PM, jonasr wrote:
> > That seems to work, thank you.
> >
> > I would have thought that the add_patch function creates two seperate
> > objects independent of the defined Rectangle.
>
> add_patch doesn't create any objects; it just attaches the axes to the
> patch in both directions: a reference to the patch object is appended to
> a list of axes artists, and the patch object gets a reference to the
> axes.  Fortunately, python has garbage collection to handle such
> circular references.
>
> Eric
>
> >
> > greets jonas
>
>
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Rectangle Bug

2012-09-07 Thread Eric Firing
On 2012/09/06 9:03 PM, Phil Elson wrote:
> This seems to a be common misconception...
>
> I guess in future, we could add a check to the add_patch method to see
> if the given artist already has an associated Axes, and if it does, emit
> a warning.

It's not just patches; but I think a single warning in Artist.add_axes 
would do it, perhaps at the cost of generating an unnecessary warning 
for some legitimate use case.

Eric

>
>
>
> On 7 September 2012 07:42, Eric Firing  > wrote:
>
> On 2012/09/06 8:35 PM, jonasr wrote:
>  > That seems to work, thank you.
>  >
>  > I would have thought that the add_patch function creates two seperate
>  > objects independent of the defined Rectangle.
>
> add_patch doesn't create any objects; it just attaches the axes to the
> patch in both directions: a reference to the patch object is appended to
> a list of axes artists, and the patch object gets a reference to the
> axes.  Fortunately, python has garbage collection to handle such
> circular references.
>
> Eric
>
>  >
>  > greets jonas
>
>
> 
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond.
> Discussions
> will include endpoint security, mobile security and the latest in
> malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> 
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] John Hunter's memorial service

2012-09-07 Thread Fernando Perez
Hi all,

I have just received the following information from John's family
regarding the memorial service:

John's memorial service will be held on Monday, October 1, 2012, at
11.a.m. at Rockefeller Chapel at the University of Chicago.  The exact
address is 5850 S. Woodlawn Ave, Chicago, IL 60615.  The service is
open to the public.  The service will be fully planned and scripted
with no room for people to eulogize, however, we will have a reception
after the service, hosted by Tradelink, where people can talk.

Regards,

f

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] MemoryError with NetCDF

2012-09-07 Thread Shahar Shani-Kadmiel
1. an ipython session is invoked with qtconsole --pylab 
2. I load a large NetCDF grid (Grid file format: nf (# 18) GMT netCDF format 
(float)  (COARDS-compliant) [DEFAULT]), approx. 1.15 GB
3. I then try to plot with imshow the data

added below are the lines leading up to the error and the error itself.


This is running on OS X 10.7.4 with a recently installed EPD 7.3.


{code}
from scipy.io import netcdf_file as netcdf
data = netcdf('srtm_43_44_05_06_07_08.grd','r').variables['z'][::-1]

fig, ax = subplots()

data.shape
Out[5]: (24004, 12002)

im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), 
interpolation='none')
---
MemoryError   Traceback (most recent call last)
 in ()
> 1 im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), 
interpolation='none')

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py
 in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, 
origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
   6743 im.set_clim(vmin, vmax)
   6744 else:
-> 6745 im.autoscale_None()
   6746 im.set_url(url)
   6747 

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/cm.py
 in autoscale_None(self)
281 if self._A is None:
282 raise TypeError('You must first set_array for mappable')
--> 283 self.norm.autoscale_None(self._A)
284 self.changed()
285 

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py
 in autoscale_None(self, A)
889 ' autoscale only None-valued vmin or vmax'
890 if self.vmin is None:
--> 891 self.vmin = ma.min(A)
892 if self.vmax is None:
893 self.vmax = ma.max(A)

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
 in min(obj, axis, out, fill_value)
   5873 def min(obj, axis=None, out=None, fill_value=None):
   5874 try:
-> 5875 return obj.min(axis=axis, fill_value=fill_value, out=out)
   5876 except (AttributeError, TypeError):
   5877 # If obj doesn't have a max method,

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
 in min(self, axis, out, fill_value)
   5054 # No explicit output
   5055 if out is None:
-> 5056 result = self.filled(fill_value).min(axis=axis, 
out=out).view(type(self))
   5057 if result.ndim:
   5058 # Set the mask

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
 in filled(self, fill_value)
   3388 return self._data
   3389 else:
-> 3390 result = self._data.copy()
   3391 try:
   3392 np.putmask(result, m, fill_value)

MemoryError: 
{/code}
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] MemoryError with NetCDF

2012-09-07 Thread Benjamin Root
On Fri, Sep 7, 2012 at 8:44 AM, Shahar Shani-Kadmiel  wrote:

> 1. an ipython session is invoked with qtconsole --pylab
> 2. I load a large NetCDF grid (Grid file format: nf (# 18) GMT netCDF
> format (float)  (COARDS-compliant) [DEFAULT]), approx. 1.15 GB
> 3. I then try to plot with imshow the data
>
> added below are the lines leading up to the error and the error itself.
>
>
> This is running on OS X 10.7.4 with a recently installed EPD 7.3.
>
>
> {code}
> from scipy.io import netcdf_file as netcdf
> data = netcdf('srtm_43_44_05_06_07_08.grd','r').variables['z'][::-1]
>
> fig, ax = subplots()
>
> data.shape
> Out[5]: (24004, 12002)
>
> im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])),
> interpolation='none')
> ---
> MemoryError   Traceback (most recent call last)
>  in ()
> > 1 im = ax.imshow(data,
> aspect=((data.shape[1])/float(data.shape[0])), interpolation='none')
>
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py
> in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax,
> origin, extent, shape, filternorm, filterrad, imlim, resample, url,
> **kwargs)
>6743 im.set_clim(vmin, vmax)
>6744 else:
> -> 6745 im.autoscale_None()
>6746 im.set_url(url)
>6747
>
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/cm.py
> in autoscale_None(self)
> 281 if self._A is None:
> 282 raise TypeError('You must first set_array for
> mappable')
> --> 283 self.norm.autoscale_None(self._A)
> 284 self.changed()
> 285
>
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py
> in autoscale_None(self, A)
> 889 ' autoscale only None-valued vmin or vmax'
> 890 if self.vmin is None:
> --> 891 self.vmin = ma.min(A)
> 892 if self.vmax is None:
> 893 self.vmax = ma.max(A)
>
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
> in min(obj, axis, out, fill_value)
>5873 def min(obj, axis=None, out=None, fill_value=None):
>5874 try:
> -> 5875 return obj.min(axis=axis, fill_value=fill_value, out=out)
>5876 except (AttributeError, TypeError):
>5877 # If obj doesn't have a max method,
>
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
> in min(self, axis, out, fill_value)
>5054 # No explicit output
>5055 if out is None:
> -> 5056 result = self.filled(fill_value).min(axis=axis,
> out=out).view(type(self))
>5057 if result.ndim:
>5058 # Set the mask
>
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
> in filled(self, fill_value)
>3388 return self._data
>3389 else:
> -> 3390 result = self._data.copy()
>3391 try:
>3392 np.putmask(result, m, fill_value)
>
> MemoryError:
> {/code}
>

This is more a NumPy issue than anything else.  We need to know the min and
the max of the array in order to automatically scale the colormap for
display.  Therefore, we query the array object for its min/max.  Because we
support masked arrays, the array is first cast as a masked array, and then
these queries are done.

It appears that in numpy's masked array module, it calculates the array's
min by making a copy of itself first.  I would have figured that it would
have done its task differently.  In the meantime, I suspect you can work
around this problem by explicitly setting the vmin/vmax keyword arguments
to imshow if you know them.  Therefore, there should be no need to
determine the array's min/max in this inefficient manner.

Ben Root
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] MemoryError with NetCDF

2012-09-07 Thread Shahar Shani-Kadmiel
On Sep 7, 2012, at 4:25 PM, Benjamin Root wrote:

> 
> 
> On Fri, Sep 7, 2012 at 8:44 AM, Shahar Shani-Kadmiel  
> wrote:
> 1. an ipython session is invoked with qtconsole --pylab
> 2. I load a large NetCDF grid (Grid file format: nf (# 18) GMT netCDF format 
> (float)  (COARDS-compliant) [DEFAULT]), approx. 1.15 GB
> 3. I then try to plot with imshow the data
> 
> added below are the lines leading up to the error and the error itself.
> 
> 
> This is running on OS X 10.7.4 with a recently installed EPD 7.3.
> 
> 
> {code}
> from scipy.io import netcdf_file as netcdf
> data = netcdf('srtm_43_44_05_06_07_08.grd','r').variables['z'][::-1]
> 
> fig, ax = subplots()
> 
> data.shape
> Out[5]: (24004, 12002)
> 
> im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), 
> interpolation='none')
> ---
> MemoryError   Traceback (most recent call last)
>  in ()
> > 1 im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), 
> interpolation='none')
> 
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py
>  in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, 
> origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
>6743 im.set_clim(vmin, vmax)
>6744 else:
> -> 6745 im.autoscale_None()
>6746 im.set_url(url)
>6747
> 
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/cm.py
>  in autoscale_None(self)
> 281 if self._A is None:
> 282 raise TypeError('You must first set_array for mappable')
> --> 283 self.norm.autoscale_None(self._A)
> 284 self.changed()
> 285
> 
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py
>  in autoscale_None(self, A)
> 889 ' autoscale only None-valued vmin or vmax'
> 890 if self.vmin is None:
> --> 891 self.vmin = ma.min(A)
> 892 if self.vmax is None:
> 893 self.vmax = ma.max(A)
> 
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
>  in min(obj, axis, out, fill_value)
>5873 def min(obj, axis=None, out=None, fill_value=None):
>5874 try:
> -> 5875 return obj.min(axis=axis, fill_value=fill_value, out=out)
>5876 except (AttributeError, TypeError):
>5877 # If obj doesn't have a max method,
> 
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
>  in min(self, axis, out, fill_value)
>5054 # No explicit output
>5055 if out is None:
> -> 5056 result = self.filled(fill_value).min(axis=axis, 
> out=out).view(type(self))
>5057 if result.ndim:
>5058 # Set the mask
> 
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
>  in filled(self, fill_value)
>3388 return self._data
>3389 else:
> -> 3390 result = self._data.copy()
>3391 try:
>3392 np.putmask(result, m, fill_value)
> 
> MemoryError:
> {/code}
> 
> This is more a NumPy issue than anything else.  We need to know the min and 
> the max of the array in order to automatically scale the colormap for 
> display.  Therefore, we query the array object for its min/max.  Because we 
> support masked arrays, the array is first cast as a masked array, and then 
> these queries are done.
> 
> It appears that in numpy's masked array module, it calculates the array's min 
> by making a copy of itself first.  I would have figured that it would have 
> done its task differently.  In the meantime, I suspect you can work around 
> this problem by explicitly setting the vmin/vmax keyword arguments to imshow 
> if you know them.  Therefore, there should be no need to determine the 
> array's min/max in this inefficient manner.
> 
> Ben Root
> 

Hi Ben,
I tried adding vmin & vmax the the imshow call but I still get a MemoryError.
The grid file is 1.15 GB and I have ~4.5 out of 8 GB of memory available when I 
launch ipython, 3.5 when I execute imshow and 2 when I execute plt.draw().

im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), 
interpolation=None, vmin=-400., vmax=3000.)

plt.draw()
---
MemoryError   Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/artist.py
 in draw_wrapper(artist, renderer, *args, **kwargs)
 53 def draw_wrapper(artist, renderer, *args, **kwargs):
 54 before(artist, renderer)
---> 55 draw(artist, renderer, *args, **kwargs)
 56 after(ar

Re: [Matplotlib-users] MemoryError with NetCDF

2012-09-07 Thread Benjamin Root
On Fri, Sep 7, 2012 at 9:49 AM, Shahar Shani-Kadmiel  wrote:

> On Sep 7, 2012, at 4:25 PM, Benjamin Root wrote:
>
>
>
> On Fri, Sep 7, 2012 at 8:44 AM, Shahar Shani-Kadmiel <
> kadm...@post.bgu.ac.il> wrote:
>
>> 1. an ipython session is invoked with qtconsole --pylab
>> 2. I load a large NetCDF grid (Grid file format: nf (# 18) GMT netCDF
>> format (float)  (COARDS-compliant) [DEFAULT]), approx. 1.15 GB
>> 3. I then try to plot with imshow the data
>>
>> added below are the lines leading up to the error and the error itself.
>>
>>
>> This is running on OS X 10.7.4 with a recently installed EPD 7.3.
>>
>>
>> {code}
>> from scipy.io import netcdf_file as netcdf
>> data = netcdf('srtm_43_44_05_06_07_08.grd','r').variables['z'][::-1]
>>
>> fig, ax = subplots()
>>
>> data.shape
>> Out[5]: (24004, 12002)
>>
>> im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])),
>> interpolation='none')
>>
>> ---
>> MemoryError   Traceback (most recent call
>> last)
>>  in ()
>> > 1 im = ax.imshow(data,
>> aspect=((data.shape[1])/float(data.shape[0])), interpolation='none')
>>
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py
>> in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax,
>> origin, extent, shape, filternorm, filterrad, imlim, resample, url,
>> **kwargs)
>>6743 im.set_clim(vmin, vmax)
>>6744 else:
>> -> 6745 im.autoscale_None()
>>6746 im.set_url(url)
>>6747
>>
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/cm.py
>> in autoscale_None(self)
>> 281 if self._A is None:
>> 282 raise TypeError('You must first set_array for
>> mappable')
>> --> 283 self.norm.autoscale_None(self._A)
>> 284 self.changed()
>> 285
>>
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py
>> in autoscale_None(self, A)
>> 889 ' autoscale only None-valued vmin or vmax'
>> 890 if self.vmin is None:
>> --> 891 self.vmin = ma.min(A)
>> 892 if self.vmax is None:
>> 893 self.vmax = ma.max(A)
>>
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
>> in min(obj, axis, out, fill_value)
>>5873 def min(obj, axis=None, out=None, fill_value=None):
>>5874 try:
>> -> 5875 return obj.min(axis=axis, fill_value=fill_value, out=out)
>>5876 except (AttributeError, TypeError):
>>5877 # If obj doesn't have a max method,
>>
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
>> in min(self, axis, out, fill_value)
>>5054 # No explicit output
>>5055 if out is None:
>> -> 5056 result = self.filled(fill_value).min(axis=axis,
>> out=out).view(type(self))
>>5057 if result.ndim:
>>5058 # Set the mask
>>
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
>> in filled(self, fill_value)
>>3388 return self._data
>>3389 else:
>> -> 3390 result = self._data.copy()
>>3391 try:
>>3392 np.putmask(result, m, fill_value)
>>
>> MemoryError:
>> {/code}
>>
>
> This is more a NumPy issue than anything else.  We need to know the min
> and the max of the array in order to automatically scale the colormap for
> display.  Therefore, we query the array object for its min/max.  Because we
> support masked arrays, the array is first cast as a masked array, and then
> these queries are done.
>
> It appears that in numpy's masked array module, it calculates the array's
> min by making a copy of itself first.  I would have figured that it would
> have done its task differently.  In the meantime, I suspect you can work
> around this problem by explicitly setting the vmin/vmax keyword arguments
> to imshow if you know them.  Therefore, there should be no need to
> determine the array's min/max in this inefficient manner.
>
> Ben Root
>
>
> Hi Ben,
> I tried adding vmin & vmax the the imshow call but I still get a
> MemoryError.
> The grid file is 1.15 GB and I have ~4.5 out of 8 GB of memory available
> when I launch ipython, 3.5 when I execute imshow and 2 when I execute
> plt.draw().
>

Well, it looks like setting vmin/vmax helped, because your traceback shows
that the code made significant progress.  The issue here is that the
process_value() method doesn't make a lot of sense.  I am not sure what is
the rationale behind its logic.  Hopefully, someone else can chime in with
an explanation of what is going on.

In the meantime, are you using a 32 or 64-bit machine?

Ben Root
---

Re: [Matplotlib-users] MemoryError with NetCDF

2012-09-07 Thread Shahar Shani-Kadmiel
On Sep 7, 2012, at 5:00 PM, Benjamin Root  wrote:

> 
> 
> On Fri, Sep 7, 2012 at 9:49 AM, Shahar Shani-Kadmiel  
> wrote:
> On Sep 7, 2012, at 4:25 PM, Benjamin Root wrote:
> 
>> 
>> 
>> On Fri, Sep 7, 2012 at 8:44 AM, Shahar Shani-Kadmiel 
>>  wrote:
>> 1. an ipython session is invoked with qtconsole --pylab
>> 2. I load a large NetCDF grid (Grid file format: nf (# 18) GMT netCDF format 
>> (float)  (COARDS-compliant) [DEFAULT]), approx. 1.15 GB
>> 3. I then try to plot with imshow the data
>> 
>> added below are the lines leading up to the error and the error itself.
>> 
>> 
>> This is running on OS X 10.7.4 with a recently installed EPD 7.3.
>> 
>> 
>> {code}
>> from scipy.io import netcdf_file as netcdf
>> data = netcdf('srtm_43_44_05_06_07_08.grd','r').variables['z'][::-1]
>> 
>> fig, ax = subplots()
>> 
>> data.shape
>> Out[5]: (24004, 12002)
>> 
>> im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), 
>> interpolation='none')
>> ---
>> MemoryError   Traceback (most recent call last)
>>  in ()
>> > 1 im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), 
>> interpolation='none')
>> 
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py
>>  in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, 
>> origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
>>6743 im.set_clim(vmin, vmax)
>>6744 else:
>> -> 6745 im.autoscale_None()
>>6746 im.set_url(url)
>>6747
>> 
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/cm.py
>>  in autoscale_None(self)
>> 281 if self._A is None:
>> 282 raise TypeError('You must first set_array for mappable')
>> --> 283 self.norm.autoscale_None(self._A)
>> 284 self.changed()
>> 285
>> 
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py
>>  in autoscale_None(self, A)
>> 889 ' autoscale only None-valued vmin or vmax'
>> 890 if self.vmin is None:
>> --> 891 self.vmin = ma.min(A)
>> 892 if self.vmax is None:
>> 893 self.vmax = ma.max(A)
>> 
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
>>  in min(obj, axis, out, fill_value)
>>5873 def min(obj, axis=None, out=None, fill_value=None):
>>5874 try:
>> -> 5875 return obj.min(axis=axis, fill_value=fill_value, out=out)
>>5876 except (AttributeError, TypeError):
>>5877 # If obj doesn't have a max method,
>> 
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
>>  in min(self, axis, out, fill_value)
>>5054 # No explicit output
>>5055 if out is None:
>> -> 5056 result = self.filled(fill_value).min(axis=axis, 
>> out=out).view(type(self))
>>5057 if result.ndim:
>>5058 # Set the mask
>> 
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
>>  in filled(self, fill_value)
>>3388 return self._data
>>3389 else:
>> -> 3390 result = self._data.copy()
>>3391 try:
>>3392 np.putmask(result, m, fill_value)
>> 
>> MemoryError:
>> {/code}
>> 
>> This is more a NumPy issue than anything else.  We need to know the min and 
>> the max of the array in order to automatically scale the colormap for 
>> display.  Therefore, we query the array object for its min/max.  Because we 
>> support masked arrays, the array is first cast as a masked array, and then 
>> these queries are done.
>> 
>> It appears that in numpy's masked array module, it calculates the array's 
>> min by making a copy of itself first.  I would have figured that it would 
>> have done its task differently.  In the meantime, I suspect you can work 
>> around this problem by explicitly setting the vmin/vmax keyword arguments to 
>> imshow if you know them.  Therefore, there should be no need to determine 
>> the array's min/max in this inefficient manner.
>> 
>> Ben Root
>> 
> 
> Hi Ben,
> I tried adding vmin & vmax the the imshow call but I still get a MemoryError.
> The grid file is 1.15 GB and I have ~4.5 out of 8 GB of memory available when 
> I launch ipython, 3.5 when I execute imshow and 2 when I execute plt.draw().
> 
> Well, it looks like setting vmin/vmax helped, because your traceback shows 
> that the code made significant progress.  The issue here is that the 
> process_value() method doesn't make a lot of sense.  I am not sure what is 
> the rationale behind its logic.  Hopefully, someone else can chime in with an 
> explanation of what is going on.
> 
> In the meantime, are you u

Re: [Matplotlib-users] MemoryError with NetCDF

2012-09-07 Thread Eric Firing
On 2012/09/07 4:00 AM, Benjamin Root wrote:
>
>
> On Fri, Sep 7, 2012 at 9:49 AM, Shahar Shani-Kadmiel
> mailto:kadm...@post.bgu.ac.il>> wrote:
>
> On Sep 7, 2012, at 4:25 PM, Benjamin Root wrote:
>
>>
>>
>> On Fri, Sep 7, 2012 at 8:44 AM, Shahar Shani-Kadmiel
>> mailto:kadm...@post.bgu.ac.il>> wrote:
>>
>> 1. an ipython session is invoked with qtconsole --pylab
>> 2. I load a large NetCDF grid (Grid file format: nf (# 18) GMT
>> netCDF format (float)  (COARDS-compliant) [DEFAULT]), approx.
>> 1.15 GB
>> 3. I then try to plot with imshow the data
>>
>> added below are the lines leading up to the error and the
>> error itself.
>>
>>
>> This is running on OS X 10.7.4 with a recently installed EPD 7.3.
>>
>>
>> {code}
>> from scipy.io  import netcdf_file as netcdf
>> data =
>> netcdf('srtm_43_44_05_06_07_08.grd','r').variables['z'][::-1]
>>
>> fig, ax = subplots()
>>
>> data.shape
>> Out[5]: (24004, 12002)
>>
>> im = ax.imshow(data,
>> aspect=((data.shape[1])/float(data.shape[0])),
>> interpolation='none')
>> 
>> ---
>> MemoryError   Traceback (most
>> recent call last)
>>  in ()
>> > 1 im = ax.imshow(data,
>> aspect=((data.shape[1])/float(data.shape[0])),
>> interpolation='none')
>>
>> 
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py
>> in imshow(self, X, cmap, norm, aspect, interpolation, alpha,
>> vmin, vmax, origin, extent, shape, filternorm, filterrad,
>> imlim, resample, url, **kwargs)
>>6743 im.set_clim(vmin, vmax)
>>6744 else:
>> -> 6745 im.autoscale_None()
>>6746 im.set_url(url)
>>6747
>>
>> 
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/cm.py
>> in autoscale_None(self)
>> 281 if self._A is None:
>> 282 raise TypeError('You must first set_array
>> for mappable')
>> --> 283 self.norm.autoscale_None(self._A)
>> 284 self.changed()
>> 285
>>
>> 
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py
>> in autoscale_None(self, A)
>> 889 ' autoscale only None-valued vmin or vmax'
>> 890 if self.vmin is None:
>> --> 891 self.vmin = ma.min(A)
>> 892 if self.vmax is None:
>> 893 self.vmax = ma.max(A)
>>
>> 
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
>> in min(obj, axis, out, fill_value)
>>5873 def min(obj, axis=None, out=None, fill_value=None):
>>5874 try:
>> -> 5875 return obj.min(axis=axis,
>> fill_value=fill_value, out=out)
>>5876 except (AttributeError, TypeError):
>>5877 # If obj doesn't have a max method,
>>
>> 
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
>> in min(self, axis, out, fill_value)
>>5054 # No explicit output
>>5055 if out is None:
>> -> 5056 result =
>> self.filled(fill_value).min(axis=axis, out=out).view(type(self))
>>5057 if result.ndim:
>>5058 # Set the mask
>>
>> 
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc
>> in filled(self, fill_value)
>>3388 return self._data
>>3389 else:
>> -> 3390 result = self._data.copy()
>>3391 try:
>>3392 np.putmask(result, m, fill_value)
>>
>> MemoryError:
>> {/code}
>>
>>
>> This is more a NumPy issue than anything else.  We need to know
>> the min and the max of the array in order to automatically scale
>> the colormap for display.  Therefore, we query the array object
>> for its min/max.  Because we support masked arrays, the array is
>> first cast as a masked array, and then these queries are done.
>>
>> It appears that in numpy's masked array module, it calculates the
>> array's min by making a copy of itself first.  I would have
>> figured that it would have done its task differently.  In the
>> meantime, I suspect you can work around this problem by explicitly
>> setting the vmin/vmax keyword arguments to imshow if you know
>> them.  Theref

Re: [Matplotlib-users] MemoryError with NetCDF

2012-09-07 Thread Ethan Gutmann

On Sep 7, 2012, at 11:04 AM, Eric Firing wrote:

> On 2012/09/07 4:00 AM, Benjamin Root wrote:
>> 
>> 
>> On Fri, Sep 7, 2012 at 9:49 AM, Shahar Shani-Kadmiel
>> mailto:kadm...@post.bgu.ac.il>> wrote:
>> 
>>On Sep 7, 2012, at 4:25 PM, Benjamin Root wrote:
>> 
>>> 
>>> 
>>>On Fri, Sep 7, 2012 at 8:44 AM, Shahar Shani-Kadmiel
>>>mailto:kadm...@post.bgu.ac.il>> wrote:
>>> 
> 


> Normalization has to handle all sorts of inputs--masked or not, all 
> sorts of numbers, scalar or array--and it is much easier to do this 
> efficiently if all these possibilities are reduced to a very few at the 
> start.  Specifically, it needs to supply a copy of the input (so that 
> normalization doesn't change the original) in a floating point masked 
> array, using float32 if possible for space efficiency.  It needs to keep 
> track of whether the input was a scalar, so that normalization can 
> return a scalar when given a scalar input.
> 
> Eric

Another option as I understand it is to pass in a 1D (greyscale) or 3d (color) 
array (where the 3rd dimension is RGB and optionally A) of type uint8(?). This 
array does not need to get normalized, it will be displayed as raw pixel 
values.  I don't remember if you also have to specifically tell it not to 
normalize the data. 

But the easier answer for your case would probably be imshow(data[::10,::10]) 
which will take every 10th element in x and y thus reducing the size by a 
factor of 100 (depending on the size of your data you could use ::2 or ::50, 
etc)

Ethan--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Using the lasso tool when file is not main

2012-09-07 Thread Benjamin Root
I think I see your problem... see below:


class start_lasso():
def __init__(self):
data = [Datum(*xy) for xy in rand(100, 2)]

fig = figure()
ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1),
autoscale_on=False)
lman = LassoManager(ax, data)
show()

You aren't saving any of the objects created in the "start_lasso" class to
your start_lasso object.  Luckily, with the way pyplot works, the figure
object your create gets implicitly saved to the "pyplot state manager" (a
sort of smart global location for the figure objects), and the axes object
gets implicitly attached to the figure object.  Therefore, when the python
execution goes out of this scope, the figure object and the axes do not get
garbage-collected.  However, the lasso widget that gets created and all the
callbacks that were attached are all done with weak references to the
figure and axes.  So when you leave this scope, the LassoManager no longer
exists and the callback fails to execute (as designed).

So, make sure that at least lman (and possibly fig and ax) gets saved to
the start_lasso object to solve that part of the problem.  Next, you don't
save the start_lasso object your create anywhere, so even if you saved lman
to start_lasso, the start_lasso object gets garbage-collected anyway as a
temporary.

I hope this is clear.  Let me know if you still have more issues.

Cheers!
Ben Root
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Using the lasso tool when file is not main

2012-09-07 Thread Mark Budde
Thanks Ben, that solved my issue. I guess I got thrown off because the
plot stayed open, as you described. It's hard to troubleshoot when you
don't get any errors. In the future I will attach all of my objects.
-Mark

On Fri, Sep 7, 2012 at 12:03 PM, Benjamin Root  wrote:
> I think I see your problem... see below:
>
>
> class start_lasso():
> def __init__(self):
> data = [Datum(*xy) for xy in rand(100, 2)]
>
> fig = figure()
> ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1),
> autoscale_on=False)
> lman = LassoManager(ax, data)
> show()
>
> You aren't saving any of the objects created in the "start_lasso" class to
> your start_lasso object.  Luckily, with the way pyplot works, the figure
> object your create gets implicitly saved to the "pyplot state manager" (a
> sort of smart global location for the figure objects), and the axes object
> gets implicitly attached to the figure object.  Therefore, when the python
> execution goes out of this scope, the figure object and the axes do not get
> garbage-collected.  However, the lasso widget that gets created and all the
> callbacks that were attached are all done with weak references to the figure
> and axes.  So when you leave this scope, the LassoManager no longer exists
> and the callback fails to execute (as designed).
>
> So, make sure that at least lman (and possibly fig and ax) gets saved to the
> start_lasso object to solve that part of the problem.  Next, you don't save
> the start_lasso object your create anywhere, so even if you saved lman to
> start_lasso, the start_lasso object gets garbage-collected anyway as a
> temporary.
>
> I hope this is clear.  Let me know if you still have more issues.
>
> Cheers!
> Ben Root
>

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] python question from matlab user

2012-09-07 Thread Jody Klymak

Hi All,

Sorry to ask a dumb python newbie question, but the problem arose while reading 
the matplotlib documentation, and an hour or so on the internet didnt' help, so 
I felt it was fair-ish game to post here. 

In http://matplotlib.sourceforge.net/examples/pylab_examples/customize_rc.html 
it says:
"""
If you like to work interactively, and need to create different sets
of defaults for figures (eg one set of defaults for publication, one
set for interactive exploration), you may want to define some
functions in a custom module that set the defaults, eg

def set_pub():
rc('font', weight='bold')# bold fonts are easier to see

Then as you are working interactively, you just need to do

>>> set_pub()
"""

Which I thought was great, because I'd like to have some presets for different 
journals.  However, saving the def into a file (jmkfigure.py) and calling 

from jmkfigure import *

set_pub()

yields the error: "NameError: global name 'rc' is not defined" 

I tried importing matplotlib and rc into jmkfigure.py, but to no avail.  

I appreciate this is a scoping issue with python, but I can't figure out how to 
set rc from within an external module.

Thanks for any help,

Cheers,   Jody





--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] python question from matlab user

2012-09-07 Thread Paul Tremblay

in your jmkfile.py you should have

from  pylab  import  *

Paul



On 9/8/12 12:45 AM, Jody Klymak wrote:

Hi All,

Sorry to ask a dumb python newbie question, but the problem arose while reading 
the matplotlib documentation, and an hour or so on the internet didnt' help, so 
I felt it was fair-ish game to post here.

In http://matplotlib.sourceforge.net/examples/pylab_examples/customize_rc.html 
it says:
"""
If you like to work interactively, and need to create different sets
of defaults for figures (eg one set of defaults for publication, one
set for interactive exploration), you may want to define some
functions in a custom module that set the defaults, eg

def set_pub():
 rc('font', weight='bold')# bold fonts are easier to see

Then as you are working interactively, you just need to do


set_pub()

"""

Which I thought was great, because I'd like to have some presets for different 
journals.  However, saving the def into a file (jmkfigure.py) and calling

from jmkfigure import *

set_pub()

yields the error: "NameError: global name 'rc' is not defined"

I tried importing matplotlib and rc into jmkfigure.py, but to no avail.

I appreciate this is a scoping issue with python, but I can't figure out how to 
set rc from within an external module.

Thanks for any help,

Cheers,   Jody








--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users