Re: [Matplotlib-users] polar stereographic projection

2013-09-11 Thread Jeff Whitaker
 	   
   	Sourav Chatterjee  
  September 11, 
2013 3:48 AMI am using 'spstere' for polar 
stereo graphic projection over Antarctica. The specifications llcrnrlat,
 llcrnrlon etc are specified in a python module. When I am doing it over
 north pole it is okay. But in South pole the latitude circles are not 
appearing. Can anyone tell where is the fault?
Thanks in advanceSample
 code please?-Jeff--
 Sourav Chatterjee

--How
 ServiceNow helps IT people transform IT departments:1. Consolidate 
legacy IT systems to a single system of record for IT2. Standardize 
and globalize service processes across IT3. Implement zero-touch 
automation to replace manual, redundant taskshttp://pubads.g.doubleclick.net/gampad/clk?id=5127&iu=/4140/ostg.clktrk___Matplotlib-users
 mailing [email protected]://lists.sourceforge.net/lists/listinfo/matplotlib-users 
--
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=5127&iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Quiver plot of a netcdf file

2009-06-15 Thread Jeff Whitaker
JPKay wrote:
> Hello, 
>
> Now that I have correctly imported the NetCDF file and set up the kind of
> projection I am interested in having the data displayed over I am having
> trouble plotting my data with the quiver function. I am interested in
> plotting the principal vectors of the stress field onto a Mercator
> projection. 
> My netcdf file is telling me the following after "ncdump -h"
> dimensions:
>   nsr_delta = 20 ;
>   time = 24 ;
>   latitude = 37 ;
>   longitude = 73 ;
> variables:
>   float nsr_delta(nsr_delta) ;
>   nsr_delta:units = "" ;
>   nsr_delta:long_name = "NSR Surface Delta (mu/(eta*omega))" ;
>   float time(time) ;
>   time:units = "degrees" ;
>   time:long_name = "degrees after periapse" ;
>   float latitude(latitude) ;
>   latitude:units = "degrees_north" ;
>   latitude:long_name = "latitude" ;
>   float longitude(longitude) ;
>   longitude:units = "degrees_east" ;
>   longitude:long_name = "longitude" ;
>   float Ttt_D(time, latitude, longitude) ;
>   Ttt_D:units = "Pa" ;
>   Ttt_D:long_name = "north-south component stress of Diurnal 
> stresses" ;
>   float Tpt_D(time, latitude, longitude) ;
>   Tpt_D:units = "Pa" ;
>   Tpt_D:long_name = "shear component of Diurnal stresses" ;
>   float Tpp_D(time, latitude, longitude) ;
>   Tpp_D:units = "Pa" ;
>   Tpp_D:long_name = "east-west component of Diurnal stresses" ;
>   float Ttt_N(nsr_delta, latitude, longitude) ;
>   Ttt_N:units = "Pa" ;
>   Ttt_N:long_name = "north-south component of NSR stresses" ;
>   float Tpt_N(nsr_delta, latitude, longitude) ;
>   Tpt_N:units = "Pa" ;
>   Tpt_N:long_name = "shear component of NSR stresses" ;
>   float Tpp_N(nsr_delta, latitude, longitude) ;
>   Tpp_N:units = "Pa" ;
>   Tpp_N:long_name = "east-west component of NSR stresses" ;
>
> // global attributes:
>   :description = "Testing pySatStress on a regular grid" ;
>   :history = "Created: Mon Jun 15 12:46:13 2009 using 
> pySatStress" ;
>   :Conventions = "COARDS" ;
> However, when I am strugglingto use the quiver_demo.py as a guide to making
> my quiver plot. 
> Thanks for any help you can offer. 
> Jon 
>
>   
Jon:  Have you looked the quiver_demo.py in the basemap examples?  If 
so, what problems did you have adopting that code? 

As always, a simple script demonstrating your problem is most helpful.

-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


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Axes.frame vs. Axes.spines in SVN Basemap and Matplotlib? (was New contourf()...)

2009-06-16 Thread Jeff Whitaker
Andrew Straw wrote:
> Zane Selvans wrote:
>   
>> Yep, looks like the trunk has fixed the contourf() issue.
>>
>> Unfortunately there also seems to be some new incompatibility with the
>> Basemap toolkit, even after re-installing Basemap from source.  I get:
>>
>> AttributeError: Axes.frame was removed in favor of Axes.spines
>> 
>
>
> It appears Basemap hasn't caught up with the new Axes.spines usage.
>
> Can you change mpl_toolkits/basemap/__init__.py line 1265 from::
>
>   ax.frame.set_linewidth(linewidth)
>
> to::
>
>   for spine in ax.spines.itervalues():
>   spine.set_linewidth(linewidth)
>
> There may be more issues, here -- this is just the first one and based
> off your traceback.
>
> Jeff: I had to drop the Axes.frame to implement spines that could be
> moved relative to the Axes boundary. I made sure this worked with the
> custom projection examples in the main MPL distribution, so I imagine it
> won't take too much to convert basemap. Please see svn r7144, 7145, and
> 7170 for my changes to lib/matplotlib/projections/geo.py
>
> -Andrew
>   

Andrew:  This is now fixed in SVN.

BTW: basemap predates the custom projection support in matplotlib, so it 
actually doesn't use it. 

-Jeff


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap & ax parameter : bug or feature ?

2009-06-23 Thread Jeff Whitaker
Pierre GM wrote:
> All (and Jeff W. in particular),
>
> It's the time of the year where I have to draw maps in batch. I wrote  
> a script to process some data recorded at various stations,  
> interpolate the data on a grid, draw the corresponding contours on a  
> basemap, add a colorbar, and end with adding some extra information on  
> the map (scale, stations positions...).
>
> Nothing too fancy, but I ran into a problem with the last few steps.  
> As I do not give an explicit 'ax' parameter to any of the basemap  
> related methods (.contourf, .plot, .drawmapscale...), I have to rely  
> on the defaults: use self.ax if it is not None, gca() otherwise.  
> However, drawing a colorbar in midprocess switches the focus to the  
> colorbar, and the extra information I was talking about gets plotted  
> on the colorbar.
>
> Which brings me to the famous question: is it a bug or a feature ? Is  
> there any rational in *not* setting the 'ax' attribute to gca() when  
> sit hasn't been set yet and no 'ax' parameter has been specifically  
> given as input of a method ?
>   

Pierre:  The reason I did it that way was so that the basemap instance 
could be created independent of any axes instances.  For instance, you 
can create a basemap instance before an axes instance is created, or you 
read in a basemap instance from a pickle. If a axes instance is 
associated with a Basemap instance, you can't save it in a pickle.  If I 
understand you correctly, you are suggesting that when the basemap 
instance is created, the "ax" attribute be set to plt.gca() if no axes 
instance is passed in through the kwarg, instead of just setting it to 
None.  In that case, an axes instance will be created and assigned to 
the Basemap instance if one doesn't already exist.  I guess I don't see 
any compelling reason for that, since you can always assign an axes 
instance to the Basemap instance later (via "map.ax = plt.gca()".  I'd 
rather have this done explicitly by the user, than have it happen 
automatically, with potentially surprising results. 

-Jeff
> Thanks a lot in advance for any explanation:
> P.
>
>
> [As a workaround, I modified my local sources by adding a ._check_ax  
> method as below, and used :
> ax = ax or self._check_ax(ax)
> or
> ax = kwargs.pop('ax', None) or self._check_ax()
> depending on the context
>
>  def _check_ax(self, ax=None):
>  """
>  Returns the axis on which to draw.
>  By default, returns self.ax. If this latter is None, set it to  
> gca().
>  """
>  #
>  if ax is None:
>  if self.ax is None:
>  try:
>  ax = plt.gca()
>  except:
>  import matplotlib.pyplot as plt
>  ax = plt.gca()
>  self.ax = ax
>  return self.ax
>  return ax
>
> --
> Are you an open source citizen? Join us for the Open Source Bridge conference!
> Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
> Need another reason to go? 24-hour hacker lounge. Register today!
> http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


--
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap & ax parameter : bug or feature ?

2009-06-23 Thread Jeff Whitaker
Pierre GM wrote:
>
> On Jun 23, 2009, at 8:27 AM, Jeff Whitaker wrote:
>>
>> Pierre:  The reason I did it that way was so that the basemap 
>> instance could be created independent of any axes instances.  For 
>> instance, you can create a basemap instance before an axes instance 
>> is created, or you read in a basemap instance from a pickle. If a 
>> axes instance is associated with a Basemap instance, you can't save 
>> it in a pickle.
>
> I understand that, I use pickled basemaps all the time. It's a great 
> feature, by the way, thanks a lot.
>
>> If I understand you correctly, you are suggesting that when the 
>> basemap instance is created, the "ax" attribute be set to plt.gca() 
>> if no axes instance is passed in through the kwarg, instead of just 
>> setting it to None.
>>  In that case, an axes instance will be created and assigned to the 
>> Basemap instance if one doesn't already exist.
>
> That's the gist of it, yes. My point is that as soon something is 
> drawn, the basemap should be linked to an Axes instance. The link 
> could be overwritten later.
>
>>  I guess I don't see any compelling reason for that, since you can 
>> always assign an axes instance to the Basemap instance later (via 
>> "map.ax = plt.gca()".
>>  I'd rather have this done explicitly by the user, than have it 
>> happen automatically, with potentially surprising results.
>
> Well, talking about surprising results, the experience I was relating 
> in the original message: I load a basemap from a pickle, plot some 
> contours on it (therefore, a new Axes is created), add a colorbar (a 
> second Axes is created) and then draw a mapscale. I expect the 
> mapscale to be drawn on the axes associated with the basemap, because 
> I'm using one of the basemap's methods to plot the mapscale. With the 
> current implementation, the scale gets drawn on the colorbar.
>
> So yes, I could explicitly link the basemap to the first Axes myself. 
> I still think my suggestion would be far less confusing, but I won't 
> lose sleep over it. In any case, I think the snippet I put in the 
> latest message could simplify the code (just drop the line setting 
> self.ax to ax)...
>
>
>
>
>
>
Pierre:  Doing what you suggest (having Basemap.__init__  automatically 
set self.ax to the current axes) will break pickling, so I can't do 
that.  I think the next best thing is just to set it manually.  I know 
the colorbar behavior is annoying, but I think it's just something you 
have to live with if you use the pylab interface.

-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


--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap & ax parameter : bug or feature ?

2009-06-24 Thread Jeff Whitaker
Pierre GM wrote:
> On Jun 23, 2009, at 6:01 PM, Jeff Whitaker wrote:
>   
>> Pierre:  Doing what you suggest (having Basemap.__init__   
>> automatically set self.ax to the current axes) will break pickling,  
>> so I can't do that.
>> 
>
> Oh, I'm sorry for the misunderstanding: I never suggested that  
> Basemap.ax should be set at creation (apart from Basemap.ax=None).  
> Instead, I suggested that it would be set when a drawing method is  
> called that requires access to the underlying Axes (basically, all the  
> plotting methods).
> That way, as soon as something is plotted, we associate the basemap  
> instance with one particular Axes instance and we stick to it by  
> default. We can always break the link by changing basemap.ax (that is,  
> associate to another Axes instance),  but we don't have the surprise  
> of using the last Axes instance by default.
>   

OK, Pierre.  Now I understand.  That sounds reasonable, and I don't 
think it will break any existing code.
> Now, the more I think about it, the more I'd prefer to separate  
> Basemaps from Axes. Right now, self.ax assures the connection in a way  
> I find frustrating. I'd prefer getting rid of Basemap.ax and force  
> 'ax' to be defined all the time.
>   

Don't exactly know what you mean here - make the ax keyword to the 
drawing methods mandatory?
> Alternatively, we could consider having  2 separate objects:  a  
> Basemap that stores all the projection information but has *NO*  
> plotting methods, and a MapAxes that inherits from Axes and requires a  
> specific Basemap attribute at creation. The current plotting routines  
> would be associated with the MapAxes object.
>   

Hmm.  I see how this could work, but what would be the added benefit 
(beyond what we would get by implementing your first suggestion)?

-Jeff


--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Pre-defined binning with hexbin ... impossible?

2009-07-01 Thread Jeff Whitaker
Alexandar Hansen wrote:
> Hello,
>
> I've been struggling with this for a while now and have effectively 
> two issues. One, how can I define the range over which hexbin ... 
> bins? And two, how do I change the background color of a plot?

Alexandar:  To change the background color to the lowest value in the 
colormap:

ax = plt.gca()
ax.set_axis_bgcolor(plt.cm.jet(0))


-Jeff
> The latter I thought would be trivial, but nothing I've tried has 
> worked.  Let's take the example:
>
> import numpy as np
> import matplotlib.cm  as cm
> import  matplotlib.pyplot as plt
>
> n = 10
> x = np.random.standard_normal(n)
> y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n)
> #xmin = x.min()
> #xmax = x.max()
> #ymin = y.min()
> #ymax = y.max()
> xmin = 0
> xmax = 10
> ymin = 0
> ymax = 30
>
> plt.hexbin(x,y, cmap=cm.jet)
> #plt.hexbin(x,y, cmap=cm.jet, extent=[xmin, xmax, ymin, ymax])
> plt.axis([xmin, xmax, ymin, ymax])
> plt.title("Hexagon binning")
> cb = plt.colorbar()
> cb.set_label('counts')
>
> plt.show()
>
>
> Let's say i'm only interested in the positive quadrant of the data, so 
> I only want to bin data in the range of 0-10 in x and 0-30 in y.  The 
> first thing I tried was to use the extent option to only bin the 
> specified range of data, but that gives these errors:
>
> [tesla:~/NMR/500-Tupp/IM7][349] HexBin.py
> Traceback (most recent call last):
>   File "HexBin.py", line 28, in 
> plt.hexbin(x,y, cmap=cm.jet, extent=[xmin, xmax, ymin, ymax])
>   File "/usr/lib64/python2.5/site-packages/matplotlib/pyplot.py", line 
> 1920, in hexbin
> ret =  gca().hexbin(*args, **kwargs)
>   File "/usr/lib64/python2.5/site-packages/matplotlib/axes.py", line 
> 5447, in hexbin
> collection.update(kwargs)
>   File "/usr/lib64/python2.5/site-packages/matplotlib/artist.py", line 
> 548, in update
> raise AttributeError('Unknown property %s'%k)
> AttributeError: Unknown property extent
>
>
> After that, I just set the plt.axis range to what I'm interested in. 
> However, the range not binned by hexbin shows up as white, instead of 
> the 0-count blue. I've tried adding facecolor, edgecolor, axisbg, and 
> who knows what else as part of plt.hexbin, plt.axis, and plt.savefig, 
> But most have no consequence on the plot. plt.savefig(myname, 
> facecolor='blue') successfully changed everything blue except the 
> white region within the plot.
>
> So, where am I going wrong? I'm finding myself out of options and 
> would ideally not like to trim or add false points to my data just to 
> get the axis and colors correct.
>
> Best,
> Alex
>
>
> 
>
> --
>   
> 
>
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap: GEOS_ERRORs

2009-07-02 Thread Jeff Whitaker
Stephane Raynaud wrote:
> Hi (Jeff),
>
>
> I recently performed updates to matplotlib and basemap.
> >From this time, I have a random and reccurent error when I create a
> Basemap instance.
> Here is one example :
>
>   
 from mpl_toolkits.basemap import Basemap
 Basemap(**{'lon_0': -4.5250263598141309, 'urcrnrlat': 49.140154231678416, 
 'projection': 'cyl', 'llcrnrlon': -7.268048710144, 'lat_ts': 
 47.468781818043126, 'urcrnrlon': -1.7500559147572474, 'area_thresh': 0.1, 
 'llcrnrlat': 45.797409404407844, 'resolution': 'i', 'lat_0': 
 47.468781818043126})
 
>
> GEOS_ERROR: TopologyException: found non-noded intersection between
> 8.67583 4.66292, 8.70206 4.66997 and 8.71039 4.67664, 8.67708 4.64997
> 8.70205 4.66997
>
> It depends on the area and the resolution (polygons).
>
> I have version '0.99.3' of basemap.
>
> Any idea?
>   
Stephane:  I'd say it's an issue with your geos library installation 
that basemap is linking to.  I don't see that error using your example 
for geos 2.2.3 or geos 3.0.3.

I'd suggest rebuilding the geos library, then recompiling basemap.

-Jeff

--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] gps-satellite sky-plot

2009-07-02 Thread Jeff Whitaker
Massimo Di Stefano wrote:
> Hi All,
>
>
> i'm starting to learn matplotlib,
> for my study i need to parse the nmea sentence from a gps
> and plot a "sky graphic" to plot satellite visibility.
>
> (i tried to write code from scratch ... it works  but my teacher  
> suggest me to not reinvent the well, so, to have a good nema parser, i  
> installed gpsd ... it has in the source code a nice python code that  
> allow me to retrieve satellite constallation iformation).
>
> now i need to learn how to produce a sky plot,
> have you any suggestion on how to produce such kind of graphic ?
>   

Massimo:  I've no idea what a "sky plot" is. Can you point us to an example?

-Jeff
> thanks to all for any suggestion!
>
> Massimo.
>
> --
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Empty squares at end of data after interpolation with griddata?

2009-07-05 Thread Jeff Whitaker
Rick Muller wrote:
> Having one last problem with matplotlib. I have some data that I'm 
> interpolating with griddata, and then plotting with contourf. For 
> reasons that escape me, the upper right and the lower left squares are 
> not being plotted. I'm printing out a 10x10 version of this to 
> exaggerate the effect:
>
> http://files.getdropbox.com/u/533499/griddata-example-text.png

Rick:  That URL doesn't work.

griddata won't do extrapolation, that is it won't interpolate outside 
the convex hull of the data.  That's probably why you see those empty 
squares at the edges.

-Jeff
>
> In reality, I interpolate/plot this 200x200 squares, and none of it is 
> all that noticeable. However, I'm worried that I'm doing something 
> wrong here, and that the mistake is going to come back and bite me 
> later on. Has anyone seen anything like this?
>
> Thanks for any help you can offer with this, and thank for all of the 
> help the list members have already given me.
>
> Rick
> -- 
> Rick Muller
> [email protected] 
> 
>
> --
>   
> 
>
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Where to put MPL/Basemap data files?

2009-07-07 Thread Jeff Whitaker
Mauro Cavalcanti wrote:
> Dear Jeff & ALL,
>
> In trying to freeze my app using bb-freeze
> (http://pypi.python.org/pypi/bbfreeze/), I stumbled upon a problem:
> the app is correctly freezed, but it then looks for the Basemap
> datafiles and since cannot find them, fails to start (with a message
> complaining that the above mentioned files are missing). So, my
> question is: can Basemap data files be installed in a directory other
> than the default one? And if so, how to instruct a program to look for
> them in another location?
>
> Thanks in advance for any assistance you can provide.
>
> Best regards,
>
>   
Mauro:  If you set the env var BASEMAPDATA, it will look for the basemap 
data files there.  There is no way supported way to install the files in 
a different directory using setup.py, so if you want them somewhere 
other than the default location you'll have to install them there manually.

-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


--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Where to put MPL/Basemap data files?

2009-07-07 Thread Jeff Whitaker
Mauro Cavalcanti wrote:
> Dear Jeff,
>
> Thanks for your fast reply. No problem with manually installing the
> Basemap data files -- indeed, this is just what I do intend in order
> to create a frozen application. But other than setting up the
> BASEMAPDATA environment variable, is there any way to tell an
> application to look for the data in a specific directory?
>
>   

No.

-Jeff
> Best regards,
>
> 2009/7/7 Jeff Whitaker :
>   
>> Mauro Cavalcanti wrote:
>> 
>>> Dear Jeff & ALL,
>>>
>>> In trying to freeze my app using bb-freeze
>>> (http://pypi.python.org/pypi/bbfreeze/), I stumbled upon a problem:
>>> the app is correctly freezed, but it then looks for the Basemap
>>> datafiles and since cannot find them, fails to start (with a message
>>> complaining that the above mentioned files are missing). So, my
>>> question is: can Basemap data files be installed in a directory other
>>> than the default one? And if so, how to instruct a program to look for
>>> them in another location?
>>>
>>> Thanks in advance for any assistance you can provide.
>>>
>>> Best regards,
>>>
>>>
>>>   
>> Mauro:  If you set the env var BASEMAPDATA, it will look for the basemap
>> data files there.  There is no way supported way to install the files in a
>> different directory using setup.py, so if you want them somewhere other than
>> the default location you'll have to install them there manually.
>>
>> -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
>>
>>
>> 
>
>
>
>   


--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] speeding-up griddata()

2009-07-13 Thread Jeff Whitaker
Robert Cimrman wrote:
> Hi all,
>
> I would like to use griddata() to interpolate a function given at 
> specified points of a bunch of other points. While the method works 
> well, it slows down considerably as the number of points to 
> interpolate to increases.
>
> The dependence of time/(number of points) is nonlinear (see the 
> attachment) - it seems that while the Delaunay trinagulation itself is 
> fast, I wonder how to speed-up the interpolation. The docstring says, 
> that it is based on "natural neighbor interpolation" - how are the 
> neighbors searched? Does it use the kd-trees like scipy.spatial? I 
> have a very good experience with scipy.spatial performance.
>
> Also, is there a way of reusing the triangulation when interpolating 
> several times using the same grid?
>
> cheers,
> r.

Robert:  The griddata function uses the delaunay module, which is a 
straight copy of Robert Kern's delaunay scikit.  No one here is that 
familiar with the internals of delaunay, so I'd suggest you either ask 
Robert, or dig into the source code yourself (which is here:  
http://scipy.org/scipy/scikits/browser/trunk/delaunay).

-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


--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] unable to plot multiple lines with plot?

2009-07-14 Thread Jeff Whitaker
per freem wrote:
> hi all,
>
> i'm getting very strange behavior from the matplotlib 'plot' function 
> when attempting to plot multiple lines. i have a series of x, y data 
> points that are being generated in a loop and i want to simply plot 
> each of them on the same plot. my code is:
>
> import matplotlib
> matplotlib.use('PDF')
> import matplotlib.pyplot as plt
> from matplotlib import rc
> rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
> plt.rcParams['ps.useafm'] = True
> rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
>
> my_fig = plt.figure(figsize=(6,5), dpi=100)
> num_lines = 3
>
> for n in range(0, num_lines):
> print "Printing line %d" %(n+1)
> x = range(0, 100)
> y = (ones(100)*(n+1))
> plt.plot(x, y)
>
> plt.savefig('plot_example.pdf')
>
> when I do this, it only plots the last line (a horizontal line at y = 
> 3). how can i get to actually plot all three lines?
>
> more strangely, it shows *stochastic* behavior: sometimes when i run 
> the code, it generates a green line at y = 3, and other times a blue 
> line. from plot to plot, the upper bound of the y axis changes, 
> sometimes being 3.15, sometimes 3.2.  i'm not sure why it is doing that.
>
> how can i get it to simply add whatever i plot in the body of the 
> 'for' loop to the same graph? i tried adding plt.plot() after my call 
> to plt.plot but that did not fix it.
>
> thank you.

Per:  The plots are there, you just can't see them because the y-axis 
has been auto-scaled so that the first and last lines lie on the top and 
bottom of the plot window.  Just add plt.ylim(0,4) after the loop and 
you will see all three lines.

-Jeff


--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] griddata returns nan

2009-07-22 Thread Jeff Whitaker
plankton wrote:
> Greetings all,
>
> I rotate a vector field and than I tried to interpolate it to a new grid
> using griddata. 
>
> CODE:
>
> x_grid_unique = unique(x_grid)
> y_grid_unique = unique(y_grid)
> x_meshgrid,  y_meshgrid =   meshgrid(x_grid_unique, y_grid_unique)
> x_rot_meshgrid = reshape(x_rot,  [ len(x_meshgrid[:, 0]),
> len(x_meshgrid[0, :])] )
> y_rot_meshgrid = reshape(y_rot,  [ len(x_meshgrid[:, 0]),
> len(x_meshgrid[0, :])] )
> u_rot_meshgrid = reshape(u_rot,  [ len(x_meshgrid[:, 0]),
> len(x_meshgrid[0, :])] )
> v_rot_meshgrid = reshape(v_rot,  [ len(x_meshgrid[:, 0]),
> len(x_meshgrid[0, :])] )
> u_interpolate = griddata(x_rot,  y_rot, u_rot,  x_rot_meshgrid, 
> y_rot_meshgrid)
> v_interpolate = griddata(x_rot,  y_rot, v_rot,  x_rot_meshgrid, 
> y_rot_meshgrid)
>
>
>
> I unfortunately griddata returns some nan (It seems that there are multiple
> occurrences of the same [X,Y] pair in the data). In matlab you can use
> griddata with additional options  e.g. ru =
> griddata(nx,ny,nu,rx,ry,'linear', {'QJ'}) to fix this, but this seems to be
> not possible using the griddata function in matplotlib. Is there any other
> way to avoid a return of nan?
>
> For any help many thanks in advance
>
> Andreas
>
>
>
>   
Andreas:  Can you provide a standalone script that I can run which 
demonstrates the problem?  Otherwise, it's hard to know what's going on.

-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


--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] speeding-up griddata()

2009-07-23 Thread Jeff Whitaker
Denis-B wrote:
> Robert C, Robert K, folks,
>
>   messing with the nice delaunay/testfuncs.py to time
> linear_interpolate_grid nn_interpolate_grid and nn_interpolate_unstructured
> in _delaunay, I see linear ~ 100 times faster than the nn_ s:
>
> # from: trigrid Ntri=1000 Ngrid=100  run: 21 Jul 2009 17:33  mac 10.4.11 ppc
>
> time: 0.027 sec trigrid: build Triangulation 1000
> time: 0.0059 sec trigrid 100 "linear"  corners: 0 1 2 1
> time: 0.5 sec trigrid 100 "nn_grid"  corners: 0 1 2 1
> time: 0.49 sec trigrid 100 "nn_unstruct"  corners: 0 1 2 1
>
> Correct me: if all 3 methods do gridpoint-to-triangle in the same way, 
> then the huge diff is in find-neighboring-triangles (6 on average ?), not in
> gridpoint-to-triangle ?
>
> This is with the _delaunay.so that comes with the mac 98.5.3 egg,
> however that was compiled (-O3 ?)
>
>
> What to do ?
>
> 1) does it matter, how many people care ? (all who believe in telekinesis,
> raise my right hand)
>
> 2) natgrid ? don't see it in matplotlib.sf.net
>
> 3) stick with fast linear, smooth the triangle planes a la 3t^2 - 2t^3  or
> fancier smoothing
>
> In any case, add griddata( ... method = "linear" / "nn" ... ) so users have
> a choice.
>   

