[Yt-svn] yt: 2 new changesets
hg at spacepope.org
hg at spacepope.org
Wed Jun 9 05:00:10 PDT 2010
hg Repository: yt
details: yt/rev/ecf95c26193d
changeset: 1764:ecf95c26193d
user: Matthew Turk <matthewturk at gmail.com>
date:
Tue Jun 08 17:07:21 2010 -0400
description:
Adding more docstrings
hg Repository: yt
details: yt/rev/2298396aca46
changeset: 1765:2298396aca46
user: Matthew Turk <matthewturk at gmail.com>
date:
Tue Jun 08 17:16:09 2010 -0400
description:
Last couple docstrings for PlotCollection!
diffstat:
yt/raven/plot_collection.py | 190 +++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 167 insertions(+), 23 deletions(-)
diffs (221 lines):
diff -r 7e381df9ded8 -r 2298396aca46 yt/raven/plot_collection.py
--- a/yt/raven/plot_collection.py Mon Jun 07 23:45:30 2010 -0400
+++ b/yt/raven/plot_collection.py Tue Jun 08 17:16:09 2010 -0400
@@ -1166,6 +1166,7 @@
>>> plot_options = {'color':'b'})
"""
if id is None: id = self._get_new_id()
+ if plot_options is None: plot_options = {}
sp = PlotTypes.ScatterPlot(data_source, fields, id,
plot_options = plot_options,
figure=figure, axes=axes)
@@ -1226,43 +1227,186 @@
p["Axis"] = "na"
return p
- def add_ortho_ray(self, axis, coords, field, axes = None,
- figure = None, **kwargs):
- data_source = self.pf.h.ortho_ray(axis, coords, field)
+ def add_ortho_ray(self, axis, coords, field, figure = None,
+ axes = None, field_parameters = None,
+ plot_options = None):
+ r"""Create a ray parallel to some axis, from that a line plot, and add
+ it to the current collection.
+
+ This function will generate a `yt.lagos.AMROrthoRayBase` from the given
+ parameters. This ray then gets passed to a `yt.raven.LineQueryPLot`, and
+ the resultant plot is added to the current collection. Various
+ parameters allow control of the way the line plot is displayed, as well as
+ how the ray is generated.
+
+ Parameters
+ ----------
+ axis : int
+ The axis along which to cast the ray. Can be 0, 1, or 2 for x, y,
+ z.
+ coords : tuple of floats
+ The coordinates to place the ray at. Note that the axes are in the
+ form of x_dict[axis] and y_dict[axis] for some axis.
+ field : string
+ The initial field to slice and display.
+ figure : `matplotlib.figure.Figure`, optional
+ The figure onto which the axes will be placed. Typically not used
+ unless *axes* is also specified.
+ axes : `matplotlib.axes.Axes`, optional
+ The axes object which will be used to create the image plot.
+ Typically used for things like multiplots and the like.
+ field_parameters : dict, optional
+ This set of parameters will be passed to the slice upon creation,
+ which can be used for passing variables to derived fields.
+ plot_options : dict
+ These options will be given to `matplotlib.axes.Axes.plot`
+
+ Returns
+ -------
+ plot : `yt.raven.LineQueryPlot`
+ The plot that has been added to the PlotCollection.
+
+ See Also
+ --------
+ yt.lagos.AMROrthoRayBase : This is the type created by this function and
+ passed to the plot created here.
+
+ Examples
+ --------
+
+ This will cast a ray from (0.0, 0.5, 0.5) to (1.0, 0.5, 0.5) and plot
+ it.
+
+ >>> pf = load("RD0005-mine/RedshiftOutput0005")
+ >>> pc = PlotCollection(pf, [0.5, 0.5, 0.5])
+ >>> p = pc.add_ortho_ray(0, (0.5, 0.5), "Density")
+ """
+
+ if field_parameters is None: field_parameters = {}
+ if plot_options is None: plot_options = {}
+ data_source = self.pf.h.ortho_ray(axis, coords, field,
+ **field_parameters)
p = self._add_plot(PlotTypes.LineQueryPlot(data_source,
[axis_names[axis], field], self._get_new_id(),
- figure, axes, plot_options=kwargs))
+ figure, axes, plot_options=plot_options))
return p
- def add_ray(self, start_point, end_point, field, axes = None,
- figure = None, **kwargs):
- data_source = self.pf.h.ray(start_point, end_point, field)
+ def add_ray(self, start_point, end_point, field, figure = None,
+ axes = None, plot_options = None):
+ r"""Create a ray between two points, from that a line plot, and add
+ it to the current collection.
+
+ This function will generate a `yt.lagos.AMRRayBase` from the given
+ parameters. This ray then gets passed to a `yt.raven.LineQueryPLot`, and
+ the resultant plot is added to the current collection. Various
+ parameters allow control of the way the line plot is displayed, as well as
+ how the ray is generated.
+
+ Parameters
+ ----------
+ start_point : array_like
+ The starting point of the ray.
+ end_point : array_like
+ The ending point of the ray.
+ field : string
+ The initial field to slice and display.
+ figure : `matplotlib.figure.Figure`, optional
+ The figure onto which the axes will be placed. Typically not used
+ unless *axes* is also specified.
+ axes : `matplotlib.axes.Axes`, optional
+ The axes object which will be used to create the image plot.
+ Typically used for things like multiplots and the like.
+ field_parameters : dict, optional
+ This set of parameters will be passed to the slice upon creation,
+ which can be used for passing variables to derived fields.
+ plot_options : dict
+ These options will be given to `matplotlib.axes.Axes.plot`
+
+ Returns
+ -------
+ plot : `yt.raven.LineQueryPlot`
+ The plot that has been added to the PlotCollection.
+
+ See Also
+ --------
+ yt.lagos.AMRRayBase : This is the type created by this function and
+ passed to the plot created here.
+
+ Examples
+ --------
+
+ This will cast a ray from (0.1, 0.2, 0.3) to (0.9, 0.7, 0.4) and plot
+ it.
+
+ >>> pf = load("RD0005-mine/RedshiftOutput0005")
+ >>> pc = PlotCollection(pf, [0.5, 0.5, 0.5])
+ >>> p = pc.add_ray((0.1, 0.2, 0.3), (0.9, 0.7, 0.4), "Density")
+ """
+ if field_parameters is None: field_parameters = {}
+ if plot_options is None: plot_options = {}
+ data_source = self.pf.h.ray(start_point, end_point, field,
+ **field_parameters)
p = self._add_plot(PlotTypes.LineQueryPlot(data_source,
['t', field], self._get_new_id(),
- figure, axes, plot_options=kwargs))
+ figure, axes, plot_options=plot_options))
return p
def _get_new_id(self):
self.__id_counter += 1
return self.__id_counter-1
+ @rootonly
+ def save_book(self, filename, author = None, title = None, keywords = None,
+ subject = None, creator = None, producer = None,
+ creation_data = None):
+ r"""Save a multipage PDF of all the current plots, rather than
+ individual image files.
- def clear_plots(self):
- """
- Delete all plots and their attendant data.
- """
- for i in range(len(self.plots)):
- del self.plots[-1].data
- del self.plots[-1]
+ This function will utilize the matplotlib PDF backend to create a new
+ PDF, and for every plot that the PlotCollection currently has, it will
+ render a new page into that PDF. The pages will be in the order of the
+ current plots.
- @rootonly
- def save_book(self, filename, info = None):
- """
- This will save out a single PDF, where each page is a plot object. The
- *info* keyword can be a dictionary composed of the keys and values
- "Author", "Title", "Subject", "Keywords", "Creator", "Producer" ad
- "CreationDate". Any keywords not filled in will be blank. The default
- is to use the current settings in Matplotlib for filling them in.
+ Parameters
+ ----------
+ filename : string
+ The name of the PDF file to generate. Note that it will be
+ overwritten, and '.pdf' will not be appended.
+ author : string, optional
+ The string to place in the metadata value of the PDF for 'author'.
+ title : string, optional
+ The string to place in the metadata value of the PDF for 'title'.
+ keywords : string, optional
+ The string to place in the metadata value of the PDF for 'keywords'.
+ subject : string, optional
+ The string to place in the metadata value of the PDF for 'subject'.
+ creator : string, optional
+ The string to place in the metadata value of the PDF for 'creator'.
+ producer : string, optional
+ The string to place in the metadata value of the PDF for 'producer'.
+ creation_date : string, optional
+ The string to place in the metadata value of the PDF for
+ 'creation_date'.
+
+ Returns
+ -------
+ Nothing
+
+ Examples
+ --------
+ This will set up a new PlotCollection, add some plots, and then save it
+ as a PDF.
+
+ >>> pc = PlotCollection(pf, [0.5, 0.5, 0.5])
+ >>> pc.add_projection("Density", 0)
+ >>> pc.add_projection("Density", 1)
+ >>> pc.add_projection("Density", 2)
+ >>> pc.set_width(0.5, 'pc')
+ >>> dd = pf.h.all_data()
+ >>> pc.add_phase_object(dd, ["Density", "Temperature", "CellMassMsun"],
+ ... weight = None)
+ >>> pc.save_book("my_plots.pdf", author="Matthew Turk",
+ ... title="Fun plots")
"""
from matplotlib.backends.backend_pdf import PdfPages
outfile = PdfPages(filename)
More information about the yt-svn
mailing list