[Yt-svn] yt: 2 new changesets

hg at spacepope.org hg at spacepope.org
Thu Feb 3 13:05:59 PST 2011


hg Repository: yt
details:   yt/rev/f402289f07ca
changeset: 3712:f402289f07ca
user:      Matthew Turk <matthewturk at gmail.com>
date:
Wed Dec 08 17:07:17 2010 -0800
description:
Adding docstrings for several data objects.

hg Repository: yt
details:   yt/rev/a94c1e154226
changeset: 3713:a94c1e154226
user:      Matthew Turk <matthewturk at gmail.com>
date:
Thu Dec 09 10:02:59 2010 -0800
description:
Documented some 2D data objects.

diffstat:

 yt/data_objects/data_containers.py |  323 +++++++++++++++++++++++++++++++++---
 1 files changed, 291 insertions(+), 32 deletions(-)

diffs (truncated from 396 to 300 lines):

diff -r 993c49faa159 -r a94c1e154226 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py	Tue Feb 01 22:35:44 2011 -0500
+++ b/yt/data_objects/data_containers.py	Thu Dec 09 10:02:59 2010 -0800
@@ -186,6 +186,7 @@
         self._point_indices = {}
         self._vc_data = {}
         for key, val in kwargs.items():
+            mylog.info("Setting %s to %s", key, val)
             self.set_field_parameter(key, val)
 
     def __set_default_field_parameters(self):
@@ -467,8 +468,36 @@
     _con_args = ('axis', 'coords')
     def __init__(self, axis, coords, fields=None, pf=None, **kwargs):
         """
-        Dimensionality is reduced to one, and an ordered list of points at an
-        (x,y) tuple along *axis* are available.
+        This is an orthogonal ray cast through the entire domain, at a specific
+        coordinate.
+
+        This object is typically accessed through the `ortho_ray` object that
+        hangs off of hierarchy objects.  The resulting arrays have their
+        dimensionality reduced to one, and an ordered list of points at an
+        (x,y) tuple along `axis` are available.
+
+        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 (plane_x, plane_y) coordinates at which to cast the ray.  Note
+            that this is in the plane coordinates: so if you are casting along
+            x, this will be (y,z).  If you are casting along y, this will be
+            (x,z).  If you are casting along z, this will be (x,y).
+        fields : list of strings, optional
+            If you want the object to pre-retrieve a set of fields, supply them
+            here.  This is not necessary.
+        kwargs : dict of items
+            Any additional values are passed as field parameters that can be
+            accessed by generated fields.
+
+        Examples
+        --------
+
+        >>> pf = load("RedshiftOutput0005")
+        >>> oray = pf.h.ortho_ray(0, (0.2, 0.74))
+        >>> print oray["Density"]
         """
         AMR1DData.__init__(self, pf, fields, **kwargs)
         self.axis = axis
@@ -519,8 +548,35 @@
     sort_by = 't'
     def __init__(self, start_point, end_point, fields=None, pf=None, **kwargs):
         """
-        We accept a start point and an end point and then get all the data
-        between those two.
+        This is an arbitrarily-aligned ray cast through the entire domain, at a
+        specific coordinate.
+
+        This object is typically accessed through the `ray` object that hangs
+        off of hierarchy objects.  The resulting arrays have their
+        dimensionality reduced to one, and an ordered list of points at an
+        (x,y) tuple along `axis` are available, as is the `t` field, which
+        corresponds to a unitless measurement along the ray from start to
+        end.
+
+        Parameters
+        ----------
+        start_point : array-like set of 3 floats
+            The place where the ray starts.
+        end_point : array-like set of 3 floats
+            The place where the ray ends.
+        fields : list of strings, optional
+            If you want the object to pre-retrieve a set of fields, supply them
+            here.  This is not necessary.
+        kwargs : dict of items
+            Any additional values are passed as field parameters that can be
+            accessed by generated fields.
+
+        Examples
+        --------
+
+        >>> pf = load("RedshiftOutput0005")
+        >>> ray = pf.h._ray((0.2, 0.74), (0.4, 0.91))
+        >>> print ray["Density"], ray["t"]
         """
         AMR1DData.__init__(self, pf, fields, **kwargs)
         self.start_point = na.array(start_point, dtype='float64')