Denis:  I have added an 'interp' keyword to griddata (svn revision 7287) 
so you can choose the faster linear interpolation with interp='linear'.  
However, for linear interpolation the output grid is assumed to be 
regular with constant dx and dy (and this is *not* checked for by griddata).

The natgrid toolkit is on the sf site under 'Files', then 
'matplotlib-toolkits'.  It is in fact slower than the Delaunay package 
included in matplotlib, but a little bit more robust for pathological cases.

-Jeff
> Can a real user or two tell us about the flow,
> with some rough numbers for Ntri Ngrid Npix --
> Ntri = nr original sample points, say 1000
> Ngrid 100 x 100
> Npix 800 x 600 ?
> (Ntri -> Ngrid slowly and accurately,
> then Ngrid -> Npix w fast inaccurate image interpolation ? hmm.)
>
> cheers
>   -- denis
>
>   


--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] speeding-up griddata()

2009-07-24 Thread Jeff Whitaker
Denis-B wrote:
>
> Jeff Whitaker wrote:
>   
>> Denis:  I have added an 'interp' keyword to griddata (svn revision 7287) 
>> so you can choose the faster linear interpolation with interp='linear'.  
>>
>>
>> 
>
> Thanks Jeff,
>that was quick.  Do you also see linear wy faster than NN, factor 100
> ?!
> (Fwiw, a quick run of the Mac Shark profiler shows lots of time in
> NaturalNeighbors::interpolate_one
> which uses stdlib stacks heavily -- overkill for tiny stacks.)
>   

Denis:  I see more like a factor of 3 or 4, not 100.
> Did my last question on Ntri -> Ngrid -> Npix make any sense at all ?
>   

Not really, but I haven't had the time to think about it very hard.

-Jeff
> It would be nice if one could go straight from a triangulation to pixels --
> will ask AGG.
>
> cheers
>   -- denis
>
>
>   


-- 
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


--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Equal area projection

2009-07-27 Thread Jeff Whitaker
Angus McMorland wrote:
> Hi all,
>
> I've recently implemented a simple equal area (Lambert) projection in
> mpl, using two polar Axes (to draw each hemisphere), and this
> currently works fine to draw lines and points, since I'm transforming
> the points in my own code, from 3d-polar to 2d-projected-polar
> co-ordinates, and then plotting those.
>
> Now I have a need to also be able to draw coloured intensity maps on
> the Axes using the same transform, and I'm wondering what the best way
> to go about this would be. When I started the first implementation, I
> looked at basemap and its transforms, but they didn't seem to do what
> I wanted any more easily than just implementing it myself. 

Angus:  I'm curious about how you came to this conclusion.  It seems 
like this should be trivial in Basemap, in fact it's exactly what I 
designed it for.

If you send me a sample of your data, I can give you a simple script to 
plot it with Basemap.

-Jeff
> I'm also
> vaguely aware of some transformation capabilities (that are relatively
> new?) in mpl itself, but I'm not sure whether they're useful to me for
> polar co-ordinate systems and plot contents, rather than plot
> decorations. Ideally, the transform would apply to the interpolation
> too, but I think it would be sufficient to linearly interpolate
> between the points: I can simply provide them at high enough density
> to minimize the discrepancy.
>
> Any suggestions on the best way to do this would be gratefully received.
>
> Thanks,
>
> Angus.
>   


-- 
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


--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] define standard longitude for lambert conformal projection

2009-08-03 Thread Jeff Whitaker
Ufuk Utku Turuncoglu wrote:
> Hi,
>
> Is there any way to set standard longitude value for lambert conformal 
> projection. My current basemap parameters are,
>
> m = Basemap(projection='lcc',
> lat_1=30.0,
> lat_2=60.0,
> lat_0=40.0,
> lon_0=16.0,
> llcrnrlon=-10.0,
> llcrnrlat=25.0,
> urcrnrlon=50.0,
> urcrnrlat=50.0,
> resolution='i')
>
> but i want to add standard longitude (32) as parameter to basemap. 
>
> Thanks,
>
> --ufuk

Don't quite know what you mean by standard longitude, but I think it's 
probably lon_0 (which you have set to 16).  I don't think it will have 
any effect though, since lon_0 just defines the origin of the coordinate 
system (which will be over-ridden by the corner latitude and longitude 
parameters that you specify).  If you use the width and height keywords 
instead to define the projection region, then lon_0, lat_0 will be used 
to determine the center of the map.

-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


--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap and UTM Coordinates

2009-08-06 Thread Jeff Whitaker
Anja Roesel wrote:
> Dear list,
>
> I am a matplotlib newbie and I have some simple problems with the
> coordinate reprojection.
>
> I have a landsat scene in UTM Projection and I would like to plot it in
> a polarstereograhic projection (it is in the Arctic)
>
> I tried it like this:
> m=Basemap(resolution='i',projection='npstere',lon_0=-45,boundinglat=70)
> XP,YP = m(X_utm,Y_utm)
>
> but the outcome is nonsense (an array with 1.0's)
> I am wondering if there is an option to specify the input parameters
> like utm zone etc.
>
> Thanks for any help and ideas!
> Anja
>   

Anja:  You need to pass the latitude and longitude values (in degrees) 
to the Basemap instance when converting to projection coordinates.  So, 
to convert from UTM coordinates to polar stereographic coordinates you 
will need to do something like this:

map1 = Basemap()

lons, lats = map1(x, y, inverse=True) # x and y are projection 
coordinates on original UTM grid.

# lons and lats are now latitudes and longitudes of UTM grid (in degrees)

map2 =

Basemap(resolution='i',projection='npstere',lon_0=-45,boundinglat=70)

x, y = map2(lons, lats)

# x,y are now polar stereo coordinates of UTM grid.

Or, if you already have the latitudes and logintudes of the original UTM 
grid you can skip the first two lines and just pass those to the 
stereographic Basemap instance.

-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


--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] detailed political boundaries & major cities for basemap

2009-08-06 Thread Jeff Whitaker
P.R. wrote:
> Hi,
> Im looking for a tutorial/method/dataset to setup more detailed political
> boundaries & also automatically generate major cities on a basemap
> projection.
>
> Please help,
> Thanks,
> P.R.M.
>
>   
P.R.:  If you have ESRI shapefiles with political boundaries and/or city 
data, you can plot them on a Basemap.  See the fillstates.py and 
plotcities.py examples.

Basemap does not have a built-in city dataset, but you can draw 
political boundaries with the drawcountries and drawstates methods.  See 
http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html 
for details.  Note that the drawstates methods just draws 
states/provinces in North America (Mexico, Canada and the U.S.)

-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


--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap and UTM Coordinates

2009-08-07 Thread Jeff Whitaker
Anja Roesel wrote:
> Thanks Jeff, that's actually what I wanted to know.
> Unfortunately I guess, there is a small difference between Transverse
> Mercator and Universal Transverse Mercator Projections
> Do I have the possibility to define somewere the UTM zone and the Datum
> of my Projection.
> I tried it like Jeff suggested,
>
> map1 = Basemap(projection='tmerc',
> resolution='i',llcrnrlon=-128.3841365,llcrnrlat=68.3952899,urcrnrlon=-121.5846218,urcrnrlat=70.7793990,
> lon_0=-124.98437915,lat_0=69.5873989)
>
> lons,lats = map1(X_utm,Y_utm,inverse='True')
>
> but the lons and lats
> look like this:
>
> In [53]: lons
> Out[53]:
> array([[-124.98437915, -124.98437915, -124.98437915, ..., -124.98437915,
> -124.98437915, -124.98437915],
>[-124.98437915, -124.98437915, -124.98437915, ..., -124.98437915,
> -124.98437915, -124.98437915],
>[-124.98437915, -124.98437915, -124.98437915, ..., -124.98437915,
> -124.98437915, -124.98437915],
>...,
>[-124.98437915, -124.98437915, -124.98437915, ..., -124.98437915,
> -124.98437915, -124.98437915],
>[-124.98437915, -124.98437915, -124.98437915, ..., -124.98437915,
> -124.98437915, -124.98437915],
>[-124.98437915, -124.98437915, -124.98437915, ..., -124.98437915,
> -124.98437915, -124.98437915]])
>
> In [54]: lats
> Out[54]:
> array([[ 90.,  90.,  90., ...,  90.,  90.,  90.],
>[ 90.,  90.,  90., ...,  90.,  90.,  90.],
>[ 90.,  90.,  90., ...,  90.,  90.,  90.],
>...,
>[ 90.,  90.,  90., ...,  90.,  90.,  90.],
>[ 90.,  90.,  90., ...,  90.,  90.,  90.],
>[ 90.,  90.,  90., ...,  90.,  90.,  90.]])
>
> Has anyone an idea?
>
>   
Anja:  Basemap measures X and Y in meters from the lower left corner of 
the plot.  I don't know how your X_utm and Y_utm are defined, or what 
units they are.  You also may have to specify the major and minor radii 
of the earth to exactly match the UTM projection definition you are 
using.  Basemap cannot define a UTM projection, the the pyproj module 
inside basemap does.  If you know the UTM zone you could do, for example:

from mpl_toolkits.basemap import pyproj
p = pyproj.Proj(proj='utm',zone=10,ellps='WGS84')
lons, lats = p(X_utm,Y_utm,inverse=True)

you would still need to be careful about the units of X_utm and Y_utm 
and the ellipse definition, however.

-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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[email protected]

2009-08-11 Thread Jeff Whitaker
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 = 
> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[email protected]

2009-08-11 Thread Jeff Whitaker
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']
---
BadZipfileTraceback (most recent call last)

/Users/jsw/python/basemap/ in ()

/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/zipfile.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:[email protected]] 
> Sent: 2009-08-11 9:26 PM
> To: P.R.
> Cc: [email protected]
> 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 = 
>> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] force aspect ratio in basemap

2009-08-12 Thread Jeff Whitaker
Alexander Barth wrote:
> Hi all,
>
> I want to implement a web map server (WMS) using matplotlib/basemap.
> The client of WMS does specify the bounding box in lon/lat and width
> and height of the image. The spec requires that the server produces
> such images without blank spaces around the image. The image might
> thus have a wrong aspect ratio and it is up to the client of the WMS
> to display the image correctly.
>
> I ran in exactly the same problem as described here:
>
> http://www.nabble.com/fill-entire-figure-area---DONT-maintain-aspect-ratio-td22365115.html
>
> But I found as work around to this problem. If the aspect ratio of the
> axis is set to auto (ax.set_aspect("auto")) before the figure is
> saved, then one obtains a stretched figure (as required). Is this a
> proper solution, are just a trick that will probably no longer work in
> future version of basemap? I'm asking because the previous emails on
> this issue indicate that basemap is intended to produce always images
> in the correct aspect ratio.
>
>
> Thanks and regards
>
>   

Alexander.  Basemap now has a 'fix_aspect' kwarg.  If you set it to 
False, I think you can get what you want (the default is True).  Let me 
know if it doesn't.

-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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] contourf interpolation/smoothness

2009-08-13 Thread Jeff Whitaker
Eric Firing wrote:
> P.R. wrote:
>   
>> This has probably been asked before, so I apologize...
>>
>> Is it possible to improve the smoothness/interpolation used in contourf?
>> I know that the interpolation can be set for imshow(pcolor?), but I couldn't
>> see how to set it for contourf.
>>
>> Right now, contourf is producing some relatively jagged output for my
>> dataset, and I'd like to try to smoothen it out, without resorting to using
>> pcolor/imshow...
>> 
>
> There are two approaches:
>
> 1) manipulate the contours (the patch boundaries)
> 2) smooth and interpolate the data to a finer grid before contouring.
>
> There are many problems with the first approach, and we have never tried 
> to implement it.
>
> That leaves the second method, which is really not a plotting task but a 
> data processing task.  You might want to see if there is a suitable tool 
> in scipy.
>
> Eric
>
>
>   
Pablo:  You could use the interp function in Basemap to bilinearly 
interpolate to a finer grid.

http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html#mpl_toolkits.basemap.interp

-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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] contourf interpolation/smoothness

2009-08-13 Thread Jeff Whitaker
P.R. wrote:
> Jeff,
> One more question:
> Given two arbitrary X&Y arrays, what's the easiest/fastest way to convert to
> a finer array ?
> (for example, convert a 0.5 degree 'X' or 'Y' array to a 0.25 array over the
> same bounds as the original array)
>
> - I need a method that can handle arbitrary grid sizes & resolutions, so I
> can't just hard-code the X&Y sizes for the finer grid.
>
> Any ideas?
>
> Thanks,
> P.Romero
>   
P.R.  The interp function can do that easily, you just create an array 
of lats and lons defining the output grid by dividing the input grid 
size by 2.  Is there something in the docstring that is not clear?

-Jeff
> -Original Message-
> From: Jeff Whitaker [mailto:[email protected]] 
> Sent: 2009-08-13 7:15 AM
> To: Eric Firing
> Cc: P.R.; [email protected]
> Subject: Re: [Matplotlib-users] contourf interpolation/smoothness
>
> Eric Firing wrote:
>   
>> P.R. wrote:
>>   
>> 
>>> This has probably been asked before, so I apologize...
>>>
>>> Is it possible to improve the smoothness/interpolation used in contourf?
>>> I know that the interpolation can be set for imshow(pcolor?), but I
>>>   
> couldn't
>   
>>> see how to set it for contourf.
>>>
>>> Right now, contourf is producing some relatively jagged output for my
>>> dataset, and I'd like to try to smoothen it out, without resorting to
>>>   
> using
>   
>>> pcolor/imshow...
>>> 
>>>   
>> There are two approaches:
>>
>> 1) manipulate the contours (the patch boundaries)
>> 2) smooth and interpolate the data to a finer grid before contouring.
>>
>> There are many problems with the first approach, and we have never tried 
>> to implement it.
>>
>> That leaves the second method, which is really not a plotting task but a 
>> data processing task.  You might want to see if there is a suitable tool 
>> in scipy.
>>
>> Eric
>>
>>
>>   
>> 
> Pablo:  You could use the interp function in Basemap to bilinearly 
> interpolate to a finer grid.
>
> http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html#mpl_
> toolkits.basemap.interp
>
> -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


--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colormap creation

2009-08-14 Thread Jeff Whitaker
P.R. wrote:
> Can someone please recommend a (semi) automatic way to create the rgb
> dictionaries needed for colormap creation?
> Basically, I have a 'general' idea of how I want my colors ordered, but Im
> finding it difficult to create the smooth transitions by manually editing
> the rgb dictionary for my custom colormap...the trial & error process is
> tedious & not very accurate...
>
> How were the matplotlib colormaps created?
> Were they created manually or programmatically?
> Was it done using a random color selection?
>
> Please help,
> Thanks,
> P.Romero
>   

P.R.:  If you haven't already, you should look at the custom_cmap.py 
example.

-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


--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap day and night

2009-08-24 Thread Jeff Whitaker
Arto Oksanen wrote:
> Thanks Jeff!
>
> That is just a perfect solution!!
>
> arto

Arto:  I've cleaned up that example and added it to svn as 
examples/daynight.py.

-Jeff
>
> 2009/8/24 Jeff Whitaker mailto:[email protected]>>
>
> Arto Oksanen wrote:
>
> Thanks for your prompt reply. I should have given a more
> detailed explanation. I do know the solar position and then
> the latitude and longitude of the point on globe where the Sun
> is on the zenith. And as the sun illuminates always half of
> the globe, I just need to draw a "dark half globe" over the
> normal globe. Is this possible? That should be a lot simpler
> than drawing continents etc. :-)
>
> arto
>
>
> Arto:  Here's something  - is this what you're looking for?  It
> computes the day-night terminator, then shades one side of the
> terminator gray on  a map.
>
> -Jeff
>
>     P.S.  I've cc-ed the matplotlib users list in case anyone else has
> ideas.
>
>
>
>
> 2009/8/24 Jeff Whitaker  <mailto:[email protected]>
> <mailto:[email protected]
> <mailto:[email protected]>>>
>
>
>Arto Oksanen wrote:
>
>Hello from Finland!
>
>I am writing an utility for quickly seeing where
> astronomical
>events (like a GRB) are visible on Earth. I have installed
>Basemap and it generates very nice Earth views, but I
> still need
>to somehow display the day and night on the globe. Any
> sample
>code somewhere or some pointers how to do this?
>
>I am looking for something like this:
>  
>  
> http://www.fourmilab.ch/cgi-bin/Earth?imgsize=320&opt=-l&lat=57.1667&ns=North&lon=49.125&ew=West&alt=372461&img=learth.evif
> 
> <http://www.fourmilab.ch/cgi-bin/Earth?imgsize=320&opt=-l&lat=57.1667&ns=North&lon=49.125&ew=West&alt=372461&img=learth.evif>
>  
>  
> <http://www.fourmilab.ch/cgi-bin/Earth?imgsize=320&opt=-l&lat=57.1667&ns=North&lon=49.125&ew=West&alt=372461&img=learth.evif
> 
> <http://www.fourmilab.ch/cgi-bin/Earth?imgsize=320&opt=-l&lat=57.1667&ns=North&lon=49.125&ew=West&alt=372461&img=learth.evif>>
>  
>  
> <http://www.fourmilab.ch/cgi-bin/Earth?imgsize=320&opt=-l&lat=57.1667&ns=North&lon=49.125&ew=West&alt=372461&img=learth.evif
> 
> <http://www.fourmilab.ch/cgi-bin/Earth?imgsize=320&opt=-l&lat=57.1667&ns=North&lon=49.125&ew=West&alt=372461&img=learth.evif>
>  
>  
> <http://www.fourmilab.ch/cgi-bin/Earth?imgsize=320&opt=-l&lat=57.1667&ns=North&lon=49.125&ew=West&alt=372461&img=learth.evif
> 
> <http://www.fourmilab.ch/cgi-bin/Earth?imgsize=320&opt=-l&lat=57.1667&ns=North&lon=49.125&ew=West&alt=372461&img=learth.evif>>>
>
>TIA!
>
>arto
>
>--Arto Oksanen
>[email protected]
> <mailto:[email protected]>
> <mailto:[email protected]
> <mailto:[email protected]>>
><mailto:[email protected]
> <mailto:[email protected]>
><mailto:[email protected]
> <mailto:[email protected]>>>
>Muurame, Finland
>
>Arto:  This might help:
>
>http://en.wikipedia.org/wiki/Sunrise_equation
>
>-Jeff
>
>
>
>
> -- 
> Arto Oksanen
> [email protected] <mailto:[email protected]>
> <mailto:[email protected]
> <mailto:[email protected]>>
> Muurame, Finland
>
>
>
> -- 
> Jeffrey S. Whitaker Phone  : (303)497-6313
> Meteorologist   FAX: (303)497-6449
> NOAA/OAR/PSD  R/PSD1Email  : [email protected]
> <mailto:[email protected]>
> 325 BroadwayOffice : Skaggs Research Cntr 1D-113
> Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg
>
>
>
>
> -- 
> Arto Oksanen
> [email protected] <mailto:[email protected]

Re: [Matplotlib-users] heatmap and masked values

2009-08-27 Thread Jeff Whitaker
Christian Meesters wrote:
> Hi,
>
> I have a 2D masked array, created like:
>
> import numpy as np
> data = np.ma.array(data, mask=[data == 'NA'])
>
> which I would like to plot as a heatmap.
>
> import pylab
>
> pylab.pcolor(data)
> or
> pylab.pcolormesh(data)
>
> Well, it works with any array, but not if masked values are in there.
> Can somebody supply me with a snippet, as I apparently don't get the
> relevant piece in the docs (or did not find it ;-) ).
>
> TIA
> Christian
>
>   

Christian:  That should work, if you created the masked array 
correctly.  Why are you creating the mask with data=='NA'?  I suspect 
that this always evaluates to False, so you don't get a mask.  You 
probably want to check for a numeric value, not a string.  For example:

import matplotlib.pyplot as plt
import numpy as np
def func3(x,y):
return (1- x/2 + x**5 + y**3)*np.exp(-x**2-y**2)
dx, dy = 0.05, 0.05
x = np.arange(-3.0, 3.0001, dx)
y = np.arange(-3.0, 3.0001, dy)
X,Y = np.meshgrid(x, y)
Z = func3(X, Y)
Z = np.ma.array(Z, mask=Z>0.5)
plt.pcolor(Z)
plt.show()

-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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] heatmap and masked values

2009-08-27 Thread Jeff Whitaker
Christian Meesters wrote:
>> Christian:  That should work, if you created the masked array 
>> correctly.  Why are you creating the mask with data=='NA'?  I suspect 
>> that this always evaluates to False, so you don't get a mask.  You 
>> probably want to check for a numeric value, not a string.  For example:
>> 
> Thanks a lot, Jeff!
>
> Yes, the non-numerical comparison was indeed causing problems - although
> I don't understand why.
>
> However, I can easily inject numerical non-sense values into the array.
> As to the 'NA': The data are an R output file. As I don't like R too
> much, I'm falling back to Python.
>
> Christian
>
>   
Christian:  What type of array is that (data.dtype)?  I don't see how a 
numpy array can have values equal to 'NA', unless it is an array of 
strings.  In that case, it would not be plottable anyway. 

-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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] mplot3D plot_surface colors

2009-08-28 Thread Jeff Whitaker
Michael Droettboom wrote:
> It's important to note that we're not, as far as I'm aware, 
> considering anything lighting or ray-tracing-like yet.  I'm not sure 
> that Phong shading actually makes sense without doing that.  The 
> Gouraud shading we're in the process of implementing uses only 
> explicit colors specified in the plot, not any sort of 
> light-source-calculated values.
>
> Add perhaps more importantly, Gouraud is implemented in a number of 
> vector formats, including PDF and PS (though matplotlib doesn't have 
> support for that yet, that's coming...)
>
> Mike

Mike:  I did add some support for crude light-source shading a while 
back.  It works directly on rgb values - see 
pylab_examples/shading_example.py.

-Jeff
>
> On 08/26/2009 07:06 PM, Nicolas Bigaouette wrote:
>> Its great news that the 3D is receiving more polish :)
>>
>> After reading on wikipedia, wouldn't it be nicier to have Phong 
>> reflection[1] instead of Gouraud?
>>
>> Maybe it would be too hard, as the Gouraud seems to be implemented 
>> directly in Agg (from what others just said...)
>>
>> Anyway, just a suggestion ;)
>>
>>
>> [1] http://en.wikipedia.org/wiki/Phong_reflection_model
>>
>>
>> 2009/8/26 Eric Firing mailto:[email protected]>>
>>
>> Reinier Heeres wrote:
>> > Hi JJ,
>> >
>> > Thanks for the examples! I indeed suspected the anti-aliasing
>> as well.
>> > I'll include an option for linecolors = facecolors soon
>> (probably this
>> > weekend); it seems to be a good solution.
>>
>> No, not in general.  There are two problems: it distorts the
>> sizes and
>> positions of the patches, very slightly, but enough that it might
>> be a
>> problem in some applications; and it does not work with alpha != 1.
>>
>> Eric
>>
>> 
>> --
>> 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
>> [email protected]
>> 
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>>  
>> --
>> 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
>> [email protected] 
>> 
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>   
>
> 
>
> --
> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Fetching a data slab with NetCDFFile

