[Yt-svn] yt-commit r1740 - trunk/yt/raven

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Fri Jun 4 23:20:10 PDT 2010


Author: mturk
Date: Fri Jun  4 23:20:09 2010
New Revision: 1740
URL: http://yt.enzotools.org/changeset/1740

Log:
Porting back the docstrings for the FRB



Modified:
   trunk/yt/raven/FixedResolution.py

Modified: trunk/yt/raven/FixedResolution.py
==============================================================================
--- trunk/yt/raven/FixedResolution.py	(original)
+++ trunk/yt/raven/FixedResolution.py	Fri Jun  4 23:20:09 2010
@@ -28,12 +28,55 @@
 import _MPL
 class FixedResolutionBuffer(object):
     def __init__(self, data_source, bounds, buff_size, antialias = True):
-        """
-        Accepts a 2D data object, such as a Projection or Slice, and implements
-        a protocol for generating a pixelized, fixed-resolution buffer.
-        *bounds* is (px_min,px_max,py_min,py_max), *buff_size* is 
-        (width, height), and antialias is a boolean referring to whether or not
-        the buffer should have pixel boundary antialiasing.
+        r"""
+        FixedResolutionBuffer(data_source, bounds, buff_size, antialias = True)
+
+        This accepts a 2D data object, such as a Projection or Slice, and
+        implements a protocol for generating a pixelized, fixed-resolution
+        image buffer.
+
+        yt stores 2D AMR data internally as a set of 2D coordinates and the
+        half-width of individual pixels.  Converting this to an image buffer
+        requires a deposition step, where individual variable-resolution pixels
+        are deposited into a buffer of some resolution, to create an image.
+        This object is an interface to that pixelization step: it can deposit
+        multiple fields.  It acts as a standard AMRData object, such that
+        dict-style access returns an image of a given field.
+
+        Parameters
+        ----------
+        data_source : :class:`yt.lagos.AMRProjBase` or :class:`yt.lagos.AMRSliceBase`
+            This is the source to be pixelized, which can be a projection or a
+            slice.  (For cutting planes, see
+            `yt.raven.ObliqueFixedResolutionBuffer`.)
+        bounds : sequence of floats
+            Bounds are the min and max in the image plane that we want our
+            image to cover.  It's in the order of (xmin, xmax, ymin, ymax),
+            where the coordinates are all in the appropriate code units.
+        buff_size : sequence of ints
+            The size of the image to generate.
+        antialias : boolean
+            This can be true or false.  It determines whether or not sub-pixel
+            rendering is used during data deposition.
+
+        See Also
+        --------
+        :class:`yt.raven.ObliqueFixedResolutionBuffer` : A similar object,
+                                                         used for cutting
+                                                         planes.
+
+        Examples
+        --------
+        To make a projection and then several images, you can generate multiple
+        images.
+
+        >>> proj = pf.h.slice(0, "Density")
+        >>> frb1 = FixedResolutionBuffer(proj, (0.2, 0.3, 0.4, 0.5),
+                        (1024, 1024))
+        >>> print frb1["Density"].max()
+        1.0914e-9
+        >>> print frb1["Temperature"].max()
+        104923.1
         """
         self.data_source = data_source
         self.pf = data_source.pf
@@ -59,8 +102,19 @@
         self.data[item] = val
 
     def convert_to_pixel(self, coords):
-        """
-        This converts a code-location to an image-location
+        r"""This function converts coordinates in code-space to pixel-space.
+
+        Parameters
+        ----------
+        coords : sequence of array_like
+            This is (x_coord, y_coord).  Because of the way the math is done,
+            these can both be arrays.
+
+        Returns
+        -------
+        output : sequence of array_like
+            This returns px_coord, py_coord
+
         """
         dpx = (self.bounds[1]-self.bounds[0])/self.buff_size[0]
         dpy = (self.bounds[3]-self.bounds[2])/self.buff_size[1]
@@ -69,23 +123,53 @@
         return (px, py)
 
     def convert_distance_x(self, distance):
-        """
-        This converts a real distance to a pixel distance in x.
+        r"""This function converts code-space distance into pixel-space
+        distance in the x-coordiante.
+
+        Parameters
+        ----------
+        distance : array_like
+            This is x-distance in code-space you would like to convert.
+
+        Returns
+        -------
+        output : array_like
+            The return value is the distance in the y-pixel coordinates.
+
         """
         dpx = (self.bounds[1]-self.bounds[0])/self.buff_size[0]
         return distance/dpx
         
     def convert_distance_y(self, distance):
-        """
-        This converts a real distance to a pixel distance in y.
+        r"""This function converts code-space distance into pixel-space
+        distance in the y-coordiante.
+
+        Parameters
+        ----------
+        distance : array_like
+            This is y-distance in code-space you would like to convert.
+
+        Returns
+        -------
+        output : array_like
+            The return value is the distance in the x-pixel coordinates.
+
         """
         dpy = (self.bounds[3]-self.bounds[2])/self.buff_size[1]
         return distance/dpy
 
     def export_hdf5(self, filename, fields = None):
-        """
-        This function opens (append-mode) an HDF5 file and adds all of the
-        requested *fields* (default: All) to the top level of the data file.
+        r"""Export a set of fields to a set of HDF5 datasets.
+
+        This function will export any number of fields into datasets in a new
+        HDF5 file.
+        
+        Parameters
+        ----------
+        filename : string
+            This file will be opened in "append" mode.
+        fields : list of strings
+            These fields will be pixelized and output.
         """
         import h5py
         if fields is None: fields = self.data.keys()
@@ -104,6 +188,21 @@
         This requires the *pyfits* module, which is a standalone module
         provided by STSci to interface with FITS-format files.
         """
+        r"""Export a set of pixelized fields to a set of fits files.
+
+        This will export a set of FITS images of either the fields specified
+        or all the fields already in the object.  The output filenames are
+        the specified prefix plus an underscore plus the name of the field.
+
+        Parameters
+        ----------
+        filename_prefix : string
+            This prefix will be prepended to every FITS file name.
+        fields : list of strings
+            These fields will be pixelized and output.
+        clobber : boolean
+            If the file exists, this governs whether we will overwrite.
+        """
         import pyfits
         extra_fields = ['x','y','z','px','py','pz','pdx','pdy','pdz','weight_field']
         if filename_prefix.endswith('.fits'): filename_prefix=filename_prefix[:-5]
@@ -120,9 +219,22 @@
 
     def open_in_ds9(self, field, take_log=True):
         """
-        This will open a given field in DS9.  This requires the *numdisplay*
-        package, which is a simple download from STSci.  Furthermore, it
-        presupposed that it can connect to DS9 -- that is, that DS9 is already open.
+        This will open a given field in the DS9 viewer.
+
+        Displaying fields can often be much easier in an interactive viewer,
+        particularly one as versatile as DS9.  This function will pixelize a
+        field and export it to an interactive DS9 package.  This requires the
+        *numdisplay* package, which is a simple download from STSci.
+        Furthermore, it presupposed that it can connect to DS9 -- that is, that
+        DS9 is already open.
+
+        Parameters
+        ----------
+        field : strings
+            This field will be pixelized and displayed.
+        take_log : boolean
+            DS9 seems to have issues with logging fields in-memory.  This will
+            pre-log the field before sending it to DS9.
         """
         import numdisplay
         numdisplay.open()



More information about the yt-svn mailing list