[yt-svn] commit/yt: 16 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Nov 20 14:04:18 PST 2014


16 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/6dc13b55ea7f/
Changeset:   6dc13b55ea7f
Branch:      yt
User:        ngoldbaum
Date:        2014-11-18 22:49:33+00:00
Summary:     Wiring up a data_source keyword argument for SlicePlot
Affected #:  2 files

diff -r 6b9ada3a86ad7c86171132650c032e4d157f8f79 -r 6dc13b55ea7f5c24945052be5da119b809567aa9 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -562,7 +562,7 @@
             if data_source.ds is not self.ds:
                 raise RuntimeError("Attempted to construct a DataContainer with a data_source from a different DataSet", ds, data_source.ds)
             else:
-                print "DataSets: ", self.ds, data_source.ds
+                pass
             if data_source._dimensionality < self._dimensionality:
                 raise RuntimeError("Attempted to construct a DataContainer with a data_source of lower dimensionality (%u vs %u)" %
                                     (data_source._dimensionality, self._dimensionality))

diff -r 6b9ada3a86ad7c86171132650c032e4d157f8f79 -r 6dc13b55ea7f5c24945052be5da119b809567aa9 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1015,6 +1015,9 @@
     field_parameters : dictionary
          A dictionary of field parameters than can be accessed by derived
          fields.
+    data_source : YTSelectionContainer Object
+         Object to be used for data selection.  Defaults to a region covering
+         the entire simulation.
 
     Examples
     --------
@@ -1032,7 +1035,7 @@
 
     def __init__(self, ds, axis, fields, center='c', width=None, axes_unit=None,
                  origin='center-window', fontsize=18, field_parameters=None,
-                 window_size=8.0, aspect=None):
+                 window_size=8.0, aspect=None, data_source=None):
         # this will handle time series data and controllers
         ts = self._initialize_dataset(ds)
         self.ts = ts
@@ -1041,8 +1044,8 @@
         (bounds, center, display_center) = \
                 get_window_parameters(axis, center, width, ds)
         if field_parameters is None: field_parameters = {}
