[yt-svn] commit/yt: 2 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Jul 28 18:38:00 PDT 2015
2 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/15759637de14/
Changeset: 15759637de14
Branch: yt
User: qobilidop
Date: 2015-07-28 04:09:43+00:00
Summary: add cookbook recipe smoothed_field.py
Affected #: 1 file
diff -r 60bd0bc6b0a9d81f1a6a741c5c709725cbc536db -r 15759637de147985bb8ccb6aa4133dffeee6ff79 doc/source/cookbook/smoothed_field.py
--- /dev/null
+++ b/doc/source/cookbook/smoothed_field.py
@@ -0,0 +1,48 @@
+import yt
+
+# Load a Gadget dataset following the demonstration notebook.
+fname = 'GadgetDiskGalaxy/snapshot_200.hdf5'
+
+unit_base = {'UnitLength_in_cm' : 3.08568e+21,
+ 'UnitMass_in_g' : 1.989e+43,
+ 'UnitVelocity_in_cm_per_s' : 100000}
+
+bbox_lim = 1e5 # kpc
+
+bbox = [[-bbox_lim, bbox_lim],
+ [-bbox_lim, bbox_lim],
+ [-bbox_lim, bbox_lim]]
+
+ds = yt.load(fname, unit_base=unit_base, bounding_box=bbox)
+
+# Create a derived field, the metal density.
+def _metal_density(field, data):
+ density = data['PartType0', 'Density']
+ Z = data['PartType0', 'metallicity']
+ return density * Z
+
+# Add it to the dataset.
+ds.add_field(('PartType0', 'metal_density'), function=_metal_density,
+ units="g/cm**3", particle_type=True)
+
+
+# Add the corresponding smoothed field to the dataset.
+from yt.fields.particle_fields import add_volume_weighted_smoothed_field
+
+add_volume_weighted_smoothed_field('PartType0', 'Coordinates', 'Masses',
+ 'SmoothingLength', 'Density',
+ 'metal_density', ds.field_info)
+
+# Define the region where the disk galaxy is. (See the Gadget notebook for
+# details. Here I make the box a little larger than needed to eliminate the
+# margin effect.)
+center = ds.arr([31996, 31474, 28970], "code_length")
+box_size = ds.quan(250, "code_length")
+left_edge = center - box_size/2*1.1
+right_edge = center + box_size/2*1.1
+box = ds.box(left_edge=left_edge, right_edge=right_edge)
+
+# And make a projection plot!
+yt.ProjectionPlot(ds, 'z',
+ ('deposit', 'PartType0_smoothed_metal_density'),
+ center=center, width=box_size, data_source=box).save()
https://bitbucket.org/yt_analysis/yt/commits/6faa62d05f5e/
Changeset: 6faa62d05f5e
Branch: yt
User: qobilidop
Date: 2015-07-28 04:37:21+00:00
Summary: add entry in calculating_information.rst
Affected #: 1 file
diff -r 15759637de147985bb8ccb6aa4133dffeee6ff79 -r 6faa62d05f5e8a6011455b345be4b49aa0a08675 doc/source/cookbook/calculating_information.rst
--- a/doc/source/cookbook/calculating_information.rst
+++ b/doc/source/cookbook/calculating_information.rst
@@ -93,6 +93,16 @@
.. yt_cookbook:: hse_field.py
+Smoothed Fields
+~~~~~~~~~~~~~~~
+
+This recipe demonstrates how to create a smoothed field,
+corresponding to a user-created derived field, using the
+:meth:`~yt.fields.particle_fields.add_volume_weighted_smoothed_field` method.
+See :ref:`gadget-notebook` for how to work with Gadget data.
+
+.. yt_cookbook:: smoothed_field.py
+
Using Particle Filters to Calculate Star Formation Rates
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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