Jesper Larsen wrote:
> Hi matplotlib users,
>
> I have a small web application for calculating tsunami travel times 
> (http://ocean.dmi.dk/apps/tsunami). The application uses matplotlib/basemap 
> for producing contour maps of the tsunami travel times.
>
> To speed up the response time of the application I made a version in which 
> the 
> calculations are performed for every second integer longitude and latitude 
> for calculation windows of 60x60 degrees lon x lat, 90x90, 180x180 and 
> global. This is a lot of plots for which I am making a new Basemap instances 
> for each plot since:
>
> llcrnrlon
> llcrnrlat
> urcrnrlon
> urcrnrlat
>
> differs for each plot. The initialization of the Basemap instances are 
> responsible for the vast majority of the CPU usage in the application.
>
> In converting the application to numpy (from numarray) I was wondering 
> whether 
> I could reduce the plotting time as well. Is it possible to reuse a Basemap 
> instance somehow in my case or is that out of the question?
>
> Regards,
> Jesper
>
>   
Jesper:  As long as you are using the cylindrical equidistant 
projection, something like this might work:

from matplotlib.toolkits.basemap import Basemap
import pylab as p
map = Basemap()
map.fillcontinents(color='coral')
map.drawparallels(p.arange(-90,91,30))
map.drawmeridians(p.arange(-180,181,30))
p.savefig('fig1.png')

ax = p.gca()
llcrnrlat = 20
llcrnrlon = -140
urcrnrlat = 55
urcrnrlon = -65
corners = ((llcrnrlon,llcrnrlat), (urcrnrlon,urcrnrlat))
ax.update_datalim( corners )
ax.set_xlim((llcrnrlon, urcrnrlon))
ax.set_ylim((llcrnrlat, urcrnrlat))
p.savefig('fig2.png')

llcrnrlat = 30
llcrnrlon = -20
urcrnrlat = 80
urcrnrlon = 50
corners = ((llcrnrlon,llcrnrlat), (urcrnrlon,urcrnrlat))
ax.update_datalim( corners )
ax.set_xlim((llcrnrlon, urcrnrlon))
ax.set_ylim((llcrnrlat, urcrnrlat))
p.savefig('fig3.png')


You might not be able to get labels on the meridians and parallels with 
this approach though.

-Jeff

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


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to