@@ -712,13 +768,6 @@
         self._store_fields(self.fields, node_name, force)
 
 class AMRSliceBase(AMR2DData):
-    """
-    AMRSlice is an orthogonal slice through the data, taking all the points
-    at the finest resolution available and then indexing them.  It is more
-    appropriately thought of as a slice 'operator' than an object,
-    however, as its field and coordinate can both change.
-    """
-
     _top_node = "/Slices"
     _type_name = "slice"
     _con_args = ('axis', 'coord')
@@ -726,8 +775,42 @@
     def __init__(self, axis, coord, fields = None, center=None, pf=None,
                  node_name = False, **kwargs):
         """
-        Slice along *axis*:ref:`axis-specification`, at the coordinate *coord*.
-        Optionally supply fields.
+        This is a data object corresponding to a slice through the simulation
+        domain.
+
+        This object is typically accessed through the `slice` object that hangs
+        off of hierarchy objects.  AMRSlice is an orthogonal slice through the
+        data, taking all the points at the finest resolution available and then
+        indexing them.  It is more appropriately thought of as a slice
+        'operator' than an object, however, as its field and coordinate can
+        both change.
+
+        Parameters
+        ----------
+        axis : int
+            The axis along which to slice.  Can be 0, 1, or 2 for x, y, z.
+        coord : float
+            The coordinate along the axis at which to slice.  This is in
+            "domain" coordinates.
+        fields : list of strings, optional
+            If you want the object to pre-retrieve a set of fields, supply them
+            here.  This is not necessary.
+        center : array_like, optional
+            The 'center' supplied to fields that use it.  Note that this does
+            not have to have `coord` as one value.  Strictly optional.
+        node_name: string, optional
+            The node in the .yt file to find or store this slice at.  Should
+            probably not be used.
+        kwargs : dict of items
+            Any additional values are passed as field parameters that can be
+            accessed by generated fields.
+
+        Examples
+        --------
+
+        >>> pf = load("RedshiftOutput0005")
+        >>> slice = pf.h.slice(0, 0.25)
+        >>> print slice["Density"]
         """
         AMR2DData.__init__(self, axis, fields, pf, **kwargs)
         self._set_center(center)
@@ -866,12 +949,6 @@
     quantities = property(__get_quantities)
 
 class AMRCuttingPlaneBase(AMR2DData):
-    """
-    AMRCuttingPlane is an oblique plane through the data,
-    defined by a normal vector and a coordinate.  It attempts to guess
-    an 'up' vector, which cannot be overridden, and then it pixelizes
-    the appropriate data onto the plane without interpolation.
-    """
     _plane = None
     _top_node = "/CuttingPlanes"
     _key_fields = AMR2DData._key_fields + ['pz','pdz']
@@ -880,9 +957,47 @@
     def __init__(self, normal, center, fields = None, node_name = None,
                  **kwargs):
         """
-        The Cutting Plane slices at an oblique angle, where we use
-        the *normal* vector and the *center* to define the viewing plane.
-        The 'up' direction is guessed at automatically.
+        This is a data object corresponding to an oblique slice through the
+        simulation domain.
+
+        This object is typically accessed through the `cutting` object
+        that hangs off of hierarchy objects.  AMRCuttingPlane is an oblique
+        plane through the data, defined by a normal vector and a coordinate.
+        It attempts to guess an 'up' vector, which cannot be overridden, and
+        then it pixelizes the appropriate data onto the plane without
+        interpolation.
+
+        Parameters
+        ----------
+        normal : array_like
+            The vector that defines the desired plane.  For instance, the
+            angular momentum of a sphere.
+        center : array_like, optional
+            The center of the cutting plane.
+        fields : list of strings, optional
+            If you want the object to pre-retrieve a set of fields, supply them
+            here.  This is not necessary.
+        node_name: string, optional
+            The node in the .yt file to find or store this slice at.  Should
+            probably not be used.
+        kwargs : dict of items
+            Any additional values are passed as field parameters that can be
+            accessed by generated fields.
+
+        Notes
+        -----
+
+        This data object in particular can be somewhat expensive to create.
+        It's also important to note that unlike the other 2D data objects, this
+        oject provides px, py, pz, as some cells may have a height from the
+        plane.
+
+        Examples
+        --------
+
+        >>> pf = load("RedshiftOutput0005")
+        >>> cp = pf.h.cutting([0.1, 0.2, -0.9], [0.5, 0.42, 0.6])
+        >>> print cp["Density"]
         """
         AMR2DData.__init__(self, 4, fields, **kwargs)
         self._set_center(center)
