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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sat Jul 19 18:12:38 PDT 2014


3 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/0d8233c5a914/
Changeset:   0d8233c5a914
Branch:      yt-3.0
User:        brittonsmith
Date:        2014-07-18 22:20:14
Summary:     Updating profile docs to discuss create_profile.
Affected #:  1 file

diff -r 894d44f837d4d259550bb7b741091424226375b7 -r 0d8233c5a914a7feb544d602c0fc008ebe1648ab doc/source/analyzing/generating_processed_data.rst
--- a/doc/source/analyzing/generating_processed_data.rst
+++ b/doc/source/analyzing/generating_processed_data.rst
@@ -43,7 +43,7 @@
 
 .. code-block:: python
 
-   sl = pf.slice(0, 0.5)
+   sl = ds.slice(0, 0.5)
    frb = FixedResolutionBuffer(sl, (0.3, 0.5, 0.6, 0.8), (512, 512))
    my_image = frb["density"]
 
@@ -62,101 +62,92 @@
 (described in :ref:`how-to-make-1d-profiles` and
 :ref:`how-to-make-2d-profiles`).  These generate profiles transparently, but the
 objects they handle and create can be handled manually, as well, for more
-control and access.  For instance, if you wanted to plot a time series of the
-evolution of a profile, or if you wanted to handle the fields in some way to
-calculate an accretion rate or some modified version of the resultant
-histogram.  For full documentation, see the API reference for
-:class:`~yt.data_objects.profiles.BinnedProfile1D`,
-:class:`~yt.data_objects.profiles.BinnedProfile2D`, or
-:class:`~yt.data_objects.profiles.BinnedProfile3D`.
+control and access.  The :func:`~yt.data_objects.profiles.create_profile` function 
+can be used to generate 1, 2, and 3D profiles.  
 
 Profile objects can be created from any data object (see :ref:`using-objects`,
 specifically the section :ref:`available-objects` for more information) and are
 best thought of as distribution calculations.  They can either sum up or
 average one quantity with respect to one or more other quantities, and they do
-this over all the data contained in their source object.
+this over all the data contained in their source object.  When calculating average 
+values, the variance will also be calculated.
 
-To generate a profile, you need to supply the limits of the distribution for
-each variable along which you are distributing (i.e., the x- and y-axes for 2D
-profiles, but only the x-axis for 1D profiles) as well as the number of bins
-into which you want the values distributed.  Often these are the least
-straightforward pieces of information; the usage of derived quantities,
-specifically ``Extrema``, can help with this.  (See :ref:`derived-quantities`
-for more information on this.)  Once you have created the profile object, you
-can add fields to it either one at a time or multiple simultaneously.  If you
-supply a weighting field, the average will be taken.  Otherwise, if the weight
-field is set to ``None``, only an accumulation inside a bin will be performed.
-Note that by default the weight field is ``CellMassMsun``!
-
-For instance, to create a sphere at (0.3, 0.6, 0.4) and then take the 1D
-average distribution of fields with respect to Density, you would first
-construct your profile.  Then you would add fields to it; for instance, we can
-add ``CellMassMsun`` in an unweighted fashion to get the total mass in each
-bin.  Then we add ``Temperature`` with the default weighting to get the
-average value in each bin.  Here's an example, where we have used our knowledge
-of the bounds of density in advance to set up the profile.
+To generate a profile, one need only specify the binning fields and the field 
+to be profiled.  The binning fields are given together in a list.  The 
+:func:`~yt.data_objects.profiles.create_profile` function will guess the 
+dimensionality of the profile based on the number of fields given.  For example, 
+a one-dimensional profile of the mass-weighted average temperature as a function of 
+density within a sphere can be created in the following way:
 
 .. code-block:: python
 
-   source = pf.sphere( (0.3, 0.6, 0.4), 1.0/pf['pc'])
-   profile = BinnedProfile1D(source, 128, "density", 1e-24, 1e-10)
-   profile.add_fields("cell_mass", weight = None)
-   profile.add_fields("temperature")
+   import yt
+   ds = yt.load("galaxy0030/galaxy0030")
+   source = ds.sphere( "c", (10, "kpc"))
+   profile = yt.create_profile(source, 
+                               [("gas", "density")],          # the bin field
+                               [("gas", "temperature"),       # profile field
+                                ("gas", "radial_velocity")],  # profile field
+                               weight_field=("gas", "cell_mass"))
 
