[Yt-svn] yt-commit r650 - in trunk/yt/lagos: . hop

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Sun Jul 6 10:53:14 PDT 2008


Author: mturk
Date: Sun Jul  6 10:53:13 2008
New Revision: 650
URL: http://yt.spacepope.org/changeset/650

Log:
Refactored the SpecificAngularMomentum field, added some docstrings to the
DerivedField class.

Fixed some stuff in write_out in the HopResults object; added a maximum_radius
and an additional newline.



Modified:
   trunk/yt/lagos/DerivedFields.py
   trunk/yt/lagos/hop/HopOutput.py

Modified: trunk/yt/lagos/DerivedFields.py
==============================================================================
--- trunk/yt/lagos/DerivedFields.py	(original)
+++ trunk/yt/lagos/DerivedFields.py	Sun Jul  6 10:53:13 2008
@@ -157,6 +157,24 @@
                  particle_type = False, vector_field=False,
                  display_field = True, not_in_all=False,
                  projection_conversion = "cm"):
+        """
+        This is the base class used to describe a cell-by-cell derived field.
+
+        :param name: is the name of the field.
+        :param function: is a function handle that defines the field
+        :param convert_function: must convert to CGS, if it needs to be done
+        :param units: is a mathtext-formatted string that describes the field
+        :param projected_units: if we display a projection, what should the units be?
+        :param take_log: describes whether the field should be logged
+        :param validators: is a list of :class:`FieldValidator` objects
+        :param particle_type: is this field based on particles?
+        :param vector_field: describes the dimensionality of the field
+        :param display_field: governs its appearance in the dropdowns in reason
+        :param not_in_all: is used for baryon fields from the data that are not in
+                           all the grids
+        :param projection_conversion: which unit should we multiply by in a
+                                      projection?
+        """
         self.name = name
         self._function = function
         if validators:
@@ -692,14 +710,10 @@
     """
     if data.has_field_parameter("bulk_velocity"):
         bv = data.get_field_parameter("bulk_velocity")
-        xv = data["x-velocity"] - bv[0]
-        yv = data["y-velocity"] - bv[1]
-        zv = data["z-velocity"] - bv[2]
-    else:
-        xv = data["x-velocity"]
-        yv = data["y-velocity"]
-        zv = data["z-velocity"]
-
+    else: bv = na.zeros(3, dtype='float64')
+    xv = data["x-velocity"] - bv[0]
+    yv = data["y-velocity"] - bv[1]
+    zv = data["z-velocity"] - bv[2]
     center = data.get_field_parameter('center')
     coords = na.array([data['x'],data['y'],data['z']], dtype='float64')
     new_shape = tuple([3] + [1]*(len(coords.shape)-1))
@@ -708,11 +722,11 @@
     return na.cross(r_vec, v_vec, axis=0)
 def _convertSpecificAngularMomentum(data):
     return data.convert("cm")
-def _convertSpecificAngularMomentumKMSMPC(data):
-    return data.convert("mpc")/1e5
 add_field("SpecificAngularMomentum",
           convert_function=_convertSpecificAngularMomentum, vector_field=True,
           units=r"\rm{cm}^2/\rm{s}", validators=[ValidateParameter('center')])
+def _convertSpecificAngularMomentumKMSMPC(data):
+    return data.convert("mpc")/1e5
 add_field("SpecificAngularMomentumKMSMPC",
           function=_SpecificAngularMomentum,
           convert_function=_convertSpecificAngularMomentumKMSMPC, vector_field=True,

Modified: trunk/yt/lagos/hop/HopOutput.py
==============================================================================
--- trunk/yt/lagos/hop/HopOutput.py	(original)
+++ trunk/yt/lagos/hop/HopOutput.py	Sun Jul  6 10:53:13 2008
@@ -113,7 +113,7 @@
         f.write("\t".join(["# Group","Mass","# part","max dens"
                            "x","y","z", "center-of-mass",
                            "x","y","z",
-                           "vx","vy","vz"]))
+                           "vx","vy","vz","max_r","\n"]))
         for group in self:
             f.write("%10i\t" % group.id)
             f.write("%0.9e\t" % group.total_mass())
@@ -124,6 +124,7 @@
             f.write("\t".join(["%0.9e" % v for v in group.center_of_mass()]))
             f.write("\t")
             f.write("\t".join(["%0.9e" % v for v in group.bulk_velocity()]))
+            f.write("%0.9e\t" % group.maximum_radius())
             f.write("\n")
         f.close()
 



More information about the yt-svn mailing list