You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks in advance for taking the time to reply to
this request.
I am using the Basemap package of matplotlib to
generate plots upon request from a website. The
website interface generates a datafile to be loaded
and ploted on top a global coastline map. Typically,
the following line of code takes about 4.5 seconds:
This not only resulted in map being diassociated with
the figure axis (since the Basemap could not be
pickled after calling it with the ax=ax parameter)
but the pickle.load command took over 7 seconds
(worse than simply generating the plot from scratch
every time).
Is there a way to store the map object into a file
and plot the data on top of the loaded map object
each time the python script executes rather than
regenerating the Basemap each time and wasting 4.5
seconds?
Alternatively, perhaps there is a method I am not
aware of for writing a png or svg file and then
reloading the image and ploting on top of it to avoid
pickling?
Thanks again for the help.
Rupert Minnett
UCSD - SIO
IGPP - Scripps Institute of Oceanography
The text was updated successfully, but these errors were encountered:
One to be aware of #1020, which implements pickling of matplotlib figures (and their associated artists). This work could then potentially lead on to pickling of Basemap's, but I am not sure.
Original report at SourceForge, opened Mon Jun 12 02:49:17 2006
Thanks in advance for taking the time to reply to
this request.
I am using the Basemap package of matplotlib to
generate plots upon request from a website. The
website interface generates a datafile to be loaded
and ploted on top a global coastline map. Typically,
the following line of code takes about 4.5 seconds:
map = Basemap(projection='cyl',resolution='c')
map.fillcontinents ...
Having resorted to the crude resolution level, there
appears to be little else that can be done to
expedite this line of code.
One thought was to pickle the object and recover the
picked map object, although this was rather
unsuccessful:
from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import
FigureCanvasAgg as FigureCanvas
fig = Figure()
canvas = FigureCanvas(fig)
ax = fig.add_axes([0.125,0.175,0.75,0.75])
pickle_file = open(pickle_path+"/glm.map.obj",'r')
map = pickle.load(pickle_file)
pickle_file.close()
map.set_axes_limits(ax=ax)
fig.set_figsize_inches((8,map.aspect*8.))
map.fillcontinents ...
This not only resulted in map being diassociated with
the figure axis (since the Basemap could not be
pickled after calling it with the ax=ax parameter)
but the pickle.load command took over 7 seconds
(worse than simply generating the plot from scratch
every time).
Is there a way to store the map object into a file
and plot the data on top of the loaded map object
each time the python script executes rather than
regenerating the Basemap each time and wasting 4.5
seconds?
Alternatively, perhaps there is a method I am not
aware of for writing a png or svg file and then
reloading the image and ploting on top of it to avoid
pickling?
Thanks again for the help.
Rupert Minnett
UCSD - SIO
IGPP - Scripps Institute of Oceanography
The text was updated successfully, but these errors were encountered: