[Yt-svn] yt-commit r616 - trunk/yt/lagos

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Mon Jun 23 23:15:22 PDT 2008


Author: mturk
Date: Mon Jun 23 23:15:21 2008
New Revision: 616
URL: http://yt.spacepope.org/changeset/616

Log:
Checking in some mods to the Clump code.



Modified:
   trunk/yt/lagos/Clump.py

Modified: trunk/yt/lagos/Clump.py
==============================================================================
--- trunk/yt/lagos/Clump.py	(original)
+++ trunk/yt/lagos/Clump.py	Mon Jun 23 23:15:21 2008
@@ -1,3 +1,29 @@
+"""
+Clump finding helper classes
+
+ at author: Britton Smith
+ at organization: University of Colorado at Boulder
+ at contact: U{Britton.Smith at colorado.edu<mailto:Britton.Smith at colorado.edu>
+ at license:
+  Copyright (C) 2008 Britton Smith.  All Rights Reserved.
+
+  This file is part of yt.
+
+  yt is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""
+
+
 import yt.lagos as lagos
 import numpy as na
 
@@ -69,9 +95,7 @@
 
 def write_clumps(clump,level,f_ptr):
     if ((clump.children is None) or (len(clump.children) == 0)):
-        for q in range(level):
-            f_ptr.write("\t")
-        f_ptr.write("Clump:\n")
+        f_ptr.write("%sClump:\n" % ("\t"*level))
         write_clump_info(clump,level,f_ptr)
         f_ptr.write("\n")
         f_ptr.flush()
@@ -79,27 +103,25 @@
         for child in clump.children:
             write_clumps(child,0,f_ptr)
 
+__clump_info_template = \
+"""
+%(tl)sCells: %(num_cells)s
+%(tl)sMass: %(total_mass).6e Msolar
+%(tl)sJeans Mass (vol-weighted): %(jeans_mass_vol).6e Msolar
+%(tl)sJeans Mass (mass-weighted): %(jeans_mass_mass).6e Msolar
+%(tl)sMax grid level: %(max_level)s
+%(tl)sMin number density: %(min_density).6e cm^-3
+%(tl)sMax number density: %(max_density).6e cm^-3
+
+"""
+
 def write_clump_info(clump,level,f_ptr):
-    for q in range(level):
-        f_ptr.write("\t")
-    f_ptr.write("Cells: %d\n" % len(clump.data["CellMassMsun"]))
-    for q in range(level):
-        f_ptr.write("\t")
-    f_ptr.write("Mass: %.6e Msolar\n" % clump.data["CellMassMsun"].sum())
-    for q in range(level):
-        f_ptr.write("\t")
-    f_ptr.write("Jeans Mass (vol-weighted): %.6e Msolar\n" % \
-                    (clump.data.quantities["WeightedAverageQuantity"]("JeansMassMsun","CellVolume")))
-    for q in range(level):
-        f_ptr.write("\t")
-    f_ptr.write("Jeans Mass (mass-weighted): %.6e Msolar\n" % \
-                    (clump.data.quantities["WeightedAverageQuantity"]("JeansMassMsun","CellMassMsun")))
-    for q in range(level):
-        f_ptr.write("\t")
-    f_ptr.write("Max grid level: %d\n" % clump.data["GridLevel"].max())
-    for q in range(level):
-        f_ptr.write("\t")
-    f_ptr.write("Min number density: %.6e cm^-3\n" % clump.data["NumberDensity"].min())
-    for q in range(level):
-        f_ptr.write("\t")
-    f_ptr.write("Max number density: %.6e cm^-3\n" % clump.data["NumberDensity"].max())
+    fmt_dict = {'tl':  "\t" * level}
+    fmt_dict['num_cells'] = clump.data["CellMassMsun"].size,
+    fmt_dict['total_mass'] = clump.data["CellMassMsun"].sum(),
+    fmt_dict['jeans_mass_vol'] = clump.data.quantities["WeightedAverageQuantity"]("JeansMassMsun","CellVolume")
+    fmt_dict['jeans_mass_mass'] = clump.data.quantities["WeightedAverageQuantity"]("JeansMassMsun","CellMassMsun")
+    fmt_dict['max_level'] =  clump.data["GridLevel"].max()
+    fmt_dict['min_density'] =  clump.data["NumberDensity"].min()
+    fmt_dict['max_density'] =  clump.data["NumberDensity"].max()
+    f_ptr.write(__clump_info_template % fmt_dict)



More information about the yt-svn mailing list