@@ -1213,10 +1328,66 @@
                  source=None, node_name = None, field_cuts = None,
                  preload_style='level', serialize=True,**kwargs):
         """
-        AMRProj is a projection of a *field* along an *axis*.  The field
-        can have an associated *weight_field*, in which case the values are
-        multiplied by a weight before being summed, and then divided by the sum
-        of that weight.
+        This is a data object corresponding to a line integral through the
+        simulation domain.
+
+        This object is typically accessed through the `quad_proj` object that
+        hangs off of hierarchy objects.  AMRQuadProj is a projection of a
+        `field` along an `axis`.  The field can have an associated
+        `weight_field`, in which case the values are multiplied by a weight
+        before being summed, and then divided by the sum of that weight; the
+        two fundamental modes of operating are direct line integral (no
+        weighting) and average along a line of sight (weighting.)  What makes
+        `quad_proj` different from the standard projection mechanism is that it
+        utilizes a quadtree data structure, rather than the old mechanism for
+        projections.  It will not run in parallel, but serial runs should be
+        substantially faster.  Note also that lines of sight are integrated at
+        every projected finest-level cell.
+
+        Parameters
+        ----------
+        axis : int
+            The axis along which to slice.  Can be 0, 1, or 2 for x, y, z.
+        field : string
+            This is the field which will be "projected" along the axis.  If
+            multiple are specified (in a list) they will all be projected in
+            the first pass.
+        weight_field : string
+            If supplied, the field being projected will be multiplied by this
+            weight value before being integrated, and at the conclusion of the
+            projection the resultant values will be divided by the projected
+            `weight_field`.
+        max_level : int
+            If supplied, only cells at or below this level will be projected.
+        center : array_like, optional
+            The 'center' supplied to fields that use it.  Note that this does
+            not have to have `coord` as one value.  Strictly optional.
+        source : `yt.data_objects.api.AMRData`, optional
+            If specified, this will be the data source used for selecting
+            regions to project.
+        node_name: string, optional
+            The node in the .yt file to find or store this slice at.  Should
+            probably not be used.
+        field_cuts : list of strings, optional
+            If supplied, each of these strings will be evaluated to cut a
+            region of a grid out.  They can be of the form "grid['Temperature']
+            > 100" for instance.
+        preload_style : string
+            Either 'level' (default) or 'all'.  Defines how grids are loaded --
+            either level by level, or all at once.  Only applicable during
+            parallel runs.
+        serialize : bool, optional
+            Whether we should store this projection in the .yt file or not.
+        kwargs : dict of items
+            Any additional values are passed as field parameters that can be
+            accessed by generated fields.
+
+        Examples
+        --------
+
+        >>> pf = load("RedshiftOutput0005")
+        >>> qproj = pf.h.quad_proj(0, "Density")
+        >>> print qproj["Density"]
         """
         AMR2DData.__init__(self, axis, field, pf, node_name = None, **kwargs)
         self.weight_field = weight_field
@@ -1437,10 +1608,62 @@
                  source=None, node_name = None, field_cuts = None,
                  preload_style='level', serialize=True,**kwargs):
         """
-        AMRProj is a projection of a *field* along an *axis*.  The field
-        can have an associated *weight_field*, in which case the values are
-        multiplied by a weight before being summed, and then divided by the sum
-        of that weight.
+        This is a data object corresponding to a line integral through the
+        simulation domain.
+
+        This object is typically accessed through the `proj` object that
+        hangs off of hierarchy objects.  AMRProj is a projection of a `field`
+        along an `axis`.  The field can have an associated `weight_field`, in
+        which case the values are multiplied by a weight before being summed,
+        and then divided by the sum of that weight; the two fundamental modes
+        of operating are direct line integral (no weighting) and average along
+        a line of sight (weighting.)  Note also that lines of sight are



More information about the yt-svn mailing list