[Yt-svn] commit/yt: MatthewTurk: Actually, THIS is the correct way to look for particles and to cast the bool to

Bitbucket commits-noreply at bitbucket.org
Thu May 12 13:05:46 PDT 2011


1 new changeset in yt:

http://bitbucket.org/yt_analysis/yt/changeset/dacea37d5f8b/
changeset:   r4253:dacea37d5f8b
branch:      yt
user:        MatthewTurk
date:        2011-05-12 22:05:38
summary:     Actually, THIS is the correct way to look for particles and to cast the bool to
int.  This also fixes the leakiness of not having the plotfile particles but
having particles in the simulation.
affected #:  2 files (112 bytes)

--- a/yt/frontends/castro/data_structures.py	Thu May 12 12:57:54 2011 -0700
+++ b/yt/frontends/castro/data_structures.py	Thu May 12 13:05:38 2011 -0700
@@ -52,7 +52,8 @@
     parameterDict, \
     yt2castroFieldsDict, \
     castro_FAB_header_pattern, \
-    castro_particle_field_names
+    castro_particle_field_names, \
+    boxlib_bool_to_int
 
 from .fields import \
     CastroFieldContainer, \
@@ -567,6 +568,7 @@
         self.unique_identifier = \
             int(os.stat(self.parameter_filename)[ST_CTIME])
         lines = open(self.parameter_filename).readlines()
+        self.use_particles = False
         for lineI, line in enumerate(lines):
             if line.find("#") >= 1: # Keep the commented lines...
                 line=line[:line.find("#")]
@@ -594,8 +596,8 @@
             elif param.startswith("geometry.prob_lo"):
                 self.domain_left_edge = \
                     na.array([float(i) for i in vals.split()])
-            elif param.startswith("castro.do_dm_particles"):
-                self.use_particles = True
+            elif param.startswith("particles.write_in_plotfile"):
+                self.use_particles = boxlib_bool_to_int(vals)
 
         self.parameters["TopGridRank"] = len(self.parameters["TopGridDimensions"])
         self.dimensionality = self.parameters["TopGridRank"]


--- a/yt/frontends/castro/definitions.py	Thu May 12 12:57:54 2011 -0700
+++ b/yt/frontends/castro/definitions.py	Thu May 12 13:05:38 2011 -0700
@@ -26,14 +26,15 @@
 from yt.funcs import *
 
 def boxlib_bool_to_int(v):
-    if isinstance(v, types.StringTypes):
-        v = v.upper().strip()
-        if v[0] == 'T':
-            return 1
-        elif v[0] == 'F':
-            return 0
-    else:
+    try:
         return int(v)
+    except ValueError:
+        pass
+    v = v.upper().strip()
+    if v[0] == 'T':
+        return 1
+    elif v[0] == 'F':
+        return 0
 
 # TODO: get rid of enzo parameters we do not need
 parameterDict = {"CosmologyCurrentRedshift": float,

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list