[Yt-svn] yt-commit r915 - in branches/yt-non-3d: data yt/lagos yt/raven

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Tue Nov 11 08:38:00 PST 2008


Author: mturk
Date: Tue Nov 11 08:37:59 2008
New Revision: 915
URL: http://yt.spacepope.org/changeset/915

Log:
EnzoHierarchy2D now gets called, and *re*-sets up the grids.  This is
inefficient, but it should be okay because it's a 2D hierarchy, so the number
of grids should be << 1e4.  I'm more concerned about the changes I had to make
with the VelocityMagnitude field; we should accelerate the porting of the
yt-generalization field container back to trunk.



Modified:
   branches/yt-non-3d/data/make_slice.py
   branches/yt-non-3d/yt/lagos/DerivedFields.py
   branches/yt-non-3d/yt/lagos/HierarchyType.py
   branches/yt-non-3d/yt/lagos/OutputTypes.py
   branches/yt-non-3d/yt/raven/Callbacks.py
   branches/yt-non-3d/yt/raven/__init__.py

Modified: branches/yt-non-3d/data/make_slice.py
==============================================================================
--- branches/yt-non-3d/data/make_slice.py	(original)
+++ branches/yt-non-3d/data/make_slice.py	Tue Nov 11 08:37:59 2008
@@ -1,19 +1,18 @@
 from yt.mods import *
 
 pf = EnzoStaticOutput("DD0003/sb_L2x2_0003")
-pf.parameters["DomainLeftEdge"] = na.zeros(3, dtype='float64')
-pf.parameters["DomainRightEdge"] = na.ones(3, dtype='float64')
 
-pf.h.gridRightEdge[:,2] = 1.0
-pf.h.gridDimensions[:,2] = 1.0
+lagos.fieldInfo["VelocityMagnitude"].take_log = True
 
-for g in pf.h.grids:
-    g.dz = 1.0
-    g.LeftEdge[2] = 0.0
-    g.RightEdge[2] = 1.0
-    g.ActiveDimensions[2] = 1
+pc = PlotCollection(pf, center=[0.5,0.5,0.5])
 
-pc = PlotCollection(pf, center=[0.5,0.5,0.25])
+p = pc.add_slice("Density", 2)
+p.add_callback(ContourCallback("TotalEnergy", ncont=5, factor=1, take_log=True))
+p.add_callback(QuiverCallback("x-velocity", "y-velocity", 32))
+p.add_callback(GridBoundaryCallback())
+
+pc.set_width(0.9, '1')
+
+pc.add_phase_sphere(1.0, '1', ["Density", "TotalEnergy", "VelocityMagnitude"], weight=None)
 
-pc.add_slice("Density", 2)
 pc.save("hi")

Modified: branches/yt-non-3d/yt/lagos/DerivedFields.py
==============================================================================
--- branches/yt-non-3d/yt/lagos/DerivedFields.py	(original)
+++ branches/yt-non-3d/yt/lagos/DerivedFields.py	Tue Nov 11 08:37:59 2008
@@ -52,6 +52,7 @@
 Msun2g = 1.989e33
 MJ_constant = (((5*kboltz)/(G*mh))**(1.5)) * (3/(4*pi))**(0.5) / Msun2g
 rho_crit_now = 1.8788e-29 # g cm^-3
+axis_names = 'xyz'
 
 class FieldInfoContainer: # We are all Borg.
     _shared_state = {}
@@ -449,9 +450,12 @@
     bulk_velocity = data.get_field_parameter("bulk_velocity")
     if bulk_velocity == None:
         bulk_velocity = na.zeros(3)
