[yt-svn] commit/yt-doc: 2 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri May 17 15:23:44 PDT 2013
2 new commits in yt-doc:
https://bitbucket.org/yt_analysis/yt-doc/commits/7a552a149fc8/
Changeset: 7a552a149fc8
User: ngoldbaum
Date: 2013-05-18 00:22:56
Summary: Correcting an image link.
Affected #: 1 file
diff -r 26462bde1cd6c6eda7c422a2edb499dbeaf765a4 -r 7a552a149fc8e99941ace5f6b847eb3fd1620a05 source/visualizing/volume_rendering.rst
--- a/source/visualizing/volume_rendering.rst
+++ b/source/visualizing/volume_rendering.rst
@@ -281,7 +281,7 @@
This produces an image like this:
-.. image:: _images/vr_sample.jpg
+.. image:: _images/allsky.png
:width: 512
However, below we describe a longer, build-it-yourself method. To actually
https://bitbucket.org/yt_analysis/yt-doc/commits/64aed6437ca2/
Changeset: 64aed6437ca2
User: ngoldbaum
Date: 2013-05-18 00:23:28
Summary: Merging with tip.
Affected #: 4 files
diff -r 7a552a149fc8e99941ace5f6b847eb3fd1620a05 -r 64aed6437ca24173153ef36dde7ca7f27aa315ac source/analyzing/creating_derived_fields.rst
--- a/source/analyzing/creating_derived_fields.rst
+++ b/source/analyzing/creating_derived_fields.rst
@@ -188,6 +188,37 @@
.. _derived-field-options:
+Saving Derived Fields
+---------------------
+
+Complex fields can be time-consuming to generate, especially on large datasets. To mitigate this, yt provides a mechanism for saving fields to a backup file using the Grid Data Format. The next time you start yt, it will check this file and your field will be treated as native if present.
+
+The code below creates a new derived field called "Entr" and saves it to disk:
+
+.. code-block:: python
+
+ from yt.mods import *
+ from yt.utilities.grid_data_format import writer
+
+ def _Entropy(field, data) :
+ return data["Temperature"]*data["Density"]**(-2./3.)
+ add_field("Entr", function=_Entropy)
+
+ pf = load('GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0100')
+ writer.save_field(pf, "Entr")
+
+This creates a "_backup.gdf" file next to your datadump. If you load up the dataset again:
+
+.. code-block:: python
+
+ from yt.mods import *
+
+ pf = load('GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0100')
+ data = pf.h.all_data()
+ print data["Entr"]
+
+you can work with the field exactly as before, without having to recompute it.
+
Field Options
-------------
diff -r 7a552a149fc8e99941ace5f6b847eb3fd1620a05 -r 64aed6437ca24173153ef36dde7ca7f27aa315ac source/analyzing/generating_processed_data.rst
--- a/source/analyzing/generating_processed_data.rst
+++ b/source/analyzing/generating_processed_data.rst
@@ -141,6 +141,22 @@
.. _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
+
+.. code-block:: python
+
+ print profile["Temperature_std"]
+ print prof2d["Temperature_std"]
+
Line Queries and Planar Integrals
---------------------------------
diff -r 7a552a149fc8e99941ace5f6b847eb3fd1620a05 -r 64aed6437ca24173153ef36dde7ca7f27aa315ac source/cookbook/profile_with_variance.py
--- /dev/null
+++ b/source/cookbook/profile_with_variance.py
@@ -0,0 +1,30 @@
+from matplotlib import pyplot
+
+from yt.mods import *
+
+# Load the dataset.
+pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+
+# Create a sphere of radius 1000 kpc centered on the max density.
+sphere = pf.h.sphere("max", (1000, "kpc"))
+
+# Calculate and store the bulk velocity for the sphere.
+bulk_velocity = sphere.quantities['BulkVelocity']()
+sphere.set_field_parameter('bulk_velocity', bulk_velocity)
+
+# Create a 1D profile object for profiles over radius
+# and add a velocity profile.
+profile = BinnedProfile1D(sphere, 100, "Radiuskpc", 0.1, 1000.)
+profile.add_fields('VelocityMagnitude')
+
+# Plot the average velocity magnitude.
+pyplot.loglog(profile['Radiuskpc'], profile['VelocityMagnitude'],
+ label='mean')
+# Plot the variance of the velocity madnitude.
+pyplot.loglog(profile['Radiuskpc'], profile['VelocityMagnitude_std'],
+ label='std')
+pyplot.xlabel('r [kpc]')
+pyplot.ylabel('v [cm/s]')
+pyplot.legend()
+
+pyplot.savefig('velocity_profiles.png')
diff -r 7a552a149fc8e99941ace5f6b847eb3fd1620a05 -r 64aed6437ca24173153ef36dde7ca7f27aa315ac source/cookbook/simple_plots.rst
--- a/source/cookbook/simple_plots.rst
+++ b/source/cookbook/simple_plots.rst
@@ -55,6 +55,17 @@
.. yt_cookbook:: simple_radial_profile.py
+.. _cookbook-profile-variance:
+
+Profiles with Variance Values
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This shows how to plot the variance for a 1D profile. In this example, we
+manually create a 1D profile object, which gives us access to the variance
+data.
+
+.. yt_cookbook:: profile_with_variance.py
+
Making Plots of Multiple Fields Simultaneously
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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