-        slc = ds.slice(axis, center[axis],
-            field_parameters = field_parameters, center=center)
+        slc = ds.slice(axis, center[axis], field_parameters = field_parameters, 
+                       center=center, data_source=data_source)
         slc.get_data(fields)
         PWViewerMPL.__init__(self, slc, bounds, origin=origin,
                              fontsize=fontsize, fields=fields,


https://bitbucket.org/yt_analysis/yt/commits/2a64d917059e/
Changeset:   2a64d917059e
Branch:      yt
User:        ngoldbaum
Date:        2014-11-19 08:17:04+00:00
Summary:     Adding a cut region selector.

This makes it possible to use cut_regions as slice data sources.
Affected #:  2 files

diff -r 6dc13b55ea7f5c24945052be5da119b809567aa9 -r 2a64d917059e99d0036fd5701a3d3a49265d17e6 yt/data_objects/selection_data_containers.py
--- a/yt/data_objects/selection_data_containers.py
+++ b/yt/data_objects/selection_data_containers.py
@@ -721,10 +721,6 @@
         # Need to interpose for __getitem__, fwidth, fcoords, icoords, iwidth,
         # ires and get_data
 
-    @property
-    def selector(self):
-        raise NotImplementedError
-
     def chunks(self, fields, chunking_style, **kwargs):
         # We actually want to chunk the sub-chunk, not ourselves.  We have no
         # chunks to speak of, as we do not data IO.

diff -r 6dc13b55ea7f5c24945052be5da119b809567aa9 -r 2a64d917059e99d0036fd5701a3d3a49265d17e6 yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -783,6 +783,43 @@
 
 region_selector = RegionSelector
 
+cdef class CutRegionSelector(SelectorObject):
+    cdef SelectorObject base_selector
+    cdef dict _positions
+
+    def __init__(self, dobj):
+        self.base_selector = <SelectorObject>dobj.base_object.selector
+        positions = np.array([dobj['x'], dobj['y'], dobj['z']]).T
+        self._positions = {}
+        for position in positions:
+            self._positions[tuple(position)] = 1
+
+    cdef int select_bbox(self,  np.float64_t left_edge[3],
+                     np.float64_t right_edge[3]) nogil:
+        return self.base_selector.select_bbox(left_edge, right_edge)
+
+    cdef int select_cell(self, np.float64_t pos[3], np.float64_t dds[3]) nogil:
+        ret = self.base_selector.select_cell(pos, dds)
+        if ret:
+            with gil:
+                if (pos[0], pos[1], pos[2]) in self._positions:
+                    return 1
+                else:
+                    return 0
+        else:
+            return ret
+
+    cdef int select_point(self, np.float64_t pos[3]) nogil:
+        return self.base_selector.select_point(pos)
+
+    cdef int select_sphere(self, np.float64_t pos[3], np.float64_t radius) nogil:
+        return self.base_selector.select_sphere(pos, radius)
+
+    def _hash_vals(self):
+        return self.base_selector._hash_vals()
+
+cut_region_selector = CutRegionSelector
+
 cdef class DiskSelector(SelectorObject):
     cdef np.float64_t norm_vec[3]
     cdef np.float64_t center[3]


https://bitbucket.org/yt_analysis/yt/commits/8808981b52a4/
Changeset:   8808981b52a4
Branch:      yt
User:        ngoldbaum
Date:        2014-11-19 08:28:17+00:00
Summary:     Adding documentation for slice data sources.
Affected #:  3 files

diff -r 2a64d917059e99d0036fd5701a3d3a49265d17e6 -r 8808981b52a4ce468b35c9aaf4092ff80747b478 doc/source/analyzing/filtering.rst
--- a/doc/source/analyzing/filtering.rst
+++ b/doc/source/analyzing/filtering.rst
@@ -193,7 +193,15 @@
     center = [0.20, 0.50, 0.10]
 
     sp = ds.sphere(center, (10, 'Mpc'))
-    prj = yt.ProjectionPlot(ds, "x", "density", center=center, width=(50, "Mpc"), data_source=sp)
+    prj = yt.ProjectionPlot(ds, "x", "density", center=center, width=(50, "Mpc"),
+                            data_source=sp)
 
     # Mark the center with a big X
     prj.annotate_marker(center, 'x', plot_args={'s':100})
+
+    prj.show()
+
+    slc = yt.SlicePlot(ds, "x", "density", center=c, width=(50, 'Mpc"),
+                       data_source=sp)
+
+    slc.show()

diff -r 2a64d917059e99d0036fd5701a3d3a49265d17e6 -r 8808981b52a4ce468b35c9aaf4092ff80747b478 doc/source/analyzing/mesh_filter.ipynb
--- a/doc/source/analyzing/mesh_filter.ipynb
+++ b/doc/source/analyzing/mesh_filter.ipynb
@@ -1,7 +1,16 @@
 {
  "metadata": {
+  "kernelspec": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 2
+   },
+   "display_name": "IPython (Python 2)",
+   "language": "python",
+   "name": "python2"
+  },
   "name": "",
-  "signature": "sha256:9e2b7844e9b6e998eafb1c8a2aacaa8419e6e544aacee754449ad4b0dfea1d85"
+  "signature": "sha256:512c0d425416f92fcb8a4049f521b2960ed3b77873c7e8af73b16cf6e31ee266"
  },
  "nbformat": 3,
  "nbformat_minor": 0,
@@ -41,7 +50,7 @@
      "input": [
       "ad = ds.all_data()\n",
       "hot_ad = ad.cut_region([\"obj['temperature'] > 1e6\"])\n",
-      "dense_ad = ad.cut_region(['obj[\"density\"] > 1e-29'])\n",
+      "dense_ad = ad.cut_region(['obj[\"density\"] > 5e-30'])\n",
       "overpressure_and_fast_ad = ad.cut_region(['(obj[\"pressure\"] > 1e-14) & (obj[\"velocity_magnitude\"].in_units(\"km/s\") > 1e2)'])"
      ],
      "language": "python",
@@ -70,7 +79,9 @@
      "cell_type": "markdown",
      "metadata": {},
      "source": [
-      "However, now we can use this cut_region object as a data source in generated Projections or Profiles or any other number of tasks.  Let's look at a density projection of the densest material, or the material which is overpressure and hot."
+      "However, now we can use this cut_region object as a data source in generated Projections or Profiles or any other number of tasks.  Let's look at a density projection of the densest material, or the material which is overpressure and hot.\n",
+      "\n",
+      "We can visualize this material using the `data_source` keyword argument to the initializers of yt's plotting classes."
      ]
     },
     {
@@ -90,7 +101,7 @@
      "collapsed": false,
      "input": [
       "proj = yt.ProjectionPlot(ds, 'x', \"density\", weight_field=\"density\", data_source=dense_ad)\n",
-      "proj.annotate_title('Only Dense Material')\n",
+      "proj.annotate_title('Dense Material')\n",
       "proj.set_zlim(\"density\", 3e-31, 3e-27)\n",
       "proj.show()"
      ],
@@ -103,13 +114,72 @@
      "collapsed": false,
      "input": [
       "proj = yt.ProjectionPlot(ds, 'x', \"density\", weight_field=\"density\", data_source=overpressure_and_fast_ad)\n",
-      "proj.annotate_title('Only Overpressure and Fast Material')\n",
+      "proj.annotate_title('Overpressured and Fast Material')\n",
       "proj.set_zlim(\"density\", 3e-31, 3e-27)\n",
       "proj.show()"
      ],
      "language": "python",
      "metadata": {},
      "outputs": []
+    },
+    {
+     "cell_type": "markdown",
+     "metadata": {},
+     "source": [
+      "The `data_source` keyword argument is also accepted by `SlicePlot` and `PhasePlot`:"
+     ]
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "slc = yt.SlicePlot(ds, 'x', \"density\")\n",
+      "slc.set_zlim('density', 3e-31, 3e-27)\n",
+      "slc.annotate_title('No Cuts')\n",
+      "slc.show()"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": []
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "slc = yt.SlicePlot(ds, 'x', \"density\", data_source=dense_ad)\n",
+      "slc.set_zlim('density', 3e-31, 1e-27)\n",
+      "slc.annotate_title('Dense Material')\n",
+      "slc.show()"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": []
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "ph = yt.PhasePlot(ad, 'density', 'temperature', 'cell_mass', weight_field=None)\n",
+      "ph.set_xlim(3e-31, 3e-27)\n",
+      "ph.set_title('cell_mass', 'No Cuts')\n",
+      "ph.show()"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": []
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "ph = yt.PhasePlot(dense_ad, 'density', 'temperature', 'cell_mass', weight_field=None)\n",
+      "ph.set_xlim(3e-31, 3e-27)\n",
+      "ph.set_title('cell_mass', 'Dense material')\n",
+      "ph.show()"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": []
     }
    ],
    "metadata": {}

