[yt-svn] commit/yt-doc: 2 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Nov 6 06:42:56 PST 2013
2 new commits in yt-doc:
https://bitbucket.org/yt_analysis/yt-doc/commits/b38e97e488e6/
Changeset: b38e97e488e6
User: brittonsmith
Date: 2013-11-05 16:09:52
Summary: Updating docs for cut_region.
Affected #: 1 file
diff -r aa482e4881748677e642ab64369bc601b2ad442e -r b38e97e488e6275e23a8871c41bead01bb255c1a source/analyzing/objects.rst
--- a/source/analyzing/objects.rst
+++ b/source/analyzing/objects.rst
@@ -233,49 +233,44 @@
.. _field_cuts:
-Querying and Subselecting Objects
----------------------------------
+Cutting Objects by Field Values
+-------------------------------
-Often when analyzing astrophysical objects, only regions that posses certain
-properties are of interest. For instance, in a global galactic disk
-simulation, perhaps you want to examine only the cold gas, or only the hot gas.
-These criteria can be applied to selections of data in yt using one of two
-mechanisms: the "field cuts" mechanism or the "extract region" mechanism.
-"Field cuts" are more suited to specifying extractions based on easily
-described properties of the gas, whereas "extracted regions" are usually suited
-for when the gas properties of interest require explicit examination.
+Data objects can be cut by their field values using the ``cut_region``
+method. For example, this could be used to compute the total mass within
+a certain temperature range, as in the following example.
-Objects can be selected using field cuts by specifying one or more criteria to
-the ``cut_field`` method on a data object. These criteria should be of the
-form ``grid["FieldName"] < SOMETHING`` or similar; they will be evaluated with
-respect to a grid. The operation will then supply a new objects composed of
-all the cells that satisfy this. For instance, if I wanted to take a sphere
-and only examine inflowing gas:
+.. notebook-cell::
-.. code-block:: python
+ from yt.mods import *
+ pf = load("enzo_tiny_cosmology/DD0046/DD0046")
+ ad = pf.h.all_data()
+ total_mass = ad.quantities["TotalQuantity"]("CellMassMsun")
+ # now select only gas with 1e5 K < T < 1e7 K.
+ new_region = ad.cut_region(['grid["Temperature"] > 1e5',
+ 'grid["Temperature"] < 1e7'])
+ cut_mass = new_region.quantities["TotalQuantity"]("CellMassMsun")
+ print "The fraction of mass in this temperature range is %f." % \
+ (cut_mass[0] / total_mass[0])
- sp = pf.h.sphere("max", (100.0, 'au'))
- inflow = sp.cut_region( [ "grid['RadialVelocity'] < 0" ])
+The ``cut_region`` function generates a new object containing only the cells
+that meet all of the specified criteria. The sole argument to ``cut_region``
+is a list of strings, where each string is evaluated with an ``eval``
+statement. ``eval`` is a native Python function that evaluates a string as
+a Python expression. Any type of data object can be cut with ``cut_region``.
+Objects generated with ``cut_region`` can be used in the same way as all
+other data objects. For example, a cut region can be visualized by giving
+it as a data_source to a projection.
-The new returned object, ``inflow``, can be analyzed as any other data object.
-For instance we could examine its angular momentum vector:
+.. python-script::
-.. code-block:: python
-
- L = inflow.quantities["AngularMomentumVector"]()
-
-There are two things to note about the arguments to ``cut_region``: they are a
-list, where each argument is an independent criterion for inclusion, and they
-are evaluated on each grid object. Only the cells where all arguments are
-evaluated as ``True`` will be included in the resulting object. For instance,
-to select only dense, cold gas:
-
-.. code-block:: python
-
- dense = sp.cut_region([ "grid['dens'] > 1e5", "grid['temp'] < 200" ])
-
-Each of the criteria will be evaluated independently and the resulting
-intersection will be returned.
+ from yt.mods import *
+ pf = load("enzo_tiny_cosmology/DD0046/DD0046")
+ ad = pf.h.all_data()
+ new_region = ad.cut_region(['grid["Density"] > 1e-29'])
+ plot = ProjectionPlot(pf, "x", "Density", weight_field="Density",
+ data_source=new_region)
+ plot.save()
.. _extracting-connected-sets:
https://bitbucket.org/yt_analysis/yt-doc/commits/42f94049fb5d/
Changeset: 42f94049fb5d
User: samskillman
Date: 2013-11-06 15:42:54
Summary: Merged in brittonsmith/yt-doc (pull request #113)
Updating docs for cut_region.
Affected #: 1 file
diff -r 53e9fd3ef9ae3089c0322d2220fdb0c27eca7bb1 -r 42f94049fb5d2a8f22d00915ae24e7a4d9f644fa source/analyzing/objects.rst
--- a/source/analyzing/objects.rst
+++ b/source/analyzing/objects.rst
@@ -233,49 +233,44 @@
.. _field_cuts:
-Querying and Subselecting Objects
----------------------------------
+Cutting Objects by Field Values
+-------------------------------
-Often when analyzing astrophysical objects, only regions that posses certain
-properties are of interest. For instance, in a global galactic disk
-simulation, perhaps you want to examine only the cold gas, or only the hot gas.
-These criteria can be applied to selections of data in yt using one of two
-mechanisms: the "field cuts" mechanism or the "extract region" mechanism.
-"Field cuts" are more suited to specifying extractions based on easily
-described properties of the gas, whereas "extracted regions" are usually suited
-for when the gas properties of interest require explicit examination.
+Data objects can be cut by their field values using the ``cut_region``
+method. For example, this could be used to compute the total mass within
+a certain temperature range, as in the following example.
-Objects can be selected using field cuts by specifying one or more criteria to
-the ``cut_field`` method on a data object. These criteria should be of the
-form ``grid["FieldName"] < SOMETHING`` or similar; they will be evaluated with
-respect to a grid. The operation will then supply a new objects composed of
-all the cells that satisfy this. For instance, if I wanted to take a sphere
-and only examine inflowing gas:
+.. notebook-cell::
-.. code-block:: python
+ from yt.mods import *
+ pf = load("enzo_tiny_cosmology/DD0046/DD0046")
+ ad = pf.h.all_data()
+ total_mass = ad.quantities["TotalQuantity"]("CellMassMsun")
+ # now select only gas with 1e5 K < T < 1e7 K.
+ new_region = ad.cut_region(['grid["Temperature"] > 1e5',
+ 'grid["Temperature"] < 1e7'])
+ cut_mass = new_region.quantities["TotalQuantity"]("CellMassMsun")
+ print "The fraction of mass in this temperature range is %f." % \
+ (cut_mass[0] / total_mass[0])
- sp = pf.h.sphere("max", (100.0, 'au'))
- inflow = sp.cut_region( [ "grid['RadialVelocity'] < 0" ])
+The ``cut_region`` function generates a new object containing only the cells
+that meet all of the specified criteria. The sole argument to ``cut_region``
+is a list of strings, where each string is evaluated with an ``eval``
+statement. ``eval`` is a native Python function that evaluates a string as
+a Python expression. Any type of data object can be cut with ``cut_region``.
+Objects generated with ``cut_region`` can be used in the same way as all
+other data objects. For example, a cut region can be visualized by giving
+it as a data_source to a projection.
-The new returned object, ``inflow``, can be analyzed as any other data object.
-For instance we could examine its angular momentum vector:
+.. python-script::
-.. code-block:: python
-
- L = inflow.quantities["AngularMomentumVector"]()
-
-There are two things to note about the arguments to ``cut_region``: they are a
-list, where each argument is an independent criterion for inclusion, and they
-are evaluated on each grid object. Only the cells where all arguments are
-evaluated as ``True`` will be included in the resulting object. For instance,
-to select only dense, cold gas:
-
-.. code-block:: python
-
- dense = sp.cut_region([ "grid['dens'] > 1e5", "grid['temp'] < 200" ])
-
-Each of the criteria will be evaluated independently and the resulting
-intersection will be returned.
+ from yt.mods import *
+ pf = load("enzo_tiny_cosmology/DD0046/DD0046")
+ ad = pf.h.all_data()
+ new_region = ad.cut_region(['grid["Density"] > 1e-29'])
+ plot = ProjectionPlot(pf, "x", "Density", weight_field="Density",
+ data_source=new_region)
+ plot.save()
.. _extracting-connected-sets:
Repository URL: https://bitbucket.org/yt_analysis/yt-doc/
--
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