-    return ( (data["x-velocity"]-bulk_velocity[0])**2.0 + \
-             (data["y-velocity"]-bulk_velocity[1])**2.0 + \
-             (data["z-velocity"]-bulk_velocity[2])**2.0 )**(1.0/2.0)
+    tr = (data["x-velocity"]-bulk_velocity[0])**2.0
+    if data.pf["TopGridRank"] > 1:
+        tr += (data["y-velocity"]-bulk_velocity[1])**2.0
+    if data.pf["TopGridRank"] > 2:
+        tr += (data["z-velocity"]-bulk_velocity[2])**2.0
+    return na.sqrt(tr)
 add_field("VelocityMagnitude", take_log=False, units=r"\rm{cm}/\rm{s}")
 
 def _TangentialOverVelocityMagnitude(field, data):

Modified: branches/yt-non-3d/yt/lagos/HierarchyType.py
==============================================================================
--- branches/yt-non-3d/yt/lagos/HierarchyType.py	(original)
+++ branches/yt-non-3d/yt/lagos/HierarchyType.py	Tue Nov 11 08:37:59 2008
@@ -953,7 +953,14 @@
         return gg[(random_sample,)]
 
 class EnzoHierarchy2D(EnzoHierarchy):
-    pass
+    def __init__(self, *args, **kwargs):
+        EnzoHierarchy.__init__(self, *args, **kwargs)
+        self.gridRightEdge[:,2] = 1.0
+        self.gridDimensions[:,2] = 1.0
+        self.gridDzs[:,0] = 1.0
+        for g in self.grids:
+            g._prepare_grid()
+            g._setup_dx()
 
 class EnzoHierarchy1D(EnzoHierarchy):
     pass

Modified: branches/yt-non-3d/yt/lagos/OutputTypes.py
==============================================================================
--- branches/yt-non-3d/yt/lagos/OutputTypes.py	(original)
+++ branches/yt-non-3d/yt/lagos/OutputTypes.py	Tue Nov 11 08:37:59 2008
@@ -139,6 +139,16 @@
         if os.path.exists(cp):
             self.cool = EnzoTable(cp, cool_out_key)
 
+        # Now fixes for different types of Hierarchies
+        if self["TopGridRank"] == 2: self._setup_2d()
+
+    def _setup_2d(self):
+        self._hierarchy_class = EnzoHierarchy2D
+        self.parameters["DomainLeftEdge"] = \
+            na.concatenate([self["DomainLeftEdge"], [0.0]])
+        self.parameters["DomainRightEdge"] = \
+            na.concatenate([self["DomainRightEdge"], [1.0]])
+
     def _parse_parameter_file(self):
         """
         Parses the parameter file and establishes the various

Modified: branches/yt-non-3d/yt/raven/Callbacks.py
==============================================================================
--- branches/yt-non-3d/yt/raven/Callbacks.py	(original)
+++ branches/yt-non-3d/yt/raven/Callbacks.py	Tue Nov 11 08:37:59 2008
@@ -195,6 +195,8 @@
         z = plot.data[self.field][wI]
         if self.take_log: z=na.log10(z)
         zi = self.de.Triangulation(x,y).nn_interpolator(z)(xi,yi)
+        print z.min(), z.max(), na.nanmin(z), na.nanmax(z)
+        print zi.min(), zi.max(), na.nanmin(zi), na.nanmax(zi)
         plot._axes.contour(xi,yi,zi,self.ncont, **self.plot_args)
         plot._axes.set_xlim(xx0,xx1)
         plot._axes.set_ylim(yy0,yy1)

Modified: branches/yt-non-3d/yt/raven/__init__.py
==============================================================================
--- branches/yt-non-3d/yt/raven/__init__.py	(original)
+++ branches/yt-non-3d/yt/raven/__init__.py	Tue Nov 11 08:37:59 2008
@@ -37,6 +37,9 @@
 except:
     mylog.warning("Deliverator import failed; all deliverator actions will fail!")
 
+import matplotlib
+matplotlib.rc('contour', negative_linestyle='solid')
+
 import matplotlib.image
 import matplotlib.ticker
 import matplotlib.axes



More information about the yt-svn mailing list