diff -r 2a64d917059e99d0036fd5701a3d3a49265d17e6 -r 8808981b52a4ce468b35c9aaf4092ff80747b478 doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -172,6 +172,10 @@
 interesting region in the simulation and adjust the boundaries of the
 region to visualize on the fly.
 
+If you want to slice through a subset of the full dataset volume,
+you can use the ``data_source`` keyword with a :ref:`data object <data-objects>`
+or a :ref:`cut region <cut-regions>`.
+
 See :class:`~yt.visualization.plot_window.AxisAlignedSlicePlot` for the 
 full class description.
 


https://bitbucket.org/yt_analysis/yt/commits/55d8d1990f33/
Changeset:   55d8d1990f33
Branch:      yt
User:        ngoldbaum
Date:        2014-11-19 09:53:40+00:00
Summary:     small typo fix
Affected #:  1 file

diff -r 8808981b52a4ce468b35c9aaf4092ff80747b478 -r 55d8d1990f33a2c29b4bffa04393b9297e772afd doc/source/analyzing/mesh_filter.ipynb
--- a/doc/source/analyzing/mesh_filter.ipynb
+++ b/doc/source/analyzing/mesh_filter.ipynb
@@ -147,7 +147,7 @@
      "collapsed": false,
      "input": [
       "slc = yt.SlicePlot(ds, 'x', \"density\", data_source=dense_ad)\n",
-      "slc.set_zlim('density', 3e-31, 1e-27)\n",
+      "slc.set_zlim('density', 3e-31, 3e-27)\n",
       "slc.annotate_title('Dense Material')\n",
       "slc.show()"
      ],


https://bitbucket.org/yt_analysis/yt/commits/99dc43cd4010/
Changeset:   99dc43cd4010
Branch:      yt
User:        ngoldbaum
Date:        2014-11-19 18:59:12+00:00
Summary:     Removing an unneeded conditional.
Affected #:  1 file

diff -r 55d8d1990f33a2c29b4bffa04393b9297e772afd -r 99dc43cd40108965e21f1668c0316a08511c92e0 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -561,8 +561,6 @@
         if data_source is not None:
             if data_source.ds is not self.ds:
                 raise RuntimeError("Attempted to construct a DataContainer with a data_source from a different DataSet", ds, data_source.ds)
-            else:
-                pass
             if data_source._dimensionality < self._dimensionality:
                 raise RuntimeError("Attempted to construct a DataContainer with a data_source of lower dimensionality (%u vs %u)" %
                                     (data_source._dimensionality, self._dimensionality))


https://bitbucket.org/yt_analysis/yt/commits/fba23684b528/
Changeset:   fba23684b528
Branch:      yt
User:        ngoldbaum
Date:        2014-11-19 19:25:45+00:00
Summary:     Inherit field parameters when chaining selectors.
Affected #:  1 file

diff -r 99dc43cd40108965e21f1668c0316a08511c92e0 -r fba23684b52897d019fc89a83d45af499b03f811 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -560,11 +560,14 @@
         self._data_source = data_source
         if data_source is not None:
             if data_source.ds is not self.ds:
-                raise RuntimeError("Attempted to construct a DataContainer with a data_source from a different DataSet", ds, data_source.ds)
+                raise RuntimeError("Attempted to construct a DataContainer with a data_source "
+                                   "from a different DataSet", ds, data_source.ds)
             if data_source._dimensionality < self._dimensionality:
-                raise RuntimeError("Attempted to construct a DataContainer with a data_source of lower dimensionality (%u vs %u)" %
+                raise RuntimeError("Attempted to construct a DataContainer with a data_source "
+                                   "of lower dimensionality (%u vs %u)" %
                                     (data_source._dimensionality, self._dimensionality))
- 
+            self.field_parameters.update(data_source.field_parameters)
+
     @property
     def selector(self):
         if self._selector is not None: return self._selector


https://bitbucket.org/yt_analysis/yt/commits/4cc3cbfc621a/
Changeset:   4cc3cbfc621a
Branch:      yt
User:        ngoldbaum
Date:        2014-11-19 20:28:27+00:00
Summary:     Use a set instead of a dict to store the cell positions
Affected #:  1 file

diff -r fba23684b52897d019fc89a83d45af499b03f811 -r 4cc3cbfc621a8998c72527ec37d446d25aad9089 yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -785,14 +785,12 @@
 
 cdef class CutRegionSelector(SelectorObject):
     cdef SelectorObject base_selector
-    cdef dict _positions
+    cdef set _positions
 
     def __init__(self, dobj):
         self.base_selector = <SelectorObject>dobj.base_object.selector
         positions = np.array([dobj['x'], dobj['y'], dobj['z']]).T
-        self._positions = {}
-        for position in positions:
-            self._positions[tuple(position)] = 1
+        self._positions = set(tuple(position) for position in positions)
 
     cdef int select_bbox(self,  np.float64_t left_edge[3],
                      np.float64_t right_edge[3]) nogil:


https://bitbucket.org/yt_analysis/yt/commits/e431fb695adb/
Changeset:   e431fb695adb
Branch:      yt
User:        ngoldbaum
Date:        2014-11-19 20:29:09+00:00
Summary:     Center on the max density to have nicer cut region slices.
Affected #:  1 file

diff -r 4cc3cbfc621a8998c72527ec37d446d25aad9089 -r e431fb695adb29a24ee4bd89d6699c802e6723ac doc/source/analyzing/mesh_filter.ipynb
--- a/doc/source/analyzing/mesh_filter.ipynb
+++ b/doc/source/analyzing/mesh_filter.ipynb
@@ -10,7 +10,7 @@
    "name": "python2"
   },
   "name": "",
-  "signature": "sha256:512c0d425416f92fcb8a4049f521b2960ed3b77873c7e8af73b16cf6e31ee266"
+  "signature": "sha256:095ac25b44ba19b1455bf56a40f4250766b88fd8f667b16c8664d636af371c37"
  },
  "nbformat": 3,
  "nbformat_minor": 0,
@@ -133,7 +133,7 @@
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "slc = yt.SlicePlot(ds, 'x', \"density\")\n",
+      "slc = yt.SlicePlot(ds, 'x', \"density\", center='m')\n",
       "slc.set_zlim('density', 3e-31, 3e-27)\n",
       "slc.annotate_title('No Cuts')\n",
       "slc.show()"
@@ -146,7 +146,7 @@
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "slc = yt.SlicePlot(ds, 'x', \"density\", data_source=dense_ad)\n",
+      "slc = yt.SlicePlot(ds, 'x', \"density\", center='m', data_source=dense_ad)\n",
       "slc.set_zlim('density', 3e-31, 3e-27)\n",
       "slc.annotate_title('Dense Material')\n",
       "slc.show()"


https://bitbucket.org/yt_analysis/yt/commits/9673580da56d/
Changeset:   9673580da56d
Branch:      yt
User:        ngoldbaum
Date:        2014-11-19 20:43:04+00:00
Summary:     Tweaking the mesh filter notebook
Affected #:  1 file

diff -r e431fb695adb29a24ee4bd89d6699c802e6723ac -r 9673580da56d1697ef0503874ed076a5b0c5f260 doc/source/analyzing/mesh_filter.ipynb
--- a/doc/source/analyzing/mesh_filter.ipynb
+++ b/doc/source/analyzing/mesh_filter.ipynb
@@ -10,7 +10,7 @@
    "name": "python2"
   },
   "name": "",
-  "signature": "sha256:095ac25b44ba19b1455bf56a40f4250766b88fd8f667b16c8664d636af371c37"
+  "signature": "sha256:52f0d93ee48f7177ceabf6c524d0386930dc3cfdd0dc99ec1aa270d2d924344d"
  },
  "nbformat": 3,
  "nbformat_minor": 0,
