[Yt-svn] yt-commit r899 - in trunk: . yt/raven
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Wed Nov 5 22:55:41 PST 2008
Author: mturk
Date: Wed Nov 5 22:55:41 2008
New Revision: 899
URL: http://yt.spacepope.org/changeset/899
Log:
Using pypdf, we can not call "save_book" on a PlotCollection to generate a PDF
file with all the plots in it, in order.
Additionally, there's a concatenate_pdfs function in raven that will let you
turns a whole bunch of PDFs (maybe from different PlotCollections) and turn
them into a single PDF.
Modified:
trunk/setup.py
trunk/yt/raven/PlotCollection.py
Modified: trunk/setup.py
==============================================================================
--- trunk/setup.py (original)
+++ trunk/setup.py Wed Nov 5 22:55:41 2008
@@ -53,7 +53,8 @@
keywords='astronomy astrophysics visualization amr adaptivemeshrefinement',
install_requires = ['matplotlib', 'numpy','ipython'],
extras_require = { 'GUI' : ['wxPython'],
- 'storage' : ['tables'], },
+ 'storage' : ['tables'],
+ 'pdf' : ['pypdf']},
entry_points = { 'console_scripts' : [
'yt_timeseries = yt.commands:timeseries',
'yt_zoomin = yt.commands:zoomin']
Modified: trunk/yt/raven/PlotCollection.py
==============================================================================
--- trunk/yt/raven/PlotCollection.py (original)
+++ trunk/yt/raven/PlotCollection.py Wed Nov 5 22:55:41 2008
@@ -25,6 +25,15 @@
from yt.raven import *
+# No better place to put this
+def concatenate_pdfs(output_fn, input_fns):
+ from pyPdf import PdfFileWriter, PdfFileReader
+ outfile = PdfFileWriter()
+ for fn in input_fns:
+ infile = PdfFileReader(open(fn, 'rb'))
+ outfile.addPage(infile.getPage(0))
+ outfile.write(open(output_fn, "wb"))
+
class PlotCollection:
__id_counter = 0
def __init__(self, pf, deliverator_id=-1, center=None):
@@ -395,6 +404,13 @@
del self.plots[-1].data
del self.plots[-1]
+ def save_book(self, filename):
+ from pyPdf import PdfFileWriter, PdfFileReader
+ outfile = PdfFileWriter()
+ fns = self.save("__temp", format="pdf")
+ concatenate_pdfs(filename, fns)
+ for fn in fns: os.unlink(fn)
+
def wrap_pylab_newplot(func):
@wraps(func)
def pylabify(self, *args, **kwargs):
More information about the yt-svn
mailing list