[Yt-svn] yt-commit r1431 - in trunk/yt: lagos raven
silvia at wrangler.dreamhost.com
silvia at wrangler.dreamhost.com
Fri Sep 4 16:58:43 PDT 2009
Author: silvia
Date: Fri Sep 4 16:58:42 2009
New Revision: 1431
URL: http://yt.spacepope.org/changeset/1431
Log:
Added "fractional" keyword to add_phase_object to allow the z-axis to
show fractional values. False makes the z-axis absolute, True makes the
z-axis fractional.
Modified:
trunk/yt/lagos/Profiles.py
trunk/yt/raven/PlotCollection.py
trunk/yt/raven/PlotTypes.py
Modified: trunk/yt/lagos/Profiles.py
==============================================================================
--- trunk/yt/lagos/Profiles.py (original)
+++ trunk/yt/lagos/Profiles.py Fri Sep 4 16:58:42 2009
@@ -126,7 +126,7 @@
self["myweight"] = w
self["UsedBins"] = u
- def add_fields(self, fields, weight = "CellMassMsun", accumulation = False):
+ def add_fields(self, fields, weight = "CellMassMsun", accumulation = False, fractional=False):
"""
We accept a list of *fields* which will be binned if *weight* is not
None and otherwise summed. *accumulation* determines whether or not
@@ -138,6 +138,9 @@
self._lazy_add_fields(fields, weight, accumulation)
else:
self._unlazy_add_fields(fields, weight, accumulation)
+ if fractional:
+ for field in fields:
+ self._data[field] /= self._data[field].sum()
def keys(self):
return self._data.keys()
Modified: trunk/yt/raven/PlotCollection.py
==============================================================================
--- trunk/yt/raven/PlotCollection.py (original)
+++ trunk/yt/raven/PlotCollection.py Fri Sep 4 16:58:42 2009
@@ -372,7 +372,8 @@
x_bins=64, x_log=True, x_bounds=None,
y_bins=64, y_log=True, y_bounds=None,
lazy_reader=False, id=None,
- axes = None, figure = None):
+ axes = None, figure = None,
+ fractional=False):
"""
Given a *data_source*, and *fields*, automatically generate a 2D
profile and plot it. *id* is used internally to add onto the prefix,
@@ -400,7 +401,7 @@
figure=figure, axes=axes))
if len(fields) > 2:
# This will add it to the profile object
- p.switch_z(fields[2], weight=weight, accumulation=accumulation)
+ p.switch_z(fields[2], weight=weight, accumulation=accumulation, fractional=fractional)
return p
def add_phase_sphere(self, radius, unit, fields, **kwargs):
Modified: trunk/yt/raven/PlotTypes.py
==============================================================================
--- trunk/yt/raven/PlotTypes.py (original)
+++ trunk/yt/raven/PlotTypes.py Fri Sep 4 16:58:42 2009
@@ -737,7 +737,7 @@
self.image = None
self.set_cmap(cmap)
self._zlim = None
-
+
self.axis_names["X"] = fields[0]
self.axis_names["Y"] = fields[1]
self.axis_names["Z"] = fields[2]
@@ -772,10 +772,10 @@
if self.image != None and self.cmap != None:
self.image.set_cmap(self.cmap)
- def switch_z(self, field, weight="CellMassMsun", accumulation=False):
+ def switch_z(self, field, weight="CellMassMsun", accumulation=False, fractional=False):
self.fields[2] = field
self.axis_names["Z"] = field
- if field not in self.data.keys(): self.data.add_fields(field, weight, accumulation)
+ if field not in self.data.keys(): self.data.add_fields(field, weight, accumulation, fractional=fractional)
self._log_z = self.setup_bins(self.fields[2])
def set_xlim(self, xmin, xmax):
More information about the yt-svn
mailing list