@@ -79,44 +79,25 @@
      "cell_type": "markdown",
      "metadata": {},
      "source": [
-      "However, now we can use this cut_region object as a data source in generated Projections or Profiles or any other number of tasks.  Let's look at a density projection of the densest material, or the material which is overpressure and hot.\n",
+      "Now that we've constructed a `cut_region`, we can use it as a data source for further analysis. To create a plot based on a `cut_region`, use the `data_source` keyword argument provided by yt's plotting objects.\n",
       "\n",
-      "We can visualize this material using the `data_source` keyword argument to the initializers of yt's plotting classes."
+      "Here's an example using projections:"
      ]
     },
     {
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "proj = yt.ProjectionPlot(ds, 'x', \"density\", weight_field=\"density\")\n",
-      "proj.annotate_title('All Data, No Cuts')\n",
-      "proj.show()"
-     ],
-     "language": "python",
-     "metadata": {},
-     "outputs": []
-    },
-    {
-     "cell_type": "code",
-     "collapsed": false,
-     "input": [
-      "proj = yt.ProjectionPlot(ds, 'x', \"density\", weight_field=\"density\", data_source=dense_ad)\n",
-      "proj.annotate_title('Dense Material')\n",
-      "proj.set_zlim(\"density\", 3e-31, 3e-27)\n",
-      "proj.show()"
-     ],
-     "language": "python",
-     "metadata": {},
-     "outputs": []
-    },
-    {
-     "cell_type": "code",
-     "collapsed": false,
-     "input": [
-      "proj = yt.ProjectionPlot(ds, 'x', \"density\", weight_field=\"density\", data_source=overpressure_and_fast_ad)\n",
-      "proj.annotate_title('Overpressured and Fast Material')\n",
-      "proj.set_zlim(\"density\", 3e-31, 3e-27)\n",
-      "proj.show()"
+      "proj1 = yt.ProjectionPlot(ds, 'x', \"density\", weight_field=\"density\")\n",
+      "proj1.annotate_title('No Cuts')\n",
+      "proj1.set_figure_size(5)\n",
+      "proj1.show()\n",
+      "\n",
+      "proj2 = yt.ProjectionPlot(ds, 'x', \"density\", weight_field=\"density\", data_source=overpressure_and_fast_ad)\n",
+      "proj2.annotate_title('Hot Gas')\n",
+      "proj2.set_zlim(\"density\", 3e-31, 3e-27)\n",
+      "proj2.set_figure_size(5)\n",
+      "proj2.show()"
      ],
      "language": "python",
      "metadata": {},
@@ -133,10 +114,17 @@
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "slc = yt.SlicePlot(ds, 'x', \"density\", center='m')\n",
-      "slc.set_zlim('density', 3e-31, 3e-27)\n",
-      "slc.annotate_title('No Cuts')\n",
-      "slc.show()"
+      "slc1 = yt.SlicePlot(ds, 'x', \"density\", center='m')\n",
+      "slc1.set_zlim('density', 3e-31, 3e-27)\n",
+      "slc1.annotate_title('No Cuts')\n",
+      "slc1.set_figure_size(5)\n",
+      "slc1.show()\n",
+      "\n",
+      "slc2 = yt.SlicePlot(ds, 'x', \"density\", center='m', data_source=dense_ad)\n",
+      "slc2.set_zlim('density', 3e-31, 3e-27)\n",
+      "slc2.annotate_title('Dense Gas')\n",
+      "slc2.set_figure_size(5)\n",
+      "slc2.show()"
      ],
      "language": "python",
      "metadata": {},
@@ -146,36 +134,17 @@
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "slc = yt.SlicePlot(ds, 'x', \"density\", center='m', data_source=dense_ad)\n",
-      "slc.set_zlim('density', 3e-31, 3e-27)\n",
-      "slc.annotate_title('Dense Material')\n",
-      "slc.show()"
-     ],
-     "language": "python",
-     "metadata": {},
-     "outputs": []
-    },
-    {
-     "cell_type": "code",
-     "collapsed": false,
-     "input": [
-      "ph = yt.PhasePlot(ad, 'density', 'temperature', 'cell_mass', weight_field=None)\n",
-      "ph.set_xlim(3e-31, 3e-27)\n",
-      "ph.set_title('cell_mass', 'No Cuts')\n",
-      "ph.show()"
-     ],
-     "language": "python",
-     "metadata": {},
-     "outputs": []
-    },
-    {
-     "cell_type": "code",
-     "collapsed": false,
-     "input": [
-      "ph = yt.PhasePlot(dense_ad, 'density', 'temperature', 'cell_mass', weight_field=None)\n",
-      "ph.set_xlim(3e-31, 3e-27)\n",
-      "ph.set_title('cell_mass', 'Dense material')\n",
-      "ph.show()"
+      "ph1 = yt.PhasePlot(ad, 'density', 'temperature', 'cell_mass', weight_field=None)\n",
+      "ph1.set_xlim(3e-31, 3e-27)\n",
+      "ph1.set_title('cell_mass', 'No Cuts')\n",
+      "ph1.set_figure_size(5)\n",
+      "ph1.show()\n",
+      "\n",
+      "ph1 = yt.PhasePlot(dense_ad, 'density', 'temperature', 'cell_mass', weight_field=None)\n",
+      "ph1.set_xlim(3e-31, 3e-27)\n",
+      "ph1.set_title('cell_mass', 'Dense Gas')\n",
+      "ph1.set_figure_size(5)\n",
+      "ph1.show()"
      ],
      "language": "python",
      "metadata": {},


https://bitbucket.org/yt_analysis/yt/commits/417e1361f1a4/
Changeset:   417e1361f1a4
Branch:      yt
User:        ngoldbaum
Date:        2014-11-19 22:38:44+00:00
Summary:     Minor tweaks for mesh filter notebook.
Affected #:  1 file

diff -r 9673580da56d1697ef0503874ed076a5b0c5f260 -r 417e1361f1a437fa3e9cfdce4177c9f98a7e99e7 doc/source/analyzing/mesh_filter.ipynb
--- a/doc/source/analyzing/mesh_filter.ipynb
+++ b/doc/source/analyzing/mesh_filter.ipynb
@@ -10,7 +10,7 @@
    "name": "python2"
   },
   "name": "",
-  "signature": "sha256:52f0d93ee48f7177ceabf6c524d0386930dc3cfdd0dc99ec1aa270d2d924344d"
+  "signature": "sha256:5f32b65e9e3be2da39ec7206d0a9b680f41ae80584703e75cd9db4ac6511b43d"
  },
  "nbformat": 3,
  "nbformat_minor": 0,
