Commits

Matthew Turk committed 349d298

Adding checks for dimensionality < 3 in FLASH files.

Comments (0)

Files changed (2)

yt/data_objects/data_containers.py

             dv = dv[sl]
         mask = self.__cut_mask_child_mask(grid)[sl]
         dataVals = dv.ravel()[mask.ravel() == 1]
+        print 
         return dataVals
 
     def _gen_node_name(self):

yt/frontends/flash/data_structures.py

         offset = 7
         ii = na.argsort(self.grid_levels.flat)
         gid = self._handle["/gid"][:]
+        first_ind = -(self.parameter_file.refine_by**self.parameter_file.dimensionality)
         for g in self.grids[ii].flat:
             gi = g.id - g._id_offset
             # FLASH uses 1-indexed group info
-            g.Children = [self.grids[i - 1] for i in gid[gi,7:] if i > -1]
+            g.Children = [self.grids[i - 1] for i in gid[gi,first_ind:] if i > -1]
             for g1 in g.Children:
                 g1.Parent = g
             g._prepare_grid()
             g._setup_dx()
+        if self.parameter_file.dimensionality < 3:
+            DD = (self.parameter_file.domain_right_edge[2] -
+                  self.parameter_file.domain_left_edge[2])
+            for g in self.grids:
+                g.dds[2] = DD
+        if self.parameter_file.dimensionality < 2:
+            DD = (self.parameter_file.domain_right_edge[1] -
+                  self.parameter_file.domain_left_edge[1])
+            for g in self.grids:
+                g.dds[1] = DD
         self.max_level = self.grid_levels.max()
 
     def _setup_derived_fields(self):
         # These should be explicitly obtained from the file, but for now that
         # will wait until a reorganization of the source tree and better
         # generalization.
-        self.dimensionality = 3
         self.refine_by = 2
         self.parameters["HydroMethod"] = 'flash' # always PPM DE
         self.parameters["Time"] = 1. # default unit is 1...
             [self._find_parameter("real", "%smin" % ax) for ax in 'xyz'])
         self.domain_right_edge = na.array(
             [self._find_parameter("real", "%smax" % ax) for ax in 'xyz'])
+        self.dimensionality = self._find_parameter("integer", "dimensionality",
+                                scalar = True)
 
         # Determine domain dimensions
         try: