From: Gökhan S. <gok...@gm...> - 2012-07-05 17:55:23
|
> > And you might get back more memory if you didn't have to have all the data > in memory at once, but that may or may not help you. The only other > suggestion I can make is to attempt to eliminate the overhead in the inner > loop. Essentially, I would try making a single figure and a single > AxesGrid object (before the outer loop). Then go over each subplot in the > AxesGrid object and set the limits, the log scale, the ticks and the tick > locater (I wouldn't be surprised if that is eating up cpu cycles). All of > this would be done once before the loop you have right now. Then create > the PdfPages object, and loop over all of the plots you have, essentially > recycling the figure and AxesGrid object. > > At end of the outer loop, instead of closing the figure, you should call > "remove()" for each plot element you made. Essentially, as you loop over > the inner loop, save the output of the plot() call to a list, and then when > done with those plots, pop each element of that list and call "remove()" to > take it out of the subplot. This will let the subplot axes retain the > properties you set earlier. > > I hope that made sense. > Ben Root > > Hi Ben, I should have data the available at once, as I directly read that array from a netcdf file. The memory requirement for my data is small comparing to overhead added once plot creation is started. Fabrice's reply includes most of what you describe except the remove call part. These changes made big impact to lower my execution times. Thank you again for your explanation. -- Gökhan |