@@ -107,20 +107,20 @@
      "cell_type": "markdown",
      "metadata": {},
      "source": [
-      "The `data_source` keyword argument is also accepted by `SlicePlot` and `PhasePlot`:"
+      "The `data_source` keyword argument is also accepted by `SlicePlot`, `ProfilePlot` and `PhasePlot`:"
      ]
     },
     {
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "slc1 = yt.SlicePlot(ds, 'x', \"density\", center='m')\n",
+      "slc1 = yt.SlicePlot(ds, 'x', \"density\", center='c')\n",
       "slc1.set_zlim('density', 3e-31, 3e-27)\n",
       "slc1.annotate_title('No Cuts')\n",
       "slc1.set_figure_size(5)\n",
       "slc1.show()\n",
       "\n",
-      "slc2 = yt.SlicePlot(ds, 'x', \"density\", center='m', data_source=dense_ad)\n",
+      "slc2 = yt.SlicePlot(ds, 'x', \"density\", center='c', data_source=dense_ad)\n",
       "slc2.set_zlim('density', 3e-31, 3e-27)\n",
       "slc2.annotate_title('Dense Gas')\n",
       "slc2.set_figure_size(5)\n",


https://bitbucket.org/yt_analysis/yt/commits/1d414118e0f8/
Changeset:   1d414118e0f8
Branch:      yt
User:        ngoldbaum
Date:        2014-11-19 23:01:20+00:00
Summary:     More tweaks for mesh_filter docs.
Affected #:  1 file

diff -r 417e1361f1a437fa3e9cfdce4177c9f98a7e99e7 -r 1d414118e0f89f47b60ed038fdcb9d5e1cd95e13 doc/source/analyzing/mesh_filter.ipynb
--- a/doc/source/analyzing/mesh_filter.ipynb
+++ b/doc/source/analyzing/mesh_filter.ipynb
@@ -10,7 +10,7 @@
    "name": "python2"
   },
   "name": "",
-  "signature": "sha256:5f32b65e9e3be2da39ec7206d0a9b680f41ae80584703e75cd9db4ac6511b43d"
+  "signature": "sha256:e7a3de4de9be6a2c653bc45ed2c7ef5fa19da15aafca165d331a3125befe4d6c"
  },
  "nbformat": 3,
  "nbformat_minor": 0,
@@ -51,6 +51,9 @@
       "ad = ds.all_data()\n",
       "hot_ad = ad.cut_region([\"obj['temperature'] > 1e6\"])\n",
       "dense_ad = ad.cut_region(['obj[\"density\"] > 5e-30'])\n",
+      "\n",
+      "# you can chain cut regions in two ways:\n",
+      "dense_and_cool_ad = dense_ad.cut_region([\"obj['temperature'] < 1e5\"])\n",
       "overpressure_and_fast_ad = ad.cut_region(['(obj[\"pressure\"] > 1e-14) & (obj[\"velocity_magnitude\"].in_units(\"km/s\") > 1e2)'])"
      ],
      "language": "python",
@@ -68,8 +71,19 @@
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "print 'Temperature of all data: ad[\"temperature\"] = \\n%s' % ad[\"temperature\"] \n",
-      "print 'Temperature of \"hot\" data: hot_ad[\"temperature\"] = \\n%s' % hot_ad['temperature']"
+      "print \"Temperature of all cells:\\n ad['temperature'] = \\n%s\\n\" % ad[\"temperature\"] \n",
+      "print \"Temperatures of all \\\"hot\\\" cells:\\n hot_ad['temperature'] = \\n%s\" % hot_ad['temperature']"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": []
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "print \"Density of dense, cool material:\\n dense_and_cool_ad['density'] = \\n%s\\n\" % dense_and_cool_ad['density']\n",
+      "print \"Temperature of dense, cool material:\\n dense_and_cool_ad['temperature'] = \\n%s\" % dense_and_cool_ad['temperature']"
      ],
      "language": "python",
      "metadata": {},
@@ -114,13 +128,13 @@
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "slc1 = yt.SlicePlot(ds, 'x', \"density\", center='c')\n",
+      "slc1 = yt.SlicePlot(ds, 'x', \"density\", center='m')\n",
       "slc1.set_zlim('density', 3e-31, 3e-27)\n",
       "slc1.annotate_title('No Cuts')\n",
       "slc1.set_figure_size(5)\n",
       "slc1.show()\n",
       "\n",
-      "slc2 = yt.SlicePlot(ds, 'x', \"density\", center='c', data_source=dense_ad)\n",
+      "slc2 = yt.SlicePlot(ds, 'x', \"density\", center='m', data_source=dense_ad)\n",
       "slc2.set_zlim('density', 3e-31, 3e-27)\n",
       "slc2.annotate_title('Dense Gas')\n",
       "slc2.set_figure_size(5)\n",


https://bitbucket.org/yt_analysis/yt/commits/9debe4025b13/
Changeset:   9debe4025b13
Branch:      yt
User:        ngoldbaum
Date:        2014-11-19 23:02:20+00:00
Summary:     Reworking the cut_region API to match the rest of yt's nomenclature.
Affected #:  1 file