-At this point, we can access the fields ``CellMassMsun`` and ``Temperature``
-from the ``profile`` object, which are returned as 1D arrays.
+The binning, weight, and profile data can now be access as:
 
 .. code-block:: python
 
-   print profile["cell_mass"]
-   print profile["temperature"]
+   print profile.x       # bin field
+   print profile.weight  # weight field
+   print profile["gas", "temperature"]      # profile field
+   print profile["gas", "radial_velocity"]  # profile field
 
-The field ``UsedBins`` is also included, which is ``True`` wherever values have
-been added.  This is primarily used for 2D profiles, where many of the bins may
-be empty and need to be masked.  Note also that the bins used to generate the
-profiles, in this case ``Density``, are also defined to allow for x-y plots.
-
-One of the more interesting techniques that is enabled with this approach is
-the generation of 1D profiles that correspond to 2D profiles.  For instance, a
-phase plot that shows the distribution of mass in the density-temperature
-plane, with the average temperature overplotted.
-
-To generate a 2D profile, the interface is broadly the same except with a few
-additional parameters for the second field along which values will be
-distributed.  Here we are also distributing values along temperature, and then
-calculating the mass in each (2D) bin.
+The ``profile.used`` attribute gives a boolean array of the bins which actually 
+have data.
 
 .. code-block:: python
 
-   source = pf.sphere( (0.3, 0.6, 0.4), 1.0/pf['pc'])
-   prof2d = BinnedProfile2D(source, 128, "density", 1e-24, 1e-10, True,
-                                    128, "temperature", 10, 10000, True)
-   prof2d.add_fields("cell_mass", weight = None)
+   print profile.used
 
-Note that at this point we can use :func:`~matplotlib.pyplot.pcolormesh` to
-plot the ``prof2d["cell_mass"]`` value, and even overplot the value of
-``profile["temperature"]`` to show the average value in every density bin.
-Note that you will likely have to mask out the zero values using the
-``prof2d["UsedBins"]`` field.  Profiles can also be calculated in
-three-dimensions, with a similar extension of the calling function.
-
-.. _generating-line-queries:
-
-Calculating the Variance of Profiled Fields
-+++++++++++++++++++++++++++++++++++++++++++
-
-See :ref:`cookbook-profile-variance` for an example of the following.  
-When calculating average 1D and 2D profiles (when the *weight* keyword is not 
-None), the variance within each bin is calculated automatically.  A practical 
-application for this would be calculating velocity dispersion by profiling the 
-average velocity magnitude.  The variance values for 1D and 2D profiles are 
-accessible as the name of the profiled field followed by ``_std``.  For the 
-above examples, this is done with
+If a weight field was given, the profile data will represent the weighted mean of 
+a field.  In this case, the weighted variance will be calculated automatically and 
+can be access via the ``profile.variance`` attribute.
 
 .. code-block:: python
 
-   print profile["Temperature_std"]
-   print prof2d["Temperature_std"]
+   print profile.variance["gas", "temperature"]
+
+A two-dimensional profile of the total gas mass in bins of density and temperature 
+can be created as follows:
+
+.. code-block:: python
+
+   profile2d = yt.create_profile(source, 
+                                 [("gas", "density"),      # the x bin field
+                                  ("gas", "temperature")], # the y bin field
+                                 [("gas", "cell_mass")],   # the profile field
+                                 weight_field=None)
+
+Accessing the x, y, and profile fields work just as with one-dimensional profiles:
+
+.. code-block:: python
+
+   print profile2d.x
+   print profile2d.y
+   print profile2d["gas", "cell_mass"]
+
+One of the more interesting things that is enabled with this approach is
+the generation of 1D profiles that correspond to 2D profiles.  For instance, a
+phase plot that shows the distribution of mass in the density-temperature
+plane, with the average temperature overplotted.  The 
+:func:`~matplotlib.pyplot.pcolormesh` function can be used to manually plot 
+the 2D profile.
+
+Three-dimensional profiles can be generated and accessed following 
+the same procedures.  Additional keyword arguments are available to control 
+the following for each of the bin fields: the number of bins, min and max, units, 
+whether to use a log or linear scale, and whether or not to do accumulation to 
+create a cumulative distribution function.  For more information, see the API 
+documentation on the :func:`~yt.data_objects.profiles.create_profile` function.
+
+.. _generating-line-queries:
 
 Line Queries and Planar Integrals
 ---------------------------------
