[yt-svn] commit/yt: xarthisius: Merged in ngoldbaum/yt/yt-3.0 (pull request #1079)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Jul 29 01:09:57 PDT 2014


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/9311591c5804/
Changeset:   9311591c5804
Branch:      yt-3.0
User:        xarthisius
Date:        2014-07-29 10:09:49
Summary:     Merged in ngoldbaum/yt/yt-3.0 (pull request #1079)

Adding three new cookbook recipes.
Affected #:  6 files

diff -r 95c532180d1182130daea6a6f95de32bfbcee0ce -r 9311591c58044d4e84efa1e91a6b4b3ea5a48197 doc/source/cookbook/calculating_information.rst
--- a/doc/source/cookbook/calculating_information.rst
+++ b/doc/source/cookbook/calculating_information.rst
@@ -68,4 +68,10 @@
 
 .. yt_cookbook:: derived_field.py
 
-.. _cookbook-complex-derived-fields:
+Using Particle Filters to Calculate Star Formation Rates
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This recipe demonstrates how to use a particle filter to calculate the star
+formation rate in a galaxy evolution simulation.
+
+.. yt_cookbook:: particle_filter_sfr.py

diff -r 95c532180d1182130daea6a6f95de32bfbcee0ce -r 9311591c58044d4e84efa1e91a6b4b3ea5a48197 doc/source/cookbook/complex_plots.rst
--- a/doc/source/cookbook/complex_plots.rst
+++ b/doc/source/cookbook/complex_plots.rst
@@ -145,6 +145,29 @@
 
 .. _cookbook-camera_movement:
 
+Customized Profile Plot
+~~~~~~~~~~~~~~~~~~~~~~~
+
+This recipe demonstrates how to create a fully customized 1D profile object
+using the :meth:`~yt.data_objects.profiles.create_profile` function and then
+create a :class:`~yt.visualization.profile_plotter.ProfilePlot` using the
+customized profile.  This illustrates how a ``ProfilePlot`` created this way
+inherits the properties of the profile it is constructed from.
+
+.. yt_cookbook:: customized_profile_plot.py
+
+Customized Phase Plot
+~~~~~~~~~~~~~~~~~~~~~
+
+Similar to the recipe above, this demonstrates how to create a fully customized
+2D profile object using the :meth:`~yt.data_objects.profiles.create_profile`
+function and then create a :class:`~yt.visualization.profile_plotter.PhasePlot`
+using the customized profile object.  This illustrates how a ``PhasePlot``
+created this way inherits the properties of the profile object it is constructed
+from.
+
+.. yt_cookbook:: customized_phase_plot.py
+
 Moving a Volume Rendering Camera
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

diff -r 95c532180d1182130daea6a6f95de32bfbcee0ce -r 9311591c58044d4e84efa1e91a6b4b3ea5a48197 doc/source/cookbook/customized_phase_plot.py
--- /dev/null
+++ b/doc/source/cookbook/customized_phase_plot.py
@@ -0,0 +1,31 @@
+import yt
+import yt.units as u
+
+ds = yt.load('HiresIsolatedGalaxy/DD0044/DD0044')
+
+center = [0.53, 0.53, 0.53]
+normal = [0,0,1]
+radius = 40*u.kpc
+height = 2*u.kpc
+
+disk = ds.disk(center, [0,0,1], radius, height)
+
+profile = yt.create_profile(
+    data_source=disk,
+    bin_fields=["radius", "cylindrical_tangential_velocity"],
+    fields=["cell_mass"],
+    n_bins=256,
+    units=dict(radius="kpc",
+               cylindrical_tangential_velocity="km/s",
+               cell_mass="Msun"),
+    logs=dict(radius=False,
+              cylindrical_tangential_velocity=False),
+    weight_field=None,
+    extrema=dict(radius=(0,40),
+                 cylindrical_tangential_velocity=(-250, 250)),
+    )
+
+plot = yt.PhasePlot.from_profile(profile)
+plot.set_cmap("cell_mass", "YlOrRd")
+
+plot.save()

diff -r 95c532180d1182130daea6a6f95de32bfbcee0ce -r 9311591c58044d4e84efa1e91a6b4b3ea5a48197 doc/source/cookbook/customized_profile_plot.py
--- /dev/null
+++ b/doc/source/cookbook/customized_profile_plot.py
@@ -0,0 +1,30 @@
+import yt
+import yt.units as u
+
+ds = yt.load('HiresIsolatedGalaxy/DD0044/DD0044')
+
+center = [0.53, 0.53, 0.53]
+normal = [0,0,1]
+radius = 40*u.kpc
+height = 5*u.kpc
+
+disk = ds.disk(center, [0,0,1], radius, height)
+
+profile = yt.create_profile(
+    data_source=disk,
+    bin_fields=["radius"],
+    fields=["cylindrical_tangential_velocity_absolute"],
+    n_bins=256,
+    units=dict(radius="kpc",
+               cylindrical_tangential_velocity_absolute="km/s"),
+    logs=dict(radius=False),
+    weight_field='cell_mass',
+    extrema=dict(radius=(0,40)),
+    )
+
+plot = yt.ProfilePlot.from_profiles(profile)
+
+plot.set_log('cylindrical_tangential_velocity_absolute', False)
+plot.set_ylim('cylindrical_tangential_velocity_absolute', 60, 160)
+
+plot.save()

diff -r 95c532180d1182130daea6a6f95de32bfbcee0ce -r 9311591c58044d4e84efa1e91a6b4b3ea5a48197 doc/source/cookbook/particle_filter_sfr.py
--- /dev/null
+++ b/doc/source/cookbook/particle_filter_sfr.py
@@ -0,0 +1,34 @@
+import yt
+import numpy as np
+from yt.data_objects.particle_filters import add_particle_filter
+from matplotlib import pyplot as plt
+
+def formed_star(pfilter, data):
+    filter = data["all", "creation_time"] > 0
+    return filter
+
+add_particle_filter("formed_star", function=formed_star, filtered_type='all',
+                    requires=["creation_time"])
+
+filename = "IsolatedGalaxy/galaxy0030/galaxy0030"
+
+ds = yt.load(filename)
+ds.add_particle_filter('formed_star')
+ad = ds.all_data()
+masses = ad['formed_star', 'particle_mass'].in_units('Msun')
+formation_time = ad['formed_star', 'creation_time'].in_units('yr')
+
+time_range = [0, 5e8] # years
+n_bins = 1000
+hist, bins = np.histogram(formation_time, bins=n_bins, range=time_range,)
+inds = np.digitize(formation_time, bins=bins)
+time = (bins[:-1] + bins[1:])/2
+
+sfr = np.array([masses[inds == j].sum()/(bins[j+1]-bins[j])
+                for j in range(len(time))])
+sfr[sfr == 0] = np.nan
+
+plt.plot(time/1e6, sfr)
+plt.xlabel('Time  [Myr]')
+plt.ylabel('SFR  [M$_\odot$ yr$^{-1}$]')
+plt.savefig("filter_sfr.png")

diff -r 95c532180d1182130daea6a6f95de32bfbcee0ce -r 9311591c58044d4e84efa1e91a6b4b3ea5a48197 yt/data_objects/profiles.py
--- a/yt/data_objects/profiles.py
+++ b/yt/data_objects/profiles.py
@@ -1248,7 +1248,7 @@
         List of the binning fields for profiling.
     fields : list of strings
         The fields to be profiled.
-    n : int or list of ints
+    n_bins : int or list of ints
         The number of bins in each dimension.  If None, 64 bins for
         each bin are used for each bin field.
         Default: 64.
@@ -1263,7 +1263,7 @@
         attribute of the field.
     units : dict of strings
         The units of the fields in the profiles, including the bin_fields.
-    weight_field : str
+    weight_field : str or tuple field identifier
         The weight field for computing weighted average for the profile
         values.  If None, the profile values are sums of the data in
         each bin.

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