diff -r 1d414118e0f89f47b60ed038fdcb9d5e1cd95e13 -r 9debe4025b13b5e2beb6a1040886ad62f2c74f2e yt/data_objects/selection_data_containers.py
--- a/yt/data_objects/selection_data_containers.py
+++ b/yt/data_objects/selection_data_containers.py
@@ -693,7 +693,7 @@
 
     Parameters
     ----------
-    base_object : YTSelectionContainer3D
+    data_source : YTSelectionContainer3D
         The object to which cuts will be applied.
     conditionals : list of strings
         A list of conditionals that will be evaluated.  In the namespace
@@ -710,13 +710,20 @@
     >>> cr = ds.cut_region(sp, ["obj['temperature'] < 1e3"])
     """
     _type_name = "cut_region"
-    _con_args = ("base_object", "conditionals")
-    def __init__(self, base_object, conditionals, ds=None,
-                 field_parameters=None, data_source=None):
-        super(YTCutRegionBase, self).__init__(base_object.center, ds,
-                                              field_parameters, data_source)
+    _con_args = ("data_source", "conditionals")
+    def __init__(self, data_source, conditionals, ds=None,
+                 field_parameters=None, base_object=None):
+        if base_object is not None:
+            # passing base_object explicitly has been deprecated,
+            # but we handle it here for backward compatibility
+            if data_source is not None:
+                raise RuntimeError(
+                    "Cannot use both base_object and data_source")
+            data_source=base_object
+        super(YTCutRegionBase, self).__init__(
+            data_source.center, ds, field_parameters)
         self.conditionals = ensure_list(conditionals)
-        self.base_object = base_object
+        self.base_object = data_source
         self._selector = None
         # Need to interpose for __getitem__, fwidth, fcoords, icoords, iwidth,
         # ires and get_data
@@ -725,8 +732,8 @@
         # We actually want to chunk the sub-chunk, not ourselves.  We have no
         # chunks to speak of, as we do not data IO.
         for chunk in self.index._chunk(self.base_object,
-                                           chunking_style,
-                                           **kwargs):
+                                       chunking_style,
+                                       **kwargs):
             with self.base_object._chunked_read(chunk):
                 with self._chunked_read(chunk):
                     self.get_data(fields)


https://bitbucket.org/yt_analysis/yt/commits/01f29a9a368d/
Changeset:   01f29a9a368d
Branch:      yt
User:        ngoldbaum
Date:        2014-11-19 23:02:41+00:00
Summary:     Making it possible to chain cut_regions
Affected #:  1 file

diff -r 9debe4025b13b5e2beb6a1040886ad62f2c74f2e -r 01f29a9a368dd0073ca74b48705f4cf870b51b9d yt/data_objects/selection_data_containers.py
--- a/yt/data_objects/selection_data_containers.py
+++ b/yt/data_objects/selection_data_containers.py
@@ -762,9 +762,6 @@
             if not np.any(m): continue
             yield obj, m
 
-    def cut_region(self, *args, **kwargs):
-        raise NotImplementedError
-
     @property
     def _cond_ind(self):
         ind = None


https://bitbucket.org/yt_analysis/yt/commits/5f6205b59ed3/
Changeset:   5f6205b59ed3
Branch:      yt
User:        ngoldbaum
Date:        2014-11-19 23:03:14+00:00
Summary:     Adding data_source for OffAxisSlicePlot
Affected #:  1 file

diff -r 01f29a9a368dd0073ca74b48705f4cf870b51b9d -r 5f6205b59ed36cb6ade524bf2882ffbb9da3ab64 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1042,9 +1042,10 @@
         ds = self.ds = ts[0]
         axis = fix_axis(axis, ds)
         (bounds, center, display_center) = \
-                get_window_parameters(axis, center, width, ds)
-        if field_parameters is None: field_parameters = {}
-        slc = ds.slice(axis, center[axis], field_parameters = field_parameters, 
+            get_window_parameters(axis, center, width, ds)
+        if field_parameters is None:
+            field_parameters = {}
+        slc = ds.slice(axis, center[axis], field_parameters=field_parameters,
                        center=center, data_source=data_source)
         slc.get_data(fields)
         PWViewerMPL.__init__(self, slc, bounds, origin=origin,
@@ -1279,6 +1280,9 @@
     field_parameters : dictionary
          A dictionary of field parameters than can be accessed by derived
          fields.
+    data_source : YTSelectionContainer Object
+         Object to be used for data selection.  Defaults to a region covering
+         the entire simulation.
     """
 
     _plot_type = 'OffAxisSlice'
@@ -1286,11 +1290,13 @@
 
     def __init__(self, ds, normal, fields, center='c', width=None,
                  axes_unit=None, north_vector=None, fontsize=18,
-                 field_parameters=None):
+                 field_parameters=None, data_source=None):
         (bounds, center_rot) = get_oblique_window_parameters(normal,center,width,ds)
-        if field_parameters is None: field_parameters = {}
-        cutting = ds.cutting(normal, center, north_vector = north_vector,
-                              field_parameters = field_parameters)
+        if field_parameters is None:
+            field_parameters = {}
+        cutting = ds.cutting(normal, center, north_vector=north_vector,
+                             field_parameters=field_parameters,
+                             data_source=data_source)
         cutting.get_data(fields)
         # Hard-coding the origin keyword since the other two options
         # aren't well-defined for off-axis data objects