@@ -171,7 +162,7 @@
 
 .. code-block:: python
 
-   ray = pf.ray(  (0.3, 0.5, 0.9), (0.1, 0.8, 0.5) )
+   ray = ds.ray(  (0.3, 0.5, 0.9), (0.1, 0.8, 0.5) )
    print ray["density"]
 
 The points are ordered, but the ray is also traversing cells of varying length,


https://bitbucket.org/yt_analysis/yt/commits/7c37643c8564/
Changeset:   7c37643c8564
Branch:      yt-3.0
User:        brittonsmith
Date:        2014-07-18 22:21:50
Summary:     Fixing create_profile docstring.
Affected #:  1 file

diff -r 0d8233c5a914a7feb544d602c0fc008ebe1648ab -r 7c37643c85643cb99ca728f4b0e9d8af61aab4cc yt/data_objects/profiles.py
--- a/yt/data_objects/profiles.py
+++ b/yt/data_objects/profiles.py
@@ -1282,15 +1282,15 @@
     --------
 
     Create a 1d profile.  Access bin field from profile.x and field
-    data from profile.field_data.
+    data from profile[<field_name>].
 
     >>> pf = load("DD0046/DD0046")
     >>> ad = pf.h.all_data()
-    >>> extrema = {"density": (1.0e-30, 1.0e-25)}
-    >>> profile = create_profile(ad, ["density"], extrema=extrema,
-    ...                          fields=["temperature", "velocity_x"]))
+    >>> profile = create_profile(ad, [("gas", "density")], 
+    ...                              [("gas", "temperature"),
+    ...                               ("gas", "velocity_x")])
     >>> print profile.x