2009-09-09 Thread Jeff Whitaker
gt; in date2index(dates, nctime, calendar)
>3931 Returns an index or a sequence of indices.
>3932 """
> -> 3933 return netcdftime.date2index(dates, nctime, calendar=None)
>3934
>3935 def maskoceans(lonsin,latsin,datain,inlands=False):
>
> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc
>  
> in date2index(dates, nctime, calendar, select)
>1011 import bisect
>1012
> -> 1013 index = numpy.array([bisect.bisect_left(nctime, n) for 
> n in num], int)
>1014
>1015 nomatch = num2date(nctime[index], nctime.units) != dates
>
> TypeError: object of type 'netcdf_variable' has no len()
>
> Investigating the time axis,
>
> In [20]: taxvals = timedata[:]
>
> In [21]: taxvals
> Out[21]: array([ 32712.5,  32743. ,  32773.5,  32804. ,  32834.5, 
> 32865.5, 32895. ,  32924.5,  32955. ,  32985.5,  33016. ,  33046.5, 
> 33077.5])
>
> In [22]: num2date(taxvals,timedata.units,timedata.calendar)
> Out[22]: array([1950-08-16 12:00:00, 1950-09-16 00:00:00, 1950-10-16 
> 12:00:00,
>1950-11-16 00:00:00, 1950-12-16 12:00:00, 1951-01-16 12:00:00,
>1951-02-15 00:00:00, 1951-03-16 12:00:00, 1951-04-16 00:00:00,
>1951-05-16 12:00:00, 1951-06-16 00:00:00, 1951-07-16 12:00:00,
>1951-08-16 12:00:00], dtype=object)
>
> Which agrees with what CDAT sees.
>
> -
>
> I think this is enough for now. I also had problems opening data files 
> whose time units were like "months since -xx-xx," since the 
> "months" unit does not seem to be supported. ("years since..." could 
> also be useful in some cases.) But maybe one or two things at a time 
> is enough!
>
> Thanks for any assistance/advice!
>
> Best,
>
> Arthur
>
>
> Jeff Whitaker wrote:
>> David Huard wrote:
>>> Arthur,
>>>
>>> I wrote the date2index function and I think what you are seeing is a 
>>> bug that I fixed a couple of months ago. By using the latest version 
>>> of netcdf4-python, not only should this bug disappear, but you'll 
>>> also find that date2index now supports different selection methods: 
>>> 'exact', 'before', 'after', 'nearest', that should help with your 
>>> use case.
>>>
>>> If this does not fix the problem you are seeing, I'd appreciate 
>>> having a copy of the file and code to reproduce the problem and find 
>>> a solution.
>>>
>>> HTH,
>>>
>>> David Huard
>>
>> Arthur:  I've just updated basemap svn with David's latest version of 
>> date2index, so another option is to update basemap from svn.  Or, 
>> even simpler, just drop the attached netcdftime.py file in 
>> lib/mpl_toolkits/basemap (replacing the old one) and run python 
>> setup.py install.
>>
>> -Jeff
>>>
>>>
>>>
>>> On Mon, Sep 7, 2009 at 9:27 AM, Arthur M. Greene 
>>> mailto:[email protected]>> wrote:
>>>
>>> Hi All,
>>>
>>> The problem is not with fetching the data slice itself, but
>>> finding the
>>> correct indices to specify, particularly with the time 
>>> dimension. The
>>> below examples refer to a remote dataset that I can open and slice
>>> using
>>> indices, as in
>>>
>>> slice = remoteobj.variables['tas'][:120,20:40,30:50].
>>>
>>> However, I have problems when trying to use the syntax in
>>> plotsst.py or
>>> pnganim.py (from the examples) to find time indices:
>>>
>>> In [107]: from datetime import datetime as dt
>>> In [108]: date0 = dt(1951,1,1,0)
>>> In [110]: print date0
>>> 1951-01-01 00:00:00
>>>
>>> In [125]: timedata = remoteobj.variables['time']
>>> In [126]: nt0 = date2index(date0,timedata)
>>> 
>>> --- 
>>>
>>> AssertionErrorTraceback (most recent
>>> call last)
>>>
>>> /home/amg/work/nhmm/ in ()
>>>
>>> 
>>> /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc
>>>  
>>>
>>>
>>> in date2index(dates, nctime, calendar)
>>>3924 Returns an index or a sequence of indices.
>>>3

Re: [Matplotlib-users] Fetching a data slab with NetCDFFile

2009-09-09 Thread Jeff Whitaker
Arthur M. Greene wrote:
> Thanks much. I am able to replicate your results using netcdf4.
>
> FYI, I don't believe the xml file is a CDAT creation; rather, it is 
> probably written using CMOR (http://www2-pcmdi.llnl.gov/cmor), which 
> was used to standardize the IPCC model output files, presumably so 
> they could be accessed by a variety of applications via OpenDAP. H...
>
> At any rate, I can access the remote data object with netcdf4, but no 
> luck retrieving either data or a time index.
>
> In [94]: datobj = ncf(fname)
> In [95]: timedata = datobj.variables['time']
> In [97]: taxvals = timedata[1070:1090]
> In [99]: print taxvals
> [ 32559.5  32590.   32620.5  32651.   32681.5  32712.5  32743.   32773.5
>   32804.   32834.5  32865.5  32895.   32924.5  32955.   32985.5  33016.
>   33046.5  33077.5  33108.   33138.5]
> In [100]: print 
> date2index(date0,timedata.units,timedata.calendar,select='nearest')

Arthur:  That's because the timedata variable has no attributes (no 
calendar or units), and the date2index function looks for these 
attributes.  That's weird though, since that dataset is supposed to be 
CF compliant.  I wonder if openDAP is not handling that xml file correctly.

-Jeff
> --- 
>
> AttributeErrorTraceback (most recent call 
> last)
>
> /home/amg/work/nhmm/ in ()
>
> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/netCDF4.so 
> in netCDF4.Variable.__getattr__ (netCDF4.c:13593)()
>
> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/netCDF4.so 
> in netCDF4._get_att (netCDF4.c:1806)()
>
> AttributeError: NetCDF: Attribute not found
>
>
> In [96]: print datobj.variables['tas'].shape
> (1680, 90, 144)
> In [101]: testdat = datobj.variables['tas'][0,:,:]
> --- 
>
> RuntimeError  Traceback (most recent call 
> last)
>
> /home/amg/work/nhmm/ in ()
>
> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/netCDF4.so 
> in netCDF4.Variable.__getitem__ (netCDF4.c:14286)()
>
> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/netCDF4.so 
> in netCDF4.Variable._get (netCDF4.c:18945)()
>
> RuntimeError: NetCDF: Variable has no data in DAP request
>
> --
>
> Well, at least the error messages are different...
>
> Thanks again for all the assistance. It would be useful to access the 
> IPCC output with OpenDap at some point.
>
> Best,
>
> Arthur
>
>
> Jeff Whitaker wrote:
>> Arthur M. Greene wrote:
>>> Thanks much for the quick response. I updated both matplotlib and
>>> basemap (now at 0.99.5) via svn and noticed the new netcdftime.py. 
>>> First, from within site-packages/mpl_toolkits/basemap,
>>>
>>> $ grep date2index *.py
>>> __init__.py::func:`date2index`: compute a time variable index
>>> corresponding to a date.
>>> __init__.py:def date2index(dates, nctime, 
>>> calendar='proleptic_gregorian'):
>>> __init__.py:return netcdftime.date2index(dates, nctime, 
>>> calendar=None)
>>> netcdftime.py:def date2index(dates, nctime, calendar=None, 
>>> select='exact'):
>>> netcdftime.py:date2index(dates, nctime, calendar=None, 
>>> select='exact')
>>>
>>> so there seems to be some disagreement between __init__.py and
>>> netcdftime.py concerning the presence of the "select" argument. When I
>>> call date2index with the "select" keyword arg I get
>>>
>>> In [24]: ix0 = 
>>> date2index(date0,timedata,timedata.calendar,select='nearest')
>>> --- 
>>>
>>> TypeError Traceback (most recent 
>>> call last)
>>>
>>> /home/amg/work/nhmm/ in ()
>>>
>>> TypeError: date2index() got an unexpected keyword argument 'select'
>>
>> Arthur:  I forgot to update the wrapper function in __init__.py - 
>> that's fixed now if you do an svn update.  Concerning your other 
>> problems below, using your test case exposed a couple of other bugs, 
>> but it still doesn't work.  The basic problem is that the date2index 
>> function was designed to work with netCDF4 variable objects 
>> (http://code.google.com/p/netcdf4-python), and the netcdf 
>> file/variable objects that are produced by pupynere/pydap (the pure 
>&g

Re: [Matplotlib-users] Fetching a data slab with NetCDFFile

2009-09-10 Thread Jeff Whitaker
Arthur M. Greene wrote:
> Just to add a little info:
>
> I've been poking around various OPeNDAP servers looking for files to 
> try and open (and read), and have had a little success, so the module 
> does seem to work, if not all the time for my purposes. At the moment 
> I'm on a 64-bit machine (Fedora 10), so this is encouraging. Some 
> details:
>
> I tried several of the IPCC AR4 models at PCMDI, with results similar 
> to what I reported earlier. The time object appears with neither units 
> nor a calendar. Looking at the metadata shows this not to be correct, 
> for at least the three models I investigated (gfdl_cm2_1, mpi_echam5, 
> ncar_ccsm3_0). I believe the inclusion of units and a calendar are 
> standard procedure for all of these models, and would probably cause 
> the dataset to be flagged if they weren't present. Many users (like 
> hundreds) have downloaded and analyzed these files.
>
> The IRI data library (http://iridl.ldeo.columbia.edu/) has a large 
> collection of datasets, all available using opendap. But I had 
> problems with the ones I tried because the calendars seem all to be 
> given as "360", rather than "360_day". (Perhaps someone is cutting 
> corners with the typing, I can't say...) I couldn't correct this by 
> setting timedata.calendar='360_day' because the files are opened 
> read-only. There must be files on this server with differently-defined 
> calendars, since the data come from many different sources. I'll have 
> to root around some more to turn some up.

Arthur:  It's only the time manipulation functions (date2index, 
num2date, date2num) that require the time attributes to be CF 
compliant.  You can still read the data with the netCDF module, even if 
the time attributes are not CF compliant, or not there at all.  It is 
odd that the time attributes appear missing.  That does appear to be a 
bug in the client, or could it have something to do with the fact that 
the PCC openDAP pages at LLNL appear to be password protected?

I'll email the unidata folks and see what they think.  Thanks for your 
all your testing.

-Jeff
>
> Similarly, the time units in 
> http://test.opendap.org/opendap/data/nc/data.nc are given simply as 
> 'hour', so num2date can't figure out what dates the time values refer 
> to. I wouldn't have expected this at this URL, but maybe it's a test? 
> Aside from the fact that "... since" was missing, netcdf4 also 
> complained that 'hour' was not an acceptable unit. Only 'hours' will 
> do. (No 'months' or 'years' either, it seems.)
>
> http://test.opendap.org/opendap/data/nc/coads_climatology.nc seems to 
> download OK, and there are units, but it's a 12-month climatology, so 
> calendar is irrelevant. I could plot the data, although it appeared 
> reversed left-to-right. (I didn't add axes, but just plotted it raw.)
>
> The conclusion seems to be that (1) there may be a lot of 
> non-conforming datasets out there (and netcdf4 may be a little fussy 
> about what time units it will accept, too), but (2) since there seems 
> to be some discordance w.r.t. the IPCC data (where we believe the 
> units and calendar must actually be present) one cannot be absolutely 
> sure that all of the problems experienced are solely due to malformed 
> data descriptions. Evidently more detective work will be required to 
> sort everything out...
>
> Best, thanks again for the assistance. I've been up too late chasing 
> around the web...
>
> Arthur
>
>
> Jeff Whitaker wrote:
>> Arthur M. Greene wrote:
>>> Thanks much. I am able to replicate your results using netcdf4.
>>>
>>> FYI, I don't believe the xml file is a CDAT creation; rather, it is 
>>> probably written using CMOR (http://www2-pcmdi.llnl.gov/cmor), which 
>>> was used to standardize the IPCC model output files, presumably so 
>>> they could be accessed by a variety of applications via OpenDAP. 
>>> H...
>>>
>>> At any rate, I can access the remote data object with netcdf4, but 
>>> no luck retrieving either data or a time index.
>>>
>>> In [94]: datobj = ncf(fname)
>>> In [95]: timedata = datobj.variables['time']
>>> In [97]: taxvals = timedata[1070:1090]
>>> In [99]: print taxvals
>>> [ 32559.5  32590.   32620.5  32651.   32681.5  32712.5  32743.   
>>> 32773.5
>>>   32804.   32834.5  32865.5  32895.   32924.5  32955.   32985.5  33016.
>>>   33046.5  33077.5  33108.   33138.5]
>>> In [100]: print 
>>> date2index(date0,timedata.units,timedata.calendar,select='ne

Re: [Matplotlib-users] matplotlib with tk? online examples fail...

2009-09-25 Thread Jeff Whitaker
Jonathan Tomshine wrote:
> I'm quite new to python, but am attempting to add basic plotting
> functionality to a tk-based GUI application that is run primarily on a
> Mac.  My initial attempts at simply calling "plot" or "errorbar" from
> within the application resulted in erratic behavior on Python
> installed through macports on my machine with OSX 10.5 (the plot
> appears, but the window is unresponsive), or no plot whatsoever (on a
> friend's Mac with OSX 10.6 and Python, Numpy, and Matplotlib installed
> through their "official" .dmg packages).  All versions are current
> (Python 2.6.2, Matplotlib 0.99.1.1).
>
> When looking at the matplotlib website, I attempted to run the
> following examples:
>
> http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_tk.py
> http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_tk2.py
>
> ...but these fail on my machine (OSX 10.5):
>   
> --
>
> udp009069uds:fret_analysis jshine$ python embedding_in_tk.py
> Traceback (most recent call last):
>   File "embedding_in_tk.py", line 6, in 
> from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,
> NavigationToolbar2TkAgg
>   File 
> "/Users/jshine/Documents/root/matplotlib/lib/python/matplotlib/backends/backend_tkagg.py",
> line 8, in 
> import tkagg # Paint image to Tk photo blitter extension
>   File 
> "/Users/jshine/Documents/root/matplotlib/lib/python/matplotlib/backends/tkagg.py",
> line 1, in 
> import _tkagg
> ImportError: No module named _tkagg
> udp009069uds:fret_analysis jshine$
>   

Jonathan:  You say you're using macports matplotlib, but that traceback 
does not point to a macports directory (which should be in /opt/local).  
Perhaps you have PYTHONPATH set so you're picking up a local 
installation of matplotlib, which was not built with tkagg support?

-Jeff
> --
>
> For those familiar with macports, I did install it with the "tkinter"
> option enabled:
>
> --
>
> dp009069uds:fret_analysis jshine$ port info py26-matplotlib
> py26-matplotlib @0.99.1.1 (python, graphics, math)
> Variants: cairo, darwin_8, ghostscript, gtk2, latex, qt4,
> [+]tkinter, wxpython
>
> Description:  Matplotlib is a pure python plotting library
> with the goal of making publication quality plots using a syntax
> familiar to matlab
>   users. The library uses numpy for handling large
> data sets and supports a variety of output backends. This port
> provides variants for
>   the different GUIs (gtk2, tkinter, wxpython).
> Homepage: http://matplotlib.sourceforge.net
>
> Library Dependencies: python26, freetype, libpng, py26-dateutil,
> py26-tz, py26-numpy, py26-configobj, py26-pyobjc2, py26-pyobjc2-cocoa
> Platforms:darwin
> License:  unknown
> Maintainers:  [email protected], [email protected]
> udp009069uds:fret_analysis jshine$
>
> --
>
> ...so at this point, I'm pretty much stuck -- my own application
> doesn't work, and I don't have a working example to follow.  I'd
> greatly appreciate any pointers!
>
> Thanks,
> Jon
>
>   


-- 
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


--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap calls to colorbar() failing

2009-09-28 Thread Jeff Whitaker
Ryan May wrote:
> Jeff,
>
> Right now, for me, any Basemap example that uses colorbar() is broken
> for me.  I think there's a problem with how Basemap sets the current
> 'image' so that a colorbar can be automatically generated for plots.
> The code currently does:
>
> plt.gci._current = ret
>
> I think the current image handling in matplotlib itself was reworked
> (at least according to SVN logs, r7494), so that now instead there's a
> setter function:
>
> plt.sci(ret)
>
> I'd be happy fix these myself if you're too busy.
>
> Ryan
>
>   
Ryan:  I'm off to Australia for a conference tomorrow, so if you could 
fix that I'd be grateful.  I wonder if we shouldn't wrap the old 
plt.gci._current = ret in a try/except, and use the new way if an 
Attribute Error is raised.  That way, it will still work with old 
versions of matplotlib.

Thanks for catching this.

-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


--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap, transform_scalar question

2009-09-29 Thread Jeff Whitaker
John [H2O] wrote:
> I'm trying to 'automate' a few components within basemap. I have a pretty
> complicated, and assuredly poorly written, set of functions that allow me to
> 'dynamically' plot a grid of data (lon,lat).
>
> Here is one section where I try to deal with transforming the data based on
> the projection. 'data' is a grid, often of size 720x360 or 720x180,
> representing full globe or hemisphere at 0.5 degree resolution. 'outlon0',
> outlat0', and 'd*out' are the llcrnr coordinates and step. 'transform' is an
> option, that is set to True by default:
>
> 1680 ## set up transformations for the data array 
> 1681 if m.projection not in ['cyl','merc','mill']:
> 1682 lats = np.arange( outlat0, ( outlat0 + ( numygrid*dyout ) ),
> dyout )[:-1]
> 1683 lons = np.arange( outlon0, ( outlon0 + ( numxgrid*dxout ) ),
> dxout )[:-1]
> 1684 data = data[:-1,:-1]
> 1685 else:
> 1686 lats = np.arange( outlat0, ( outlat0 + ( numygrid*dyout ) ),
> dyout )
> 1687 lons = np.arange( outlon0, ( outlon0 + ( numxgrid*dxout ) ),
> dxout )
> 1688 
> 1689 ## transform to nx x ny regularly spaced native projection grid
> 1690 if transform:
> 1691 dx = 2.*np.pi*m.rmajor/len(lons)
> 1692 nx = int((m.xmax-m.xmin)/dx)+1; ny = int((m.ymax-m.ymin)/dx)+1
> 1693 if nx is 1:
> 1694 topodat = data
> 1695 else:
> 1696 topodat = m.transform_scalar(data,lons,lats,nx,ny)
> 1697 else:
> 1698 topodat = data
>
> The problem is, when I use the approach with a 'cyl' grid, then subsequently
> try to draw the lsmask, I get a failure. Is this approach incorrect? I had
> to use the if nx is 1 statement because it was crashing with zero division
> error in some cases.
>
> Thanks.
>   
John:  Please supply us with a self-contained example triggering the 
error that we can run.

-Jeff

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap and clim, has this changed in 0.99

2009-09-29 Thread Jeff Whitaker
Evan Mason wrote:
> Hi, I've just upgraded to mpl 0.99 (from svn) and Basemap (also from svn).
>
>
>   

Evan:  I believe Ryan May just fixed this yesterday - so if you update 
basemap from svn again it should work.

-Jeff
> It seems that plt.clim(vmin,vmax) no longer works with Basemap
> objects.  Here is an example, which before used to work:
>
>
> In [92]: M.pcolormesh(x, y, a_var,cmap=cm)
> Out[92]: 
>
> In [93]: plt.clim(-10,10)
> ---
> RuntimeError  Traceback (most recent call last)
>
> /home/emason/pytools/fig_thesis_ssh_variance_prime_month.py in ()
> > 1
>   2
>   3
>   4
>   5
>
> /usr/lib64/python2.6/site-packages/matplotlib/pyplot.pyc in clim(vmin, vmax)
>1379 im = gci()
>1380 if im is None:
> -> 1381 raise RuntimeError('You must first define an image, eg
> with imshow')
>1382
>1383 im.set_clim(vmin, vmax)
>
> RuntimeError: You must first define an image, eg with imshow
>
> In [94]:
>
>
>
> Using plt.pcolormesh there's no problem.  Has this change been done
> intentionally?  If so, what is now the recommended way to apply
> climits to a Basemap plot?
>
>
> Thanks, Evan
>
> --
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


-- 
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


--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap drawcoastlines issue

2009-10-05 Thread Jeff Whitaker
Scott Sinclair wrote:
>> 2009/10/1 ringobelingo :
>> I would like to add coastlines to a map but do not want interior
>> 'coastlines'. At present, without them my continents are not distinct enough
>> from the data I am plotting in the background. But, when I draw them using
>> drawcoastlines(), I also get e.g. the great lakes showing up, and this just
>> makes my world maps look messy and distracts from my data which should be
>> the main focus. Does anyone know of a way to force this to happen, or is it
>> something that might be added, i.e. splitting the function into
>> drawcoastlines() and drawicoastlines() ... ?
>> 
>
> The easiest way to address this is to obtain (or make) a GIS shapefile
> that has the coastlines you'd like to see. Then use the
> readshapefile() method on your Basemap object instead of the
> drawcoastlines() method.
>
> my_map = Basemap(...)
> my_map.readshapefile(my_shpfile_name)
>
> Cheers,
> Scott
>
>   

You can also use the 'area_thresh' keyword to control the minimum size 
of coastline features that are drawn.  area_thresh=100 makes the 
Great Lakes disappear, at the expense of making all the islands except 
Greenland disappear too.  If that's unacceptable, you'll have to do as 
Scott suggests and create a shapfile without the lakes.

-Jeff


--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap, transform_scalar question

2009-10-08 Thread Jeff Whitaker
John [H2O] wrote:
> Jeff,
>
> Here's a quick snippet. I've looked at the test.py file provided with the
> basemap examples. What I am unclear on are the different ways in which nx
> and ny are defined. I would like to have this 'automatically' defined, based
> solely on variables from my input object.. say for example a netcdf file
> that has len and lon dimensions defined. 
>   

John:  I don't have time to look at your code right now, but let me just 
make some general comments about plotting images on maps.  If you want 
to use imshow, the data your are plotting must coincide exactly with 
your map plot area.  So, for example if you want to plot a global 
lat/lon grid on a north polar stereographic projection, you have to 
interpolate to a rectangular grid in projection coordinates that fits in 
the map region.  However, in practice I find it's almost never worth 
doing this.  You can plot the data in the native coordinates on almost 
any map projection region using pcolormesh or contourf,  Just calculate 
the x,y values of the of the data grid, and pass those values along with 
the data to either one of those methods.  Is there any particular reason 
you want to use imshow, instead of pcolormesh or contourf?

-Jeff
> Below is my crude stab at it, but I am clearly having some problems. I guess
> the point is, maybe it's not possible to have a Basemap instance with
> extents beyond the imshow object. Then perhaps I need to make sure that when
> I set up the Basemap instance, I pass the H.outlon0 to llcrnrlon for
> example. But is that necessary?
>
> Thanks!
>
> #!/usr/bin/env python
>
> import matplotlib.pyplot as plt
> from mpl_toolkits.basemap import Basemap
> import numpy as np
>
>
>
> def plot_imshow_custom(H,transform=True ):
> """
> function to automagically plot an mxn array of arbitrary lats/lons
> """
> data = H.data
> print data.shape
> 
> m =
> Basemap(projection='npstere',boundinglat=10,lon_0=270,resolution='l')
> fig = plt.figure()
> ax = fig.gca()
>  
> print "Preparing to plot %s with dimensions:" % H.name
> print "lon0, numx, dx:"
> print H.outlon0, H.numxgrid, H.dxout
> print "lat0, numy, dy:"
> print H.outlat0, H.numygrid, H.dyout
> 
> 
> ## set up transformations for the data array
> ## THIS IS WHERE I NEED SOME HELP:
> if m.projection not in ['cyl','merc','mill']:
> lats = np.arange( H.outlat0, ( H.outlat0 + ( H.numygrid*H.dyout ) ),
> H.dyout )[:-1]
> lons = np.arange( H.outlon0, ( H.outlon0 + ( H.numxgrid*H.dxout ) ),
> H.dxout )[:-1]
> data = data[:-1,:-1]
> else:
> lats = np.arange( H.outlat0, ( H.outlat0 + ( H.numygrid*H.dyout ) ),
> H.dyout )
> lons = np.arange( H.outlon0, ( H.outlon0 + ( H.numxgrid*H.dxout ) ),
> H.dxout )
> print data.shape
> ## transform to nx x ny regularly spaced native projection grid
> if transform:
> if m.projection not in ['cyl','merc','mill']:
> dx = 2.*np.pi*m.rmajor/len(lons)
> dy = 2.*np.pi*m.rminor/len(lats)
> else:
> dx = len(lons)
> dy = len(lats)
> nx = int((m.xmax-m.xmin)/dx)+1; 
> ny = int((m.ymax-m.ymin)/dy)+1
> print nx
> if nx is 1:
> topodat = data
> else:
> topodat = m.transform_scalar(data,lons,lats,nx,ny)
> else:
> topodat = data
>
>
> ## Get the current axes, and properties for use later
> pos = ax.get_position()
> l, b, w, h = pos.bounds
>
> ## Set up the IMAGE
> colmap = plt.get_cmap('gist_ncar')
> im = m.imshow(topodat,cmap=colmap)
> m.drawcoastlines()
>
> return fig
>
>
> class SuperDict(dict):
> """just so I can use . notation"""
> def __getattr__(self, attr):
> return self[attr]
> def __setattr__(self, attr, value):
> self[attr] = value
>
> if __name__ == "__main__":
> 
> H = SuperDict()
> H.name = 'working example'
> H.outlat0 = -90
> H.numygrid = 180
> H.dyout = 1.
> H.outlon0 = -179
> H.numxgrid = 360
> H.dxout = 1.0
> H.data = np.random.rand(H.numygrid,H.numxgrid)
> print H.data.shape
> fig = plot_imshow_custom(H,transform=True)
> plt.show()
> print 'it worked'
> try:
> H.name = 'Not working example'
> H.outlat0 = 40
> H.numygri

Re: [Matplotlib-users] readshapefile

2009-10-11 Thread Jeff Whitaker
Steve Westenbroek wrote:
> Hi Jeff,
>
> I apologize in advance for contacting you directly, however, I've been
> Googling and RTFM-ing to no avail!
>
> If you have time and/or inclination, I have two questions for you
> regarding the Basemap module under Matplotlib.
>
> 1) I've been struggling to use "readshapefile" to load a simple polyline
> shapefile. I'm currently running the Enthought Python Distribution
> v5.1.0 on Windows XP. I stumbled onto an archived email message from 
> you  describing how one does a "python setup.py install" from within 
> the Thuban source directory. I can verify that the pytest.py script 
> works following installation. However, I cannot get Python to 
> recognize "readshapefile" as a valid method. I'm sure there is a 
> simple solution to this, but it is just out of my reach. Any ideas?
>
Steve:  You have to create a basemap class instance, then call the 
readshape file method.  All the necessary dependencies are included, you 
don't have to install anything else.  Try running the fillstates.py 
demo, and if that works, everything is fine.
> 2) It does not appear that one can simply pass through the Proj4 
> string when invoking "Basemap"? Is this true?  I have some whacky 
> (i.e. project-specific) projection parameters that I'd love to simply 
> feed into "Basemap", but it doesn't appear to be a possibility. If I 
> am correct, do you have a sense for how difficult it would be to 
> modify Basemap to accept Proj4 strings?

It's impossible, because a) Basemap doesn't support all the possible 
proj4 projections, and b) not all the info Basemap needs can be 
specified in a proj4 string.

Have you seen the documentation at

http://matplotlib.sourceforge.net/basemap/doc/html/ ?

-Jeff
>
> Thanks in advance!  It seems that I am tantalizingly close to making 
> this work for my problem.
>
> Cheers,
>
>  - Steve
>


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap, transform_scalar question

2009-10-11 Thread Jeff Whitaker
John [H2O] wrote:
> Jeff Whitaker wrote:
>   
>> John:  I don't have time to look at your code right now, but let me just 
>> make some general comments about plotting images on maps.  If you want 
>> to use imshow, the data your are plotting must coincide exactly with 
>> your map plot area.  So, for example if you want to plot a global 
>> lat/lon grid on a north polar stereographic projection, you have to 
>> interpolate to a rectangular grid in projection coordinates that fits in 
>> the map region.  However, in practice I find it's almost never worth 
>> doing this.  You can plot the data in the native coordinates on almost 
>> any map projection region using pcolormesh or contourf,  Just calculate 
>> the x,y values of the of the data grid, and pass those values along with 
>> the data to either one of those methods.  Is there any particular reason 
>> you want to use imshow, instead of pcolormesh or contourf?
>>
>> -Jeff
>>
>>
>> 
>
> Jeff,
>
> I started using pcolormesh, but ran into the problem that I really required
> a log scale color map for the plotting. As I recall, this could only be done
> with imshow - but perhaps that has changed? 
John:

The color mapping is the same with imshow or pcolormesh.  See the recent 
thread on "logarithmic colormaps".
> Regardless, I've done some
> further testing. It seems I have the following problems with it:
>
> 1) It is much more 'coarse' in the coloring, imshow offers a finer/smoother
> looking gradient. 
>   
Only way around that with pcolormesh is to interpolate to a finer grid.  
Imshow will interpolate the colors, pcolormesh will not.
> 2) The bigger problem occurs when plotting in npstere, which I use quite
> often. Maybe I have to add a wrap around, but as it is, I get a 'seam' at
> the -180/180 meridian. 
>   
Just add a wraparound - that's easy with the addcyclic function.
> 3) At the pole, there is a empty spot, creating a hole in my plots. This I
> can't work with... :s
>   
That's because you don't have a grid point at the pole.  You could add 
one (by extrapolating the from the highest latitude).

-Jeff
> Thanks again for your input.
>
> -john 
>
>
>   


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] cannot install kubuntu 9.04 mpl 0.99.1.1, python 2.6

2009-10-13 Thread Jeff Whitaker
KURT PETERS wrote:
> I'm pretty sure I have all the required minimal dependencies 
> installed, but get an error when I sudo python setup.py build.  Any 
> thoughts?  I can start python and import Tkinter without an error.  So 
> I don't know why it's not finding it.
>
> [code]
> sudo python setup.py build
> 
> BUILDING 
> MATPLOTLIB
> matplotlib: 
> 0.99.1.1   
> python: 2.6.2 (release26-maint, Apr 19 2009, 
> 01:56:41)  [GCC
> 
> 4.3.3] 
>   platform: 
> linux2 
>
> REQUIRED DEPENDENCIES
>  numpy: 1.2.1
>  freetype2: 9.20.3
>
> OPTIONAL BACKEND DEPENDENCIES
> libpng: 1.2.27
>Tkinter: no   
> * Using default library and include 
> directories for
> * Tcl and Tk because a Tk window failed to 
> open.  
> * You may need to define DISPLAY for Tk to 
> work so
> * that setup can determine where your 
> libraries are
> * located. Tkinter present, but header files 
> are not
> * found. You may need to install 
> development   
> * 
> packages.
>   wxPython: 
> 2.8.9.1
> * WxAgg extension not required for wxPython >= 
> 2.8 
> pkg-config: looking for pygtk-2.0 
> gtk+-2.0 
> * Package pygtk-2.0 was not found in the 
> pkg-config
> * search path. Perhaps you should add the 
> directory
> * containing `pygtk-2.0.pc' to the 
> PKG_CONFIG_PATH 
> * environment variable No package 'pygtk-2.0' 
> found
> * Package gtk+-2.0 was not found in the 
> pkg-config 
> * search path. Perhaps you should add the 
> directory
> * containing `gtk+-2.0.pc' to the 
> PKG_CONFIG_PATH  
> * environment variable No package 'gtk+-2.0' 
> found 
> * You may need to install 'dev' package(s) 
> to  
> * provide header 
> files.
>   Gtk+: 
> no 
> * Could not find Gtk+ headers in any 
> of
> * '/usr/local/include', '/usr/include', 
> '.'
>Mac OS X native: 
> no 
> Qt: 
> no 
>Qt4: 
> no 
>  Cairo: 
> 1.4.12 
>
> OPTIONAL DATE/TIMEZONE DEPENDENCIES
>   datetime: present, version unknown
>   dateutil: matplotlib will provide
>   pytz: matplotlib will provide
> adding pytz
>
> OPTIONAL USETEX DEPENDENCIES
> dvipng: no
>ghostscript: 8.64
>  latex: 3.141592
>pdftops: 0.10.5
>
> [Edit setup.cfg to suppress the above messages]
> 
> pymods ['pylab']
> packages ['matplotlib', 'matplotlib.backends', 
> 'matplotlib.projections', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 
> 'mpl_toolkits.axes_grid', 'matplotlib.sphinxext', 
> 'matplotlib.numerix', 'matplotlib.numerix.mlab', 
> 'matplotlib.numerix.ma', 'matplotlib.numerix.linear_algebra', 
> 'matplotlib.numerix.random_array', 'matplotlib.numerix.fft', 
> 'matplotlib.delaunay', 'pytz', 'dateutil', 'dateutil/zoneinfo']
> running build
> running build_py
> copying lib/matplotlib/mpl-data/matplotlibrc -> 
> build/lib.linux-i686-2.6/matplotlib/mpl-data
> copying lib/matplotlib/mpl-data/matplotlib.conf -> 
> build/lib.linux-i686-2.6/matplotlib/mpl-data
> running build_ext
> building 'matplotlib.backends._tkagg' extension
> gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall 
> -Wstrict-prototypes -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API 
> -I/usr/local/include -I/usr/local/include -I/usr/local/include 
> -I/usr/include -I. 
> -I/usr/lib/python2.6/dist-packages/numpy/core/include -Isrc 
> -Iagg24/include -I. 
> -I/usr/lib/python2.6/dist-packages/numpy/core/include 
> -I/usr/include/freetype2 -I/usr/local/include -I/usr/include -I. 
> -I/usr/include/python2.6 -c src/_tkagg.cpp -o 
> build/temp.linux-i686-2.6/src/_tkagg.o
> cc1plus: warning: command lin

Re: [Matplotlib-users] plotting from within ipython, and then go on in the shell calculations

2009-10-13 Thread Jeff Whitaker
[email protected] wrote:
> Greetings.
>
> What i want to do is something like:
>
> ipython ...
>
> 
>
> t=linspace(0,2,50)
> y=sin(2*pi*t)
>
> pyplot.plot(t,y)
> pyplot.show()
>
> 
>
> I get the plot here ... but now i want to do some more stuff in
> the ipython shell (and possibly have the plot still open)
>
> How do i free the shell from the plot thread?
>
> Thanks
>
>
>
>   
http://matplotlib.sourceforge.net/users/shell.html

bottom line - don't call show.

-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


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] cannot install kubuntu 9.04 mpl 0.99.1.1, python 2.6

2009-10-13 Thread Jeff Whitaker
KURT PETERS wrote:
> Jeff,
>I had already had tk-dev installed:
> $ sudo apt-get install tk-dev
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> tk-dev is already the newest version.
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded
>
> Please see my latest...  This is amazingly difficult.  Didn't remember 
> it being this hard when I did it on my Suse machine.
>
> Kurt


So where's your tk.h file?

-Jeff
>
> ==
> > Date: Tue, 13 Oct 2009 13:46:22 -0600
> > From: Jeff Whitaker 
> > Subject: Re: [Matplotlib-users] cannot install kubuntu 9.04 mpl
> > 0.99.1.1, python 2.6
> > To: KURT PETERS 
> > Cc: [email protected]
> > Message-ID: <[email protected]>
> 
>
> > > src/_tkagg.cpp:30:18: error: tk.h: No such file or directory
> > > src/_tkagg.cpp:38: error: ISO C++ forbids declaration of ?Tcl_Interp?
> > > with no type
> > > src/_tkagg.cpp:38: error: expected ?;? before ?*? token
> > > src/_tkagg.cpp:42: error: ?ClientData? was not declared in this scope
> > > src/_tkagg.cpp:42: error: ?Tcl_Interp? was not declared in this scope
> > > src/_tkagg.cpp:42: error: ?interp? was not declared in this scope
> > > src/_tkagg.cpp:43: error: expected primary-expression before ?int?
> > > src/_tkagg.cpp:43: error: expected primary-expression before ?char?
> > > src/_tkagg.cpp:43: error: initializer expression list treated as
> > > compound expression
> > > src/_tkagg.cpp:44: error: expected ?,? or ?;? before ?{? token
> > > 
> /usr/lib/python2.6/dist-packages/numpy/core/include/numpy/__multiarray_api.h:958:
>  
>
> > > warning: ?int _import_array()? defined but not used
> > > src/_tkagg.cpp:42: warning: ?PyAggImagePhoto? defined but not used
> > > error: command 'gcc' failed with exit status 1
> > > [/code]
> >
> > Kurt: It's not finding tk.h, so you probably need to install the 
> tk-dev package.
> >
> > -Jeff
> >
> > 
> > Jeffrey S. Whitaker Phone : (303)497-6313
> > Meteorologist FAX : (303)497-6449
> > NOAA/OAR/PSD R/PSD1 Email : [email protected]
> > 325 Broadway Office : Skaggs Research Cntr 1D-113
> > Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
> >
> 
> >
> > Here's what I "had" to install so far for Kubuntu Jaunty 9.04 (first 
> few were required by numpy):
> >
> > 495 sudo apt-get install matplotlib <-- always worth a try... didn't 
> work
> >
> > 520 sudo apt-get install libatlas3gf-3dnow
> >
> > 523 sudo apt-get install libblas-dev
> >
> > 532 sudo apt-get install gfortran
> >
> > 534 sudo apt-get install lapack
> >
> > 536 sudo apt-get install liblapack-dev
> >
> > 537 sudo apt-get install python-symeig libatlas-3dnow-dev
> >
> > 549 sudo apt-get install freetype
> >
> > 552 sudo apt-get install libfreetype6
> >
> > 554 sudo apt-get install libfreetype6-dev
> >
> > 555 sudo apt-get install tk
> >
> > 556 sudo apt-get install dvipng
> >
> > 569 sudo apt-get install python-qt4 python-qt4-common
> >
> > 574 sudo apt-get install python-tk wxPython
> >
> > 576 sudo apt-get install python-tk python-wxaddons
> >
> > 577 sudo apt-get install python-tk python-wxtools
> >
> > 590 sudo apt-get install wx-common
> >
> > 591 sudo apt-get install wx-headers
> >
> > 592 sudo apt-get install wx2.8-headers
> >
> > 593 sudo apt-get install libwxbase2.8-0
> >
> > 594 sudo apt-get install libwxgtk2.8-0
> >
> > 603 sudo apt-get install tcl8.5-dev
> > 604 sudo apt-get install tk-dev
>
> 
>
> --
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> 
>
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


-- 
Jeffrey S. Whitaker Phone  : (303)497

Re: [Matplotlib-users] cannot install kubuntu 9.04 mpl 0.99.1.1, python 2.6

2009-10-13 Thread Jeff Whitaker
KURT PETERS wrote:
> Apparently, I have two  :-)
>
> $ sudo find / -name "tk.h"
>
> /usr/include/tcl8.4/tk.h
> /usr/include/tcl8.4/tk-private/generic/tk.h

But you need /usr/include/tcl8.5/tk.h.  Matplotlib is detecting a tk 8.5 
installation, so it's looking for a tk 8.5 header.

-Jeff
>
> Kurt
>
> > Date: Tue, 13 Oct 2009 15:55:51 -0600
> > From: [email protected]
> > Subject: Re: [Matplotlib-users] cannot install kubuntu 9.04 mpl 
> 0.99.1.1, python 2.6
> > To: [email protected]
> > CC: [email protected]
> >
> > KURT PETERS wrote:
> > > Jeff,
> > > I had already had tk-dev installed:
> > > $ sudo apt-get install tk-dev
> > > Reading package lists... Done
> > > Building dependency tree
> > > Reading state information... Done
> > > tk-dev is already the newest version.
> > > 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded
> > >
> > > Please see my latest... This is amazingly difficult. Didn't remember
> > > it being this hard when I did it on my Suse machine.
> > >
> > > Kurt
> >
> >
> > So where's your tk.h file?
> >
> > -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


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting from within ipython, and then go on in the shell calculations

2009-10-13 Thread Jeff Whitaker
[email protected] wrote:
> but i want to:
>  1) plot something
>  2) go on in ipython (with the figure/plot staying on)
>
> is that really not possible?
>
> thanks,
> q
>   

That's exactly what happens in ipython (in pylab mode), if you don't 
call show.

-Jeff
> On Tue, Oct 13, 2009 at 03:54:22PM -0600, Jeff Whitaker wrote:
>   
>> [email protected] wrote:
>> 
>>> Greetings.
>>>
>>> What i want to do is something like:
>>>
>>> ipython ...
>>>
>>> 
>>>
>>> t=linspace(0,2,50)
>>> y=sin(2*pi*t)
>>>
>>> pyplot.plot(t,y)
>>> pyplot.show()
>>>
>>> 
>>>
>>> I get the plot here ... but now i want to do some more stuff in
>>> the ipython shell (and possibly have the plot still open)
>>>
>>> How do i free the shell from the plot thread?
>>>
>>> Thanks
>>>
>>>
>>>
>>>   
>>>   
>> http://matplotlib.sourceforge.net/users/shell.html
>>
>> bottom line - don't call show.
>>
>> -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
>>
>>
>> --
>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay 
>> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
>> http://p.sf.net/sfu/devconference
>> ___
>> Matplotlib-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> 
>
>   


-- 
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


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] cannot install kubuntu 9.04 mpl 0.99.1.1, python 2.6

2009-10-13 Thread Jeff Whitaker
KURT PETERS wrote:
> OK, that got me a hair further  :-)  With your suggestion I got past 
> that speed bump by:
> sudo apt-get install tk8.5-dev tcl8.5-dev
>
> Now the error is a little more sinister.  I did a tiny bit of research 
> and some posts says the error could be due to no installation of g++.  
> but...
> [code]
> sudo apt-get install g++
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> g++ is already the newest version.
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> [/code]
> 
> [code]
> building 'matplotlib.backends._tkagg' 
> extension 
>   
>
> g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions 
> build/temp.linux-i686-2.6/src/agg_py_transforms.o 
> build/temp.linux-i686-2.6/src/_tkagg.o 
> build/temp.linux-i686-2.6/CXX/cxx_extensions.o 
> build/temp.linux-i686-2.6/CXX/IndirectPythonInterface.o 
> build/temp.linux-i686-2.6/CXX/cxxsupport.o 
> build/temp.linux-i686-2.6/CXX/cxxextensions.o -L/usr/local/lib 
> -L/usr/local/lib -ltk8.5 -ltcl8.5 -lstdc++ -lm -lfreetype -lz -lstdc++ 
> -lm -o 
> build/lib.linux-i686-2.6/matplotlib/backends/_tkagg.so   
> building 'matplotlib.backends._macosx' 
> extension 
>  
>
> gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall 
> -Wstrict-prototypes -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API 
> -I/usr/lib/python2.6/dist-packages/numpy/core/include 
> -I/usr/local/include -I/usr/include -I. 
> -I/usr/lib/python2.6/dist-packages/numpy/core/include -Isrc 
> -Iagg24/include -I. -I/usr/include/python2.6 -c src/_macosx.m -o 
> build/temp.linux-i686-2.6/src/_macosx.o   
>   
>
> gcc: error trying to exec 'cc1obj': execvp: No such file or 
> directory
> error: command 'gcc' failed with exit status 1
> [/code]
>
Kurt:

I don't think you should be building the macosx backend on linux.  Try 
copying setup.cfg.template to setup.cfg, then edit that file and 
uncomment the line

#macosx = False

Then run setup.py build again.


-Jeff
> Is it possible I need a special version of g++?
> Kurt
>
>
> 
>
> --
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> 
>
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


-- 
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


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Malaren lake by Matplotlib Basemap

2009-10-25 Thread Jeff Whitaker
kkondo wrote:
> Hello
>
> I want to get the shoreline of Malaren lake as 
> http://en.wikipedia.org/wiki/File:La3-demis-malaren.png. But I find 
> that the following Matplotlib-Basemap program does not draw its 
> shoreline but its islands. Is it the flaw of GSHHS?
>
>
> from mpl_toolkits.basemap import Basemap
> import matplotlib.pyplot as plt
> m = Basemap(width=18,height=9,
> resolution='f',projection='tmerc',lon_0=17.5,lat_0=59.5)
> plt.clf()
> m.drawcoastlines()
> m.fillcontinents(color='coral',lake_color='aqua')
> m.drawmapboundary(fill_color='aqua')
> m.drawrivers(color='b')
> plt.show()
>
>
> Sincerely,
> Kentaro Kondo
>
>
Kentaro: Apparently it's a flaw in GSHHS.  I tried the online line map 
creator at http://www.aquarius.geomar.de/cgi-bin/map-cgi.pl (which uses 
GMT, which is the source of GSSHS) and got the same thing.  It's 
possible that it's fixed in the latest version of GSHHS (1.10) - I'll 
take a look and let you know.

-Jeff

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Malaren lake by Matplotlib Basemap

2009-10-26 Thread Jeff Whitaker
kkondo wrote:
> Dear Jeff
>
> Thank you for your reply.
>
> I have found that the "resolution='f'" in basemap crashes when drawing
> the Japanese Isles. Is it another flaw in GSHHS?
>

Kentaro: I cannot reproduce this crash. What version of the GEOS library
do you have? I am using 3.1.1.

-Jeff

P.S. cc'ing the matplotlib mailing list.
> % python japanese_isles.py
> GEOS_ERROR: TopologyException: side location conflict
> (130.468,32.5594,32.5594)
> Bus error
> % cat japanese_isles.py
> from mpl_toolkits.basemap import Basemap
> import matplotlib.pyplot as plt
> m = Basemap(llcrnrlon=121.,llcrnrlat=23.,urcrnrlon=152.,urcrnrlat=48.,
> resolution='f',projection='tmerc',lon_0=135.,lat_0=35.)
> m.drawcoastlines()
> plt.show()
> $ python
> Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53)
> [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import numpy
> >>> numpy.__version__
> '1.3.0'
> >>> import mpl_toolkits.basemap
> >>> mpl_toolkits.basemap.__version__
> '0.99.4'
>
> P.S. "resolution='f'" works fine for the British Isles:
> m = Basemap(llcrnrlon=-10.5,llcrnrlat=49.5,urcrnrlon=3.5,urcrnrlat=59.5,
> resolution='f',projection='tmerc',lon_0=-4.36,lat_0=54.7)
>
> Sincerely,
> Kentaro Kondo
>
>
> On 2009/10/25, at 22:40, Jeff Whitaker wrote:
>
>> kkondo wrote:
>>> Hello
>>>
>>> I want to get the shoreline of Malaren lake as
>>> http://en.wikipedia.org/wiki/File:La3-demis-malaren.png. But I find
>>> that the following Matplotlib-Basemap program does not draw its
>>> shoreline but its islands. Is it the flaw of GSHHS?
>>>
>>>
>>> from mpl_toolkits.basemap import Basemap
>>> import matplotlib.pyplot as plt
>>> m = Basemap(width=18,height=9,
>>> resolution='f',projection='tmerc',lon_0=17.5,lat_0=59.5)
>>> plt.clf()
>>> m.drawcoastlines()
>>> m.fillcontinents(color='coral',lake_color='aqua')
>>> m.drawmapboundary(fill_color='aqua')
>>> m.drawrivers(color='b')
>>> plt.show()
>>>
>>>
>>> Sincerely,
>>> Kentaro Kondo
>>>
>>>
>> Kentaro: Apparently it's a flaw in GSHHS. I tried the online line map
>> creator at http://www.aquarius.geomar.de/cgi-bin/map-cgi.pl (which
>> uses GMT, which is the source of GSSHS) and got the same thing. It's
>> possible that it's fixed in the latest version of GSHHS (1.10) - I'll
>> take a look and let you know.
>>
>> -Jeff
>
> ---
> 富士通(株)
> 次世代IT・ITSプロジェクト室
> インフラ協調プロジェクト
> 近藤 [email protected]
> (044)754-8513 fax (044)754-3292
> 〒211-8588 神奈川県川崎市中原区上小田中4-1-1
>


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Malaren lake by Matplotlib Basemap

2009-10-26 Thread Jeff Whitaker
Jeff Whitaker wrote:
> kkondo wrote:
>   
>> Hello
>>
>> I want to get the shoreline of Malaren lake as 
>> http://en.wikipedia.org/wiki/File:La3-demis-malaren.png. But I find 
>> that the following Matplotlib-Basemap program does not draw its 
>> shoreline but its islands. Is it the flaw of GSHHS?
>>
>>
>> from mpl_toolkits.basemap import Basemap
>> import matplotlib.pyplot as plt
>> m = Basemap(width=18,height=9,
>> resolution='f',projection='tmerc',lon_0=17.5,lat_0=59.5)
>> plt.clf()
>> m.drawcoastlines()
>> m.fillcontinents(color='coral',lake_color='aqua')
>> m.drawmapboundary(fill_color='aqua')
>> m.drawrivers(color='b')
>> plt.show()
>>
>>
>> Sincerely,
>> Kentaro Kondo
>>
>>
>> 
> Kentaro: Apparently it's a flaw in GSHHS.  I tried the online line map 
> creator at http://www.aquarius.geomar.de/cgi-bin/map-cgi.pl (which uses 
> GMT, which is the source of GSSHS) and got the same thing.  It's 
> possible that it's fixed in the latest version of GSHHS (1.10) - I'll 
> take a look and let you know.
>
> -Jeff
>   

Kentaro:  The problem still exists in GSHHS 1.10.  I don't know what to 
suggest other than using a shapefile to plot the lakes in that region, 
if you can find one.

-Jeff

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] drawmapscale() and 'cyl' projection [SEC=UNCLASSIFIED]

2009-10-29 Thread Jeff Whitaker
[email protected] wrote:
> Hi all,
>
> Sorry if this has been discussed before, but I can't find any previous 
> threads on this.
>
> I'm trying to draw a scale on an equidistant cylindrical projection, and I'm 
> seeing a ValueError exception with the message:
> Cannot draw map scale for projection='cyl'
>
> And indeed, in basemap/__init__.py (about line 3286, 0.99.4) there is an 
> explicit test for the 'cyl' projection and a raise of the above exception.
>
> Maybe I'm just extra ignorant today, but why *shouldn't* a scale be drawn on 
> a 'cyl' projection
>
> Thanks,
> Ross
>   
Ross: Because a cylindrical projection isn't really a projection at all 
- it's just a lat/lon coordinate system.

-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


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] drawmapscale() and 'cyl' projection [SEC=UNCLASSIFIED]

2009-10-29 Thread Jeff Whitaker
[email protected] wrote:
> -Original Message-
> 
>   
>> Maybe I'm just extra ignorant today, but why *shouldn't* a scale be drawn on 
>> a 'cyl' projection
>>
>> 
> 
>
> Ross: Because a cylindrical projection isn't really a projection at all
> - it's just a lat/lon coordinate system.
>
> -Jeff
>
> 
> -Original Message-
>
> Hi Jeff,
>
> Yes, surely, cylindrical isn't a real hairy-chested projection like Mercator, 
> et al, yet I can create a map with the 'Equidistant Cylindrical Projection' 
> and a scale has just as much meaning on a cylindrical 'projection' as any 
> other.
>
> That is, the semantics of the drawmapscale() method have meaning, even in 
> cyclindrical: "draw an annotation at this point representing the scale at 
> that other _point_".  Yes, as you move away from the point the scale 
> annotation is representing the errors grow, but that is true of many 
> projections. True, the errors for cylindrical projections get rather large, 
> especially in the higher latitudes, but that just means the creator/user must 
> understand the limitations.
>
> Ross
>   
Ross:   You're right, I guess the real reason is that when you create a 
basemap instance with projection='cyl', then do

x,y = map(lon, lat) # map is a Basemap instance for projection='cyl'

nothing happens - that is x,y are still longitudes and latitudes in 
degrees.  So, there is nothing from which to compute a map scale, since 
no projection is happening. 

-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


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap: Mask the ocean [SEC=UNCLASSIFIED]

2009-11-02 Thread Jeff Whitaker

Stephane Raynaud wrote:

Ross,


one way is to mask (or remove) ocean points using the _geoslib module 
provided with basemap.
When you create a Basemap instance, you can retrieve all its polygons 
land (continents and islands) with "mymap.coastpolygons".
Thay are stored as numpy arrays, and you can convert them to 
_geoslib.Polygon objects :


poly = _geoslib.Polygon(N.asarray(coastalpoly).T)

Then you loop over all Polygons and all (x,y) points and test :

good_point = _geoslib.Point((x,y)).within(poly)

Thanks to this method, you can choose you optimal resolution.
You can even compute the intersection of you hexagons with coastal 
polygons using .intersection() and .area (instead of simply checking 
if the center is inside) and then reject points depending the fraction 
of the cell covered by land (or ocean).


Following Stephane's excellent suggestion, here's a prototype Basemap 
method that checks to see if a point is on land or over water.  Ross - 
if you find it useful I'll include it in the next release.  Note that it 
will be slow for lots of points or large map regions.


-Jeff


On Mon, Nov 2, 2009 at 8:07 AM, > wrote:


Listers,

I'm using basemap to plot randomly sampled values (x,y,z) through
hexbin.  This produces a very nice result. Some sample code is:
--
import numpy as np
from numpy.random import seed
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
from matplotlib.mlab import griddata

ll_lat = -38.39477  # extent of area of interest
ll_lon = 144.54767
ur_lat = -37.51642
ur_lon = 145.67144

num_points = 100# sample points

# create random sampling over the area of interest
seed(0)
data = np.ones((3, num_points))
data[0,:] *= ll_lon + np.random.random((num_points))*(ur_lon-ll_lon)
data[1,:] *= ll_lat + np.random.random((num_points))*(ur_lat-ll_lat)
data[2,:] *= np.random.random((num_points))*1

# plot the data
fig = plt.figure()
ax = fig.add_subplot(111)
m = Basemap(projection='cyl', llcrnrlat=ll_lat, urcrnrlat=ur_lat,
   llcrnrlon=ll_lon, urcrnrlon=ur_lon, resolution='f',
   suppress_ticks=False, area_thresh=0.5)
plt.hexbin(data[0,:], data[1,:], data[2,:], zorder=3)
m.fillcontinents(color=(0.8,0.8,0.8,0), zorder=1)
m.drawcoastlines(linewidth=0.25, color='k', zorder=2)
plt.show()
--

This contrived example shows a sparse set of hexagons on both land
and ocean.  I would like the hexagons over the ocean to be hidden.
 I can make the ones on land disappear by changing the 'zorder'
parameter of .hexbin() to 0.  However I have found no way of doing
the inverse and hiding hexagons over the ocean.

Using drawlsmask() is too crude at a 5-minute resolution.

Any ideas?

Thanks,
Ross


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year.
Jumpstart your
developing skills, take BlackBerry mobile applications to market
and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
[email protected]

https://lists.sourceforge.net/lists/listinfo/matplotlib-users




--
Stephane Raynaud


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!

http://p.sf.net/sfu/devconference


___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  



--
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

import numpy as np
from numpy import ma
from numpy.random import seed
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap, _geoslib
from matplotlib.mlab import griddata

ll_lat = -38.39477  # extent of area of interest
ll_lon = 144.54767
ur_lat = -37.51642
ur_lon = 145.67144

num_points = 100# sample points

# create random sampling over the

Re: [Matplotlib-users] query abuot plotting polygons using a basemap projection

2009-11-03 Thread Jeff Whitaker
Gary Ruben wrote:
> I'm plotting a coverage map of a sphere using the Mollweide plot in
> basemap. The attachment is an example that is produced by sending an
> array of polygons (one polygon per row described as four corners, one
> per column) described using polar (theta) and azimuthal (phi) angles to
> the following function. As a kludge, I discard any polygons that cross
> the map boundary, but this produces artefacts and it would be better to
> subdivide these and keep the parts. I was wondering whether there's a
> function I missed that allows me to add polygons and performs the split
> across the map boundary.
>
> Gary R.

Gary:  You might be able to use the _geoslib module to compute the 
intersections of those polygons with the map boundary.  I do a similar 
thing with the coastline polygons in the _readboundarydata function.
The _boundarypolyll and _boundarypolyxy instance variables have the 
vertices of the map projection region polygons in lat/lon and projection 
coords.  You could do somethig like this:

from mpl_toolkits.basemap import _geoslib
poly = _geoslib.Polygon(b) # a geos Polygon instance 
describing your polygon)
b = self._boundarypolyxy.boundary
bx = b[:,0]; by= b[:,1]
boundarypoly = _geoslib.Polygon(b) # a geos Polygon instance 
describing the map region
if poly.intersects(boundarypoly):
geoms = poly.intersection(boundarypoly)
polygons = [] # polygon intersections to plot.
for psub in geoms:
b = psub.boundary # boundary of an intersection
polygons.append(zip(b[:,0],b[:,1]))

-Jeff
>
> def Mollweide(theta, phi):
>  def combinations(iterable, r):
>  ''' Python 2.6 itertools function'''
>  # combinations('ABCD', 2) --> AB AC AD BC BD CD
>  # combinations(range(4), 3) --> 012 013 023 123
>  pool = tuple(iterable)
>  n = len(pool)
>  if r > n:
>  return
>  indices = range(r)
>  yield tuple(pool[i] for i in indices)
>  while True:
>  for i in reversed(range(r)):
>  if indices[i] != i + n - r:
>  break
>  else:
>  return
>  indices[i] += 1
>  for j in range(i+1, r):
>  indices[j] = indices[j-1] + 1
>  yield tuple(pool[i] for i in indices)
>
>
>  def boundary_crossed(pts):
>  crossed = False
>  for c in combinations(pts, 2):
>  if abs(c[0]-c[1])>180:
>  crossed = True
>  break
>  return crossed
>
>  # Make Mollweide plot
>  m = Basemap(projection='moll', lon_0=0, resolution='c')
>
>  # draw the edge of the map projection region (the projection limb)
>  m.drawmapboundary()
>  # draw lat/lon grid lines every 30 degrees.
>  m.drawmeridians(np.arange(0,360,30), dashes=[10,0])
>  m.drawparallels(np.arange(-90,90,30), dashes=[10,0])
>
>  ax = plt.gca()  # get current axes instance
>  for i in range(theta.shape[0]):
>  pts = np.vstack((theta[i], phi[i])).T
>  if boundary_crossed(pts[:,1]):
>  continue# skip polys that cross the map boundary
>
>  polypts = [m(pt[1], pt[0]) for pt in pts]
>  poly = Polygon(polypts, facecolor="b", edgecolor="None",
> alpha=0.5)
>  ax.add_patch(poly)
>
> 
>
> 
>
> --
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> 
>
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap: Removing white space in savefig

2009-11-11 Thread Jeff Whitaker

On Tue, 10 Nov 2009 13:13 -0500, "George Bonev"
 wrote:

  Hello,
  I am plotting a fig in Basemap, but I don't need the extra
  while space on the sides of the figure when I use savfig(). I
  tried axes([0,0,1,1]) but that just gave me a blank white
  screen with some ticks on the sides. Is there another way to
  do it with Basemap? Please help!
  Thank you,
  George B.


George:  If you want to preserve the aspect ratio of the map, you
need to calculate it ahead of time and make sure that you create
a figure with the same aspect ratio and define an axes with no
white space.  For example, for a global cylindrical equidistant
projection, the aspect ration should be 2:1, so you would create
a figure like this

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(10,5))
ax = plt.axes([0,0,1,1])
m = Basemap(projection='cyl',lon_0=180)
m.drawcoastlines()
m.fillcontinents()
m.drawparallels(np.arange(-60,61,30))
m.drawmeridians(np.arange(60,301,60))
plt.savefig('nowhite.png')
plt.show()

Note that you need to create the axes instance before the Basemap
instance.

If you don't care about the aspect ratio of the map being
correct, you can set fix_aspect='False', create a map of any size
you like, and use an axes with no white space. For example,

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(8,8))
ax = plt.axes([0,0,1,1])
m = Basemap(projection='cyl',lon_0=180,fix_aspect=False)
m.drawcoastlines()
m.fillcontinents()
m.drawparallels(np.arange(-60,61,30))
m.drawmeridians(np.arange(60,301,60))
plt.savefig('nowhite2.png')
plt.show()

If you don't set fix_aspect=False in this example, you'll get a
map with a 2:1 aspect ratio and lots of white space on the top
and bottom of the plot.

-Jeff
--
Jeffrey S. Whitaker
Phone: (303)497-6313
FAX: (303)497-6449
NOAA/OAR/CDC  R/CDC1 
325 Broadway, Boulder, CO, USA 80305-3328 
http://www.cdc.noaa.gov/people/jeffrey.s.whitaker

--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] bug in run_all.py

2009-11-23 Thread Jeff Whitaker
Dr. Phillip M. Feldman wrote:
> The script run_all.py in the basemap examples does not work when Python has
> been installed to "C:\Program Files\Python25".  It appears that this problem
> involves the space in the path.
>   
Phillip:  I don't have a windows machine to test on - so could you 
please send the actual error message?

-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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] `fig.subplots_adjust` does not behave as advertized

2009-11-23 Thread Jeff Whitaker
Dr. Phillip M. Feldman wrote:
> The basemap demo `cubed_sphere.py` contains the following line of code:
>
>fig.subplots_adjust(bottom=0, left=0, right=1, top=0, wspace=0, hspace=0)
>
> >From the documentation, it would appear that `wspace=0` should remove all
> horizontal space between the subplots.  But, this isn't what happens.  (I
> tried to insert an image, but this feature of Nabble appears to be broken).
>   
Phillip:  Do you see any white space between the unfolded faces of the 
cube on the cubed_sphere plot?  If not, then that command is working as 
expected.

-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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] `fig.subplots_adjust` does not behave as advertized

2009-11-23 Thread Jeff Whitaker
Phillip M. Feldman wrote:
> Jeff Whitaker wrote:
>> Dr. Phillip M. Feldman wrote:
>>> The basemap demo `cubed_sphere.py` contains the following line of code:
>>>
>>>fig.subplots_adjust(bottom=0, left=0, right=1, top=0, wspace=0, 
>>> hspace=0)
>>>
>>> >From the documentation, it would appear that `wspace=0` should 
>>> remove all
>>> horizontal space between the subplots.  But, this isn't what 
>>> happens.  (I
>>> tried to insert an image, but this feature of Nabble appears to be 
>>> broken).
>>>   
>> Phillip:  Do you see any white space between the unfolded faces of 
>> the cube on the cubed_sphere plot?  If not, then that command is 
>> working as expected.
>>
>> -Jeff
> Jeff:
>
> (I posted this same message via Nabble, but it doesn't seem to be 
> getting through).
>
> I have some further information: I just tried it again, and realized 
> that if I use the original figure size and don't maximize the figure 
> window, there are no white spaces. I don't see the white spaces unless 
> I maximize the figure window. Maximizing the figure window should 
> change the overall size of the image, but everything should scale 
> together, so this is definitely a bug.
>
> Phillip
Philip:  It's not really a bug - but a "feature" of this particular 
example.  For the white space to disappear, the figure must have exactly 
the same aspect ratio as the map projection.  It's set that way in the 
example, but if you change but maximizing the window Basemap tries to 
maintain the aspect ratio of the map and leaves some whitespace.  To get 
rid of the whitespace, at the expensive of messing up the aspect ratio 
of the map when you resize, set fix_aspect=True when initializing the 
basemap instance (for basemap >= 0.99.4).

-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


--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] `fig.subplots_adjust` does not behave as advertized

2009-11-24 Thread Jeff Whitaker
Phillip M. Feldman wrote:
> Jeff Whitaker wrote:
>> Phillip M. Feldman wrote:
>>> Jeff Whitaker wrote:
>>>> Dr. Phillip M. Feldman wrote:
>>>>> The basemap demo `cubed_sphere.py` contains the following line of 
>>>>> code:
>>>>>
>>>>>fig.subplots_adjust(bottom=0, left=0, right=1, top=0, wspace=0, 
>>>>> hspace=0)
>>>>>
>>>>> >From the documentation, it would appear that `wspace=0` should 
>>>>> remove all
>>>>> horizontal space between the subplots.  But, this isn't what 
>>>>> happens.  (I
>>>>> tried to insert an image, but this feature of Nabble appears to be 
>>>>> broken).
>>>>>   
>>>> Phillip:  Do you see any white space between the unfolded faces of 
>>>> the cube on the cubed_sphere plot?  If not, then that command is 
>>>> working as expected.
>>>>
>>>> -Jeff
>>> Jeff:
>>>
>>> (I posted this same message via Nabble, but it doesn't seem to be 
>>> getting through).
>>>
>>> I have some further information: I just tried it again, and realized 
>>> that if I use the original figure size and don't maximize the figure 
>>> window, there are no white spaces. I don't see the white spaces 
>>> unless I maximize the figure window. Maximizing the figure window 
>>> should change the overall size of the image, but everything should 
>>> scale together, so this is definitely a bug.
>>>
>>> Phillip
>> Philip:  It's not really a bug - but a "feature" of this particular 
>> example.  For the white space to disappear, the figure must have 
>> exactly the same aspect ratio as the map projection.  It's set that 
>> way in the example, but if you change but maximizing the window 
>> Basemap tries to maintain the aspect ratio of the map and leaves some 
>> whitespace.  To get rid of the whitespace, at the expensive of 
>> messing up the aspect ratio of the map when you resize, set 
>> fix_aspect=True when initializing the basemap instance (for basemap 
>> >= 0.99.4).
>>
>> -Jeff
>>
> Jeff: According to the documentation (in 
> http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html), 
> fix_aspect=True is the default.  (I verified that specifying 
> fix_aspect=True does not change the behavior).  So, I still think that 
> there's a bug here.  If I specify fix_aspect=False, then no white 
> spaces appear when I maximize the figure, but the aspect ratio is 
> messed up.  It would be really great if there were some way to get a 
> large plot without fouling up the aspect ratio.  Yours, Phillip
Philip:  Sorry, I meant to say fix_aspec=False in my previous email.  
You can't preserve the aspect ratio of the map and not have white space 
appear when you resize the figure in that example.  You can get a larger 
figure by modifying the figsize argument to plt.figure - just be sure to 
maintain the correct aspect ratio (10:7.5).

-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


--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap099.4 and geos

2009-12-02 Thread Jeff Whitaker
xiaoni wrote:
> Hello, all,
>  I have some problem with basemap and geos, and can not use Basemap。
> In the below I list the information about basemap and geos in my 
> computer. Hope someone would help me to figure out why it does not 
> work. Many thanks in adance !
>
> 1) I type:
> ---from mpl_toolkits.basemap import Basemap;
> ---mpl_toolkits.basemap.__path__
> ---mpl_toolkits.basemap.__version__
> The results:
> /usr/local/lib/python2.6/dist-packages/mpl_toolkits/basemap
> '0.99.4'
>
> 2) I also checked the same for matplotlib:
> /usr/lib/pymodules/python2.6/matplotlib
> 0.99.0
>
> 3) I type: locate _geoslib:
>
> /home/xiaoni/software/basemap-0.99.3/build/lib.linux-i686-2.6/_geoslib.so
> /home/xiaoni/software/basemap-0.99.3/build/temp.linux-i686-2.6/src/_geoslib.o
> /home/xiaoni/software/basemap-0.99.3/src/_geoslib.c  
>
> /home/xiaoni/software/basemap-0.99.3/src/_geoslib.pyx
> /usr/local/lib/python2.6/dist-packages/_geoslib.so
> /home/xiaoni/software/temp/basemap-0.99.3-backup/build/lib.linux-i686-2.6/_geoslib.so
> /home/xiaoni/software/temp/basemap-0.99.3-backup/src/_geoslib.c
> /home/xiaoni/software/temp/basemap-0.99.3-backup/src/_geoslib.pyx
>
>
> 4) I type:  locate libgeos.so 
>
> /home/xiaoni/software/temp/basemap-0.99.3-backup/geos-2.2.3/source/geom/.libs/libgeos.so
> /home/xiaoni/software/temp/basemap-0.99.3-backup/geos-2.2.3/source/geom/.libs/libgeos.so.2
> /home/xiaoni/software/temp/basemap-0.99.3-backup/geos-2.2.3/source/geom/.libs/libgeos.so.2.2.3
> /home/xiaoni/software/temp/geos-3.2.0rc1/source/.libs/libgeos.so
> /home/xiaoni/software/temp/lib/libgeos.so
> /home/xiaoni/software/temp/lib/libgeos.so.2
> /home/xiaoni/software/temp/lib/libgeos.so.2.2.3
> /usr/lib/libgeos.so
> /usr/local/lib/libgeos.so
> /usr/local/lib/backup2/libgeos.so
> /usr/local/lib/backup2/libgeos.so.2
> /usr/local/lib/backup2/libgeos.so.2.2.3
>
> 5) locate libgeos_c.so 
>
> /home/xiaoni/software/temp/basemap-0.99.3-backup/geos-2.2.3/source/capi/.libs/libgeos_c.so
> /home/xiaoni/software/temp/basemap-0.99.3-backup/geos-2.2.3/source/capi/.libs/libgeos_c.so.1
> /home/xiaoni/software/temp/basemap-0.99.3-backup/geos-2.2.3/source/capi/.libs/libgeos_c.so.1.1.1
> /home/xiaoni/software/temp/basemap-0.99.3-backup/geos-2.2.3/source/capi/.libs/libgeos_c.so.1.1.1T
> /home/xiaoni/software/temp/geos-3.2.0rc1/capi/.libs/libgeos_c.so
> /home/xiaoni/software/temp/geos-3.2.0rc1/capi/.libs/libgeos_c.so.1
> /home/xiaoni/software/temp/geos-3.2.0rc1/capi/.libs/libgeos_c.so.1.6.0
> /home/xiaoni/software/temp/geos-3.2.0rc1/capi/.libs/libgeos_c.so.1.6.0T
> /home/xiaoni/software/temp/lib/libgeos_c.so
> /home/xiaoni/software/temp/lib/libgeos_c.so.1
> /home/xiaoni/software/temp/lib/libgeos_c.so.1.1.1
> /usr/lib/libgeos_c.so
> /usr/lib/libgeos_c.so.1
> /usr/lib/libgeos_c.so.1.5.0
> /usr /local/lib/libgeos_c.so.1
> /us r/local/lib/libgeos_c.so.1.6.0
> /usr/local/lib/backup2/libgeos_c.so
> /usr/local/lib/backup2/libgeos_c.so.1
> /usr/local/lib/backup2/libgeos_c.so.1.1.1
>
>   
>
> 6) I also type:
>  ls  -l  /usr/local/lib/python2.6/dist-packages/_geoslib.so
> It does not linked to any files (no pointer)
>
> 2) ls -l  /usr/local/lib/libgeos.so
> /usr/local/lib/libgeos.so -> libgeos-3.2.0.so 
>
> 3) ls  -l  /usr/local/lib/libgeos.so
> /usr/local/lib/libgeos.so -> libgeos-3.2.0.so
>
> 4) ls -l /usr/local/lib/backup2/libgeos.so.2
> /usr/local/lib/backup2/libgeos.so.2 -> libgeos.so 
> .2.2.3
>
> 5) ls -l /usr/local/lib/backup2/libgeos.so.2.2.3
> /usr/local/lib/backup2/libgeos.so.2.2.3, no links
>
>
> It seems that Basemap can not be used because of something wrong with 
> the installation of GEOS ? Anyone would give some hints for help ? I 
> appreciate it a lot !!
>
> xiaoni
>
>
Xianoi:  You never said what the actual problem is with basemap.  I have 
seen segfaults when there are two versions of geos installed (version 2 
and version 3) and you pick up the header from one version and lib from 
the other version.  I suggest setting the GEOS_DIR env var to 
/usr/local/lib and re-running the basemap install (python setup.py 
install), after deleting the existing build directory.  Hopefully then 
it will grab both the header and lib for version 3.2.0 (which by the way 
is a pre-release, as yet untested with basemap).

-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



--
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
___

Re: [Matplotlib-users] basemap099.4 and geos

2009-12-02 Thread Jeff Whitaker
xiaoni wrote:
> Jeff,
>Many thanks for your help ! The problem was : there was a 
> segmentation error when I call Basemap. I applied the following steps, 
> and then tried to launch ipython, it still has the same problem.
>  
> --add export GEOS_DIR=/usr/local/lib
> --download basemap 099.4 to /home/xiaoni/software, where the previous 
> version099.3 is saved also
> -- sudo python setup.py install
>
> The installation is OK. Then I test:
> --ls  -l  /usr/local/lib/libgeos.so  : /usr/local/lib/libgeos.so -> 
> libgeos-3.2.0.so
> --ls  -l /usr/lib/libgeos.so   : /usr/lib/libgeos.so -> 
> libgeos-3.1.0.so
> --ls -l  /usr/local/lib/libgeos.so   : /usr/local/lib/libgeos.so -> 
> libgeos-3.2.0.so
> --locate libgeos.so   : /usr/lib/libgeos.so , and 
> /usr/local/lib/libgeos.so
> --locate _geoslib  :
> /home/xiaoni/software/basemap-0.99.3/build/lib.linux-i686-2.6/_geoslib.so
> /home/xiaoni/software/basemap-0.99.3/build/temp.linux-i686-2.6/src/_geoslib.o
> /home/xiaoni/software/basemap-0.99.3/src/_geoslib.c
> /home/xiaoni/software/basemap-0.99.3/src/_geoslib.pyx
> /usr/local/lib/python2.6/dist-packages/_geoslib.so
> (in fact I have saved both basemap -099.3 and basemap-0.99.4 in the 
> /home/xiaoni/software. This result only shows 0.99.3 and is strange to 
> me).
>
> Many thanks again !!
>
> xiaoni

Xiaoni:  Is there no traceback?  Can you run ldd on the _geoslib.so that 
you are actually importing when the error occurs (presumably 
/usr/local/lib/python2.6/dist-packages/_geoslib.so)?  That will tell you 
what version of the geos library you actually linked.  I don't think I 
can be of much help here - all I can suggest is that you clean out all 
old versions of basemap, _geoslib.so and libgeos, then rebuild again.  
The fact that there are so may versions floating around increases the 
chance that you have a version mismatch somewhere.

Also check the build output and make sure there were no errors building 
_geoslib.so.


-Jeff

>
>
> 
> *From:* Jeff Whitaker 
> *To:* xiaoni 
> *Cc:* [email protected]
> *Sent:* Wed, December 2, 2009 4:47:51 PM
> *Subject:* Re: [Matplotlib-users] basemap099.4 and geos
>
> xiaoni wrote:
> > Hello, all,
> >  I have some problem with basemap and geos, and can not use 
> Basemap。
> > In the below I list the information about basemap and geos in my 
> computer. Hope someone would help me to figure out why it does not 
> work. Many thanks in adance !
> >
> > 1) I type:
> > ---from mpl_toolkits.basemap import Basemap;
> > ---mpl_toolkits.basemap.__path__
> > ---mpl_toolkits.basemap.__version__
> > The results:
> >/usr/local/lib/python2.6/dist-packages/mpl_toolkits/basemap
> >'0.99.4'
> >
> > 2) I also checked the same for matplotlib:
> >/usr/lib/pymodules/python2.6/matplotlib
> >0.99.0
> >
> > 3) I type: locate _geoslib:
> >
> > 
> /home/xiaoni/software/basemap-0.99.3/build/lib.linux-i686-2.6/_geoslib.so
> > 
> /home/xiaoni/software/basemap-0.99.3/build/temp.linux-i686-2.6/src/_geoslib.o
> > /home/xiaoni/software/basemap-0.99.3/src/_geoslib.c  
>
> > /home/xiaoni/software/basemap-0.99.3/src/_geoslib.pyx
> /usr/local/lib/python2.6/dist-packages/_geoslib.so
> > 
> /home/xiaoni/software/temp/basemap-0.99.3-backup/build/lib.linux-i686-2.6/_geoslib.so
> > /home/xiaoni/software/temp/basemap-0.99.3-backup/src/_geoslib.c
> > /home/xiaoni/software/temp/basemap-0.99.3-backup/src/_geoslib.pyx
> >
> >
> > 4) I type:  locate libgeos.so <http://libgeos.so> <http://libgeos.so/>
> >
> > 
> /home/xiaoni/software/temp/basemap-0.99.3-backup/geos-2.2.3/source/geom/.libs/libgeos.so
> > 
> /home/xiaoni/software/temp/basemap-0.99.3-backup/geos-2.2.3/source/geom/.libs/libgeos.so.2
> > 
> /home/xiaoni/software/temp/basemap-0.99.3-backup/geos-2.2.3/source/geom/.libs/libgeos.so.2.2.3
> > /home/xiaoni/software/temp/geos-3.2.0rc1/source/.libs/libgeos.so
> > /home/xiaoni/software/temp/lib/libgeos.so
> > /home/xiaoni/software/temp/lib/libgeos.so.2
> > /home/xiaoni/software/temp/lib/libgeos.so.2.2.3
> > /usr/lib/libgeos.so
> > /usr/local/lib/libgeos.so
> > /usr/local/lib/backup2/libgeos.so
> > /usr/local/lib/backup2/libgeos.so.2
> > /usr/local/lib/backup2/libgeos.so.2.2.3
> >
> > 5) locate libgeos_c.so <http://libgeos_c.so> <http://libgeos_c.so/>
> >
> > 
> /home/xiaoni/software/temp/basemap-0.99.3-backup/geos-2.2.3/source/capi/.libs/libgeos_c.so
>

Re: [Matplotlib-users] basemap099.4 and geos

2009-12-02 Thread Jeff Whitaker
xiaoni wrote:
> Jeff,
> Many thanks !
>
> ldd  /usr/local/lib/python2.6/dist-packages/_geoslib.so
> The results are:
>linux-gate.so.1 =>  (0x00cf2000)
> libgeos_c.so.1 => /usr/local/lib/libgeos_c.so.1 (0x00944000)
> libgeos-3.1.0.so => /usr/lib/libgeos-3.1.0.so (0x005cd000)
> libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0x00a0e000)
> libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00165000)
> libgeos-3.2.0.so => /usr/local/lib/libgeos-3.2.0.so (0xb75c1000)
> libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00d5c000)
> libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x00cf7000)
> libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00f77000)
> /lib/ld-linux.so.2 (0x00148000)
>
> It seems that it mixed geos3.1 and 3.2 ?

Xianoi:  Yep, there's your problem right there.  My suggestion is to 
remove the 3.2.0 geos lib and headers from /usr/local/lib and 
/usr/local/include and try again.

-Jeff
>
> If I have to clean out all the old versions of basemap, _geoslib.so 
> and libgeos, then rebuild again, What is the safe way to do so ? I am 
> afraid that I may damage the system if I simplely apply "rm". Do you 
> have some suggestion about the steps of deleting ?
>
> Many thanks !!
>
> xiaoni
>
>
> 
> *From:* Jeff Whitaker 
> *To:* xiaoni ; Matplotlib Users 
> 
> *Sent:* Wed, December 2, 2009 5:42:17 PM
> *Subject:* Re: [Matplotlib-users] basemap099.4 and geos
>
> xiaoni wrote:
> > Jeff,
> >Many thanks for your help ! The problem was : there was a 
> segmentation error when I call Basemap. I applied the following steps, 
> and then tried to launch ipython, it still has the same problem.
> >  --add export GEOS_DIR=/usr/local/lib
> > --download basemap 099.4 to /home/xiaoni/software, where the 
> previous version099.3 is saved also
> > -- sudo python setup.py <http://setup.py> install
> >
> > The installation is OK. Then I test:
> > --ls  -l  /usr/local/lib/libgeos.so  : /usr/local/lib/libgeos.so -> 
> libgeos-3.2.0.so <http://libgeos-3.2.0.so>
> > --ls  -l /usr/lib/libgeos.so  : /usr/lib/libgeos.so -> 
> libgeos-3.1.0.so <http://libgeos-3.1.0.so>
> > --ls -l  /usr/local/lib/libgeos.so  : /usr/local/lib/libgeos.so -> 
> libgeos-3.2.0.so
> > --locate libgeos.so <http://libgeos.so>  : 
> /usr/lib/libgeos.so , and /usr/local/lib/libgeos.so
> > --locate _geoslib  :
> > 
> /home/xiaoni/software/basemap-0.99.3/build/lib.linux-i686-2.6/_geoslib.so
> > 
> /home/xiaoni/software/basemap-0.99.3/build/temp.linux-i686-2.6/src/_geoslib.o
> > /home/xiaoni/software/basemap-0.99.3/src/_geoslib.c
> > /home/xiaoni/software/basemap-0.99.3/src/_geoslib.pyx
> > /usr/local/lib/python2.6/dist-packages/_geoslib.so
> > (in fact I have saved both basemap -099.3 and basemap-0.99.4 in the 
> /home/xiaoni/software. This result only shows 0.99.3 and is strange to 
> me).
> >
> > Many thanks again !!
> >
> > xiaoni
>
> Xiaoni:  Is there no traceback?  Can you run ldd on the _geoslib.so 
> <http://_geoslib.so> that you are actually importing when the error 
> occurs (presumably 
> /usr/local/lib/python2.6/dist-packages/_geoslib.so)?  That will tell 
> you what version of the geos library you actually linked.  I don't 
> think I can be of much help here - all I can suggest is that you clean 
> out all old versions of basemap, _geoslib.so and libgeos, then rebuild 
> again.  The fact that there are so may versions floating around 
> increases the chance that you have a version mismatch somewhere.
>
> Also check the build output and make sure there were no errors 
> building _geoslib.so.
>
>
> -Jeff
>
> >
> >
> > 
> > *From:* Jeff Whitaker mailto:[email protected]>>
> > *To:* xiaoni mailto:[email protected]>>
> > *Cc:* [email protected] 
> <mailto:[email protected]>
> > *Sent:* Wed, December 2, 2009 4:47:51 PM
> > *Subject:* Re: [Matplotlib-users] basemap099.4 and geos
> >
> > xiaoni wrote:
> > > Hello, all,
> > >  I have some problem with basemap and geos, and can not use 
> Basemap。
> > > In the below I list the information about basemap and geos in my 
> computer. Hope someone would help me to figure out why it does not 
> work. Many thanks in adance !
> > >
> > > 1) I type:
> > > ---from mpl_t

Re: [Matplotlib-users] basemap099.4 and geos

2009-12-02 Thread Jeff Whitaker
xiaoni wrote:
> Jeff,
> Just to be safe because I am going to operate on the root:
> 1) ls -l /usr/local/lib:   
> libgeos-3.2.0.so
> libgeos.so -> libgeos-3.2.0.so
Xianoi:  I'm assuming you installed libgeos 3.2.0rc1 yourself in 
/usr/local, and nothing is linked against it besides your non-working 
basemap?  If so, it should be safe to do

rm /usr/local/lib/libgeos*
>
> shall I just remove libgeos-3.2.0.so ? But then the link for 
> libgeos.so may not work.
>
> 2) ls /usr/local/include:
> geos  geos_c.h  geos.h

rm /usr/local/include/geos*h
>
> and in the folder of geos, there are a lot of files and headers.
> To remove the geos3.2 headers, shall I just remove  
> /usr/local/include/geos_c.h and /usr/local/include/geos.h ? I can not 
> tell where the headers of geos3.1.

presumably in /usr/include.  If not, you probably need to install a 
libgeos-dev package or somesuch.

-Jeff
>
> Many thanks again !
>
> xiaoni
>
> ----
> *From:* Jeff Whitaker 
> *To:* xiaoni 
> *Cc:* Matplotlib Users 
> *Sent:* Wed, December 2, 2009 5:55:58 PM
> *Subject:* Re: [Matplotlib-users] basemap099.4 and geos
>
> xiaoni wrote:
> > Jeff,
> >Many thanks !
> >
> > ldd  /usr/local/lib/python2.6/dist-packages/_geoslib.so
> > The results are:
> >linux-gate.so <http://linux-gate.so>.1 =>  (0x00cf2000)
> >libgeos_c.so <http://libgeos_c.so>.1 => 
> /usr/local/lib/libgeos_c.so.1 (0x00944000)
> >libgeos-3.1.0.so <http://libgeos-3.1.0.so> => 
> /usr/lib/libgeos-3.1.0.so (0x005cd000)
> >libpthread.so <http://libpthread.so>.0 => 
> /lib/tls/i686/cmov/libpthread.so.0 (0x00a0e000)
> >libc.so <http://libc.so>.6 => /lib/tls/i686/cmov/libc.so.6 
> (0x00165000)
> >libgeos-3.2.0.so <http://libgeos-3.2.0.so> => 
> /usr/local/lib/libgeos-3.2.0.so (0xb75c1000)
> >libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00d5c000)
> >libm.so <http://libm.so>.6 => /lib/tls/i686/cmov/libm.so.6 
> (0x00cf7000)
> >libgcc_s.so <http://libgcc_s.so>.1 => /lib/libgcc_s.so.1 
> (0x00f77000)
> >/lib/ld-linux.so.2 (0x00148000)
> >
> > It seems that it mixed geos3.1 and 3.2 ?
>
> Xianoi:  Yep, there's your problem right there.  My suggestion is to 
> remove the 3.2.0 geos lib and headers from /usr/local/lib and 
> /usr/local/include and try again.
>
> -Jeff
> >
> > If I have to clean out all the old versions of basemap, _geoslib.so 
> <http://_geoslib.so> and libgeos, then rebuild again, What is the safe 
> way to do so ? I am afraid that I may damage the system if I simplely 
> apply "rm". Do you have some suggestion about the steps of deleting ?
> >
> > Many thanks !!
> >
> > xiaoni
> >
> >
> > 
> > *From:* Jeff Whitaker mailto:[email protected]>>
> > *To:* xiaoni mailto:[email protected]>>; 
> Matplotlib Users  <mailto:[email protected]>>
> > *Sent:* Wed, December 2, 2009 5:42:17 PM
> > *Subject:* Re: [Matplotlib-users] basemap099.4 and geos
> >
> > xiaoni wrote:
> > > Jeff,
> > >Many thanks for your help ! The problem was : there was a 
> segmentation error when I call Basemap. I applied the following steps, 
> and then tried to launch ipython, it still has the same problem.
> > >  --add export GEOS_DIR=/usr/local/lib
> > > --download basemap 099.4 to /home/xiaoni/software, where the 
> previous version099.3 is saved also
> > > -- sudo python setup.py <http://setup.py> <http://setup.py> install
> > >
> > > The installation is OK. Then I test:
> > > --ls  -l  /usr/local/lib/libgeos.so  : /usr/local/lib/libgeos.so -> 
> libgeos-3.2.0.so <http://libgeos-3.2.0.so>
> > > --ls  -l /usr/lib/libgeos.so  : /usr/lib/libgeos.so -> 
> libgeos-3.1.0.so <http://libgeos-3.1.0.so>
> > > --ls -l  /usr/local/lib/libgeos.so  : /usr/local/lib/libgeos.so -> 
> libgeos-3.2.0.so
> > > --locate libgeos.so <http://libgeos.so> <http://libgeos.so>
>   : /usr/lib/libgeos.so , and /usr/local/lib/libgeos.so
> > > --locate _geoslib  :
> > > 
> /home/xiaoni/software/basemap-0.99.3/build/lib.linux-i686-2.6/_geoslib.so
> > > 
> /home/xiaoni/software/basemap-0.99.3/build/temp.linux-i686-2.6/src/_geoslib.o
> > > /home/xiaoni/software/basemap-0.99.3/src/_geos

Re: [Matplotlib-users] bluemarble is too dark

2009-12-25 Thread Jeff Whitaker
Phillip M. Feldman wrote:
> Hello Jose-
>
> I searched the Python installation on my computer, but have not been 
> able to find the bluemarble image.
>
> I also followed the link that you provided, but didn't find any images 
> that cover the entire surface of the Earth.
>
> Python Developers-
>
> I'd really like to have an option in Basemap.bluemarble() to select from 
> a set of images, rather than just having a single hardwired image.
>   

You already can.

See the documentation for the warpimage method at 
http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html.

-Jeff
> Phillip
>
> Jose Gomez-Dans wrote:
>   
>> Hi,
>>
>> 2009/12/14 Dr. Phillip M. Feldman > >
>>
>> When I generate a map with a background generated via
>> Basemap.bluemarble(),
>> the background is extremely dark.  Is there any way to get a
>> lighter/brighter version?  (I've looked at all of the available
>> parameters,
>> but none of them seems to allow for adjustment of the luminance).
>>
>>
>> I find this problem when generating a PDF and viewing it in Linux,but 
>> the on-screen version seems to work fine. One reason for your darkness 
>> might be the actual bluemarble scene. There is one for every month 
>> , so you can 
>> have a look at the different month and pick u which is better for your 
>> area/application. Another thing you can do is to modify the bluemarble 
>> that comes with matplotlib using the gimp, as it is just an image file 
>> you can edit easily. Starts looking like data cooking, tho' ;-)
>>
>> J 
>> 


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Can not get animated matplotlib example to work

2009-12-29 Thread Jeff Whitaker
TheLonelyStar wrote:
> Hi,
>
> I am trying to get the exaple from here:
> http://matplotlib.sourceforge.net/examples/animation/animate_decay_tk_blit.html
>
> I copied it into a file and tried to execute it.
> I get:
>
> File "test.py", line 56, in 
> manager.window.after(100, run)
> AttributeError: 'gtk.Window' object has no attribute 'after'
>
> What is wrong? How can I correct that?
>
> Thanks!
> Nathan
>   

Nathan:  You're using the GTKAgg backend (the default), whereas the 
script expects the TkAgg backend.  Either edit your matplotlibrc file to 
set TkAgg as your default backend, or run the script like this:

python animate_decay_tk_blit.py -dTkAgg

-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 Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Simple text style question

2010-01-11 Thread Jeff Whitaker
Gökhan Sever wrote:
> Hello,
>
> Is there a way to color words differently in a label or title, for 
> example:
>
> ylabel("measurement 1 (in red color)" , "measurement 2 (in blue 
> color)") to match with the plotted line colors?
>
> Thanks.
>
> -- 
> Gökhan
Gökhan:

ylabel('measurement 1',color='r')
ylabel('measurement 2',color='b')


-Jeff


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Simple text style question

2010-01-11 Thread Jeff Whitaker
Gökhan Sever wrote:
>
>
> On Mon, Jan 11, 2010 at 6:51 AM, Jeff Whitaker  <mailto:[email protected]>> wrote:
>
> Gökhan Sever wrote:
>
> Hello,
>
> Is there a way to color words differently in a label or title,
> for example:
>
> ylabel("measurement 1 (in red color)" , "measurement 2 (in
> blue color)") to match with the plotted line colors?
>
> Thanks.
>
> -- 
> Gökhan
>
> Gökhan:
>
> ylabel('measurement 1',color='r')
> ylabel('measurement 2',color='b')
>
>
> -Jeff
>
>
> In this fashion the second call replaces the first text. What I want 
> is two words next to each other and in different colors.
>
> -- 
> Gökhan

Gökhan:  Then I think you'll have to go with the TeX solution (i..e 
\color{red}{Red text goes here} \color{blue}{Blue text goes here}).  -

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 Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] question re: map projection conversion and NetCDF files

2010-01-19 Thread Jeff Whitaker
Michael Mason wrote:
> Hello,
>
> I have a set of NetCDF files that are in Lambert Conformal projection,
> and I want to convert them to rectilinear, lat/lon projection.  I'm
> able to do this and plot the data and print the data out to a png
> file.  However, I want to get access to the underlying data as it
> appears after the projection.  I want to take this data and write it
> out to another file using an in-house file format.
>
> I've been trying to probe the objects that are involved in creating
> the images using 'dir' to see if there is a way that I can get access
> to the underlying data, but I've come up short so far.
>
> Here is a skeleton of the code that I'm working with:
>
># create Basemap using this info
> map = Basemap(projection='merc',
>   lat_0 = map_center_lat, lon_0 = -map_center_lon,
>   llcrnrlat = min_lat, urcrnrlat = max_lat,
>   llcrnrlon = min_lon, urcrnrlon = max_lon,
>   rsphere = 6371200.0, resolution = 'f',
>   area_thresh = 1)
>
> # this part is what takes the most amount of time
> # x, y = map(lons.data, lats.data) # compute map projection coordinates.
> x, y = map(lons[0], lats[0])
>
> # the first slot in the shape array denotes the number of hours
> num_hours = data.shape[0]
>
> # frame counter for the output filenames
> frame_num = 0
>
> # step through all of the hours
> for hr in range (num_hours):
>
> # get all of the data (2D data) for the current hr
> data_hr = data[hr, :, :]
>
> # create a figure
> fig = plt.figure(figsize=(10,8))
> plt.subplot(111)
> ax = plt.gca()
> dlon = 1.0
>
> for xlabel_i in ax.get_xticklabels():
> xlabel_i.set_fontsize(4)
>
> for ylabel_i in ax.get_yticklabels():
> ylabel_i.set_fontsize(4)
>
> draw_map (map, ax, dlon)
>
> v = 
>
> p = map.contourf (x, y, data_hr, v)
>
> Any suggestions?  Thanks!
>
>   

Michael:  contourf is not doing performing any transformations or 
interpolations on the input data - it's just plotting data on the grid 
defined by the x and y coordinates of the Lambert conformal grid that 
you give it.  You can use the interpolation function "interp" to 
interpolate from one rectilinear grid to another, but contourf is not 
doing that under the hood.

-Jeff


--
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] strange error when attempting to generate a map using 'geos' projection

2010-01-24 Thread Jeff Whitaker
Dr. Phillip M. Feldman wrote:
> I’ve been experimenting with basemap, and have been able to make maps using
> the orthographic and polyconic projections.  When I try to generate a map
> using the geostationary projection, I get the error message shown below.  I
> haven’t been able to make head or tail of this message; any advice will be
> appreciated.
>
> Phillip
>
> RuntimeError  Traceback (most recent call last)
>
> C:\Phillip\pmap.py in ()
>6163
>6164   # Create basemap object:
> -> 6165   map= Basemap(**map_parms)
>6166   ax= fig.add_axes([0.1,0.08,0.7,0.82])
>6167
>
> C:\Python25\lib\site-packages\mpl_toolkits\basemap\__init__.pyc in
> __init__(self, llcrnrlon, llc
> rnrlat, urcrnrlon, urcrnrlat, llcrnrx, llcrnry, urcrnrx, urcrnry, width,
> height, projection, res
> olution, area_thresh, rsphere, lat_ts, lat_1, lat_2, lat_0, lon_0, lon_1,
> lon_2, no_rot, suppres
> s_ticks, satellite_height, boundinglat, fix_aspect, anchor, ax)
> 680
> 681 # initialize proj4
> --> 682 proj =
> Proj(projparams,self.llcrnrlon,self.llcrnrlat,self.urcrnrlon,self.urcrnrl
> at)
> 683
> 684 # make sure axis ticks are suppressed.
>
> C:\Python25\lib\site-packages\mpl_toolkits\basemap\proj.pyc in
> __init__(self, projparams, llcrnr
> lon, llcrnrlat, urcrnrlon, urcrnrlat, urcrnrislatlon)
> 117 urcrnry = -llcrnry
> 118 elif self.projection == 'geos':
> --> 119 self._proj4 = pyproj.Proj(projparams)
> 120 # find major and minor axes of ellipse defining map proj
> region.
> 121 # h is measured from surface of earth at equator.
>
> C:\Python25\lib\site-packages\mpl_toolkits\basemap\pyproj.pyc in
> __new__(self, projparams, **kwa
> rgs)
> 146 kvpairs.append(kvpair+' ')
> 147 projstring = ''.join(kvpairs)
> --> 148 return _Proj.__new__(self, projstring)
> 149
> 150 def __call__(self, *args, **kw):
>
> C:\Python25\lib\site-packages\mpl_toolkits\basemap\_proj.pyd in
> _proj.Proj.__cinit__ (src/_proj.
> c:587)()
>  23
>  24
> ---> 25
>  26
>  27
>
> RuntimeError: unknown prime meridian conversion id
> WARNING: Failure executing file: 
>
>   
Philip:  That's an error from the proj4 c library saying that it didn't 
like one of the parameters you used to define the projection.  Since you 
didn't include the parameters you used, I can't say which one is the 
culprit.

-Jeff

--
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] strange error when attempting to generate a map using 'geos' projection

2010-01-24 Thread Jeff Whitaker
Dr. Phillip M. Feldman wrote:
> Jeff Whitaker wrote:
>   
>> 
>> Philip:  That's an error from the proj4 c library saying that it didn't 
>> like one of the parameters you used to define the projection.  Since you 
>> didn't include the parameters you used, I can't say which one is the 
>> culprit.
>>
>> -Jeff
>>
>> 
>
>   
Philip: I believe that lat_0 must be zero for the geostationary 
projection (you have to be looking down on the equator).  I usually 
leave the lat_0 parameter off entirely, in which case zero is assumed.  
I'll try to catch that and raise a more insightful error message.

-Jeff


--
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] two issues with labels on maps

2010-01-25 Thread Jeff Whitaker
Dr. Phillip M. Feldman wrote:
> The attached program generates a map and then saves it to a file.  I have two
> problems with the result:
>
> (1) Note that the screenshot shows a title above the map, while the .png
> file that was saved by the program does not.
>   
Philip:

mapdemo.jpeg (which was presumably created from the png saved by your 
program) is totally empty. 
> (2) I would like to be able to label the lines of latitude and longitude,
> but have not been able to figure out how to do this.
>   

use the label keyword to drawmeridians and drawparallels.

-Jeff
> Thanks!
>
> Phillip
>
> http://old.nabble.com/file/p27313185/mapdemo.py mapdemo.py 
> http://old.nabble.com/file/p27313185/mapdemo%2Bscreenshot.jpeg 
> http://old.nabble.com/file/p27313185/mapdemo.jpeg 
>
>   


-- 
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


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] two issues with labels on maps

2010-01-25 Thread Jeff Whitaker
Phillip M. Feldman wrote:
> Jeff Whitaker wrote:
>> Dr. Phillip M. Feldman wrote:
>>> The attached program generates a map and then saves it to a file.  I 
>>> have two
>>> problems with the result:
>>>
>>> (1) Note that the screenshot shows a title above the map, while the 
>>> .png
>>> file that was saved by the program does not.
>>>   
>> Philip:
>>
>> mapdemo.jpeg (which was presumably created from the png saved by your 
>> program) is totally empty.
>>> (2) I would like to be able to label the lines of latitude and 
>>> longitude,
>>> but have not been able to figure out how to do this.
>>>   
>>
>> use the label keyword to drawmeridians and drawparallels.
>>
>> -Jeff
>>
> Hello Jeff,
>
> I had tried that, but thought that it wasn't working because I wasn't 
> seeing anything on the screen.  I now think that the label parameter 
> must be working, because the lines of latitude and longitude are 
> labeled in the version of the map that is saved by the program, and 
> that I'm not seeing them on the screen because I have black text on a 
> black background.  Is there a way to control the color of the text 
> labels?  Note also that the plot title appears on the screen shot 
> jpeg, but not in the version saved by the program.  Any advice will be 
> appreciated.
>
> Philllip

Philip:  To change the color of the lat/lon lines, use the color keyword 
in drawparallels and drawmeridians (i.e. color="red").  To change the 
font color for the labels, use fontdict=dict(color='red').  The plot 
title color can be changed in the same way.
-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


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to close a plot?

2010-02-07 Thread Jeff Whitaker
zxc wrote:
> Hi there!
> I need to know how to close a figure/chart in matplot.
>
> Does anyone know how it works and could you please explain on the 
> example below?
> The problem is: close(1)  doesn't close the figure 1 and when the 2nd 
> figure will be plot the program hangs.
> I tried with draw() but the figure doesn't appear.

Use fig.close()

-Jeff


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 16bit tiff support?

2010-02-15 Thread Jeff Whitaker
Philipp Lies wrote:
> On 02/12/2010 07:49 PM, Eric Firing wrote:
>   
>> Philipp Lies wrote:
>> 
>>> Hi,
>>>
>>> is there a backend that supports 16bit tiff images?
>>>   

The macosx backend supports tiff.

-Jeff
>> Can you just use png, and use the netpbm utilities or ImageMagick
>> convert program to go to and from tiff?
>> 
> Would be 'dirty' but acceptable if matplotlib would support saving 
> uncompressed grayscale uint16 png files. But saving  nxm uint16 arrays 
> leads to nxmx3 float arrays which do not even closely resemble my 
> original data.
> Example:
> A
> array([[47705, 11865,   739, 16941, 37700],
> [64321, 26860, 49945, 63556, 13498],
> [ 2676,  7720,  5995, 22399, 32735],
> [56577, 34443,  6636, 23409, 61331],
> [ 1020, 26013, 34677, 37262, 36136]], dtype=uint16)
> imsave('t.png',A)
> B = imread('t.png')
> B[:,:,0]
>
> array([[ 1.,  0.,  0.,  0.,  0.74117649],
> [ 0.49803922,  0.19607843,  1.,  0.5529412 ,  0. ],
> [ 0.,  0.,  0.,  0.,  0.48627451],
> [ 1.,  0.57647061,  0.,  0.01960784,  0.71372551],
> [ 0.,  0.14509805,  0.58823532,  0.72941178,  0.6669]], 
> dtype=float32)
>
>
>   
>>> According to the website GDK supports tiff but that's wrong:
>>>
>>>   
>> import matplotlib
>> matplotlib.use('GDK')
>> import matplotlib.pyplot as pyplot
>> pyplot.imsave(arr=X, fname='test.tif')
>> 
>>> Traceback (most recent call last):
>>> File "", line 1, in 
>>> File "/usr/lib/pymodules/python2.6/matplotlib/pyplot.py", line 1425,
>>> in imsave
>>> return _imsave(*args, **kwargs)
>>> File "/usr/lib/pymodules/python2.6/matplotlib/image.py", line 813, in
>>> imsave
>>> fig.savefig(fname, dpi=1, format=format)
>>> File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 1033,
>>> in savefig
>>> self.canvas.print_figure(*args, **kwargs)
>>> File "/usr/lib/pymodules/python2.6/matplotlib/backend_bases.py", line
>>> 1420, in print_figure
>>> '%s.' % (format, ', '.join(formats)))
>>> ValueError: Format "tif" is not supported.
>>> Supported formats: emf, eps, pdf, png, ps, raw, rgba, svg, svgz.
>>>   
>> matplotlib.backends.backend
>> 
>>> 'gdk'
>>>
>>> matplotlib 0.99.0 python 2.6.4 ubuntu karmic x64
>>>
>>> If matplotlib cannot provide tiff support, does someone know an
>>> alternative? PIL doesn't work either, at least not intuitively.
>>>
>>> Cheers
>>>
>>> Philipp
>>>
>>>   
>
>   


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Trouble gridding irregularly spaced data

2010-02-16 Thread Jeff Whitaker
T J wrote:
> Hi,
>
> I'm trying to grid irregularly spaced data, such that the convex hull
> of the data is not rectangular.  Specifically, all my data lies in an
> equilateral triangle inside the unit circle.  I found:
>
>  http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data
>
> and tried the suggested technique.  For my grid, I made a square of
> the min and max of my data.  However, it had problems:
>
> ...
>   File 
> "/home/guest/.local/lib/python2.6/site-packages/matplotlib/delaunay/triangulate.py",
> line 125, in _compute_convex_hull
> hull.append(edges.pop(hull[-1]))
> KeyError: 0
>
>
> Should I expect matplotlib.mlab.griddata to work with a dataset like
> this?  I know that I can use hexbin, but it'd be really nice to see
> contours explicitly.
>   

We have the natgrid toolkit for just this reason - it's slower than the 
default, and has a more restrictive license, but it often succeeds when 
the default algorithm fails.  This is discussed at the end of that wiki 
page.  Let us know if the natgrid toolkit also fails.

-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


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] contours not contained to map and simular issues

2010-02-25 Thread Jeff Whitaker
Mike Bauer wrote:
> Jeff,
>
>
> Attached you'll find an example and sample data. Sample output is
> here: http://gallery.me.com/ohtinsel#100149
>
> Below you'll also find an old email about the project that you've
> answered before (might help you understand what I'm doing).
>
> Thank you so much. This is a huge help.
>
> Mike
>   

Mike:  OK,  I figure out why I have a black plot.  In the latest version 
of netCDF4, scale_factor and add_offset are applied automatically, so in 
your script they were effectively being applied twice.  Concerning the 
contours spilling out over the domain, just set the keyword masked to 
True in the call to transform_scalar.  Concerning the "floating 
whitespace" - your data is on a lat/lon grid, so just plot the data with 
projection='cyl' and specify the lat/lon values of the lower left and 
upper right corners of the grid.  Then the data will exactly fit the 
map.  Your are using a lambert conformal projection, which covers a much 
larger area than your data.

-Jeff
> mbauer wrote:
>   
>> Thanks Jeff,
>>
>> To clarify, I'm sampling a numpy array (regular lon/lat grid) and
>> extracting a series of same size frames (say 60 longitude grids and 30
>> latitude grids) around a feature of interest, which can be centered
>> somewhere on the map. What I want to do is accumulate statistics with
>> these frames such that the relative size/distances are persevered,
>> which of course means that I can't just add a frame centered on 30N
>> with one centered on 80N. Ideally, I'd like to interpolate each frame
>> to a common point (lon/lat) and display the results either in the
>> common grid space or as radial distances from the common point.
>>
>> Since you're a meteorologist I can simply say I'm creating an ensemble
>> average of extra tropical cyclones from a dozen or so computer models
>> (each with very different resolutions). I want to see how cloud and
>> precipitation features in each model's cyclones compare to a similar
>> product I'm producing from satellite data using weather model output
>> to locate the cyclones. Much the same thing as the link I provided.
>>
>> Thanks for your suggests as transform_scalar sounds like a good place
>> to begin.
>>
>> Mike
>> 
>
> Mike:  Thanks for the explanation, I get it now - and I think I have
> just the thing for you.  First, define a Basemap instance for a Lambert
> Conformal projection centered on each of you frames that is 5000 km wide
> and 5000 km tall.
>
> # for frame centered on lon_0, lat_0.
> # resolution=None skips processing of boundary datasets to save time.
> m = Basemap(lon_0=lon_0, lat_0=lat_0, projection='lcc', \
> width=500, height=500, resolution=None)
>
>
> Now interpolate your data to a nx by ny grid that is regular in the map
> projection region.
>
> # data is the lat/lon gridded data, lons and lats are 1D arrays in degrees.
> data2 = m.transform_scalar(data, lons, lats, nx, ny)
>
> The data2 grids will be approximately equally spaced on the surface of
> the earth, regardless on lat_0 and lon_0.  Therefore, you should be able
> to just ensemble average all the data2 grids and preserve the relative
> shapes and sizes of the features (this is helped by the fact that the
> projection is conformal, or shape-preserving).
>
> HTH,
>
> -Jeff
>
> 
>
> On Thu, Feb 25, 2010 at 12:16 PM, Jeff Whitaker  wrote:
>   
>> Mike Bauer wrote:
>> 
>>> Howdy All,
>>>
>>> I'm hoping someone can give me a quick solution to a couple of
>>> problems. I think I'm just missing an idea or two.
>>>
>>> Problem 1: I'm creating a map using the 'llc' lambert conformal
>>> projection and pcolormesh. Here is a sampling of the source.
>>>
>>>self.m =
>>> Basemap(lat_0=self.lat_0,lon_0=self.lon_0,projection='lcc',
>>>
>>> width=store_comp.base_width,height=store_comp.base_height,
>>> resolution='i',area_thresh=10)
>>>   self.fig = plt.figure(figsize=(width,hieght),frameon=True)
>>>   self.ax = self.fig.add_subplot(111)
>>>   self.xx, self.yy = self.m(*numpy.meshgrid(self.x,self.y))
>>>   self.the_image =
>>>
>>> self.m.pcolormesh(self.xx,self.yy,z,edgecolors='None',cmap=self.color_scheme)
>>>
>>>   The problem I have is two fold: 1) the map segm

Re: [Matplotlib-users] imshow size limitations?

2010-03-01 Thread Jeff Whitaker
David Goldsmith wrote:
> --- On Sun, 2/28/10, David Goldsmith  wrote:
>
>   
>> Question 2) is there some way I can add
>> 
>>> pieces of the
>>>   
> array incrementally to
>   
>> the image into their proper place,
>> 
>> i.e.,
>> 
>>> modify the
>>>   
> following code:
>   
>> ax.imshow(image[0:ny/2+1,
>> 
>> 0:nx/2+1]) #
>> 
>>> upper
>>>   
> left corner of image
>   
>> ax.hold(True)
>> ax.imshow(argW[ny/2+1:-1,
>> 
>> 0:nx/2+1]) #
>> 
>>> lower
>>>   
> left corner of image
>   
>> ax.imshow(argW[0:ny/2+1,
>> 
>> nx/2+1:-1]) #
>> 
>>> upper
>>>   
> right corner of image
>   
>> ax.imshow(argW[ny/2+1:-1,
>> 
>> nx/2+1:-1])
>> 
>>> # lower
>>>   
> right corner of image
>
> Try the extents keyword argument. It let's
>   
>> you
>> 
>>> specify the
>>>   
> corners of
> the image in data coordinates.
>
> Ryan
>   
 Hi, Ryan, thanks!  Can you be a little more
 
>> specific
>> 
>>> as to how I should try that?  I tried:
>>>   
 ax.imshow(argW[0:ny/2+1, 0:nx/2+1], cmap_name,
 
>>> extent=(0,nx/2,ny/2,0))
>>>   
 ax.hold(True)
 ax.imshow(argW[ny/2+1:-1, 0:nx/2+1], cmap_name,
 
>>> extent=(0,nx/2,ny,ny/2))
>>>   
 ax.imshow(argW[0:ny/2+1, nx/2+1:-1], cmap_name,
 
>>> extent=(nx/2,nx,ny/2,0))
>>>   
 ax.imshow(argW[ny/2+1:-1, nx/2+1:-1], cmap_name,
 
>>> extent=(nx/2,nx,ny,ny/2))
>>>   
 which didn't work (I only got one "corner" - the
 
>> last
>> 
>>> one, I think - i.e., I think it's still just putting
>>> subsequent images on top of prior ones).
>>>
>>> Based on just a quick look, I'd make sure:
>>>
>>> 1) To set the x and y limits appropriately:
>>>
>>> ax.set_xlim(0, nx)
>>> ax.set_ylim(ny, 0)
>>>   
>> I'll try it out and report back.
>> 
>
> Nope, still only getting the last corner.  Let me give a little more of my 
> code:
>   

David:  Just add

ax.set_xlim(0,nx)
ax.set_ylim(0,ny)

after you imshow calls.  The axes limits are being automatically set to 
match your last invocation of imshow.

-Jeff
> import numpy as N
> from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
> from matplotlib.figure import Figure
>
> w, h, DPI = (8.2, 6.2, 50)
> fig = Figure(figsize=(w, h), 
>  dpi=DPI,
>  frameon=False)
> ax = fig.add_subplot(1,1,1)
> canvas = FigureCanvas(fig)
>
> nx, xmin, xmax = (int(w*DPI), -0.5, 0.5)
> ny, ymin, ymax = (int(h*DPI),  0.6, 1.2)
> W = N.zeros((ny,nx),N.complex)
>
> ## Generate non-trivial W; unnecessary for code to run, I think
>
> argW = N.angle(W)
>
> ax.set_xlim(0, nx)
> ax.set_ylim(ny, 0)
> ax.imshow(argW[0:ny/2, 0:nx/2], extent=(0, nx/2 - 1, ny/2 - 1, 0))
> ax.hold(True)
> ax.imshow(argW[ny/2:-1, 0:nx/2], extent=(0, nx/2 - 1, ny, ny/2))
> ax.imshow(argW[0:ny/2, nx/2:-1], extent=(nx/2, nx, ny/2 - 1, 0))
> ax.imshow(argW[ny/2:-1, nx/2:-1], extent=(nx/2, nx, ny, ny/2))
> canvas.print_figure(fid, dpi=DPI)
>
> DG
>   


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Producing a KML-friendly (Google Earth) image

2010-03-03 Thread Jeff Whitaker
Bruce Ford wrote:
> All,
>
> It took a fair bit of trial and error to coax a KML-friendly image out
> of matplotlib and to understand what was and was not necessary.  Below
> is a demo script demonstrating how to accomplish a KML-friendly image
> with and without a basemap.  I hope this will help someone out.
>
> What do I mean by a KML-friendly image?  In KML you can overlay a
> complicated geo-referenced image but it is geo-referenced based on the
> boundaries of the image.  So, for the image to be correctly displayed
> in a KML document, the edges of the image have to be relatable to a
> latitude or longitude.  Most of the time this will mean you are using
> Basemap and you'll need an image that encompasses only the bounding
> box and nothing outside...no whitespace, extra room for titling, etc.
>
> The below examples accomplish this.  Turns out, the two key elements are
>
> (1)  ax = pyplot.axes((0,0,1,1))
>
> and if you are using Basemap:
>
> (2) a kwarg in Basemap:  fix_aspect=False
>
> Thanks!
>
> Bruce
>   

Bruce:  That's great, I've always wondered how to do that.   However 
your example didn't make it to the list, perhaps you forgot to attach it?


-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


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar on LEFT side of figure ?

2010-03-04 Thread Jeff Whitaker
Jim Vickroy wrote:
> Hi,
>
> I have been unable to place a colorbar on the LEFT side of a figure.  
> For example, in the Gaussian noise with vertical colorbar 
> 
>  
> demo, how can the colorbar be positioned on the left side of the figure.
>
> Thanks,
> -- jv
>   

Create your own axes instance for the colorbar (as in 
http://matplotlib.sourceforge.net/examples/pylab_examples/multi_image.html).

-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


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] shiftgrid 'cyclic point not included' error

2010-03-08 Thread Jeff Whitaker
antonv wrote:
> Hi all,
>
> I am getting a 'cyclic point not included' error using shiftgrid on a grib
> file from NOAA. I've checked and it seems that the file has the lons from 0
> to 359.5 every .5 degree but I get that error whenever I try to run this. 
>
> What I need to achieve is to shift the grid from 0 / 360 to -180 / 180 so
> that I can create a map over Great Britain. I am using a Cassini projection.
>   

Anton:  You can add the wraparound, or cyclic point using the addcyclic 
function.  Or, you can update to the latest svn version of basemap which 
does not have this restriction.


-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


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] shiftgrid 'cyclic point not included' error

2010-03-08 Thread Jeff Whitaker
antonv wrote:
> Hi Jeff,
>
> Thanks for the quick reply! I've updated to the latest shiftgrid and now I
> get the chart :D
> I still have a small issue as there is a half degree sliver missing from the
> mapping at the greenwich meridian. Any idea how to solve that issue? 
>
> Here is an image showing that (above england):
> http://old.nabble.com/file/p27824785/Global-HTSGW_DIRPW-0.png 
>
> Thanks,
> Anton
>   

Anton:  Looks like the values at the Greenwich meridian got messed up 
somehow.  Can you post your script somewhere so I can try it out?

-Jeff
>
> Jeff Whitaker wrote:
>   
>> antonv wrote:
>> 
>>> Hi all,
>>>
>>> I am getting a 'cyclic point not included' error using shiftgrid on a
>>> grib
>>> file from NOAA. I've checked and it seems that the file has the lons from
>>> 0
>>> to 359.5 every .5 degree but I get that error whenever I try to run this. 
>>>
>>> What I need to achieve is to shift the grid from 0 / 360 to -180 / 180 so
>>> that I can create a map over Great Britain. I am using a Cassini
>>> projection.
>>>   
>>>   
>> Anton:  You can add the wraparound, or cyclic point using the addcyclic 
>> function.  Or, you can update to the latest svn version of basemap which 
>> does not have this restriction.
>>
>>
>> -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
>>
>>
>> --
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> ___
>> Matplotlib-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>> 
>
>   


-- 
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


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] shiftgrid 'cyclic point not included' error

2010-03-08 Thread Jeff Whitaker
antonv wrote:
> Hi Jeff,
>
> Here is the whole script: 
> http://old.nabble.com/file/p27826457/_test_shiftgrid.py _test_shiftgrid.py 
> And here are the grib data files:
> http://socalscubainfo.com/downloads/GRIB2_files.zip
>
> Also, if there is not too much to ask, is there a sample anywhere that shows
> how to use shiftgrid for a mercator projection? If you look at the script, I
> was initially trying to make the images using the mercator projection (there
> is a commented basemap function there) but it would display just the data
> starting from the origin. I was wondering how would I be able to display
> let's say the whole globe but shift the grid 180 so that great britain would
> be in the center of the map rather than being cut at the edge.
>
> Thanks,
> Anton 
>   

Anton:  You weren't updating the lons and lats to be consistent with the 
shifted grid.  I changed the lines

#z, lons[i] = shiftgrid(180.0, z, lons[i], start=False, 
cyclic=360.0)
#zq, lons_a[i] = shiftgrid(180.0, zq, lons_a[i], start=False, 
cyclic=360.0)

in your script to

lons1 = lons[0,:]
z, lonsnew = shiftgrid(180.0, z, lons1, start=False)
zq, lonsnew = shiftgrid(180.0, zq, lons1, start=False)
lons, lonsnew = shiftgrid(180.0, lons, lons1, start=False)
lats, lonsnew = shiftgrid(180.0, lats, lons1, start=False)

and it works fine.

-Jeff
>
>
>
> Jeff Whitaker wrote:
>   
>> antonv wrote:
>> 
>>> Hi Jeff,
>>>
>>> Thanks for the quick reply! I've updated to the latest shiftgrid and now
>>> I
>>> get the chart :D
>>> I still have a small issue as there is a half degree sliver missing from
>>> the
>>> mapping at the greenwich meridian. Any idea how to solve that issue? 
>>>
>>> Here is an image showing that (above england):
>>> http://old.nabble.com/file/p27824785/Global-HTSGW_DIRPW-0.png 
>>>
>>> Thanks,
>>> Anton
>>>   
>>>   
>> Anton:  Looks like the values at the Greenwich meridian got messed up 
>> somehow.  Can you post your script somewhere so I can try it out?
>>
>> -Jeff
>> 
>>> Jeff Whitaker wrote:
>>>   
>>>   
>>>> antonv wrote:
>>>> 
>>>> 
>>>>> Hi all,
>>>>>
>>>>> I am getting a 'cyclic point not included' error using shiftgrid on a
>>>>> grib
>>>>> file from NOAA. I've checked and it seems that the file has the lons
>>>>> from
>>>>> 0
>>>>> to 359.5 every .5 degree but I get that error whenever I try to run
>>>>> this. 
>>>>>
>>>>> What I need to achieve is to shift the grid from 0 / 360 to -180 / 180
>>>>> so
>>>>> that I can create a map over Great Britain. I am using a Cassini
>>>>> projection.
>>>>>   
>>>>>   
>>>>>   
>>>> Anton:  You can add the wraparound, or cyclic point using the addcyclic 
>>>> function.  Or, you can update to the latest svn version of basemap which 
>>>> does not have this restriction.
>>>>
>>>>
>>>> -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
>>>>
>>>>
>>>> --
>>>> Download Intel® Parallel Studio Eval
>>>> Try the new software tools for yourself. Speed compiling, find bugs
>>>> proactively, and fine-tune applications for parallel performance.
>>>> See why Intel Parallel Studio got high marks during beta.
>>>> http://p.sf.net/sfu/intel-sw-dev
>>>> ___
>>>> Matplotlib-users mailing list
>>>> [email protected]
>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>>
>>>>
>>>> 
>>>> 
>>>   
>>>   
>> -- 
>> Jeffrey S. Whitaker Phone  : (303)497-6313
>> Meteorologist   FAX: (303)497-6449
>> NOAA/OAR/PSD  R/PSD1Email  

Re: [Matplotlib-users] shiftgrid 'cyclic point not included' error

2010-03-10 Thread Jeff Whitaker
Anton Vasilescu wrote:
> Hi Jeff,
>
> Thank you for looking at the code for me! It works perfect for the 
> first image but when it tries to do the second it errors out saying: 
> "lon0 outside of range of lonsin". Any idea why is that happening? Is 
> it happening for you too?
>
> Thanks,
> Anton

Anton: Probably because the original value of lons has been overwritten 
with the shifted grid longitudes.  You need to save the original lons 
array to pass to shiftgrid for the second grid.

-Jeff
>
> ----
> *From:* Jeff Whitaker 
> *To:* antonv 
> *Cc:* [email protected]
> *Sent:* Mon, March 8, 2010 12:50:48 PM
> *Subject:* Re: [Matplotlib-users] shiftgrid 'cyclic point not 
> included' error
>
> antonv wrote:
> > Hi Jeff,
> >
> > Here is the whole script: 
> http://old.nabble.com/file/p27826457/_test_shiftgrid.py 
> _test_shiftgrid.py <http://_test_shiftgrid.py> And here are the grib 
> data files:
> > http://socalscubainfo.com/downloads/GRIB2_files.zip
> >
> > Also, if there is not too much to ask, is there a sample anywhere 
> that shows
> > how to use shiftgrid for a mercator projection? If you look at the 
> script, I
> > was initially trying to make the images using the mercator 
> projection (there
> > is a commented basemap function there) but it would display just the 
> data
> > starting from the origin. I was wondering how would I be able to display
> > let's say the whole globe but shift the grid 180 so that great 
> britain would
> > be in the center of the map rather than being cut at the edge.
> >
> > Thanks,
> > Anton 
>
> Anton:  You weren't updating the lons and lats to be consistent with 
> the shifted grid.  I changed the lines
>
>   #z, lons[i] = shiftgrid(180.0, z, lons[i], start=False, 
> cyclic=360.0)
>   #zq, lons_a[i] = shiftgrid(180.0, zq, lons_a[i], start=False, 
> cyclic=360.0)
>
> in your script to
>
>   lons1 = lons[0,:]
>   z, lonsnew = shiftgrid(180.0, z, lons1, start=False)
>   zq, lonsnew = shiftgrid(180.0, zq, lons1, start=False)
>   lons, lonsnew = shiftgrid(180.0, lons, lons1, start=False)
>   lats, lonsnew = shiftgrid(180.0, lats, lons1, start=False)
>
> and it works fine.
>
> -Jeff
> >
> >
> >
> > Jeff Whitaker wrote:
> > 
> >> antonv wrote:
> >>   
> >>> Hi Jeff,
> >>>
> >>> Thanks for the quick reply! I've updated to the latest shiftgrid 
> and now
> >>> I
> >>> get the chart :D
> >>> I still have a small issue as there is a half degree sliver 
> missing from
> >>> the
> >>> mapping at the greenwich meridian. Any idea how to solve that issue?
> >>> Here is an image showing that (above england):
> >>> http://old.nabble.com/file/p27824785/Global-HTSGW_DIRPW-0.png
> >>> Thanks,
> >>> Anton
> >>>   
> >> Anton:  Looks like the values at the Greenwich meridian got messed 
> up somehow.  Can you post your script somewhere so I can try it out?
> >>
> >> -Jeff
> >>   
> >>> Jeff Whitaker wrote:
> >>>   
> >>>> antonv wrote:
> >>>>   
> >>>>> Hi all,
> >>>>>
> >>>>> I am getting a 'cyclic point not included' error using shiftgrid 
> on a
> >>>>> grib
> >>>>> file from NOAA. I've checked and it seems that the file has the lons
> >>>>> from
> >>>>> 0
> >>>>> to 359.5 every .5 degree but I get that error whenever I try to run
> >>>>> this.
> >>>>> What I need to achieve is to shift the grid from 0 / 360 to -180 
> / 180
> >>>>> so
> >>>>> that I can create a map over Great Britain. I am using a Cassini
> >>>>> projection.
> >>>>> 
> >>>> Anton:  You can add the wraparound, or cyclic point using the 
> addcyclic function.  Or, you can update to the latest svn version of 
> basemap which does not have this restriction.
> >>>>
> >>>>
> >>>> -Jeff
> >>>>
> >>>>
> >>>> -- Jeffrey S. WhitakerPhone  : (303)497-6313
> >>>> Meteorologist  FAX: (303)497-6449
> >>>> NOAA/OAR/PSD  R/PSD1Email  : [email protected] 
> <mailto:

Re: [Matplotlib-users] How do you add contrasting text to color image

2010-03-16 Thread Jeff Whitaker

On 3/16/10 10:10 AM, PaterMaximus wrote:

I have I have an image with both light and dark regions. I want to write text on
it in a color that contrasts with the underlying image color.

Right now if I make the text black, it is not very legible if the underling
color is dark. Similarly, if I make the text white, it is not legible if the
underlying color is light. (using gray text will not work)

One way to solve the problem would be to:
-produce the image
e.g. im1=plt.imshow 
(zM,origin='lower',interpolation='hanning',extent=None)
-get the underlying color from the image where I want to place the text
Need help here. How do I get the color from im1
-calculate a contrasting color
Need help here
-plot the text in the contrasting color



Another way would be to use a font with a dark edge and light interior (or vice
versa) but I know of know such font for matplotlib.

Any help appreciated...
   


You could put your text inside a colored box - see e.g. 
http://matplotlib.sourceforge.net/users/text_intro.html 



-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

--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib to draw streamlines?

2010-03-23 Thread Jeff Whitaker
On 3/23/10 5:33 PM, Reckoner wrote:
> Is it possible to draw a streamlines plot as shown in the following:
>
> http://www.pyngl.ucar.edu/Examples/Images/ngl04p.0.png
>
> using matplotlib or basemap?
>
> Thanks in advance!
>
>
>
Sorry, no.

-Jeff


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] manual placement of a colorbar

2010-04-01 Thread Jeff Whitaker
On 4/1/10 1:24 PM, Mathew Yeates wrote:
> Hi
>
> I have a Basemap and I want to manually add a colorbar to the side. As 
> you can see in the attached image, the colorbar is not correctly 
> positioned.
>
> Here is a snippet of code
>
> ax=fig.add_axes([0.1,0.1,0.8,.8])
> m = Basemap(resolution='c',projection='cyl',lon_0=0,ax=ax)
>
> cax = fig.add_axes([0.9, 0.1, 0.1, 0.8]) # setup colorbar axes.
> cmap = mpl.cm.cool
> norm = mpl.colors.Normalize(vmin=5, vmax=10)
> cb1 = mpl.colorbar.ColorbarBase(cax, cmap=cmap,
>norm=norm,
>orientation='vertical')
>
> what am I doing wrong?
>
> Mathew
Nothing.  You just have to tweak the cax parameters to get it positioned 
where you want it.

A quick and dirty approach would be to let matplotlib position the 
colorbar by using

import matplotlib.pyplot as plt



plt.colorbar(orientation='vertical',shrink=0.5)  # play with the shrink 
param to get it to be the same size as the map

-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


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap/ orthographic projection plot doesn't respect globe boundary

2010-04-02 Thread Jeff Whitaker

On 4/2/10 4:27 AM, Will Hewson wrote:
Hi forum/ mailing list, When I plot in the orthographic projection I'm 
getting the large artefact shown below extending away from the north 
east of the globe. I'm not finding the same problem when plotting in a 
full globe projection so I'm presuming the problem is with the way I'm 
projecting everything rather than my data itself. I've included my 
plotting code below, if anyone is able to spot some glaring omissions/ 
errors I'd be most grateful (I've been using python/ matplotlib for 
only a couple of weeks now!).




Will:   You'll have to provide the data so we can actually run the script.

-Jeff

#!/usr/local/bin/python2.6
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import sys, glob

#input must be 3 col file of lons lats and data
#bins input values into half degree grid, ignores negative values

plts = glob.glob('*.plt')
x = np.arange(-180, 180, 0.5); y = np.arange(-90, 90, 0.5)
grid_lon, grid_lat = np.meshgrid(x,y) #regularly spaced 2D grid
n_vals = np.zeros((360,720)) #mean divisor
dat = np.zeros((360,720)) #2D grid of zeros

for pt in plts:

in_file = pt
data = np.loadtxt(in_file, comments = ';')
fname = in_file.split('.')[0]

lon = data[:,0] #original 1D list
lat = data[:,1] #original 1D list
slcol = data[:,2] #z data

lon = (np.around(lon*2))/2 #round to nearest .0 or 0.5
lat = (np.around(lat*2))/2 #round to nearest .0 or 0.5

##keep the below between files

j=0

for i in slcol:
if lon[j] < 0:
grid_lon_ind = 360+(lon[j]*2)
grid_lat_ind = 180+(lat[j]*2)
else:
grid_lon_ind = 360-(lon[j]*2)
grid_lat_ind = 180+(lat[j]*2)

if i > 0:
dat[grid_lat_ind, grid_lon_ind] += i #add i'th value
n_vals[grid_lat_ind, grid_lon_ind] += 1 #increase cell counter by 1 
for each extra value

j+=1

dat = np.nan_to_num(dat/n_vals)

#create map object
fig = plt.figure()
m = Basemap(projection='ortho', lon_0=lon[(len(lon)/2)], lat_0=0, 
resolution='l', area_thresh=1.)

#m = Basemap(projection='moll',lon_0=0,resolution='c', area_thresh=1.)

X,Y = m(grid_lon, grid_lat)

#pass all 2d arrays to pcolor
im = m.pcolormesh(X,Y,dat)

#add coastlines, globe boundary and colourbar
m.drawcoastlines()
m.drawmapboundary()
m.drawparallels(np.arange(-90, 90,30))
m.drawmeridians(np.arange(-180,180,30))

fig.colorbar(im)
plt.title('CH20 and ting')
plt.savefig('binplot.png')

Thanks for your help,
Will.

View this message in context: Basemap/ orthographic projection plot 
doesn't respect globe boundary 

Sent from the matplotlib - users mailing list archive 
 at Nabble.com.



--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev


___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
   


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap/ orthographic projection plot doesn't respect globe boundary

2010-04-02 Thread Jeff Whitaker

On 4/2/10 4:27 AM, Will Hewson wrote:
Hi forum/ mailing list, When I plot in the orthographic projection I'm 
getting the large artefact shown below extending away from the north 
east of the globe. I'm not finding the same problem when plotting in a 
full globe projection so I'm presuming the problem is with the way I'm 
projecting everything rather than my data itself. I've included my 
plotting code below, if anyone is able to spot some glaring omissions/ 
errors I'd be most grateful (I've been using python/ matplotlib for 
only a couple of weeks now!).
Will:  I think what's happening is that pcolormesh is having trouble 
dealing with the higher curvlinear grid, which becomes nearly 
pathological near the horizon of the projection.  If you take a look at 
the test.py file in the basemap examples directory, you'll see an 
example orthographic plot that solves this problem by first 
interpolating the data to a regular grid in projection coordinates (with 
values over the plot horizon masked).  The example uses imshow, but 
pcolormesh works as well.  A standalone version of the example using 
pcolormesah  is attached, which uses data files in the basemap examples 
directory.


-Jeff


#!/usr/local/bin/python2.6
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import sys, glob

#input must be 3 col file of lons lats and data
#bins input values into half degree grid, ignores negative values

plts = glob.glob('*.plt')
x = np.arange(-180, 180, 0.5); y = np.arange(-90, 90, 0.5)
grid_lon, grid_lat = np.meshgrid(x,y) #regularly spaced 2D grid
n_vals = np.zeros((360,720)) #mean divisor
dat = np.zeros((360,720)) #2D grid of zeros

for pt in plts:

in_file = pt
data = np.loadtxt(in_file, comments = ';')
fname = in_file.split('.')[0]

lon = data[:,0] #original 1D list
lat = data[:,1] #original 1D list
slcol = data[:,2] #z data

lon = (np.around(lon*2))/2 #round to nearest .0 or 0.5
lat = (np.around(lat*2))/2 #round to nearest .0 or 0.5

##keep the below between files

j=0

for i in slcol:
if lon[j] < 0:
grid_lon_ind = 360+(lon[j]*2)
grid_lat_ind = 180+(lat[j]*2)
else:
grid_lon_ind = 360-(lon[j]*2)
grid_lat_ind = 180+(lat[j]*2)

if i > 0:
dat[grid_lat_ind, grid_lon_ind] += i #add i'th value
n_vals[grid_lat_ind, grid_lon_ind] += 1 #increase cell counter by 1 
for each extra value

j+=1

dat = np.nan_to_num(dat/n_vals)

#create map object
fig = plt.figure()
m = Basemap(projection='ortho', lon_0=lon[(len(lon)/2)], lat_0=0, 
resolution='l', area_thresh=1.)

#m = Basemap(projection='moll',lon_0=0,resolution='c', area_thresh=1.)

X,Y = m(grid_lon, grid_lat)

#pass all 2d arrays to pcolor
im = m.pcolormesh(X,Y,dat)

#add coastlines, globe boundary and colourbar
m.drawcoastlines()
m.drawmapboundary()
m.drawparallels(np.arange(-90, 90,30))
m.drawmeridians(np.arange(-180,180,30))

fig.colorbar(im)
plt.title('CH20 and ting')
plt.savefig('binplot.png')

Thanks for your help,
Will.

View this message in context: Basemap/ orthographic projection plot 
doesn't respect globe boundary 

Sent from the matplotlib - users mailing list archive 
 at Nabble.com.



--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev


___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
   


from mpl_toolkits.basemap import Basemap, shiftgrid
import numpy as np
import matplotlib.pyplot as plt
# read in topo data (on a regular lat/lon grid)
# longitudes go from 20 to 380.
topoin = np.loadtxt('etopo20data.gz')
lons = np.loadtxt('etopo20lons.gz')
lats = np.loadtxt('etopo20lats.gz')
# shift data so lons go from -180 to 180 instead of 20 to 380.
topoin,lons = shiftgrid(180.,topoin,lons,start=False)
m = Basemap(projection='ortho',lon_0=-105,lat_0=40,resolution='l')
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/4.)+1; ny = int((m.ymax-m.ymin)/4.)+1
topodat,x,y =\
m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True,masked=True,order=1)
# create the figure.
fig=plt.figure(figsize=(8,8))
im = m.pcolormesh(x,y,topodat,cmap=plt.cm.jet)
m.drawcoastlines()
m.drawparallels(np.arange(0.,80,20.))
m.drawmeridians(np.arange(10.,360.,30.))
m.drawmapboundary()
plt.show()
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. S

Re: [Matplotlib-users] Basemap/ orthographic projection plot doesn't respect globe boundary

2010-04-02 Thread Jeff Whitaker
On 4/2/10 6:32 AM, Will Hewson wrote:
> This is great Jeff, thanks for the help - I'll give it a try over the weekend
> (it's bank holiday here in the UK!) and get back to you, if I'm still having
> trouble I'll stick up the plotting data too... thanks again.
>
> Will
>

Will:  I forgot to mention that contourf will work on your data without 
having to interpolate to projection coordinates.

-Jeff
>
>
> Jeff Whitaker wrote:
>
>> On 4/2/10 4:27 AM, Will Hewson wrote:
>>  
>>> Hi forum/ mailing list, When I plot in the orthographic projection I'm
>>> getting the large artefact shown below extending away from the north
>>> east of the globe. I'm not finding the same problem when plotting in a
>>> full globe projection so I'm presuming the problem is with the way I'm
>>> projecting everything rather than my data itself. I've included my
>>> plotting code below, if anyone is able to spot some glaring omissions/
>>> errors I'd be most grateful (I've been using python/ matplotlib for
>>> only a couple of weeks now!).
>>>
>> Will:  I think what's happening is that pcolormesh is having trouble
>> dealing with the higher curvlinear grid, which becomes nearly
>> pathological near the horizon of the projection.  If you take a look at
>> the test.py file in the basemap examples directory, you'll see an
>> example orthographic plot that solves this problem by first
>> interpolating the data to a regular grid in projection coordinates (with
>> values over the plot horizon masked).  The example uses imshow, but
>> pcolormesh works as well.  A standalone version of the example using
>> pcolormesah  is attached, which uses data files in the basemap examples
>> directory.
>>
>> -Jeff
>>
>> from mpl_toolkits.basemap import Basemap, shiftgrid
>> import numpy as np
>> import matplotlib.pyplot as plt
>> # read in topo data (on a regular lat/lon grid)
>> # longitudes go from 20 to 380.
>> topoin = np.loadtxt('etopo20data.gz')
>> lons = np.loadtxt('etopo20lons.gz')
>> lats = np.loadtxt('etopo20lats.gz')
>> # shift data so lons go from -180 to 180 instead of 20 to 380.
>> topoin,lons = shiftgrid(180.,topoin,lons,start=False)
>> m = Basemap(projection='ortho',lon_0=-105,lat_0=40,resolution='l')
>> # transform to nx x ny regularly spaced native projection grid
>> nx = int((m.xmax-m.xmin)/4.)+1; ny = int((m.ymax-m.ymin)/4.)+1
>> topodat,x,y =\
>> m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True,masked=True,order=1)
>> # create the figure.
>> fig=plt.figure(figsize=(8,8))
>> im = m.pcolormesh(x,y,topodat,cmap=plt.cm.jet)
>> m.drawcoastlines()
>> m.drawparallels(np.arange(0.,80,20.))
>> m.drawmeridians(np.arange(10.,360.,30.))
>> m.drawmapboundary()
>> plt.show()
>>
>>
>>  
>


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap/ orthographic projection plot doesn't respect globe boundary

2010-04-04 Thread Jeff Whitaker
On 4/4/10 11:06 AM, Will Hewson wrote:
> Hi again Jeff et al...
>
> I've had a play around with the extra few lines of code - on paper this
> seems like it should solve the problems I'm experiencing. However, an
> error's being thrown up by the transform scalar function, as my lons and
> lats won't necessarily be increasing. The data I'm plotting is satellite
> data and so at the beginning and end of the orbit file lats go over the pole
> from 90 to -90, with a similar problem for the lons - whereby the data is
> taken across the satellite track. I've thought about sorting the data before
> passing it to transform_scalar but I'm always going to be left with the
> problem in either lats or lons.
>
> I've uploaded the file I'm currently working with this time. It's three
> columns of lons, lats and z values.
>
> Once again, many thanks for your help.
>
> Will.
>
> http://old.nabble.com/file/p28133659/test.plt test.plt
>

Will:  Is it a regular lat/lon grid or a satellite swath?  If it's the 
latter, you can't use my solution.

-Jeff


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap/ orthographic projection plot doesn't respect globe boundary

2010-04-05 Thread Jeff Whitaker
On 4/5/10 4:16 AM, Will Hewson wrote:
> Hey Jeff,
>
> It's somewhere between the two - the original satellite swath is converted
> to a regular 0.5 degree grid by truncating, binning, and averaging each
> point's lons and lats over the top of a 720 x 360 np.zeros array. the
> plotting still works fine for non ortho/ hemispherical projections, and I've
> no big problem with using global projections for the time being. Thanks for
> your help in the meantime anyway.
>
> Cheers,
>
>
> Will.
>

Will:  If it's a regular 0.5 degree lat/lon grid, it should work in 
transform_scalar.  However, I don't see how to read the data in your 
test.plt file into a regular 360x720 grid.  It seems to only contain the 
points in the swath with nonzero values.

-Jeff
>
>
> Jeff Whitaker wrote:
>
>> On 4/4/10 11:06 AM, Will Hewson wrote:
>>  
>>> Hi again Jeff et al...
>>>
>>> I've had a play around with the extra few lines of code - on paper this
>>> seems like it should solve the problems I'm experiencing. However, an
>>> error's being thrown up by the transform scalar function, as my lons and
>>> lats won't necessarily be increasing. The data I'm plotting is satellite
>>> data and so at the beginning and end of the orbit file lats go over the
>>> pole
>>> from 90 to -90, with a similar problem for the lons - whereby the data is
>>> taken across the satellite track. I've thought about sorting the data
>>> before
>>> passing it to transform_scalar but I'm always going to be left with the
>>> problem in either lats or lons.
>>>
>>> I've uploaded the file I'm currently working with this time. It's three
>>> columns of lons, lats and z values.
>>>
>>> Once again, many thanks for your help.
>>>
>>> Will.
>>>
>>> http://old.nabble.com/file/p28133659/test.plt test.plt
>>>
>>>
>> Will:  Is it a regular lat/lon grid or a satellite swath?  If it's the
>> latter, you can't use my solution.
>>
>> -Jeff
>>
>>
>> --
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> ___
>> Matplotlib-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>>  
>


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap/ orthographic projection plot doesn't respect globe boundary

2010-04-05 Thread Jeff Whitaker

On 4/5/10 7:25 AM, Will Hewson wrote:

I should perhaps of explained my code (included in top post) a little better,
the values in my attached file aren't on a regular grid to start with, I do
a little bit of juggling as follows to get them into a regular grid:

I'm firstly setting up my 2D grid of 0.5 degree lat lons, followed by
identically sized grids of zeros for the data bin, and mean divisors:

x = np.arange(-180, 180, 0.5); y = np.arange(-90, 90, 0.5)
grid_lon, grid_lat = np.meshgrid(x,y) #regularly spaced 2D grid
n_vals = np.zeros((360,720)) #mean divisor
dat = np.zeros((360,720)) #2D grid of zeros

I'm then taking my input data (e.g. the .plt file attached), and rounding
the lat lons to the nearest 0 or 0.5:

lon = (np.around(lon*2))/2 #round to nearest .0 or 0.5
lat = (np.around(lat*2))/2 #round to nearest .0 or 0.5

Then for each row in my input file where Z is greater than 0, I'm adding the
n'th Z value to its corresponding position in the dat zeros array, and
keeping a count of how many values are going into each cell in the mean
divisor array:

j=0
for i in slcol:
   if lon[j]<  0:
 grid_lon_ind = 360+(lon[j]*2)
 grid_lat_ind = 180+(lat[j]*2)
   else:
 grid_lon_ind = 360-(lon[j]*2)
 grid_lat_ind = 180+(lat[j]*2)
   if i>  0:
 dat[grid_lat_ind, grid_lon_ind] += i #add i'th value
 n_vals[grid_lat_ind, grid_lon_ind] += 1 #increase cell counter by 1 for
each extra value
   j+=1

Finally the new dat array is divided by the mean divisor array to give me my
mean Z values:

dat = np.nan_to_num(dat/n_vals)

I've done it this way as opposed to interpolating *properly* in order to
(for instance) stop the values bleeding away from the edges of the satellite
swath.

Cheers,

Will.
   


Will:  I made some slight modifications to your original script and it 
works fine with the ortho projection using either contourf on the 
original lat/lon grid or pcolormesh on the interpolated map projection 
grid.


-Jeff


Jeff Whitaker wrote:
   

On 4/5/10 4:16 AM, Will Hewson wrote:
 

Hey Jeff,

It's somewhere between the two - the original satellite swath is
converted
to a regular 0.5 degree grid by truncating, binning, and averaging each
point's lons and lats over the top of a 720 x 360 np.zeros array. the
plotting still works fine for non ortho/ hemispherical projections, and
I've
no big problem with using global projections for the time being. Thanks
for
your help in the meantime anyway.

Cheers,


Will.

   

Will:  If it's a regular 0.5 degree lat/lon grid, it should work in
transform_scalar.  However, I don't see how to read the data in your
test.plt file into a regular 360x720 grid.  It seems to only contain the
points in the swath with nonzero values.

-Jeff
 


Jeff Whitaker wrote:

   

On 4/4/10 11:06 AM, Will Hewson wrote:

 

Hi again Jeff et al...

I've had a play around with the extra few lines of code - on paper this
seems like it should solve the problems I'm experiencing. However, an
error's being thrown up by the transform scalar function, as my lons
and
lats won't necessarily be increasing. The data I'm plotting is
satellite
data and so at the beginning and end of the orbit file lats go over the
pole
from 90 to -90, with a similar problem for the lons - whereby the data
is
taken across the satellite track. I've thought about sorting the data
before
passing it to transform_scalar but I'm always going to be left with the
problem in either lats or lons.

I've uploaded the file I'm currently working with this time. It's three
columns of lons, lats and z values.

Once again, many thanks for your help.

Will.

http://old.nabble.com/file/p28133659/test.plt test.plt


   

Will:  Is it a regular lat/lon grid or a satellite swath?  If it's the
latter, you can't use my solution.

-Jeff


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users



 


   


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matpl

Re: [Matplotlib-users] display a filled lat/lon basemap rectangle.

2010-04-07 Thread Jeff Whitaker
Yeates, Mathew C (388D) wrote:
>
>  
>
> Hi
>
> What is the simplest way to fill  in a 1 degree by 1 degree rectangle 
> on a basemap projection?
>
>  
>
> Mathew
>

Mathew:  Try this (for a 10x10 rectangle, but you get the idea)

from matplotlib.patches import Polygon
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
map = Basemap(projection='moll',lon_0=0)
x1,y1 = map(-10,-10)
x2,y2 = map(-10,10)
x3,y3 = map(10,10)
x4,y4 = map(10,-10)
p = Polygon([(x1,y1),(x2,y2),(x3,y3),(x4,y4)],\
facecolor='red',edgecolor='blue',linewidth=2)
plt.gca().add_patch(p)
map.drawcoastlines()
map.drawmapboundary()
plt.show()

-Jeff
>


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] display a filled lat/lon basemap rectangle.

2010-04-07 Thread Jeff Whitaker
Mathew Yeates wrote:
> I think this will only work with some projections but not all. I 
> looked at the code for tissot. It's pretty hairy but it almost does 
> what I want. (It draws projected circles
> instead of projected  rectangles.
Mathew:

You said you wanted a NxN degree polygon - that's what I gave you.  What 
exactly do you want?  A rectangle in map projection coordinates?  A 
rectangle in lat/lon coordinates?  A circle?

-Jeff
>
>
> On Wed, Apr 7, 2010 at 1:54 PM, Jeff Whitaker  <mailto:[email protected]>> wrote:
>
> Yeates, Mathew C (388D) wrote:
> >
> >
> >
> > Hi
> >
> > What is the simplest way to fill  in a 1 degree by 1 degree
> rectangle
> > on a basemap projection?
> >
> >
> >
> > Mathew
> >
>
> Mathew:  Try this (for a 10x10 rectangle, but you get the idea)
>
> from matplotlib.patches import Polygon
> import matplotlib.pyplot as plt
> from mpl_toolkits.basemap import Basemap
> map = Basemap(projection='moll',lon_0=0)
> x1,y1 = map(-10,-10)
> x2,y2 = map(-10,10)
> x3,y3 = map(10,10)
> x4,y4 = map(10,-10)
> p = Polygon([(x1,y1),(x2,y2),(x3,y3),(x4,y4)],\
>facecolor='red',edgecolor='blue',linewidth=2)
> plt.gca().add_patch(p)
> map.drawcoastlines()
> map.drawmapboundary()
> plt.show()
>
> -Jeff
> >
>
>
> 
> --
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> ___
> Matplotlib-users mailing list
> [email protected]
> <mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] display a filled lat/lon basemap rectangle.

2010-04-07 Thread Jeff Whitaker
Mathew Yeates wrote:
> lets say I want  to shade the area with lat/lon corners 34.-117  and 
> 35,-116
>
> but my map was created with projection='aeqd'
>
> The shade area will not be a rectangle. In fact the edges will be 
> curved. See the basemap code for "tissot". I think every point on the 
> boundary of the lat/lon box has to projected to a line segment.  The 
> collection of resulting segments forms an irregular polygon.
>
> Mathew

Mathew:  Right - it will only be a rectangle in a cylindrical 
projection.  The question remains - what do you want?  If you want a 
rectangle in map projection coordinates, just specify the vertices of a 
rectangle in map projection coordinates.  If you really want a polygon 
with vertices corresponding to those lat/on values, a polygon with 
curved sides is the right answer for that map projection.

-Jeff
>
>
>
>
> On Wed, Apr 7, 2010 at 6:24 PM, Jeff Whitaker  <mailto:[email protected]>> wrote:
>
> Mathew Yeates wrote:
>
> I think this will only work with some projections but not all.
> I looked at the code for tissot. It's pretty hairy but it
> almost does what I want. (It draws projected circles
> instead of projected  rectangles.
>
> Mathew:
>
> You said you wanted a NxN degree polygon - that's what I gave you.
>  What exactly do you want?  A rectangle in map projection
>     coordinates?  A rectangle in lat/lon coordinates?  A circle?
>
> -Jeff
>
>
>
> On Wed, Apr 7, 2010 at 1:54 PM, Jeff Whitaker
> mailto:[email protected]>
> <mailto:[email protected] <mailto:[email protected]>>> wrote:
>
>Yeates, Mathew C (388D) wrote:
>>
>>
>>
>> Hi
>>
>> What is the simplest way to fill  in a 1 degree by 1 degree
>rectangle
>> on a basemap projection?
>>
>>
>>
>> Mathew
>>
>
>Mathew:  Try this (for a 10x10 rectangle, but you get the idea)
>
>from matplotlib.patches import Polygon
>import matplotlib.pyplot as plt
>from mpl_toolkits.basemap import Basemap
>map = Basemap(projection='moll',lon_0=0)
>x1,y1 = map(-10,-10)
>x2,y2 = map(-10,10)
>x3,y3 = map(10,10)
>x4,y4 = map(10,-10)
>p = Polygon([(x1,y1),(x2,y2),(x3,y3),(x4,y4)],\
>   facecolor='red',edgecolor='blue',linewidth=2)
>plt.gca().add_patch(p)
>map.drawcoastlines()
>map.drawmapboundary()
>plt.show()
>
>-Jeff
>>
>
>
>  
>  
> --
>Download Intel® Parallel Studio Eval
>Try the new software tools for yourself. Speed compiling,
> find bugs
>proactively, and fine-tune applications for parallel
> performance.
>See why Intel Parallel Studio got high marks during beta.
>http://p.sf.net/sfu/intel-sw-dev
>___
>Matplotlib-users mailing list
>[email protected]
> <mailto:[email protected]>
><mailto:[email protected]
> <mailto:[email protected]>>
>
>https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] coordinate transformation: Basemap vs. Proj

2010-05-04 Thread Jeff Whitaker
On 5/4/10 2:03 PM, Timothy W. Hilton wrote:
> Hello matplotlib users,
>
> I am having trouble understanding the coordinate transformations in
> Basemap and pyproj.  I have gridded MODIS vegetation data, with upper
> left corner and lower right corner given in projection coordinates
> (meters).  I want to contour the data with Basemap.  The data are in a
> sinusoidal projection, but the coordinates do not correspond to what
> Basemap seems to expect.
>
> The code below illustrates the problem.  Proj translates the upper
> left to lat/lon correctly (-92.327237416031437, 30.141972433747089),
> while Basemap does not.
>
> # code 
> from mpl_toolkits.basemap import Basemap
> from mpl_toolkits.basemap import pyproj
>
> ulm = [-8895604.1573329996, 3335851.558999]  #upper left, meters
> lrm = [-7783653.6376670003, 2223901.0393329998]  #lower right, meters
>
> sinu = pyproj.Proj(proj='sinu', lon_0=0.0, x_0=0.0, y_0=0.0)
> m = Basemap(projection='sinu', resolution=None, lon_0=0.0)
>
> print "ULM: " + str(ulm)
> print "Proj: " + str(sinu(ulm[0], ulm[1], inverse=True))
> print "Basemap: " + str(m(ulm[0], ulm[1], inverse=True))
> #- end code 
>
> This gives:
> ULM: [-8895604.1573329996, 3335851.558999]
> Proj: (-92.327237416031437, 30.141972433747089)
> Basemap: (-159.99950210056144, -59.5206181125)
>
> I'm sure I'm missing something really simple, but I've read a lot of
> documentation and I'm not sure what.
>
> Many thanks for any help.
>
> Best,
> Tim
>

Tim:  Basemap is using pyproj under the hood, but only supports a subset 
of possible proj4 projections.  The basemap sinusoidal projection is 
global - you can't specify a subregion of the globe.  I think that's 
where the discrepancy is coming from.  I'm sure there's a way to plot 
your MODIS data on a global sinusoidal projection - but it will involve 
transforming the coordinates to the Basemap global sinuosidal coordinate 
system.

-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


--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] coordinate transformation: Basemap vs. Proj

2010-05-04 Thread Jeff Whitaker
On 5/4/10 4:25 PM, Timothy W. Hilton wrote:
> Hi Jeff,
>
> Thanks very much for your response.  As you noted, I do not understand
> the Basemap global sinusoidal coordinate system.  Does this statement
> not set up a global sinusoidal cartesian coordinate system centered at
> (lon = 0.0, lat = 0.0)?
>

Tim: It's a global sinusoidal projection, but x=0,y=0 is not at 
lon_0,lat_0.

 >> from mpl_toolkits.basemap import Basemap
 >> m = Basemap(projection='sinu', resolution=None, lon_0=0.0, lat_0=0.0)
 >> print m(0,0,inverse=True)
(-176.20919036912957, -89.9808395)

I forget why I did it this way, but I think it has to do with the fact 
that the matplotlib coordinate system has 0,0 in the lower left corner, 
not the middle.

At any rate, apply a offset to x and y to map to your global coordinate 
system.

-Jeff
> m = Basemap(projection='sinu', resolution=None, lon_0=0.0, lat_0=0.0)
>
> If so, I would expect m(0.0, 0.0) to return (0.0, 0.0) and m(0.0, 0.0,
> inverse=True) to return (0.0, 0.0).  Instead, I get:
>
>>>> m(0.0,0.0)
>>>>  
> (20015077.37119, 10007538.6856)
>
>>>> m(0.0,0.0,inverse=True)
>>>>  
> (-176.20919036912957, -89.9808395)
>
> Sorry if I am being obtuse.  Many thanks for your help.
>
> -Tim
>
> On Tue, May 2010, 04 at 04:01:21PM -0600, Jeff Whitaker wrote:
>
>> On 5/4/10 2:03 PM, Timothy W. Hilton wrote:
>>  
>>> Hello matplotlib users,
>>>
>>> I am having trouble understanding the coordinate transformations in
>>> Basemap and pyproj.  I have gridded MODIS vegetation data, with upper
>>> left corner and lower right corner given in projection coordinates
>>> (meters).  I want to contour the data with Basemap.  The data are in a
>>> sinusoidal projection, but the coordinates do not correspond to what
>>> Basemap seems to expect.
>>>
>>> The code below illustrates the problem.  Proj translates the upper
>>> left to lat/lon correctly (-92.327237416031437, 30.141972433747089),
>>> while Basemap does not.
>>>
>>> # code 
>>>
>> >from mpl_toolkits.basemap import Basemap
>> >from mpl_toolkits.basemap import pyproj
>>  
>>> ulm = [-8895604.1573329996, 3335851.558999]  #upper left, meters
>>> lrm = [-7783653.6376670003, 2223901.0393329998]  #lower right, meters
>>>
>>> sinu = pyproj.Proj(proj='sinu', lon_0=0.0, x_0=0.0, y_0=0.0)
>>> m = Basemap(projection='sinu', resolution=None, lon_0=0.0)
>>>
>>> print "ULM: " + str(ulm)
>>> print "Proj: " + str(sinu(ulm[0], ulm[1], inverse=True))
>>> print "Basemap: " + str(m(ulm[0], ulm[1], inverse=True))
>>> #- end code 
>>>
>>> This gives:
>>> ULM: [-8895604.1573329996, 3335851.558999]
>>> Proj: (-92.327237416031437, 30.141972433747089)
>>> Basemap: (-159.99950210056144, -59.5206181125)
>>>
>>> I'm sure I'm missing something really simple, but I've read a lot of
>>> documentation and I'm not sure what.
>>>
>>> Many thanks for any help.
>>>
>>> Best,
>>> Tim
>>>
>> Tim:  Basemap is using pyproj under the hood, but only supports a
>> subset of possible proj4 projections.  The basemap sinusoidal
>> projection is global - you can't specify a subregion of the globe.
>> I think that's where the discrepancy is coming from.  I'm sure
>> there's a way to plot your MODIS data on a global sinusoidal
>> projection - but it will involve transforming the coordinates to the
>> Basemap global sinuosidal coordinate system.
>>
>> -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


--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap continent colors

2010-05-10 Thread Jeff Whitaker
On 5/10/10 2:21 PM, Michael Hearne wrote:
> I have found  a (possible) bug in Basemap - when using 
> basemap.fillcontinents(), I see the chosen continent color only when the map 
> I create includes some ocean.  If I am in the interior of a continent (I've 
> tested with North America and Asia), the continent color is white.
>

Michael:  If there are no continent boundaries inside the map projection 
region, basemap does not draw anything (hence you see the axis 
background color).  In that case, you should just set the axis 
background color to whatever you wanted  the continent color to be.

-Jeff
> A code sample is below.  My version information:
> Basemap: 0.99.4
> Matplotlib: 0.99.1.1
> numpy: 1.4.0
> Python: 2.6.4
>
> To replicate my results, please try the following:
> ./maptest.py 37.894507 -121.816406  #map center is somewhere in the Bay Area 
> in California
> ./maptest.py 41.880332 -100.47821  #map center is somewhere in Nebraska
>
> The script creates a file called "output.png" in the calling directory.  In 
> the California case, I see the ocean as blue, and the land as a sort of 
> annoying salmon color.  In the Nebraska case, I see white with blue denoting 
> the various rivers and lakes in the area.
>
> Am I mis-using the basemap method calls in some way?
>
> Thanks,
>
> Mike
>
> 
> #!/usr/bin/env python
>
> import matplotlib
> #use the non-interactive matplotlib setting
> matplotlib.use('agg')
> from mpl_toolkits.basemap import Basemap
> import numpy as np
> from pylab import *
> import sys
>
> clat = float(sys.argv[1])
> clon = float(sys.argv[2])
>
> figwidth = 5.4
>
>
> bounds = (clon-4, clon+4, clat-4, clat+4)
> dx = (bounds[1] - bounds[0])*91 * np.cos(clat * np.pi/180)
> dy = (bounds[3] - bounds[2])*91
> aspect = dy/dx
> figheight = aspect * figwidth
>
> fig = figure(figsize=(figwidth,figheight),edgecolor='g',facecolor='g')
> ax1 = fig.add_axes([0,0,1.0,1.0])
> mapcontour = Basemap(llcrnrlon=bounds[0],llcrnrlat=bounds[2],
>   urcrnrlon=bounds[1],urcrnrlat=bounds[3],
>   resolution='h',projection='merc',lat_ts=clat)
> water_color = [.47,.60,.81]
> mapcontour.drawrivers(color=water_color)
> mapcontour.drawcountries(color='k',linewidth=2.0)
> mapcontour.drawcoastlines()
> mapcontour.fillcontinents(color=[1.0,0.8,0.8],lake_color=water_color)
>
> plt.savefig('output.png')
> 
>
>
> --
>
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


--

___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


  1   2   3   4   5   6   7   >