@@ -1840,6 +1846,9 @@
     field_parameters : dictionary
          A dictionary of field parameters than can be accessed by derived
          fields.
+    data_source : YTSelectionContainer Object
+         Object to be used for data selection.  Defaults to a region covering
+         the entire simulation.
 
     Raises
     ------


https://bitbucket.org/yt_analysis/yt/commits/7649ae14bc92/
Changeset:   7649ae14bc92
Branch:      yt
User:        ngoldbaum
Date:        2014-11-20 01:08:51+00:00
Summary:     Simplifying the cut region selector.

h/t to Doug Rudd for the excellent suggestion.
Affected #:  2 files

diff -r 5f6205b59ed36cb6ade524bf2882ffbb9da3ab64 -r 7649ae14bc9235e5224995176e2070423fb13752 yt/data_objects/selection_data_containers.py
--- a/yt/data_objects/selection_data_containers.py
+++ b/yt/data_objects/selection_data_containers.py
@@ -721,7 +721,7 @@
                     "Cannot use both base_object and data_source")
             data_source=base_object
         super(YTCutRegionBase, self).__init__(
-            data_source.center, ds, field_parameters)
+            data_source.center, ds, field_parameters, data_source=data_source)
         self.conditionals = ensure_list(conditionals)
         self.base_object = data_source
         self._selector = None

diff -r 5f6205b59ed36cb6ade524bf2882ffbb9da3ab64 -r 7649ae14bc9235e5224995176e2070423fb13752 yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -784,37 +784,33 @@
 region_selector = RegionSelector
 
 cdef class CutRegionSelector(SelectorObject):
-    cdef SelectorObject base_selector
     cdef set _positions
+    cdef tuple _conditionals
 
     def __init__(self, dobj):
-        self.base_selector = <SelectorObject>dobj.base_object.selector
         positions = np.array([dobj['x'], dobj['y'], dobj['z']]).T
+        self._conditionals = tuple(dobj.conditionals)
         self._positions = set(tuple(position) for position in positions)
 
     cdef int select_bbox(self,  np.float64_t left_edge[3],
                      np.float64_t right_edge[3]) nogil:
-        return self.base_selector.select_bbox(left_edge, right_edge)
+        return 1
 
     cdef int select_cell(self, np.float64_t pos[3], np.float64_t dds[3]) nogil:
-        ret = self.base_selector.select_cell(pos, dds)
-        if ret:
-            with gil:
-                if (pos[0], pos[1], pos[2]) in self._positions:
-                    return 1
-                else:
-                    return 0
-        else:
-            return ret
+        with gil:
+            if (pos[0], pos[1], pos[2]) in self._positions:
+                return 1
+            else:
+                return 0
 
     cdef int select_point(self, np.float64_t pos[3]) nogil:
-        return self.base_selector.select_point(pos)
+        return 1
 
     cdef int select_sphere(self, np.float64_t pos[3], np.float64_t radius) nogil:
-        return self.base_selector.select_sphere(pos, radius)
+        return 1
 
     def _hash_vals(self):
-        return self.base_selector._hash_vals()
+        return self._conditionals
 
 cut_region_selector = CutRegionSelector
 


https://bitbucket.org/yt_analysis/yt/commits/7f73da315ded/
Changeset:   7f73da315ded
Branch:      yt
User:        ngoldbaum
Date:        2014-11-20 04:53:42+00:00
Summary:     Fixing a typo pointed out by chummels.
Affected #:  2 files

diff -r 7649ae14bc9235e5224995176e2070423fb13752 -r 7f73da315ded1c7a47b956ed05e922ac8ddd8fd3 .hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -9,6 +9,7 @@
 yt/frontends/artio/_artio_caller.c
 yt/analysis_modules/halo_finding/rockstar/rockstar_groupies.c
 yt/analysis_modules/halo_finding/rockstar/rockstar_interface.c
+yt/analysis_modules/ppv_cube/ppv_utils.c
 yt/frontends/ramses/_ramses_reader.cpp
 yt/frontends/sph/smoothing_kernel.c
 yt/geometry/fake_octree.c

diff -r 7649ae14bc9235e5224995176e2070423fb13752 -r 7f73da315ded1c7a47b956ed05e922ac8ddd8fd3 doc/source/analyzing/mesh_filter.ipynb
--- a/doc/source/analyzing/mesh_filter.ipynb
+++ b/doc/source/analyzing/mesh_filter.ipynb
@@ -107,7 +107,7 @@
       "proj1.set_figure_size(5)\n",
       "proj1.show()\n",
       "\n",
-      "proj2 = yt.ProjectionPlot(ds, 'x', \"density\", weight_field=\"density\", data_source=overpressure_and_fast_ad)\n",
+      "proj2 = yt.ProjectionPlot(ds, 'x', \"density\", weight_field=\"density\", data_source=hot_ad)\n",
       "proj2.annotate_title('Hot Gas')\n",
       "proj2.set_zlim(\"density\", 3e-31, 3e-27)\n",
       "proj2.set_figure_size(5)\n",

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list