-    >>> print profile.field_data["temperature"]
+    >>> print profile["gas", "temperature"]
 
     """
     bin_fields = ensure_list(bin_fields)


https://bitbucket.org/yt_analysis/yt/commits/3c2909dfdf7a/
Changeset:   3c2909dfdf7a
Branch:      yt-3.0
User:        brittonsmith
Date:        2014-07-20 03:10:09
Summary:     Merging.
Affected #:  2 files

diff -r 7688ec7a09af1bf76b46dd9a085071c85dbdec4f -r 3c2909dfdf7ab1918119fff79f048dbef3c3caf3 doc/source/analyzing/generating_processed_data.rst
--- a/doc/source/analyzing/generating_processed_data.rst
+++ b/doc/source/analyzing/generating_processed_data.rst
@@ -62,101 +62,92 @@
 (described in :ref:`how-to-make-1d-profiles` and
 :ref:`how-to-make-2d-profiles`).  These generate profiles transparently, but the
 objects they handle and create can be handled manually, as well, for more
-control and access.  For instance, if you wanted to plot a time series of the
-evolution of a profile, or if you wanted to handle the fields in some way to
-calculate an accretion rate or some modified version of the resultant
-histogram.  For full documentation, see the API reference for
-:class:`~yt.data_objects.profiles.BinnedProfile1D`,
-:class:`~yt.data_objects.profiles.BinnedProfile2D`, or
-:class:`~yt.data_objects.profiles.BinnedProfile3D`.
+control and access.  The :func:`~yt.data_objects.profiles.create_profile` function 
+can be used to generate 1, 2, and 3D profiles.  
 
 Profile objects can be created from any data object (see :ref:`using-objects`,
 specifically the section :ref:`available-objects` for more information) and are
 best thought of as distribution calculations.  They can either sum up or
 average one quantity with respect to one or more other quantities, and they do
-this over all the data contained in their source object.
+this over all the data contained in their source object.  When calculating average 
+values, the variance will also be calculated.
 
-To generate a profile, you need to supply the limits of the distribution for
-each variable along which you are distributing (i.e., the x- and y-axes for 2D
-profiles, but only the x-axis for 1D profiles) as well as the number of bins
-into which you want the values distributed.  Often these are the least
-straightforward pieces of information; the usage of derived quantities,
-specifically ``Extrema``, can help with this.  (See :ref:`derived-quantities`
-for more information on this.)  Once you have created the profile object, you
-can add fields to it either one at a time or multiple simultaneously.  If you
-supply a weighting field, the average will be taken.  Otherwise, if the weight
-field is set to ``None``, only an accumulation inside a bin will be performed.
-Note that by default the weight field is ``CellMassMsun``!
-
-For instance, to create a sphere at (0.3, 0.6, 0.4) and then take the 1D
-average distribution of fields with respect to Density, you would first
-construct your profile.  Then you would add fields to it; for instance, we can
-add ``CellMassMsun`` in an unweighted fashion to get the total mass in each
-bin.  Then we add ``Temperature`` with the default weighting to get the
-average value in each bin.  Here's an example, where we have used our knowledge
-of the bounds of density in advance to set up the profile.
+To generate a profile, one need only specify the binning fields and the field 
+to be profiled.  The binning fields are given together in a list.  The 
+:func:`~yt.data_objects.profiles.create_profile` function will guess the 
+dimensionality of the profile based on the number of fields given.  For example, 
+a one-dimensional profile of the mass-weighted average temperature as a function of 
+density within a sphere can be created in the following way:
 
 .. code-block:: python
 
-   source = ds.sphere( (0.3, 0.6, 0.4), 1.0/ds['pc'])
-   profile = BinnedProfile1D(source, 128, "density", 1e-24, 1e-10)
-   profile.add_fields("cell_mass", weight = None)
-   profile.add_fields("temperature")
+   import yt
+   ds = yt.load("galaxy0030/galaxy0030")
+   source = ds.sphere( "c", (10, "kpc"))
+   profile = yt.create_profile(source, 
+                               [("gas", "density")],          # the bin field
+                               [("gas", "temperature"),       # profile field
+                                ("gas", "radial_velocity")],  # profile field
+                               weight_field=("gas", "cell_mass"))
 
-At this point, we can access the fields ``CellMassMsun`` and ``Temperature``
-from the ``profile`` object, which are returned as 1D arrays.
+The binning, weight, and profile data can now be access as:
 
 .. code-block:: python
 
-   print profile["cell_mass"]
-   print profile["temperature"]
+   print profile.x       # bin field
+   print profile.weight  # weight field
+   print profile["gas", "temperature"]      # profile field
+   print profile["gas", "radial_velocity"]  # profile field
 
-The field ``UsedBins`` is also included, which is ``True`` wherever values have
-been added.  This is primarily used for 2D profiles, where many of the bins may
-be empty and need to be masked.  Note also that the bins used to generate the
-profiles, in this case ``Density``, are also defined to allow for x-y plots.
-
-One of the more interesting techniques that is enabled with this approach is
-the generation of 1D profiles that correspond to 2D profiles.  For instance, a
-phase plot that shows the distribution of mass in the density-temperature
-plane, with the average temperature overplotted.
-
-To generate a 2D profile, the interface is broadly the same except with a few
-additional parameters for the second field along which values will be
-distributed.  Here we are also distributing values along temperature, and then
-calculating the mass in each (2D) bin.
+The ``profile.used`` attribute gives a boolean array of the bins which actually 
+have data.
 
 .. code-block:: python
 
-   source = ds.sphere( (0.3, 0.6, 0.4), 1.0/ds['pc'])
-   prof2d = BinnedProfile2D(source, 128, "density", 1e-24, 1e-10, True,
-                                    128, "temperature", 10, 10000, True)
-   prof2d.add_fields("cell_mass", weight = None)
+   print profile.used
 
-Note that at this point we can use :func:`~matplotlib.pyplot.pcolormesh` to
-plot the ``prof2d["cell_mass"]`` value, and even overplot the value of
-``profile["temperature"]`` to show the average value in every density bin.
-Note that you will likely have to mask out the zero values using the
-``prof2d["UsedBins"]`` field.  Profiles can also be calculated in
-three-dimensions, with a similar extension of the calling function.
-
-.. _generating-line-queries:
-
-Calculating the Variance of Profiled Fields
-+++++++++++++++++++++++++++++++++++++++++++
-
-See :ref:`cookbook-profile-variance` for an example of the following.  
-When calculating average 1D and 2D profiles (when the *weight* keyword is not 
-None), the variance within each bin is calculated automatically.  A practical 
-application for this would be calculating velocity dispersion by profiling the 
-average velocity magnitude.  The variance values for 1D and 2D profiles are 
-accessible as the name of the profiled field followed by ``_std``.  For the 
-above examples, this is done with
+If a weight field was given, the profile data will represent the weighted mean of 
+a field.  In this case, the weighted variance will be calculated automatically and 
+can be access via the ``profile.variance`` attribute.
 
 .. code-block:: python
 
-   print profile["Temperature_std"]
-   print prof2d["Temperature_std"]
+   print profile.variance["gas", "temperature"]
+
+A two-dimensional profile of the total gas mass in bins of density and temperature 
+can be created as follows:
+
+.. code-block:: python
+
+   profile2d = yt.create_profile(source, 
+                                 [("gas", "density"),      # the x bin field
+                                  ("gas", "temperature")], # the y bin field
+                                 [("gas", "cell_mass")],   # the profile field
+                                 weight_field=None)
+
+Accessing the x, y, and profile fields work just as with one-dimensional profiles:
+
+.. code-block:: python
+
+   print profile2d.x
+   print profile2d.y
+   print profile2d["gas", "cell_mass"]
+
+One of the more interesting things that is enabled with this approach is
+the generation of 1D profiles that correspond to 2D profiles.  For instance, a
+phase plot that shows the distribution of mass in the density-temperature
+plane, with the average temperature overplotted.  The 
+:func:`~matplotlib.pyplot.pcolormesh` function can be used to manually plot 
+the 2D profile.
+
+Three-dimensional profiles can be generated and accessed following 
+the same procedures.  Additional keyword arguments are available to control 
+the following for each of the bin fields: the number of bins, min and max, units, 
+whether to use a log or linear scale, and whether or not to do accumulation to 
+create a cumulative distribution function.  For more information, see the API 
+documentation on the :func:`~yt.data_objects.profiles.create_profile` function.
+
+.. _generating-line-queries:
 
 Line Queries and Planar Integrals
 ---------------------------------

diff -r 7688ec7a09af1bf76b46dd9a085071c85dbdec4f -r 3c2909dfdf7ab1918119fff79f048dbef3c3caf3 yt/data_objects/profiles.py
--- a/yt/data_objects/profiles.py
+++ b/yt/data_objects/profiles.py
@@ -1282,15 +1282,15 @@
     --------
 
     Create a 1d profile.  Access bin field from profile.x and field
-    data from profile.field_data.
+    data from profile[<field_name>].
 
     >>> ds = load("DD0046/DD0046")
-    >>> ad = ds.all_data()
-    >>> extrema = {"density": (1.0e-30, 1.0e-25)}
-    >>> profile = create_profile(ad, ["density"], extrema=extrema,
-    ...                          fields=["temperature", "velocity_x"]))
+    >>> ad = ds.h.all_data()
+    >>> profile = create_profile(ad, [("gas", "density")], 
+    ...                              [("gas", "temperature"),
+    ...                               ("gas", "velocity_x")])
     >>> print profile.x
-    >>> print profile.field_data["temperature"]
+    >>> print profile["gas", "temperature"]
 
     """
     bin_fields = ensure_list(bin_fields)
@@ -1340,7 +1340,7 @@
                 field_ex = list(extrema[bin_field])
             if units is not None and bin_field in units:
                 if isinstance(field_ex[0], tuple):
-                    field_ex = [data_source.pf.quan(*f) for f in field_ex]
+                    field_ex = [data_source.ds.quan(*f) for f in field_ex]
                 fe = data_source.ds.arr(field_ex, units[bin_field])
                 fe.convert_to_units(bf_units)
                 field_ex = [fe[0].v, fe[1].v]

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