[Yt-svn] yt-commit r736 - trunk/yt
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Thu Aug 21 22:43:19 PDT 2008
Author: mturk
Date: Thu Aug 21 22:43:18 2008
New Revision: 736
URL: http://yt.spacepope.org/changeset/736
Log:
Added some new experimental stuff...
...but stuff that is kind of hip and slick and a bit of an abuse.
try this on for size:
>>> from yt.mods import *
>>> pf = "galaxy1200" | static
>>> pf | slicer
>>> pf | slicer(field="Temperature", width=(1.0,'kpc'))
>>> pf | projector(axis=1, field="Density", width=(1.0,'kpc'), name='hiya')
or if you want to be ultra terse, forget the pf part:
>>> from yt.mods import *
>>> "galaxy1200" | slicer
It'll just output a slice, dropped to the file system. No fuss, no muss.
Modified:
trunk/yt/mods.py
Modified: trunk/yt/mods.py
==============================================================================
--- trunk/yt/mods.py (original)
+++ trunk/yt/mods.py Thu Aug 21 22:43:18 2008
@@ -30,7 +30,7 @@
import yt.raven as raven
import yt.fido as fido
import numpy as na
-import sys
+import sys, types
from yt.lagos import EnzoStaticOutput, \
BinnedProfile1D, BinnedProfile2D, BinnedProfile3D, \
@@ -53,3 +53,45 @@
def get_pf():
return lagos.EnzoStaticOutput(sys.argv[-1])
+class _StaticOutputIfier(object):
+ def __init__(self):
+ pass
+ def __ror__(self, other):
+ return EnzoStaticOutput(other)
+static = _StaticOutputIfier()
+
+class __PlotVM(object):
+ def __init__(self, axis = 0, field = "Density", name = None, width = None):
+ self.axis = axis
+ self.field = field
+ self.name = name
+ self.width = width
+
+ def __ror__(self, pf):
+ if isinstance(pf, types.StringTypes): pf = EnzoStaticOutput(pf)
+ pc = PlotCollection(pf)
+ self._add_plot(pc)
+ if self.name is None: self.name = str(pf)
+ if self.width is not None:
+ pc.set_width(*self.width)
+ return pc.save(self.name)
+
+ def __call__(self, *args, **kwargs):
+ return _PlotSlice(*args, **kwargs)
+
+class _PlotSlice(__PlotVM):
+ def _add_plot(self, pc):
+ pc.add_slice(self.field, self.axis)
+slicer = _PlotSlice()
+x_slicer = _PlotSlice(axis=0)
+y_slicer = _PlotSlice(axis=1)
+z_slicer = _PlotSlice(axis=2)
+
+class _PlotProj(__PlotVM):
+ def _add_plot(self, pc):
+ pc.add_projection(self.field, self.axis)
+projector = _PlotProj()
+x_projector = _PlotProj(axis=0)
+y_projector = _PlotProj(axis=1)
+z_projector = _PlotProj(axis=2)
+
More information about the yt-svn
mailing list